Skip to content

Commit

Permalink
remove busy waiting for blockchain rpc endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemadero committed Feb 7, 2025
1 parent 2c76e3f commit 238fbb9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
13 changes: 3 additions & 10 deletions cmd/networkcmd/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/ava-labs/avalanche-cli/pkg/binutils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
"github.com/ava-labs/avalanche-cli/pkg/evm"
"github.com/ava-labs/avalanche-cli/pkg/models"
"github.com/ava-labs/avalanche-cli/pkg/utils"
"github.com/ava-labs/avalanche-cli/pkg/ux"
Expand Down Expand Up @@ -170,16 +169,10 @@ func TrackSubnet(
}
networkInfo.RPCEndpoints = rpcEndpoints.List()
networkInfo.WSEndpoints = wsEndpoints.List()
for _, rpcURL := range networkInfo.RPCEndpoints {
ux.Logger.PrintToUser("Waiting for %s to be available", rpcURL)
if err := evm.WaitForRPC(ctx, rpcURL); err != nil {
return err
}
}
if err := IsBootstrapped(cli, blockchainID.String()); err != nil {
if err := WaitBootstrapped(cli, blockchainID.String()); err != nil {
return err
}
if err := IsBootstrapped(cli, "P"); err != nil {
if err := WaitBootstrapped(cli, "P"); err != nil {
return err
}
if _, err := cli.UpdateStatus(ctx); err != nil {
Expand All @@ -204,7 +197,7 @@ func TrackSubnet(
return nil
}

func IsBootstrapped(cli client.Client, blockchainID string) error {
func WaitBootstrapped(cli client.Client, blockchainID string) error {
blockchainBootstrapCheckFrequency := time.Second
ctx, cancel := utils.GetANRContext()
defer cancel()
Expand Down
10 changes: 0 additions & 10 deletions pkg/node/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/ava-labs/avalanche-cli/pkg/application"
"github.com/ava-labs/avalanche-cli/pkg/binutils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
"github.com/ava-labs/avalanche-cli/pkg/evm"
"github.com/ava-labs/avalanche-cli/pkg/localnet"
"github.com/ava-labs/avalanche-cli/pkg/models"
"github.com/ava-labs/avalanche-cli/pkg/networkoptions"
Expand Down Expand Up @@ -100,8 +99,6 @@ func TrackSubnetWithLocalMachine(
if err != nil {
return err
}
networkInfo := sc.Networks[network.Name()]
rpcEndpoints := []string{}
for _, nodeInfo := range status.ClusterInfo.NodeInfos {
ux.Logger.PrintToUser("Restarting node %s to track newly deployed network", nodeInfo.Name)
if err := LocalNodeTrackSubnet(
Expand All @@ -120,18 +117,11 @@ func TrackSubnetWithLocalMachine(
if err := AddNodeInfoToSidecar(&sc, nodeInfo, network); err != nil {
return fmt.Errorf("failed to update sidecar with new node info: %w", err)
}
rpcEndpoints = append(rpcEndpoints, models.GetRPCEndpoint(nodeInfo.Uri, networkInfo.BlockchainID.String()))
}
ux.Logger.PrintToUser("Waiting for blockchain %s to be bootstrapped", blockchainName)
if err := WaitBootstrapped(ctx, cli, blockchainID.String()); err != nil {
return fmt.Errorf("failure waiting for local cluster %s bootstrapping: %w", blockchainName, err)
}
for _, rpcURL := range rpcEndpoints {
ux.Logger.PrintToUser("Waiting for rpc %s to be available", rpcURL)
if err := evm.WaitForRPC(ctx, rpcURL); err != nil {
return err
}
}
if err := app.UpdateSidecar(&sc); err != nil {
return err
}
Expand Down

0 comments on commit 238fbb9

Please # to comment.