From 29b347ef646214f1e69402511f5458e6cce7cf14 Mon Sep 17 00:00:00 2001 From: Raymond Sukanto Date: Wed, 11 Dec 2024 11:16:00 -0500 Subject: [PATCH 1/6] enable mainnet --- cmd/blockchaincmd/deploy.go | 3 +++ cmd/nodecmd/create.go | 2 +- pkg/keychain/keychain.go | 14 +++++++------- pkg/node/local.go | 7 +++++++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/cmd/blockchaincmd/deploy.go b/cmd/blockchaincmd/deploy.go index a90460e0b..ed0f1348b 100644 --- a/cmd/blockchaincmd/deploy.go +++ b/cmd/blockchaincmd/deploy.go @@ -689,6 +689,9 @@ func deployBlockchain(cmd *cobra.Command, args []string) error { if network.Kind == models.Fuji { globalNetworkFlags.UseFuji = true } + if network.Kind == models.Mainnet { + globalNetworkFlags.UseMainnet = true + } // anrSettings, avagoVersionSettings, globalNetworkFlags are empty if err = node.StartLocalNode( app, diff --git a/cmd/nodecmd/create.go b/cmd/nodecmd/create.go index 191a521b3..284c8265a 100644 --- a/cmd/nodecmd/create.go +++ b/cmd/nodecmd/create.go @@ -45,7 +45,7 @@ const ( ) var ( - createSupportedNetworkOptions = []networkoptions.NetworkOption{networkoptions.Fuji, networkoptions.Devnet, networkoptions.EtnaDevnet} + createSupportedNetworkOptions = []networkoptions.NetworkOption{networkoptions.Fuji, networkoptions.Devnet, networkoptions.EtnaDevnet, networkoptions.Mainnet} globalNetworkFlags networkoptions.NetworkFlags useAWS bool useGCP bool diff --git a/pkg/keychain/keychain.go b/pkg/keychain/keychain.go index a595535de..0cd9a8ca7 100644 --- a/pkg/keychain/keychain.go +++ b/pkg/keychain/keychain.go @@ -198,13 +198,13 @@ func GetKeychain( } // always have index 0, for change ledgerIndices := []uint32{0} - if requiredFunds > 0 { - ledgerIndicesAux, err := searchForFundedLedgerIndices(network, ledgerDevice, requiredFunds) - if err != nil { - return nil, err - } - ledgerIndices = append(ledgerIndices, ledgerIndicesAux...) - } + //if requiredFunds > 0 { + // ledgerIndicesAux, err := searchForFundedLedgerIndices(network, ledgerDevice, requiredFunds) + // if err != nil { + // return nil, err + // } + // ledgerIndices = append(ledgerIndices, ledgerIndicesAux...) + //} if len(ledgerAddresses) > 0 { ledgerIndicesAux, err := getLedgerIndices(ledgerDevice, ledgerAddresses) if err != nil { diff --git a/pkg/node/local.go b/pkg/node/local.go index ae2e83e7c..3c447d5a1 100644 --- a/pkg/node/local.go +++ b/pkg/node/local.go @@ -321,6 +321,13 @@ func StartLocalNode( constants.FujiAPIEndpoint, clusterName, ) + case globalNetworkFlags.UseMainnet: + network = models.NewNetwork( + models.Mainnet, + avagoconstants.MainnetID, + constants.MainnetAPIEndpoint, + clusterName, + ) default: network, err = networkoptions.GetNetworkFromCmdLineFlags( app, From be67edf97c5e301f03336a58e571cfdf13902cab Mon Sep 17 00:00:00 2001 From: Felipe Madero Date: Wed, 11 Dec 2024 13:35:20 -0300 Subject: [PATCH 2/6] increase mainnet bootstrapping timeout --- pkg/constants/constants.go | 3 ++- pkg/models/network.go | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index 34fe2a6bb..c7b257d80 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -56,7 +56,8 @@ const ( APIRequestLargeTimeout = 10 * time.Second FastGRPCDialTimeout = 100 * time.Millisecond - FujiBootstrapTimeout = 15 * time.Minute + FujiBootstrapTimeout = 15 * time.Minute + MainnetBootstrapTimeout = time.Hour SSHServerStartTimeout = 1 * time.Minute SSHScriptTimeout = 2 * time.Minute diff --git a/pkg/models/network.go b/pkg/models/network.go index 47249f3d1..c7475cfd0 100644 --- a/pkg/models/network.go +++ b/pkg/models/network.go @@ -232,8 +232,11 @@ func (n *Network) Equals(n2 Network) bool { // Context for bootstrapping a partial synced Node func (n *Network) BootstrappingContext() (context.Context, context.CancelFunc) { timeout := constants.ANRRequestTimeout - if n.Kind == Fuji { + switch n.Kind { + case Fuji: timeout = constants.FujiBootstrapTimeout + case Mainnet: + timeout = constants.MainnetBootstrapTimeout } return context.WithTimeout(context.Background(), timeout) } From f6f5997d68a13b60fb780f52f5bd83d8db310624 Mon Sep 17 00:00:00 2001 From: Felipe Madero Date: Wed, 11 Dec 2024 14:46:18 -0300 Subject: [PATCH 3/6] increase mainnet partial sync timeout --- pkg/constants/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index c7b257d80..7877cc281 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -57,7 +57,7 @@ const ( FastGRPCDialTimeout = 100 * time.Millisecond FujiBootstrapTimeout = 15 * time.Minute - MainnetBootstrapTimeout = time.Hour + MainnetBootstrapTimeout = 2 * time.Hour SSHServerStartTimeout = 1 * time.Minute SSHScriptTimeout = 2 * time.Minute From c6e9a23f3fd8da7853898dbc590e58247f25c251 Mon Sep 17 00:00:00 2001 From: Raymond Sukanto Date: Thu, 12 Dec 2024 18:40:05 -0500 Subject: [PATCH 4/6] add mainnet logger --- pkg/node/local.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/node/local.go b/pkg/node/local.go index 3c447d5a1..3c97d78a3 100644 --- a/pkg/node/local.go +++ b/pkg/node/local.go @@ -344,6 +344,8 @@ func StartLocalNode( } if network.Kind == models.Fuji { ux.Logger.PrintToUser(logging.Yellow.Wrap("Warning: Fuji Bootstrapping can take several minutes")) + } else if network.Kind == models.Mainnet { + ux.Logger.PrintToUser(logging.Yellow.Wrap("Warning: Mainnet Bootstrapping can take 1-2 hours")) } if err := preLocalChecks(anrSettings, avaGoVersionSetting, useEtnaDevnet, globalNetworkFlags); err != nil { return err From 4197f8db82cb57260fc6a734d1a4c91895cb17fc Mon Sep 17 00:00:00 2001 From: Raymond Sukanto Date: Fri, 13 Dec 2024 11:10:57 -0500 Subject: [PATCH 5/6] lint --- pkg/keychain/keychain.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/keychain/keychain.go b/pkg/keychain/keychain.go index 0cd9a8ca7..a595535de 100644 --- a/pkg/keychain/keychain.go +++ b/pkg/keychain/keychain.go @@ -198,13 +198,13 @@ func GetKeychain( } // always have index 0, for change ledgerIndices := []uint32{0} - //if requiredFunds > 0 { - // ledgerIndicesAux, err := searchForFundedLedgerIndices(network, ledgerDevice, requiredFunds) - // if err != nil { - // return nil, err - // } - // ledgerIndices = append(ledgerIndices, ledgerIndicesAux...) - //} + if requiredFunds > 0 { + ledgerIndicesAux, err := searchForFundedLedgerIndices(network, ledgerDevice, requiredFunds) + if err != nil { + return nil, err + } + ledgerIndices = append(ledgerIndices, ledgerIndicesAux...) + } if len(ledgerAddresses) > 0 { ledgerIndicesAux, err := getLedgerIndices(ledgerDevice, ledgerAddresses) if err != nil { From 35fd87a5f4ac3547e8ab0a3c2574d57f33aec855 Mon Sep 17 00:00:00 2001 From: Raymond Sukanto Date: Fri, 13 Dec 2024 11:23:57 -0500 Subject: [PATCH 6/6] fix lint --- cmd/blockchaincmd/deploy.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/blockchaincmd/deploy.go b/cmd/blockchaincmd/deploy.go index 19a6ac618..5b1a58cc7 100644 --- a/cmd/blockchaincmd/deploy.go +++ b/cmd/blockchaincmd/deploy.go @@ -1231,7 +1231,6 @@ func setBootstrapValidatorValidationID(avaGoBootstrapValidators []*txs.ConvertSu } } - func getClusterBootstrapValidators( clusterName string, network models.Network,