Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove busy waiting for blockchain rpc endpoints on local network deploy #2600

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions pkg/evm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,21 +804,3 @@ func TransactionError(tx *types.Transaction, err error, msg string, args ...inte
args = append(args, err)
return fmt.Errorf(msg+msgSuffix, args...)
}

func WaitForRPC(ctx context.Context, rpcURL string) error {
client, err := GetClient(rpcURL)
if err != nil {
return err
}
for {
_, err := client.ChainID(ctx)
if err == nil {
return nil
}
select {
case <-ctx.Done():
return ctx.Err()
case <-time.After(1 * time.Second):
}
}
}
12 changes: 1 addition & 11 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 @@ -99,8 +98,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 @@ -119,18 +116,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)
ux.Logger.PrintToUser("Waiting for blockchain %s ID %s to be bootstrapped", blockchainName, blockchainID.String())
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var _ = ginkgo.Describe("[Etna AddRemove Validator SOV PoA]", func() {
gomega.Expect(err).Should(gomega.BeNil())
fmt.Println(output)
// parse blockchainID from output
re := regexp.MustCompile(`Waiting for rpc http://.*?/bc/([A-Za-z0-9]+)/rpc`)
re := regexp.MustCompile(`Waiting for blockchain .* ID ([A-Za-z0-9]+) to be bootstrapped`)
// Find the first match
match := re.FindStringSubmatch(output)
gomega.Expect(match).ToNot(gomega.BeEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var _ = ginkgo.Describe("[Etna AddRemove Validator SOV PoS]", func() {
gomega.Expect(err).Should(gomega.BeNil())
fmt.Println(output)
// parse blockchainID from output
re := regexp.MustCompile(`Waiting for rpc http://.*?/bc/([A-Za-z0-9]+)/rpc`)
re := regexp.MustCompile(`Waiting for blockchain .* ID ([A-Za-z0-9]+) to be bootstrapped`)
// Find the first match
match := re.FindStringSubmatch(output)
gomega.Expect(match).ToNot(gomega.BeEmpty())
Expand Down
Loading