diff --git a/cmd/blockchaincmd/deploy.go b/cmd/blockchaincmd/deploy.go index d772696c1..abf84a218 100644 --- a/cmd/blockchaincmd/deploy.go +++ b/cmd/blockchaincmd/deploy.go @@ -26,7 +26,6 @@ import ( "github.com/ava-labs/avalanche-cli/pkg/contract" "github.com/ava-labs/avalanche-cli/pkg/utils" - "github.com/ava-labs/avalanchego/config" "github.com/ava-labs/avalanchego/utils/formatting/address" "github.com/ava-labs/avalanchego/vms/platformvm/fx" "github.com/ava-labs/avalanchego/vms/platformvm/signer" @@ -82,6 +81,7 @@ var ( avagoBinaryPath string numBootstrapValidators int numLocalNodes int + partialSync bool changeOwnerAddress string subnetOnly bool icmSpec subnet.ICMSpec @@ -152,6 +152,7 @@ so you can take your locally tested Subnet and deploy it on Fuji or Mainnet.`, cmd.Flags().IntVar(&numBootstrapValidators, "num-bootstrap-validators", 0, "(only if --generate-node-id is true) number of bootstrap validators to set up in sovereign L1 validator)") cmd.Flags().IntVar(&numLocalNodes, "num-local-nodes", 5, "number of nodes to be created on local machine") cmd.Flags().StringVar(&changeOwnerAddress, "change-owner-address", "", "address that will receive change if node is no longer L1 validator") + cmd.Flags().BoolVar(&partialSync, "partial-sync", true, "set primary network partial sync for new validators") return cmd } @@ -542,7 +543,6 @@ func deployBlockchain(cmd *cobra.Command, args []string) error { return err } } - nodeConfig[config.PartialSyncPrimaryNetworkKey] = true // anrSettings, avagoVersionSettings, globalNetworkFlags are empty if err = node.StartLocalNode( app, @@ -550,6 +550,7 @@ func deployBlockchain(cmd *cobra.Command, args []string) error { useEtnaDevnet, avagoBinaryPath, uint32(numLocalNodes), + partialSync, nodeConfig, anrSettings, avagoVersionSettings, diff --git a/cmd/nodecmd/create.go b/cmd/nodecmd/create.go index aa3e589e1..fd0fab29c 100644 --- a/cmd/nodecmd/create.go +++ b/cmd/nodecmd/create.go @@ -129,6 +129,7 @@ will apply to all nodes in the cluster`, cmd.Flags().StringArrayVar(&bootstrapIPs, "bootstrap-ips", []string{}, "IP:port pairs of bootstrap nodes") cmd.Flags().StringVar(&genesisPath, "genesis", "", "path to genesis file") cmd.Flags().StringVar(&upgradePath, "upgrade", "", "path to upgrade file") + cmd.Flags().BoolVar(&partialSync, "partial-sync", true, "primary network partial sync") return cmd } @@ -231,6 +232,10 @@ func preCreateChecks(clusterName string) error { return fmt.Errorf("invalid ip:port pair %s", ipPortPair) } } + if globalNetworkFlags.UseDevnet { + partialSync = false + ux.Logger.PrintToUser("disabling partial sync default for devnet") + } return nil } @@ -790,10 +795,12 @@ func createNodes(cmd *cobra.Command, args []string) error { avalancheGoVersion, bootstrapIDs, bootstrapIPs, + partialSync, genesisPath, upgradePath, addMonitoring, - publicAccessToHTTPPort); err != nil { + publicAccessToHTTPPort, + ); err != nil { nodeResults.AddResult(host.NodeID, nil, err) ux.SpinFailWithError(spinner, "", err) return diff --git a/cmd/nodecmd/local.go b/cmd/nodecmd/local.go index 91a894a0a..2ba631349 100644 --- a/cmd/nodecmd/local.go +++ b/cmd/nodecmd/local.go @@ -10,7 +10,6 @@ import ( "github.com/ava-labs/avalanche-cli/pkg/node" "github.com/ava-labs/avalanche-cli/pkg/utils" "github.com/ava-labs/avalanche-cli/pkg/ux" - "github.com/ava-labs/avalanchego/config" "github.com/ava-labs/avalanchego/utils/logging" "github.com/spf13/cobra" ) @@ -27,6 +26,7 @@ var ( stakingSignerKeyPath string numNodes uint32 nodeConfigPath string + partialSync bool ) // const snapshotName = "local_snapshot" @@ -85,6 +85,7 @@ status by running avalanche node status local cmd.Flags().StringVar(&stakingSignerKeyPath, "staking-signer-key-path", "", "path to provided staking signer key for node") cmd.Flags().Uint32Var(&numNodes, "num-nodes", 1, "number of nodes to start") cmd.Flags().StringVar(&nodeConfigPath, "node-config", "", "path to common avalanchego config settings for all nodes") + cmd.Flags().BoolVar(&partialSync, "partial-sync", true, "primary network partial sync") return cmd } @@ -162,7 +163,6 @@ func localStartNode(_ *cobra.Command, args []string) error { return err } } - nodeConfig[config.PartialSyncPrimaryNetworkKey] = true return node.StartLocalNode( app, @@ -170,6 +170,7 @@ func localStartNode(_ *cobra.Command, args []string) error { globalNetworkFlags.UseEtnaDevnet, avalanchegoBinaryPath, numNodes, + partialSync, nodeConfig, anrSettings, avaGoVersionSetting, diff --git a/pkg/docker/config.go b/pkg/docker/config.go index 16c26f827..8a8a303c9 100644 --- a/pkg/docker/config.go +++ b/pkg/docker/config.go @@ -17,6 +17,7 @@ import ( type AvalancheGoConfigOptions struct { BootstrapIPs []string BootstrapIDs []string + PartialSync bool GenesisPath string UpgradePath string AllowPublicAccess bool @@ -31,6 +32,7 @@ func prepareAvalanchegoConfig( if avalancheGoConfig.AllowPublicAccess || utils.IsE2E() { avagoConf.HTTPHost = "0.0.0.0" } + avagoConf.PartialSync = avalancheGoConfig.PartialSync avagoConf.BootstrapIPs = strings.Join(avalancheGoConfig.BootstrapIPs, ",") avagoConf.BootstrapIDs = strings.Join(avalancheGoConfig.BootstrapIDs, ",") if avalancheGoConfig.GenesisPath != "" { diff --git a/pkg/docker/ssh.go b/pkg/docker/ssh.go index 7c7b83223..aab8a089c 100644 --- a/pkg/docker/ssh.go +++ b/pkg/docker/ssh.go @@ -31,6 +31,7 @@ func ComposeSSHSetupNode( avalancheGoVersion string, avalanchegoBootstrapIDs []string, avalanchegoBootstrapIPs []string, + partialSync bool, avalanchegoGenesisFilePath string, avalanchegoUpgradeFilePath string, withMonitoring bool, @@ -57,6 +58,7 @@ func ComposeSSHSetupNode( AvalancheGoConfigOptions{ BootstrapIDs: avalanchegoBootstrapIDs, BootstrapIPs: avalanchegoBootstrapIPs, + PartialSync: partialSync, GenesisPath: avalanchegoGenesisFilePath, UpgradePath: avalanchegoUpgradeFilePath, AllowPublicAccess: publicAccessToHTTPPort, diff --git a/pkg/node/local.go b/pkg/node/local.go index a8acef90c..354c38743 100644 --- a/pkg/node/local.go +++ b/pkg/node/local.go @@ -24,6 +24,7 @@ import ( "github.com/ava-labs/avalanche-network-runner/client" anrutils "github.com/ava-labs/avalanche-network-runner/utils" "github.com/ava-labs/avalanchego/api/info" + "github.com/ava-labs/avalanchego/config" "github.com/ava-labs/avalanchego/ids" avagoconstants "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/logging" @@ -155,6 +156,7 @@ func StartLocalNode( useEtnaDevnet bool, avalanchegoBinaryPath string, numNodes uint32, + partialSync bool, nodeConfig map[string]interface{}, anrSettings ANRSettings, avaGoVersionSetting AvalancheGoVersionSettings, @@ -237,6 +239,10 @@ func StartLocalNode( return nil } + if partialSync { + nodeConfig[config.PartialSyncPrimaryNetworkKey] = true + } + nodeConfigBytes, err := json.Marshal(nodeConfig) if err != nil { return err diff --git a/pkg/remoteconfig/avalanche.go b/pkg/remoteconfig/avalanche.go index a51c140f9..777539fe9 100644 --- a/pkg/remoteconfig/avalanche.go +++ b/pkg/remoteconfig/avalanche.go @@ -27,6 +27,7 @@ type AvalancheConfigInputs struct { TrackSubnets string BootstrapIDs string BootstrapIPs string + PartialSync bool GenesisPath string UpgradePath string ProposerVMUseCurrentHeight bool diff --git a/pkg/remoteconfig/templates/avalanche-node.tmpl b/pkg/remoteconfig/templates/avalanche-node.tmpl index 45d7849fd..dfd9e318e 100644 --- a/pkg/remoteconfig/templates/avalanche-node.tmpl +++ b/pkg/remoteconfig/templates/avalanche-node.tmpl @@ -4,6 +4,7 @@ "index-enabled": {{.IndexEnabled}}, "proposervm-use-current-height-bool": {{.ProposerVMUseCurrentHeight}}, "network-id": "{{if .NetworkID}}{{.NetworkID}}{{else}}fuji{{end}}", + "partial-sync-primary-network": "{{ .PartialSync }}", {{- if .BootstrapIDs }} "bootstrap-ids": "{{ .BootstrapIDs }}", {{- end }} diff --git a/pkg/ssh/ssh.go b/pkg/ssh/ssh.go index 2339643e2..858c6c72e 100644 --- a/pkg/ssh/ssh.go +++ b/pkg/ssh/ssh.go @@ -24,6 +24,7 @@ import ( "github.com/ava-labs/avalanche-cli/pkg/remoteconfig" "github.com/ava-labs/avalanche-cli/pkg/utils" "github.com/ava-labs/avalanche-cli/pkg/ux" + "github.com/ava-labs/avalanchego/config" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanche-cli/pkg/constants" @@ -587,6 +588,13 @@ func RunSSHRenderAvalancheNodeConfig( bootstrapIPs, _ := utils.StringValue(remoteAvagoConf, "bootstrap-ips") avagoConf.BootstrapIDs = bootstrapIDs avagoConf.BootstrapIPs = bootstrapIPs + partialSyncI, ok := remoteAvagoConf[config.PartialSyncPrimaryNetworkKey] + if ok { + partialSync, ok := partialSyncI.(bool) + if ok { + avagoConf.PartialSync = partialSync + } + } } // ready to render node config nodeConf, err := remoteconfig.RenderAvalancheNodeConfig(avagoConf)