From de6895ec156b5032cb53f0f437334875d993ed27 Mon Sep 17 00:00:00 2001 From: Fornax <23104993+0xfornax@users.noreply.github.com> Date: Tue, 3 Jun 2025 12:13:46 -0300 Subject: [PATCH 1/4] Remove initialize voting power functions and checks --- bindings/network/voting.go | 56 ------ rocketpool-cli/network/dao-proposals.go | 5 - rocketpool-cli/node/status.go | 6 - rocketpool-cli/pdao/commands.go | 12 -- .../pdao/initialize-voting-with-delegate.go | 68 ------- rocketpool-cli/pdao/initialize-voting.go | 90 ---------- rocketpool-cli/pdao/status.go | 5 - rocketpool/api/network/dao-proposals.go | 22 +-- rocketpool/api/node/status.go | 7 - rocketpool/api/pdao/commands.go | 100 ----------- .../pdao/initialize-voting-with-delegate.go | 116 ------------ rocketpool/api/pdao/initialize-voting.go | 131 -------------- rocketpool/api/pdao/set-snapshot-address.go | 10 -- rocketpool/api/pdao/status.go | 21 +-- rocketpool/node/auto-init-voting-power.go | 167 ------------------ .../node/collectors/snapshot-collector.go | 14 +- rocketpool/node/node.go | 19 +- shared/services/config/smartnode-config.go | 17 -- shared/types/api/network.go | 1 - shared/types/api/node.go | 1 - shared/types/api/pdao.go | 10 +- 21 files changed, 16 insertions(+), 862 deletions(-) delete mode 100644 rocketpool-cli/pdao/initialize-voting-with-delegate.go delete mode 100644 rocketpool-cli/pdao/initialize-voting.go delete mode 100644 rocketpool/api/pdao/initialize-voting-with-delegate.go delete mode 100644 rocketpool/api/pdao/initialize-voting.go delete mode 100644 rocketpool/node/auto-init-voting-power.go diff --git a/bindings/network/voting.go b/bindings/network/voting.go index db39eae30..d5ad8ec5b 100644 --- a/bindings/network/voting.go +++ b/bindings/network/voting.go @@ -88,62 +88,6 @@ func GetNodeInfoSnapshotFast(rp *rocketpool.RocketPool, blockNumber uint32, mult return votingInfos, nil } -// Check whether or not on-chain voting has been initialized for the given node -func GetVotingInitialized(rp *rocketpool.RocketPool, address common.Address, opts *bind.CallOpts) (bool, error) { - rocketNetworkVoting, err := getRocketNetworkVoting(rp, nil) - if err != nil { - return false, err - } - value := new(bool) - if err := rocketNetworkVoting.Call(opts, value, "getVotingInitialised", address); err != nil { - return false, fmt.Errorf("error getting voting initialized status: %w", err) - } - return *value, nil -} - -// Estimate the gas of InitializeVoting -func EstimateInitializeVotingGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { - rocketNetworkVoting, err := getRocketNetworkVoting(rp, nil) - if err != nil { - return rocketpool.GasInfo{}, err - } - return rocketNetworkVoting.GetTransactionGasInfo(opts, "initialiseVoting") -} - -// Initialize on-chain voting for the node -func InitializeVoting(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (common.Hash, error) { - rocketNetworkVoting, err := getRocketNetworkVoting(rp, nil) - if err != nil { - return common.Hash{}, err - } - tx, err := rocketNetworkVoting.Transact(opts, "initialiseVoting") - if err != nil { - return common.Hash{}, fmt.Errorf("error initializing voting: %w", err) - } - return tx.Hash(), nil -} - -// Estimate the gas of InitializeVotingWithDelegate -func EstimateInitializeVotingWithDelegateGas(rp *rocketpool.RocketPool, delegateAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { - rocketNetworkVoting, err := getRocketNetworkVoting(rp, nil) - if err != nil { - return rocketpool.GasInfo{}, err - } - return rocketNetworkVoting.GetTransactionGasInfo(opts, "initialiseVotingWithDelegate", delegateAddress) -} - -// Initialize on-chain voting for the node and delegate voting power at the same transaction -func InitializeVotingWithDelegate(rp *rocketpool.RocketPool, delegateAddress common.Address, opts *bind.TransactOpts) (common.Hash, error) { - rocketNetworkVoting, err := getRocketNetworkVoting(rp, nil) - if err != nil { - return common.Hash{}, err - } - tx, err := rocketNetworkVoting.Transact(opts, "initialiseVotingWithDelegate", delegateAddress) - if err != nil { - return common.Hash{}, fmt.Errorf("error initializing voting with delegate: %w", err) - } - return tx.Hash(), nil -} // Get the number of nodes that were present in the network at the provided block func GetVotingNodeCount(rp *rocketpool.RocketPool, blockNumber uint32, opts *bind.CallOpts) (*big.Int, error) { diff --git a/rocketpool-cli/network/dao-proposals.go b/rocketpool-cli/network/dao-proposals.go index 2fa0efae0..d4d918a45 100644 --- a/rocketpool-cli/network/dao-proposals.go +++ b/rocketpool-cli/network/dao-proposals.go @@ -134,11 +134,6 @@ func getActiveDAOProposals(c *cli.Context) error { // Onchain Voting Status fmt.Printf("%s=== Onchain Voting ===%s\n", colorGreen, colorReset) - if snapshotProposalsResponse.IsVotingInitialized { - fmt.Printf("The node %s%s%s has been initialized for onchain voting.\n", colorBlue, snapshotProposalsResponse.AccountAddressFormatted, colorReset) - } else { - fmt.Printf("The node %s%s%s has NOT been initialized for onchain voting. You need to run `rocketpool pdao initialize-voting` to participate in onchain votes.\n", colorBlue, snapshotProposalsResponse.AccountAddressFormatted, colorReset) - } if snapshotProposalsResponse.OnchainVotingDelegate == blankAddress { fmt.Println("The node doesn't have a delegate, which means it can vote directly on onchain proposals after it initializes voting.") diff --git a/rocketpool-cli/node/status.go b/rocketpool-cli/node/status.go index 9b8f43c79..23b572c96 100644 --- a/rocketpool-cli/node/status.go +++ b/rocketpool-cli/node/status.go @@ -204,12 +204,6 @@ func getStatus(c *cli.Context) error { // Onchain voting status fmt.Printf("%s=== Onchain Voting ===%s\n", colorGreen, colorReset) - if status.IsVotingInitialized { - fmt.Println("The node has been initialized for onchain voting.") - - } else { - fmt.Println("The node has NOT been initialized for onchain voting. You need to run `rocketpool pdao initialize-voting` to participate in onchain votes.") - } if status.OnchainVotingDelegate == blankAddress { fmt.Println("The node doesn't have a delegate, which means it can vote directly on onchain proposals after it initializes voting.") diff --git a/rocketpool-cli/pdao/commands.go b/rocketpool-cli/pdao/commands.go index 017134fb2..ab6fc3ca8 100644 --- a/rocketpool-cli/pdao/commands.go +++ b/rocketpool-cli/pdao/commands.go @@ -67,18 +67,6 @@ func RegisterCommands(app *cli.App, name string, aliases []string) { }, }, - { - Name: "initialize-voting", - Aliases: []string{"iv"}, - Usage: "Unlocks a node operator's voting power (only required for node operators who registered before governance structure was in place)", - UsageText: "rocketpool pdao initialize-voting", - Action: func(c *cli.Context) error { - - // Run - return initializeVotingPrompt(c) - - }, - }, { Name: "set-signalling-address", Aliases: []string{"ssa"}, diff --git a/rocketpool-cli/pdao/initialize-voting-with-delegate.go b/rocketpool-cli/pdao/initialize-voting-with-delegate.go deleted file mode 100644 index 4eff04319..000000000 --- a/rocketpool-cli/pdao/initialize-voting-with-delegate.go +++ /dev/null @@ -1,68 +0,0 @@ -package pdao - -import ( - "fmt" - - "github.com/rocket-pool/smartnode/shared/services/gas" - "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" - "github.com/urfave/cli" -) - -func initializeVotingWithDelegate(c *cli.Context) error { - // Get RP client - rp, err := rocketpool.NewClientFromCtx(c).WithReady() - if err != nil { - return err - } - defer rp.Close() - - // Get the address - delegateAddressString := c.String("address") - if delegateAddressString == "" { - delegateAddressString = prompt.Prompt("Please enter the delegate's address:", "^0x[0-9a-fA-F]{40}$", "Invalid member address") - } - delegateAddress, err := cliutils.ValidateAddress("delegateAddress", delegateAddressString) - if err != nil { - return err - } - - resp, err := rp.CanInitializeVotingWithDelegate(delegateAddress) - if err != nil { - return fmt.Errorf("error calling get-voting-initialized: %w", err) - } - - if resp.VotingInitialized { - fmt.Println("Node voting was already initialized") - return nil - } - - // Assign max fees - err = gas.AssignMaxFeeAndLimit(resp.GasInfo, rp, c.Bool("yes")) - if err != nil { - return err - } - - // Prompt for confirmation - if !(c.Bool("yes") || prompt.Confirm("Are you sure you want to initialize voting?")) { - fmt.Println("Cancelled.") - return nil - } - - // Initialize voting - response, err := rp.InitializeVotingWithDelegate(delegateAddress) - if err != nil { - return fmt.Errorf("error calling initialize-voting: %w", err) - } - - fmt.Printf("Initializing voting...\n") - cliutils.PrintTransactionHash(rp, response.TxHash) - if _, err = rp.WaitForTransaction(response.TxHash); err != nil { - return fmt.Errorf("error initializing voting: %w", err) - } - - // Log & return - fmt.Println("Successfully initialized voting.") - return nil -} diff --git a/rocketpool-cli/pdao/initialize-voting.go b/rocketpool-cli/pdao/initialize-voting.go deleted file mode 100644 index fb6dbe00d..000000000 --- a/rocketpool-cli/pdao/initialize-voting.go +++ /dev/null @@ -1,90 +0,0 @@ -package pdao - -import ( - "fmt" - "strings" - - "github.com/rocket-pool/smartnode/shared/services/gas" - "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" - "github.com/urfave/cli" -) - -func initializeVotingPrompt(c *cli.Context) error { - fmt.Println("Thanks for initializing your voting power!") - fmt.Println("") - fmt.Println("You have two options:") - fmt.Println("") - fmt.Println("1. Vote directly (delegate vote power to yourself)") - fmt.Println(" This will allow you to vote on proposals directly,") - fmt.Println(" allowing you to personally shape the direction of the protocol.") - fmt.Println("") - fmt.Println("2. Delegate your vote") - fmt.Println(" This will delegate your vote power to someone you trust,") - fmt.Println(" giving them the power to vote on your behalf. You will have the option to override.") - fmt.Println("") - fmt.Printf("You can see a list of existing public delegates at %s,\n", "https://delegates.rocketpool.net") - fmt.Println("however, you can delegate to any node address.") - fmt.Println("") - fmt.Printf("Learn more about how this all works via: %s\n", "https://docs.rocketpool.net/guides/houston/participate#participating-in-on-chain-pdao-proposals") - fmt.Println("") - - inputString := prompt.Prompt("Please type `direct` or `delegate` to continue:", "^(?i)(direct|delegate)$", "Please type `direct` or `delegate` to continue:") - switch strings.ToLower(inputString) { - case "direct": - return initializeVoting(c) - case "delegate": - return initializeVotingWithDelegate(c) - } - return nil - -} - -func initializeVoting(c *cli.Context) error { - - // Get RP client - rp, err := rocketpool.NewClientFromCtx(c).WithReady() - if err != nil { - return err - } - defer rp.Close() - - resp, err := rp.CanInitializeVoting() - if err != nil { - return fmt.Errorf("error calling get-voting-initialized: %w", err) - } - - if resp.VotingInitialized { - fmt.Println("Node voting was already initialized") - return nil - } - - // Assign max fees - err = gas.AssignMaxFeeAndLimit(resp.GasInfo, rp, c.Bool("yes")) - if err != nil { - return err - } - - // Prompt for confirmation - if !(c.Bool("yes") || prompt.Confirm("Are you sure you want to initialize voting?")) { - fmt.Println("Cancelled.") - return nil - } - - // Initialize voting - response, err := rp.InitializeVoting() - if err != nil { - return fmt.Errorf("error calling initialize-voting: %w", err) - } - - fmt.Printf("Initializing voting...\n") - cliutils.PrintTransactionHash(rp, response.TxHash) - if _, err = rp.WaitForTransaction(response.TxHash); err != nil { - return fmt.Errorf("error initializing voting: %w", err) - } - - // Log & return - fmt.Println("Successfully initialized voting.") - return nil -} diff --git a/rocketpool-cli/pdao/status.go b/rocketpool-cli/pdao/status.go index ba616bc3d..8354a339f 100644 --- a/rocketpool-cli/pdao/status.go +++ b/rocketpool-cli/pdao/status.go @@ -98,11 +98,6 @@ func getStatus(c *cli.Context) error { // Onchain Voting Status fmt.Printf("%s=== Onchain Voting ===%s\n", colorGreen, colorReset) - if response.IsVotingInitialized { - fmt.Printf("The node %s%s%s has been initialized for onchain voting.\n", colorBlue, response.AccountAddressFormatted, colorReset) - } else { - fmt.Printf("The node %s%s%s has NOT been initialized for onchain voting. You need to run `rocketpool pdao initialize-voting` to participate in onchain votes.\n", colorBlue, response.AccountAddressFormatted, colorReset) - } if response.OnchainVotingDelegate == blankAddress { fmt.Println("The node doesn't have a delegate, which means it can vote directly on onchain proposals after it initializes voting.") diff --git a/rocketpool/api/network/dao-proposals.go b/rocketpool/api/network/dao-proposals.go index 97ae79577..bd36f5a7e 100644 --- a/rocketpool/api/network/dao-proposals.go +++ b/rocketpool/api/network/dao-proposals.go @@ -3,7 +3,6 @@ package network import ( "context" "fmt" - "math/big" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -63,13 +62,6 @@ func getActiveDAOProposals(c *cli.Context) (*api.NetworkDAOProposalsResponse, er var wg errgroup.Group var blockNumber uint64 - // Check if Voting is initialized and add to response - wg.Go(func() error { - var err error - response.IsVotingInitialized, err = network.GetVotingInitialized(rp, nodeAccount.Address, nil) - return err - }) - // Get the node onchain voting delegate wg.Go(func() error { var err error @@ -142,16 +134,12 @@ func getActiveDAOProposals(c *cli.Context) (*api.NetworkDAOProposalsResponse, er return nil, err } - // Get the delegated voting power if voting is initialized - if response.IsVotingInitialized { - totalDelegatedVP, _, _, err := propMgr.GetArtifactsForVoting(response.BlockNumber, nodeAccount.Address) - if err != nil { - return nil, err - } - response.TotalDelegatedVp = totalDelegatedVP - } else { - response.TotalDelegatedVp = big.NewInt(0) + // Get the delegated voting power + totalDelegatedVP, _, _, err := propMgr.GetArtifactsForVoting(response.BlockNumber, nodeAccount.Address) + if err != nil { + return nil, err } + response.TotalDelegatedVp = totalDelegatedVP // Get the local tree votingTree, err := propMgr.GetNetworkTree(response.BlockNumber, nil) diff --git a/rocketpool/api/node/status.go b/rocketpool/api/node/status.go index 60d45f2d1..16798762c 100644 --- a/rocketpool/api/node/status.go +++ b/rocketpool/api/node/status.go @@ -276,13 +276,6 @@ func getStatus(c *cli.Context) (*api.NodeStatusResponse, error) { }) } - // Check if Voting is Initialized - wg.Go(func() error { - var err error - response.IsVotingInitialized, err = network.GetVotingInitialized(rp, nodeAccount.Address, nil) - return err - }) - // Get the node onchain voting delegate wg.Go(func() error { var err error diff --git a/rocketpool/api/pdao/commands.go b/rocketpool/api/pdao/commands.go index 23f761e42..ed3266c24 100644 --- a/rocketpool/api/pdao/commands.go +++ b/rocketpool/api/pdao/commands.go @@ -922,106 +922,6 @@ func RegisterSubcommands(command *cli.Command, name string, aliases []string) { }, }, - { - Name: "can-initialize-voting-with-delegate", - Aliases: []string{"civd"}, - Usage: "Checks if voting can be initialized.", - UsageText: "rocketpool api pdao can-initialize-voting-with-delegate delegate-address", - Action: func(c *cli.Context) error { - - // Validate args - if err := cliutils.ValidateArgCount(c, 1); err != nil { - return err - } - - delegateAddress, err := cliutils.ValidateAddress("delegate address", c.Args().Get(0)) - if err != nil { - return err - } - - // Run - api.PrintResponse(canNodeInitializeVotingWithDelegate(c, delegateAddress)) - return nil - - }, - }, - { - Name: "initialize-voting-with-delegate", - Aliases: []string{"ivd"}, - Usage: "Initialize voting with delegate.", - UsageText: "rocketpool api pdao initialize-voting-with-delegate delegate-address", - Action: func(c *cli.Context) error { - - // Validate args - if err := cliutils.ValidateArgCount(c, 1); err != nil { - return err - } - - delegateAddress, err := cliutils.ValidateAddress("delegate address", c.Args().Get(0)) - if err != nil { - return err - } - - // Run - api.PrintResponse(nodeInitializeVotingWithDelegate(c, delegateAddress)) - return nil - - }, - }, - { - Name: "is-voting-initialized", - Aliases: []string{"ivi"}, - Usage: "Checks if voting is initialized.", - UsageText: "rocketpool api pdao is-voting-initialized", - Action: func(c *cli.Context) error { - - // Validate args - if err := cliutils.ValidateArgCount(c, 0); err != nil { - return err - } - - // Run - api.PrintResponse(isVotingInitialized(c)) - return nil - - }, - }, - { - Name: "can-initialize-voting", - Aliases: []string{"civ"}, - Usage: "Checks if voting can be initialized.", - UsageText: "rocketpool api pdao can-initialize-voting", - Action: func(c *cli.Context) error { - - // Validate args - if err := cliutils.ValidateArgCount(c, 0); err != nil { - return err - } - - // Run - api.PrintResponse(canNodeInitializeVoting(c)) - return nil - - }, - }, - { - Name: "initialize-voting", - Aliases: []string{"iv"}, - Usage: "Initialize voting.", - UsageText: "rocketpool api pdao initialize-voting", - Action: func(c *cli.Context) error { - - // Validate args - if err := cliutils.ValidateArgCount(c, 0); err != nil { - return err - } - - // Run - api.PrintResponse(nodeInitializeVoting(c)) - return nil - - }, - }, { Name: "estimate-set-voting-delegate-gas", Usage: "Estimate the gas required to set an on-chain voting delegate", diff --git a/rocketpool/api/pdao/initialize-voting-with-delegate.go b/rocketpool/api/pdao/initialize-voting-with-delegate.go deleted file mode 100644 index e43350ec9..000000000 --- a/rocketpool/api/pdao/initialize-voting-with-delegate.go +++ /dev/null @@ -1,116 +0,0 @@ -package pdao - -import ( - "fmt" - - "github.com/ethereum/go-ethereum/common" - "github.com/urfave/cli" - - "github.com/rocket-pool/smartnode/bindings/network" - "github.com/rocket-pool/smartnode/shared/services" - "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/eth1" -) - -func canNodeInitializeVotingWithDelegate(c *cli.Context, delegateAddress common.Address) (*api.PDAOCanInitializeVotingResponse, error) { - - // Get services - if err := services.RequireNodeWallet(c); err != nil { - return nil, err - } - if err := services.RequireRocketStorage(c); err != nil { - return nil, err - } - w, err := services.GetWallet(c) - if err != nil { - return nil, err - } - rp, err := services.GetRocketPool(c) - if err != nil { - return nil, err - } - nodeAccount, err := w.GetNodeAccount() - if err != nil { - return nil, err - } - - // Response - response := api.PDAOCanInitializeVotingResponse{} - - isInitialized, err := network.GetVotingInitialized(rp, nodeAccount.Address, nil) - if err != nil { - return nil, err - } - if isInitialized { - return nil, fmt.Errorf("voting already initialized") - } - - // Get transactor - opts, err := w.GetNodeAccountTransactor() - if err != nil { - return nil, err - } - - gasInfo, err := network.EstimateInitializeVotingWithDelegateGas(rp, delegateAddress, opts) - if err != nil { - return nil, fmt.Errorf("Could not estimate the gas required to claim RPL: %w", err) - } - response.GasInfo = gasInfo - - return &response, nil -} - -func nodeInitializeVotingWithDelegate(c *cli.Context, delegateAddress common.Address) (*api.PDAOInitializeVotingResponse, error) { - - // Get services - if err := services.RequireNodeWallet(c); err != nil { - return nil, err - } - if err := services.RequireRocketStorage(c); err != nil { - return nil, err - } - w, err := services.GetWallet(c) - if err != nil { - return nil, err - } - rp, err := services.GetRocketPool(c) - if err != nil { - return nil, err - } - nodeAccount, err := w.GetNodeAccount() - if err != nil { - return nil, err - } - - // Response - response := api.PDAOInitializeVotingResponse{} - - isInitialized, err := network.GetVotingInitialized(rp, nodeAccount.Address, nil) - if err != nil { - return nil, err - } - if isInitialized { - return nil, fmt.Errorf("voting already initialized") - } - - // Get transactor - opts, err := w.GetNodeAccountTransactor() - if err != nil { - return nil, err - } - - // Override the provided pending TX if requested - err = eth1.CheckForNonceOverride(c, opts) - if err != nil { - return nil, fmt.Errorf("Error checking for nonce override: %w", err) - } - - hash, err := network.InitializeVotingWithDelegate(rp, delegateAddress, opts) - if err != nil { - return nil, fmt.Errorf("Error initializing voting: %w", err) - } - response.TxHash = hash - - return &response, nil - -} diff --git a/rocketpool/api/pdao/initialize-voting.go b/rocketpool/api/pdao/initialize-voting.go deleted file mode 100644 index a2789c66f..000000000 --- a/rocketpool/api/pdao/initialize-voting.go +++ /dev/null @@ -1,131 +0,0 @@ -package pdao - -import ( - "fmt" - - "github.com/urfave/cli" - - "github.com/rocket-pool/smartnode/bindings/network" - "github.com/rocket-pool/smartnode/shared/services" - "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/eth1" -) - -func isVotingInitialized(c *cli.Context) (*api.PDAOIsVotingInitializedResponse, error) { - - w, err := services.GetWallet(c) - if err != nil { - return nil, err - } - rp, err := services.GetRocketPool(c) - if err != nil { - return nil, err - } - nodeAccount, err := w.GetNodeAccount() - if err != nil { - return nil, err - } - - response := api.PDAOIsVotingInitializedResponse{} - response.VotingInitialized, err = network.GetVotingInitialized(rp, nodeAccount.Address, nil) - - return &response, nil - -} - -func canNodeInitializeVoting(c *cli.Context) (*api.PDAOCanInitializeVotingResponse, error) { - - // Get services - if err := services.RequireNodeWallet(c); err != nil { - return nil, err - } - if err := services.RequireRocketStorage(c); err != nil { - return nil, err - } - w, err := services.GetWallet(c) - if err != nil { - return nil, err - } - rp, err := services.GetRocketPool(c) - if err != nil { - return nil, err - } - nodeAccount, err := w.GetNodeAccount() - if err != nil { - return nil, err - } - - // Response - response := api.PDAOCanInitializeVotingResponse{} - - isInitialized, err := network.GetVotingInitialized(rp, nodeAccount.Address, nil) - if isInitialized { - return nil, fmt.Errorf("voting already initialized") - } - - // Get transactor - opts, err := w.GetNodeAccountTransactor() - if err != nil { - return nil, err - } - - gasInfo, err := network.EstimateInitializeVotingGas(rp, opts) - if err != nil { - return nil, fmt.Errorf("Could not estimate the gas required to initialize voting: %w", err) - } - response.GasInfo = gasInfo - - return &response, nil -} - -func nodeInitializeVoting(c *cli.Context) (*api.PDAOInitializeVotingResponse, error) { - - // Get services - if err := services.RequireNodeWallet(c); err != nil { - return nil, err - } - if err := services.RequireRocketStorage(c); err != nil { - return nil, err - } - w, err := services.GetWallet(c) - if err != nil { - return nil, err - } - rp, err := services.GetRocketPool(c) - if err != nil { - return nil, err - } - nodeAccount, err := w.GetNodeAccount() - if err != nil { - return nil, err - } - - // Response - response := api.PDAOInitializeVotingResponse{} - - isInitialized, err := network.GetVotingInitialized(rp, nodeAccount.Address, nil) - if isInitialized { - return nil, fmt.Errorf("voting already initialized") - } - - // Get transactor - opts, err := w.GetNodeAccountTransactor() - if err != nil { - return nil, err - } - - // Override the provided pending TX if requested - err = eth1.CheckForNonceOverride(c, opts) - if err != nil { - return nil, fmt.Errorf("Error checking for nonce override: %w", err) - } - - hash, err := network.InitializeVoting(rp, opts) - if err != nil { - return nil, fmt.Errorf("Error initializing voting: %w", err) - } - response.TxHash = hash - - return &response, nil - -} diff --git a/rocketpool/api/pdao/set-snapshot-address.go b/rocketpool/api/pdao/set-snapshot-address.go index 4d3a1c8a4..3d96f2e72 100644 --- a/rocketpool/api/pdao/set-snapshot-address.go +++ b/rocketpool/api/pdao/set-snapshot-address.go @@ -7,7 +7,6 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" - "github.com/rocket-pool/smartnode/bindings/network" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/contracts" @@ -37,10 +36,6 @@ func canSetSignallingAddress(c *cli.Context, signallingAddress common.Address, s if err != nil { return nil, err } - rp, err := services.GetRocketPool(c) - if err != nil { - return nil, err - } nodeAccount, err := w.GetNodeAccount() if err != nil { return nil, err @@ -57,11 +52,6 @@ func canSetSignallingAddress(c *cli.Context, signallingAddress common.Address, s // Response response := api.PDAOCanSetSignallingAddressResponse{} - response.VotingInitialized, err = network.GetVotingInitialized(rp, nodeAccount.Address, nil) - if !response.VotingInitialized { - return nil, fmt.Errorf("Voting must be initialized to set a signalling address. Use 'rocketpool pdao initialize-voting' to initialize voting first.") - } - // Get signer registry contract address addressString := cfg.Smartnode.GetRocketSignerRegistryAddress() if addressString == "" { diff --git a/rocketpool/api/pdao/status.go b/rocketpool/api/pdao/status.go index d863cacd5..a79d6dce3 100644 --- a/rocketpool/api/pdao/status.go +++ b/rocketpool/api/pdao/status.go @@ -109,13 +109,6 @@ func getStatus(c *cli.Context) (*api.PDAOStatusResponse, error) { return nil }) - // Check if Voting is initialized and add to response - wg.Go(func() error { - var err error - response.IsVotingInitialized, err = network.GetVotingInitialized(rp, nodeAccount.Address, nil) - return err - }) - // Check whether RPL locking is allowed for the node wg.Go(func() error { var err error @@ -192,16 +185,12 @@ func getStatus(c *cli.Context) (*api.PDAOStatusResponse, error) { return nil, err } - // Get the delegated voting power if voting is initialized - if response.IsVotingInitialized { - totalDelegatedVP, _, _, err := propMgr.GetArtifactsForVoting(response.BlockNumber, nodeAccount.Address) - if err != nil { - return nil, err - } - response.TotalDelegatedVp = totalDelegatedVP - } else { - response.TotalDelegatedVp = nil + // Get the delegated voting power + totalDelegatedVP, _, _, err := propMgr.GetArtifactsForVoting(response.BlockNumber, nodeAccount.Address) + if err != nil { + return nil, err } + response.TotalDelegatedVp = totalDelegatedVP // Get the local tree votingTree, err := propMgr.GetNetworkTree(response.BlockNumber, nil) diff --git a/rocketpool/node/auto-init-voting-power.go b/rocketpool/node/auto-init-voting-power.go deleted file mode 100644 index e97ae5035..000000000 --- a/rocketpool/node/auto-init-voting-power.go +++ /dev/null @@ -1,167 +0,0 @@ -package node - -import ( - "fmt" - "math/big" - - "github.com/ethereum/go-ethereum/common" - "github.com/rocket-pool/smartnode/bindings/network" - "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - "github.com/rocket-pool/smartnode/shared/services" - "github.com/rocket-pool/smartnode/shared/services/beacon" - "github.com/rocket-pool/smartnode/shared/services/config" - rpgas "github.com/rocket-pool/smartnode/shared/services/gas" - "github.com/rocket-pool/smartnode/shared/services/state" - "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" - "github.com/rocket-pool/smartnode/shared/utils/log" - "github.com/urfave/cli" -) - -type autoInitVotingPower struct { - c *cli.Context - log *log.ColorLogger - cfg *config.RocketPoolConfig - w wallet.Wallet - rp *rocketpool.RocketPool - bc beacon.Client - gasThreshold float64 - maxFee *big.Int - maxPriorityFee *big.Int - gasLimit uint64 - nodeAddress common.Address -} - -func newAutoInitVotingPower(c *cli.Context, logger log.ColorLogger, gasThreshold float64) (*autoInitVotingPower, error) { - // Get services - cfg, err := services.GetConfig(c) - if err != nil { - return nil, err - } - w, err := services.GetHdWallet(c) - if err != nil { - return nil, err - } - rp, err := services.GetRocketPool(c) - if err != nil { - return nil, err - } - bc, err := services.GetBeaconClient(c) - if err != nil { - return nil, err - } - - // Get the user-requested max fee - maxFeeGwei := cfg.Smartnode.ManualMaxFee.Value.(float64) - var maxFee *big.Int - if maxFeeGwei == 0 { - maxFee = nil - } else { - maxFee = eth.GweiToWei(maxFeeGwei) - } - - // Get the user-requested priority fee - priorityFeeGwei := cfg.Smartnode.PriorityFee.Value.(float64) - var priorityFee *big.Int - if priorityFeeGwei == 0 { - logger.Println("WARNING: priority fee was missing or 0, setting a default of 2.") - priorityFee = eth.GweiToWei(2) - } else { - priorityFee = eth.GweiToWei(priorityFeeGwei) - } - - // Get the node account - account, err := w.GetNodeAccount() - if err != nil { - return nil, fmt.Errorf("error getting node account: %w", err) - } - - // Return task - return &autoInitVotingPower{ - c: c, - log: &logger, - cfg: cfg, - w: w, - rp: rp, - bc: bc, - gasThreshold: gasThreshold, - maxFee: maxFee, - maxPriorityFee: priorityFee, - gasLimit: 0, - nodeAddress: account.Address, - }, nil - -} - -// Auto Initialize Vote Power -func (t *autoInitVotingPower) run(state *state.NetworkState) error { - // Log - t.log.Println("Checking for node initialized voting power...") - - // Check if voting is initialized then initialize if it isn't - votingInitialized, err := network.GetVotingInitialized(t.rp, t.nodeAddress, nil) - if err != nil { - return fmt.Errorf("Error getting voting initialized status %w", err) - } - if !votingInitialized { - err := t.submitInitializeVotingPower() - if err != nil { - return fmt.Errorf("Error submitting initialize voting power %w", err) - } - } - - // Return - return nil -} - -func (t *autoInitVotingPower) submitInitializeVotingPower() error { - - // Get transactor - opts, err := t.w.GetNodeAccountTransactor() - if err != nil { - return err - } - - // Get the gas limit - gasInfo, err := network.EstimateInitializeVotingGas(t.rp, opts) - if err != nil { - return fmt.Errorf("Could not estimate the gas required to initialize voting: %w", err) - } - gas := big.NewInt(int64(gasInfo.SafeGasLimit)) - // Get the max fee - maxFee := t.maxFee - if maxFee == nil || maxFee.Uint64() == 0 { - maxFee, err = rpgas.GetHeadlessMaxFeeWei() - if err != nil { - return err - } - } - - // Print the gas info - if !api.PrintAndCheckGasInfo(gasInfo, true, t.gasThreshold, t.log, maxFee, t.gasLimit) { - return nil - } - - opts.GasFeeCap = maxFee - opts.GasTipCap = GetPriorityFee(t.maxPriorityFee, maxFee) - opts.GasLimit = gas.Uint64() - - // Initialize the Voting Power - hash, err := network.InitializeVoting(t.rp, opts) - if err != nil { - return fmt.Errorf("Error initializing voting: %w", err) - } - - // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, t.log) - if err != nil { - return err - } - - // Log - t.log.Println("Successfully Initialized Vote Power.") - - // Return - return nil -} diff --git a/rocketpool/node/collectors/snapshot-collector.go b/rocketpool/node/collectors/snapshot-collector.go index a74036e62..13341ae7b 100644 --- a/rocketpool/node/collectors/snapshot-collector.go +++ b/rocketpool/node/collectors/snapshot-collector.go @@ -137,7 +137,6 @@ func (collector *SnapshotCollector) Collect(channel chan<- prometheus.Metric) { var propMgr *proposals.ProposalManager var blockNumber uint64 var onchainVotingDelegate common.Address - var isVotingInitialized bool activeProposals := float64(0) closedProposals := float64(0) blankAddress := common.Address{} @@ -198,17 +197,6 @@ func (collector *SnapshotCollector) Collect(channel chan<- prometheus.Metric) { return err }) - // Get Voting Initialized status - wg.Go(func() error { - if time.Since(collector.lastApiCallTimestamp).Hours() >= hoursToWait { - isVotingInitialized, err = network.GetVotingInitialized(collector.rp, collector.nodeAddress, nil) - if err != nil { - return fmt.Errorf("Error checking if voting is initialized: %w", err) - } - } - return err - }) - // Wait for data if err := wg.Wait(); err != nil { collector.logError(err) @@ -216,7 +204,7 @@ func (collector *SnapshotCollector) Collect(channel chan<- prometheus.Metric) { } // Check if sufficient time has passed and voting is initialized - if time.Since(collector.lastApiCallTimestamp).Hours() >= hoursToWait && isVotingInitialized { + if time.Since(collector.lastApiCallTimestamp).Hours() >= hoursToWait { // Get voting power for the node nodeVotingPower, err := getVotingPower(propMgr, uint32(blockNumber), collector.nodeAddress) if err != nil { diff --git a/rocketpool/node/node.go b/rocketpool/node/node.go index 3c57ef657..e8b4f8458 100644 --- a/rocketpool/node/node.go +++ b/rocketpool/node/node.go @@ -41,7 +41,6 @@ const ( ReduceBondAmountColor = color.FgHiBlue DefendPdaoPropsColor = color.FgYellow VerifyPdaoPropsColor = color.FgYellow - AutoInitVotingPowerColor = color.FgHiYellow DistributeMinipoolsColor = color.FgHiGreen ErrorColor = color.FgRed WarningColor = color.FgYellow @@ -170,15 +169,7 @@ func run(c *cli.Context) error { return err } } - var autoInitVotingPower *autoInitVotingPower - // Make sure the user opted into this duty - AutoInitVPThreshold := cfg.Smartnode.AutoInitVPThreshold.Value.(float64) - if AutoInitVPThreshold != 0 { - autoInitVotingPower, err = newAutoInitVotingPower(c, log.NewColorLogger(AutoInitVotingPowerColor), AutoInitVPThreshold) - if err != nil { - return err - } - } + var prestakeMegapoolValidator *prestakeMegapoolValidator prestakeMegapoolValidator, err = newPrestakeMegapoolValidator(c, log.NewColorLogger(PrestakeMegapoolValidatorColor)) if err != nil { @@ -273,14 +264,6 @@ func run(c *cli.Context) error { time.Sleep(taskCooldown) } - // Run the auto vote initilization check - if autoInitVotingPower != nil { - if err := autoInitVotingPower.run(state); err != nil { - errorLog.Println(err) - } - time.Sleep(taskCooldown) - } - // Run the megapool prestake check if prestakeMegapoolValidator != nil { if err := prestakeMegapoolValidator.run(state); err != nil { diff --git a/shared/services/config/smartnode-config.go b/shared/services/config/smartnode-config.go index e697ef51f..69891031b 100644 --- a/shared/services/config/smartnode-config.go +++ b/shared/services/config/smartnode-config.go @@ -109,9 +109,6 @@ type SmartnodeConfig struct { // The toggle for enabling pDAO proposal verification duties VerifyProposals config.Parameter `yaml:"verifyProposals,omitempty"` - // Threshold for automatic vote power initialization transactions - AutoInitVPThreshold config.Parameter `yaml:"autoInitVPThreshold,omitempty"` - // Delay for automatic queue assignment AutoAssignmentDelay config.Parameter `yaml:"autoAssignmentDelay,omitempty"` @@ -328,19 +325,6 @@ func NewSmartnodeConfig(cfg *RocketPoolConfig) *SmartnodeConfig { OverwriteOnUpgrade: false, }, - AutoInitVPThreshold: config.Parameter{ - ID: "autoInitVPThreshold", - Name: "Auto-Init Vote Power Gas Threshold", - Description: "The Smartnode will regularly check if the node has initialized voting power and attempt to initialize voting power if it isn't initialized.\n\n" + - "This threshold is a limit (in gwei) you can set on this automatic transaction; your node will not attempt to initialize voting power if the network suggested fee is below this limit.\n\n" + - "A value of 0 will disable this task. Disable this if your node was registered post-houston or your vote power is already initialized.\n\n", - Type: config.ParameterType_Float, - Default: map[config.Network]interface{}{config.Network_All: float64(5)}, - AffectsContainers: []config.ContainerID{config.ContainerID_Node}, - CanBeBlank: false, - OverwriteOnUpgrade: false, - }, - AutoAssignmentDelay: config.Parameter{ ID: "autoAssignmentDelay", Name: "Automatic queue assigment delay", @@ -642,7 +626,6 @@ func (cfg *SmartnodeConfig) GetParameters() []*config.Parameter { &cfg.AutoTxGasThreshold, &cfg.DistributeThreshold, &cfg.VerifyProposals, - &cfg.AutoInitVPThreshold, &cfg.AutoAssignmentDelay, &cfg.RewardsTreeMode, &cfg.PriceBalanceSubmissionReferenceTimestamp, diff --git a/shared/types/api/network.go b/shared/types/api/network.go index 1f322d8f6..50556fbd2 100644 --- a/shared/types/api/network.go +++ b/shared/types/api/network.go @@ -82,7 +82,6 @@ type NetworkDAOProposalsResponse struct { TotalDelegatedVp *big.Int `json:"totalDelegateVp"` SumVotingPower *big.Int `json:"sumVotingPower"` VotingDelegate common.Address `json:"votingDelegate"` - IsVotingInitialized bool `json:"isVotingInitialized"` VotingPower *big.Int `json:"votingPower"` BlockNumber uint32 `json:"blockNumber"` IsNodeRegistered bool `json:"isNodeRegistered"` diff --git a/shared/types/api/node.go b/shared/types/api/node.go index 64a9ef503..096453add 100644 --- a/shared/types/api/node.go +++ b/shared/types/api/node.go @@ -51,7 +51,6 @@ type NodeStatusResponse struct { PendingMaximumRplStake *big.Int `json:"pendingMaximumRplStake"` PendingBorrowedCollateralRatio float64 `json:"pendingBorrowedCollateralRatio"` PendingBondedCollateralRatio float64 `json:"pendingBondedCollateralRatio"` - IsVotingInitialized bool `json:"isVotingInitialized"` OnchainVotingDelegate common.Address `json:"onchainVotingDelegate"` OnchainVotingDelegateFormatted string `json:"onchainVotingDelegateFormatted"` MinipoolLimit uint64 `json:"minipoolLimit"` diff --git a/shared/types/api/pdao.go b/shared/types/api/pdao.go index 8dea07a40..edb860ef8 100644 --- a/shared/types/api/pdao.go +++ b/shared/types/api/pdao.go @@ -434,7 +434,6 @@ type PDAOStatusResponse struct { OnchainVotingDelegateFormatted string `json:"onchainVotingDelegateFormatted"` BlockNumber uint32 `json:"blockNumber"` VerifyEnabled bool `json:"verifyEnabled"` - IsVotingInitialized bool `json:"isVotingInitialized"` SnapshotResponse SnapshotResponseStruct `json:"snapshotResponse"` IsRPLLockingAllowed bool `json:"isRPLLockingAllowed"` NodeRPLLocked *big.Int `json:"nodeRPLLocked"` @@ -448,11 +447,10 @@ type PDAOStatusResponse struct { } type PDAOCanSetSignallingAddressResponse struct { - Status string `json:"status"` - Error string `json:"error"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` - VotingInitialized bool `json:"votingInitialized"` - NodeToSigner common.Address `json:"nodeToSigner"` + Status string `json:"status"` + Error string `json:"error"` + GasInfo rocketpool.GasInfo `json:"gasInfo"` + NodeToSigner common.Address `json:"nodeToSigner"` } type PDAOSetSignallingAddressResponse struct { From 0300f0ae8b85abfe87cdbb98a75d55ea3028baf0 Mon Sep 17 00:00:00 2001 From: Fornax <23104993+0xfornax@users.noreply.github.com> Date: Tue, 3 Jun 2025 12:16:27 -0300 Subject: [PATCH 2/4] Lint fix --- bindings/network/voting.go | 1 - 1 file changed, 1 deletion(-) diff --git a/bindings/network/voting.go b/bindings/network/voting.go index d5ad8ec5b..9701db738 100644 --- a/bindings/network/voting.go +++ b/bindings/network/voting.go @@ -88,7 +88,6 @@ func GetNodeInfoSnapshotFast(rp *rocketpool.RocketPool, blockNumber uint32, mult return votingInfos, nil } - // Get the number of nodes that were present in the network at the provided block func GetVotingNodeCount(rp *rocketpool.RocketPool, blockNumber uint32, opts *bind.CallOpts) (*big.Int, error) { rocketNetworkVoting, err := getRocketNetworkVoting(rp, nil) From fdc176e41f14cd1ed28b2e875e56337c17e6f920 Mon Sep 17 00:00:00 2001 From: Fornax <23104993+0xfornax@users.noreply.github.com> Date: Tue, 3 Jun 2025 14:23:32 -0300 Subject: [PATCH 3/4] Update rocketpool/api/network/dao-proposals.go Co-authored-by: Jacob Shufro <116244+jshufro@users.noreply.github.com> --- rocketpool/api/network/dao-proposals.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rocketpool/api/network/dao-proposals.go b/rocketpool/api/network/dao-proposals.go index bd36f5a7e..d71e9d62d 100644 --- a/rocketpool/api/network/dao-proposals.go +++ b/rocketpool/api/network/dao-proposals.go @@ -135,11 +135,10 @@ func getActiveDAOProposals(c *cli.Context) (*api.NetworkDAOProposalsResponse, er } // Get the delegated voting power - totalDelegatedVP, _, _, err := propMgr.GetArtifactsForVoting(response.BlockNumber, nodeAccount.Address) + response.TotalDelegatedVp, _, _, err = propMgr.GetArtifactsForVoting(response.BlockNumber, nodeAccount.Address) if err != nil { return nil, err } - response.TotalDelegatedVp = totalDelegatedVP // Get the local tree votingTree, err := propMgr.GetNetworkTree(response.BlockNumber, nil) From 1850b4e0fdebad815204f2b68b96501680a6ab1e Mon Sep 17 00:00:00 2001 From: Fornax <23104993+0xfornax@users.noreply.github.com> Date: Tue, 3 Jun 2025 14:23:42 -0300 Subject: [PATCH 4/4] Update rocketpool/api/pdao/status.go Co-authored-by: Jacob Shufro <116244+jshufro@users.noreply.github.com> --- rocketpool/api/pdao/status.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rocketpool/api/pdao/status.go b/rocketpool/api/pdao/status.go index a79d6dce3..5fbbc8c66 100644 --- a/rocketpool/api/pdao/status.go +++ b/rocketpool/api/pdao/status.go @@ -186,11 +186,10 @@ func getStatus(c *cli.Context) (*api.PDAOStatusResponse, error) { } // Get the delegated voting power - totalDelegatedVP, _, _, err := propMgr.GetArtifactsForVoting(response.BlockNumber, nodeAccount.Address) + response.TotalDelegatedVp, _, _, err = propMgr.GetArtifactsForVoting(response.BlockNumber, nodeAccount.Address) if err != nil { return nil, err } - response.TotalDelegatedVp = totalDelegatedVP // Get the local tree votingTree, err := propMgr.GetNetworkTree(response.BlockNumber, nil)