Skip to content

Commit

Permalink
integrate deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
sukantoraymond committed Oct 15, 2024
1 parent c729cab commit 6507c94
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
27 changes: 17 additions & 10 deletions cmd/blockchaincmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/ava-labs/avalanche-cli/pkg/evm"

Check failure on line 10 in cmd/blockchaincmd/deploy.go

View workflow job for this annotation

GitHub Actions / Lint

File is not `gofumpt`-ed (gofumpt)
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -743,9 +744,12 @@ func deployBlockchain(cmd *cobra.Command, args []string) error {
}

if !generateNodeID {
clusterName, err := node.GetClusterNameFromList(app)
if err != nil {
return err
clusterName := network.ClusterName
if clusterName == "" {
clusterName, err = node.GetClusterNameFromList(app)
if err != nil {
return err
}
}

if !useLocalMachine {
Expand All @@ -761,7 +765,6 @@ func deployBlockchain(cmd *cobra.Command, args []string) error {
return err
}
}

chainSpec := contract.ChainSpec{
BlockchainName: blockchainName,
}
Expand All @@ -783,25 +786,29 @@ func deployBlockchain(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
aggregatorExtraPeerEndpoints, err := GetAggregatorExtraPeerEndpoints(network)
client, err := evm.GetClient(rpcURL)
if err != nil {
return err
}
evm.WaitForChainID(client)
privateAggregatorEndpoints, err := GetAggregatorExtraPeerEndpoints(network)
if err != nil {
return err
}
ux.Logger.PrintToUser("Initializing Proof of Authority Validator Manager contract on blockchain %s ...\", blockchainName")

Check failure on line 798 in cmd/blockchaincmd/deploy.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (macos-14)

(*github.com/ava-labs/avalanche-cli/pkg/ux.UserLog).PrintToUser format %s reads arg #1, but call has 0 args

Check failure on line 798 in cmd/blockchaincmd/deploy.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (ubuntu-22.04)

(*github.com/ava-labs/avalanche-cli/pkg/ux.UserLog).PrintToUser format %s reads arg #1, but call has 0 args
if err := validatormanager.SetupPoA(
app,
network,
rpcURL,
contract.ChainSpec{
BlockchainName: blockchainName,
},
chainSpec,
genesisPrivateKey,
common.HexToAddress(sidecar.PoAValidatorManagerOwner),
avaGoBootstrapValidators,
aggregatorExtraPeerEndpoints,
privateAggregatorEndpoints,
); err != nil {
return err
}
ux.Logger.GreenCheckmarkToUser("L1 is successfully converted to sovereign blockchain")
ux.Logger.GreenCheckmarkToUser("Proof of Authority Validator Manager contract successfully initialized on blockchain %s", blockchainName)
} else {
ux.Logger.GreenCheckmarkToUser("Generated Node ID and BLS info for bootstrap validator(s)")
ux.Logger.PrintToUser("To convert L1 to sovereign blockchain, create the corresponding Avalanche node(s) with the provided Node ID and BLS Info")
Expand Down
1 change: 1 addition & 0 deletions cmd/contractcmd/init_poa_validator_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func initPOAManager(_ *cobra.Command, args []string) error {
return err
}
}
fmt.Printf("obtained rpc url %s \n", initPOAManagerFlags.rpcEndpoint)
ux.Logger.PrintToUser(logging.Yellow.Wrap("RPC Endpoint: %s"), initPOAManagerFlags.rpcEndpoint)
genesisAddress, genesisPrivateKey, err := contract.GetEVMSubnetPrefundedKey(
app,
Expand Down
24 changes: 24 additions & 0 deletions pkg/evm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,30 @@ func GetClient(rpcURL string) (ethclient.Client, error) {
return client, err
}

func WaitForChainID(client ethclient.Client) {
startTime := time.Now()
spinSession := ux.NewUserSpinner()
spinner := spinSession.SpinToUser("Checking if node is healthy...")
for {
ctx, cancel := utils.GetAPILargeContext()
defer cancel()
_, err := client.ChainID(ctx)
if err == nil {
ux.SpinComplete(spinner)
spinSession.Stop()
ux.Logger.GreenCheckmarkToUser("Node is healthy after %d seconds", uint32(time.Since(startTime).Seconds()))
break
} else {
if time.Since(startTime) > 60*time.Second {
ux.SpinFailWithError(spinner, "", fmt.Errorf("failure getting chain id from client %#v: %w", client, err))
spinSession.Stop()
break
}
time.Sleep(5 * time.Second)
}
}
}

func GetChainID(client ethclient.Client) (*big.Int, error) {
var (
chainID *big.Int
Expand Down

0 comments on commit 6507c94

Please sign in to comment.