Skip to content

Commit

Permalink
Merge pull request #743 from ava-labs/wait-for-info-bootstrapped
Browse files Browse the repository at this point in the history
add wait for info.Bootstrapped to blockchain deploy
  • Loading branch information
felipemadero authored Nov 13, 2024
2 parents 5a17aec + 56796ba commit 5913530
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions local/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ const (
subnetValidatorsWeight = 1000
// check period for blockchain logs while waiting for custom chains to be ready
blockchainLogPullFrequency = time.Second
// check period for blockchain bootstrap status while waiting for custom chains to be ready
blockchainBootstrapCheckFrequency = time.Second
// check period while waiting for all validators to be ready
waitForValidatorsPullFrequency = time.Second
defaultTimeout = time.Minute
Expand Down Expand Up @@ -684,6 +686,7 @@ func (ln *localNetwork) waitForCustomChainsReady(
return err
}

// wait for blockchain to produce logs
for _, nodeName := range nodeNames {
node := ln.nodes[nodeName]
if node.paused {
Expand Down Expand Up @@ -716,6 +719,36 @@ func (ln *localNetwork) waitForCustomChainsReady(
}
}
}

// wait for info.isBootstrapped
// we need this check to be sure all APIs recognize the blockchain ID
for _, nodeName := range nodeNames {
node := ln.nodes[nodeName]
if node.paused {
continue
}
for {
boostrapped, err := node.client.InfoAPI().IsBootstrapped(ctx, chainInfo.blockchainID.String())
if err != nil && !strings.Contains(err.Error(), "there is no chain with alias/ID") {
return err
}
if boostrapped {
break
}
ln.log.Info("not boostrapped, retrying...",
zap.String("subnet-ID", chainInfo.subnetID.String()),
zap.String("blockchain-ID", chainInfo.blockchainID.String()),
zap.String("node", node.name),
)
select {
case <-ln.onStopCh:
return errAborted
case <-ctx.Done():
return ctx.Err()
case <-time.After(blockchainBootstrapCheckFrequency):
}
}
}
}

ln.log.Info(logging.Green.Wrap("all custom chains are running!!!"))
Expand Down

0 comments on commit 5913530

Please sign in to comment.