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

Enable mainnet #2427

Merged
merged 9 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions cmd/blockchaincmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion cmd/nodecmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ const (
APIRequestLargeTimeout = 10 * time.Second
FastGRPCDialTimeout = 100 * time.Millisecond

FujiBootstrapTimeout = 15 * time.Minute
FujiBootstrapTimeout = 15 * time.Minute
MainnetBootstrapTimeout = 2 * time.Hour

SSHServerStartTimeout = 1 * time.Minute
SSHScriptTimeout = 2 * time.Minute
Expand Down
14 changes: 7 additions & 7 deletions pkg/keychain/keychain.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
ledgerAddresses []string,
keyName string,
network models.Network,
requiredFunds uint64,

Check failure on line 188 in pkg/keychain/keychain.go

View workflow job for this annotation

GitHub Actions / Lint

unused-parameter: parameter 'requiredFunds' seems to be unused, consider removing or renaming it as _ (revive)
) (*Keychain, error) {
if !useEwoq && !useLedger && keyName == "" {
return nil, fmt.Errorf("one of the options ewoq/ledger/keyName must be provided")
Expand All @@ -198,13 +198,13 @@
}
// 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 {

Check failure on line 201 in pkg/keychain/keychain.go

View workflow job for this annotation

GitHub Actions / Lint

commentFormatting: put a space between `//` and comment text (gocritic)
// ledgerIndicesAux, err := searchForFundedLedgerIndices(network, ledgerDevice, requiredFunds)
// if err != nil {
// return nil, err
// }
// ledgerIndices = append(ledgerIndices, ledgerIndicesAux...)
//}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will need to undo this change

if len(ledgerAddresses) > 0 {
ledgerIndicesAux, err := getLedgerIndices(ledgerDevice, ledgerAddresses)
if err != nil {
Expand Down Expand Up @@ -279,7 +279,7 @@
}

// search for a set of indices that pay a given amount
func searchForFundedLedgerIndices(network models.Network, ledgerDevice keychain.Ledger, amount uint64) ([]uint32, error) {

Check failure on line 282 in pkg/keychain/keychain.go

View workflow job for this annotation

GitHub Actions / Lint

func `searchForFundedLedgerIndices` is unused (unused)
ux.Logger.PrintToUser("Looking for ledger indices to pay for %.9f AVAX...", float64(amount)/float64(units.Avax))
pClient := platformvm.NewClient(network.Endpoint)
totalBalance := uint64(0)
Expand Down
5 changes: 4 additions & 1 deletion pkg/models/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/node/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading