diff --git a/bindings/settings/protocol/performance.go b/bindings/settings/protocol/performance.go index fbd08a758..7f4ac6122 100644 --- a/bindings/settings/protocol/performance.go +++ b/bindings/settings/protocol/performance.go @@ -3,7 +3,6 @@ package protocol import ( "fmt" "math/big" - "sync" "time" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -17,134 +16,124 @@ import ( // Config const ( - PerformanceSettingsContractName string = "rocketDAOProtocolSettingsPerformance" - PerformanceExitsEnabledSettingPath string = "performance.exits.enabled" - PerformancePeriodSettingPath string = "performance.period" - ProofBufferSettingPath string = "proof.buffer" - PerformanceThresholdSettingPath string = "performance.threshold" - PerformanceChallengePeriodSettingPath string = "performance.challenge.period" - PerformanceChallengeBondSettingPath string = "performance.challenge.bond" + PerformanceExitsEnabledSettingPath string = "network.performance.exits.enabled" + PerformancePeriodSettingPath string = "network.performance.period" + ProofBufferSettingPath string = "network.performance.proof.buffer" + PerformanceThresholdSettingPath string = "network.performance.threshold" + PerformanceChallengePeriodSettingPath string = "network.performance.challenge.period" + PerformanceChallengeBondSettingPath string = "network.performance.challenge.bond" ) // Performance exits currently enabled func GetPerformanceExitsEnabled(rp *rocketpool.RocketPool, opts *bind.CallOpts) (bool, error) { - performanceSettingsContract, err := getPerformanceSettingsContract(rp, opts) + networkSettingsContract, err := getNetworkSettingsContract(rp, opts) if err != nil { return false, err } value := new(bool) - if err := performanceSettingsContract.Call(opts, value, "getPerformanceExitsEnabled"); err != nil { + if err := networkSettingsContract.Call(opts, value, "getPerformanceExitsEnabled"); err != nil { return false, fmt.Errorf("error getting performance exits enabled status: %w", err) } return *value, nil } func ProposePerformanceExitsEnabled(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { - return protocol.ProposeSetBool(rp, fmt.Sprintf("set %s", PerformanceExitsEnabledSettingPath), PerformanceSettingsContractName, PerformanceExitsEnabledSettingPath, value, blockNumber, treeNodes, opts) + return protocol.ProposeSetBool(rp, fmt.Sprintf("set %s", PerformanceExitsEnabledSettingPath), NetworkSettingsContractName, PerformanceExitsEnabledSettingPath, value, blockNumber, treeNodes, opts) } func EstimateProposePerformanceExitsEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { - return protocol.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", PerformanceExitsEnabledSettingPath), PerformanceSettingsContractName, PerformanceExitsEnabledSettingPath, value, blockNumber, treeNodes, opts) + return protocol.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", PerformanceExitsEnabledSettingPath), NetworkSettingsContractName, PerformanceExitsEnabledSettingPath, value, blockNumber, treeNodes, opts) } // Number of epochs over which attestation performance is measured func GetPerformancePeriod(rp *rocketpool.RocketPool, opts *bind.CallOpts) (uint64, error) { - performanceSettingsContract, err := getPerformanceSettingsContract(rp, opts) + networkSettingsContract, err := getNetworkSettingsContract(rp, opts) if err != nil { return 0, err } value := new(*big.Int) - if err := performanceSettingsContract.Call(opts, value, "getPerformancePeriod"); err != nil { + if err := networkSettingsContract.Call(opts, value, "getPerformancePeriod"); err != nil { return 0, fmt.Errorf("error getting performance period: %w", err) } return (*value).Uint64(), nil } func ProposePerformancePeriod(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { - return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", PerformancePeriodSettingPath), PerformanceSettingsContractName, PerformancePeriodSettingPath, value, blockNumber, treeNodes, opts) + return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", PerformancePeriodSettingPath), NetworkSettingsContractName, PerformancePeriodSettingPath, value, blockNumber, treeNodes, opts) } func EstimateProposePerformancePeriodGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { - return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", PerformancePeriodSettingPath), PerformanceSettingsContractName, PerformancePeriodSettingPath, value, blockNumber, treeNodes, opts) + return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", PerformancePeriodSettingPath), NetworkSettingsContractName, PerformancePeriodSettingPath, value, blockNumber, treeNodes, opts) } // Buffer to detect underperformance and generate proofs before a validator can be challenged (epochs) func GetProofBuffer(rp *rocketpool.RocketPool, opts *bind.CallOpts) (uint64, error) { - performanceSettingsContract, err := getPerformanceSettingsContract(rp, opts) + networkSettingsContract, err := getNetworkSettingsContract(rp, opts) if err != nil { return 0, err } value := new(*big.Int) - if err := performanceSettingsContract.Call(opts, value, "getProofBuffer"); err != nil { + if err := networkSettingsContract.Call(opts, value, "getPerformanceProofBuffer"); err != nil { return 0, fmt.Errorf("error getting proof buffer: %w", err) } return (*value).Uint64(), nil } func ProposeProofBuffer(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { - return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", ProofBufferSettingPath), PerformanceSettingsContractName, ProofBufferSettingPath, value, blockNumber, treeNodes, opts) + return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", ProofBufferSettingPath), NetworkSettingsContractName, ProofBufferSettingPath, value, blockNumber, treeNodes, opts) } func EstimateProposeProofBufferGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { - return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ProofBufferSettingPath), PerformanceSettingsContractName, ProofBufferSettingPath, value, blockNumber, treeNodes, opts) + return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ProofBufferSettingPath), NetworkSettingsContractName, ProofBufferSettingPath, value, blockNumber, treeNodes, opts) } // Minimum target attestation timeliness percentage required to avoid exit func GetPerformanceThreshold(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.Int, error) { - performanceSettingsContract, err := getPerformanceSettingsContract(rp, opts) + networkSettingsContract, err := getNetworkSettingsContract(rp, opts) if err != nil { return nil, err } value := new(*big.Int) - if err := performanceSettingsContract.Call(opts, value, "getPerformanceThreshold"); err != nil { + if err := networkSettingsContract.Call(opts, value, "getPerformanceThreshold"); err != nil { return nil, fmt.Errorf("error getting performance threshold: %w", err) } return *value, nil } func ProposePerformanceThreshold(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { - return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", PerformanceThresholdSettingPath), PerformanceSettingsContractName, PerformanceThresholdSettingPath, value, blockNumber, treeNodes, opts) + return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", PerformanceThresholdSettingPath), NetworkSettingsContractName, PerformanceThresholdSettingPath, value, blockNumber, treeNodes, opts) } func EstimateProposePerformanceThresholdGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { - return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", PerformanceThresholdSettingPath), PerformanceSettingsContractName, PerformanceThresholdSettingPath, value, blockNumber, treeNodes, opts) + return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", PerformanceThresholdSettingPath), NetworkSettingsContractName, PerformanceThresholdSettingPath, value, blockNumber, treeNodes, opts) } -// How long a performance exit challenge remains open +// How long a performance exit challenge remains open (stored on-chain in seconds) func GetPerformanceChallengePeriod(rp *rocketpool.RocketPool, opts *bind.CallOpts) (time.Duration, error) { - performanceSettingsContract, err := getPerformanceSettingsContract(rp, opts) + networkSettingsContract, err := getNetworkSettingsContract(rp, opts) if err != nil { return 0, err } value := new(*big.Int) - if err := performanceSettingsContract.Call(opts, value, "getPerformanceChallengePeriod"); err != nil { + if err := networkSettingsContract.Call(opts, value, "getPerformanceChallengePeriod"); err != nil { return 0, fmt.Errorf("error getting performance challenge period: %w", err) } - return time.Duration((*value).Int64()) * time.Hour, nil + return time.Duration((*value).Int64()) * time.Second, nil } func ProposePerformanceChallengePeriod(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { - return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", PerformanceChallengePeriodSettingPath), PerformanceSettingsContractName, PerformanceChallengePeriodSettingPath, value, blockNumber, treeNodes, opts) + return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", PerformanceChallengePeriodSettingPath), NetworkSettingsContractName, PerformanceChallengePeriodSettingPath, value, blockNumber, treeNodes, opts) } func EstimateProposePerformanceChallengePeriodGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { - return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", PerformanceChallengePeriodSettingPath), PerformanceSettingsContractName, PerformanceChallengePeriodSettingPath, value, blockNumber, treeNodes, opts) + return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", PerformanceChallengePeriodSettingPath), NetworkSettingsContractName, PerformanceChallengePeriodSettingPath, value, blockNumber, treeNodes, opts) } // RPL bond required to propose a performance exit func GetPerformanceChallengeBond(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.Int, error) { - performanceSettingsContract, err := getPerformanceSettingsContract(rp, opts) + networkSettingsContract, err := getNetworkSettingsContract(rp, opts) if err != nil { return nil, err } value := new(*big.Int) - if err := performanceSettingsContract.Call(opts, value, "getPerformanceChallengeBond"); err != nil { + if err := networkSettingsContract.Call(opts, value, "getPerformanceChallengeBond"); err != nil { return nil, fmt.Errorf("error getting performance challenge bond: %w", err) } return *value, nil } func ProposePerformanceChallengeBond(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { - return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", PerformanceChallengeBondSettingPath), PerformanceSettingsContractName, PerformanceChallengeBondSettingPath, value, blockNumber, treeNodes, opts) + return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", PerformanceChallengeBondSettingPath), NetworkSettingsContractName, PerformanceChallengeBondSettingPath, value, blockNumber, treeNodes, opts) } func EstimateProposePerformanceChallengeBondGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { - return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", PerformanceChallengeBondSettingPath), PerformanceSettingsContractName, PerformanceChallengeBondSettingPath, value, blockNumber, treeNodes, opts) -} - -// Get contracts -var performanceSettingsContractLock sync.Mutex - -func getPerformanceSettingsContract(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*rocketpool.Contract, error) { - performanceSettingsContractLock.Lock() - defer performanceSettingsContractLock.Unlock() - return rp.GetContract(PerformanceSettingsContractName, opts) + return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", PerformanceChallengeBondSettingPath), NetworkSettingsContractName, PerformanceChallengeBondSettingPath, value, blockNumber, treeNodes, opts) } diff --git a/bindings/settings/protocol/setting-types.go b/bindings/settings/protocol/setting-types.go index dcf5f7a8a..e4dc4cbf0 100644 --- a/bindings/settings/protocol/setting-types.go +++ b/bindings/settings/protocol/setting-types.go @@ -62,6 +62,12 @@ var pdaoSettingKinds = map[string]map[string]settingKind{ MinipoolUserDistributeWindowLengthSettingPath: settingKindUint256, }, NetworkSettingsContractName: { + PerformanceExitsEnabledSettingPath: settingKindBool, + PerformancePeriodSettingPath: settingKindUint256, + ProofBufferSettingPath: settingKindUint256, + PerformanceThresholdSettingPath: settingKindUint256, + PerformanceChallengePeriodSettingPath: settingKindUint256, + PerformanceChallengeBondSettingPath: settingKindUint256, CooperativeExitPhaseSettingPath: settingKindUint256, DidNotExitPenaltyBaseSettingPath: settingKindUint256, DidNotExitBaseSettingPath: settingKindUint256, @@ -134,14 +140,6 @@ var pdaoSettingKinds = map[string]map[string]settingKind{ MegapoolPenaltyThreshold: settingKindUint256, MegapoolPrestakeChallengePeriodPath: settingKindUint256, }, - PerformanceSettingsContractName: { - PerformanceExitsEnabledSettingPath: settingKindBool, - PerformancePeriodSettingPath: settingKindUint256, - ProofBufferSettingPath: settingKindUint256, - PerformanceThresholdSettingPath: settingKindUint256, - PerformanceChallengePeriodSettingPath: settingKindUint256, - PerformanceChallengeBondSettingPath: settingKindUint256, - }, } // GetProposalSettingType returns the on-chain type used by proposalSettingMulti diff --git a/bindings/settings/security/performance.go b/bindings/settings/security/performance.go index deb59add8..44a6052f0 100644 --- a/bindings/settings/security/performance.go +++ b/bindings/settings/security/performance.go @@ -12,14 +12,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) -const ( - performanceNamespace string = "performance" -) - // Performance exits currently enabled func ProposePerformanceExitsEnabled(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (uint64, common.Hash, error) { - return security.ProposeSetBool(rp, fmt.Sprintf("set %s", psettings.PerformanceExitsEnabledSettingPath), performanceNamespace, psettings.PerformanceExitsEnabledSettingPath, value, opts) + return security.ProposeSetBool(rp, fmt.Sprintf("set %s", psettings.PerformanceExitsEnabledSettingPath), networkNamespace, psettings.PerformanceExitsEnabledSettingPath, value, opts) } func EstimateProposePerformanceExitsEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { - return security.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", psettings.PerformanceExitsEnabledSettingPath), performanceNamespace, psettings.PerformanceExitsEnabledSettingPath, value, opts) + return security.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", psettings.PerformanceExitsEnabledSettingPath), networkNamespace, psettings.PerformanceExitsEnabledSettingPath, value, opts) } diff --git a/rocketpool-cli/cli/saturn2-check.go b/rocketpool-cli/cli/saturn2-check.go index 3f5c2ed53..acba87a55 100644 --- a/rocketpool-cli/cli/saturn2-check.go +++ b/rocketpool-cli/cli/saturn2-check.go @@ -12,12 +12,13 @@ const Saturn2NotDeployedMessage = "This command is not available until Saturn 2 // IsSaturn2OnlySetting reports whether a protocol setting exists only after Saturn 2. func IsSaturn2OnlySetting(contract, setting string) bool { switch contract { - case protocol.PerformanceSettingsContractName: - return true case protocol.NetworkSettingsContractName: switch setting { case protocol.CooperativeExitPhaseSettingPath, protocol.DidNotExitPenaltyBaseSettingPath, - protocol.DidNotExitBaseSettingPath, protocol.DidNotExitBackoffSettingPath: + protocol.DidNotExitBaseSettingPath, protocol.DidNotExitBackoffSettingPath, + protocol.PerformanceExitsEnabledSettingPath, protocol.PerformancePeriodSettingPath, + protocol.ProofBufferSettingPath, protocol.PerformanceThresholdSettingPath, + protocol.PerformanceChallengePeriodSettingPath, protocol.PerformanceChallengeBondSettingPath: return true } return false diff --git a/rocketpool-cli/pdao/propose-settings.go b/rocketpool-cli/pdao/propose-settings.go index e1216039c..faa1e36da 100644 --- a/rocketpool-cli/pdao/propose-settings.go +++ b/rocketpool-cli/pdao/propose-settings.go @@ -372,32 +372,32 @@ func proposeSettingMegapoolPrestakeChallengePeriod(value uint64, yes bool, toJso func proposeSettingPerformanceExitsEnabled(value bool, yes bool, toJson string) error { trueValue := fmt.Sprint(value) - return proposeSetting(protocol.PerformanceSettingsContractName, protocol.PerformanceExitsEnabledSettingPath, trueValue, yes, toJson) + return proposeSetting(protocol.NetworkSettingsContractName, protocol.PerformanceExitsEnabledSettingPath, trueValue, yes, toJson) } func proposeSettingPerformancePeriod(value uint64, yes bool, toJson string) error { trueValue := fmt.Sprint(value) - return proposeSetting(protocol.PerformanceSettingsContractName, protocol.PerformancePeriodSettingPath, trueValue, yes, toJson) + return proposeSetting(protocol.NetworkSettingsContractName, protocol.PerformancePeriodSettingPath, trueValue, yes, toJson) } func proposeSettingProofBuffer(value uint64, yes bool, toJson string) error { trueValue := fmt.Sprint(value) - return proposeSetting(protocol.PerformanceSettingsContractName, protocol.ProofBufferSettingPath, trueValue, yes, toJson) + return proposeSetting(protocol.NetworkSettingsContractName, protocol.ProofBufferSettingPath, trueValue, yes, toJson) } func proposeSettingPerformanceThreshold(value *big.Int, yes bool, toJson string) error { trueValue := value.String() - return proposeSetting(protocol.PerformanceSettingsContractName, protocol.PerformanceThresholdSettingPath, trueValue, yes, toJson) + return proposeSetting(protocol.NetworkSettingsContractName, protocol.PerformanceThresholdSettingPath, trueValue, yes, toJson) } func proposeSettingPerformanceChallengePeriod(value time.Duration, yes bool, toJson string) error { - trueValue := fmt.Sprint(uint64(value.Hours())) - return proposeSetting(protocol.PerformanceSettingsContractName, protocol.PerformanceChallengePeriodSettingPath, trueValue, yes, toJson) + trueValue := fmt.Sprint(uint64(value.Seconds())) + return proposeSetting(protocol.NetworkSettingsContractName, protocol.PerformanceChallengePeriodSettingPath, trueValue, yes, toJson) } func proposeSettingPerformanceChallengeBond(value *big.Int, yes bool, toJson string) error { trueValue := value.String() - return proposeSetting(protocol.PerformanceSettingsContractName, protocol.PerformanceChallengeBondSettingPath, trueValue, yes, toJson) + return proposeSetting(protocol.NetworkSettingsContractName, protocol.PerformanceChallengeBondSettingPath, trueValue, yes, toJson) } func proposeSettingCooperativeExitPhase(value time.Duration, yes bool, toJson string) error { diff --git a/rocketpool-cli/security/propose-settings.go b/rocketpool-cli/security/propose-settings.go index 6d759026e..6dd29c918 100644 --- a/rocketpool-cli/security/propose-settings.go +++ b/rocketpool-cli/security/propose-settings.go @@ -84,7 +84,7 @@ func proposeSettingNodeComissionShareSecurityCouncilAdder(value *big.Int, yes bo func proposeSettingPerformanceExitsEnabled(value bool, yes bool) error { trueValue := fmt.Sprint(value) - return proposeSetting(protocol.PerformanceSettingsContractName, protocol.PerformanceExitsEnabledSettingPath, trueValue, yes) + return proposeSetting(protocol.NetworkSettingsContractName, protocol.PerformanceExitsEnabledSettingPath, trueValue, yes) } // Master general proposal function diff --git a/rocketpool/api/pdao/propose-settings.go b/rocketpool/api/pdao/propose-settings.go index 9d01eeb30..8ab5b9850 100644 --- a/rocketpool/api/pdao/propose-settings.go +++ b/rocketpool/api/pdao/propose-settings.go @@ -354,6 +354,72 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, case protocol.NetworkSettingsContractName: switch settingName { + // PerformanceExitsEnabled + case protocol.PerformanceExitsEnabledSettingPath: + newValue, err := cliutils.ValidateBool(valueName, value) + if err != nil { + return nil, err + } + response.GasLimits, err = protocol.EstimateProposePerformanceExitsEnabledGas(rp, newValue, blockNumber, pollard, opts) + if err != nil { + return nil, fmt.Errorf("error estimating gas for proposing PerformanceExitsEnabled: %w", err) + } + + // PerformancePeriod + case protocol.PerformancePeriodSettingPath: + newValue, err := cliutils.ValidateBigInt(valueName, value) + if err != nil { + return nil, err + } + response.GasLimits, err = protocol.EstimateProposePerformancePeriodGas(rp, newValue, blockNumber, pollard, opts) + if err != nil { + return nil, fmt.Errorf("error estimating gas for proposing PerformancePeriod: %w", err) + } + + // ProofBuffer + case protocol.ProofBufferSettingPath: + newValue, err := cliutils.ValidateBigInt(valueName, value) + if err != nil { + return nil, err + } + response.GasLimits, err = protocol.EstimateProposeProofBufferGas(rp, newValue, blockNumber, pollard, opts) + if err != nil { + return nil, fmt.Errorf("error estimating gas for proposing ProofBuffer: %w", err) + } + + // PerformanceThreshold + case protocol.PerformanceThresholdSettingPath: + newValue, err := cliutils.ValidateBigInt(valueName, value) + if err != nil { + return nil, err + } + response.GasLimits, err = protocol.EstimateProposePerformanceThresholdGas(rp, newValue, blockNumber, pollard, opts) + if err != nil { + return nil, fmt.Errorf("error estimating gas for proposing PerformanceThreshold: %w", err) + } + + // PerformanceChallengePeriod + case protocol.PerformanceChallengePeriodSettingPath: + newValue, err := cliutils.ValidateBigInt(valueName, value) + if err != nil { + return nil, err + } + response.GasLimits, err = protocol.EstimateProposePerformanceChallengePeriodGas(rp, newValue, blockNumber, pollard, opts) + if err != nil { + return nil, fmt.Errorf("error estimating gas for proposing PerformanceChallengePeriod: %w", err) + } + + // PerformanceChallengeBond + case protocol.PerformanceChallengeBondSettingPath: + newValue, err := cliutils.ValidateBigInt(valueName, value) + if err != nil { + return nil, err + } + response.GasLimits, err = protocol.EstimateProposePerformanceChallengeBondGas(rp, newValue, blockNumber, pollard, opts) + if err != nil { + return nil, fmt.Errorf("error estimating gas for proposing PerformanceChallengeBond: %w", err) + } + // CooperativeExitPhase case protocol.CooperativeExitPhaseSettingPath: newValue, err := cliutils.ValidateBigInt(valueName, value) @@ -1015,75 +1081,6 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, } } - case protocol.PerformanceSettingsContractName: - switch settingName { - // PerformanceExitsEnabled - case protocol.PerformanceExitsEnabledSettingPath: - newValue, err := cliutils.ValidateBool(valueName, value) - if err != nil { - return nil, err - } - response.GasLimits, err = protocol.EstimateProposePerformanceExitsEnabledGas(rp, newValue, blockNumber, pollard, opts) - if err != nil { - return nil, fmt.Errorf("error estimating gas for proposing PerformanceExitsEnabled: %w", err) - } - - // PerformancePeriod - case protocol.PerformancePeriodSettingPath: - newValue, err := cliutils.ValidateBigInt(valueName, value) - if err != nil { - return nil, err - } - response.GasLimits, err = protocol.EstimateProposePerformancePeriodGas(rp, newValue, blockNumber, pollard, opts) - if err != nil { - return nil, fmt.Errorf("error estimating gas for proposing PerformancePeriod: %w", err) - } - - // ProofBuffer - case protocol.ProofBufferSettingPath: - newValue, err := cliutils.ValidateBigInt(valueName, value) - if err != nil { - return nil, err - } - response.GasLimits, err = protocol.EstimateProposeProofBufferGas(rp, newValue, blockNumber, pollard, opts) - if err != nil { - return nil, fmt.Errorf("error estimating gas for proposing ProofBuffer: %w", err) - } - - // PerformanceThreshold - case protocol.PerformanceThresholdSettingPath: - newValue, err := cliutils.ValidateBigInt(valueName, value) - if err != nil { - return nil, err - } - response.GasLimits, err = protocol.EstimateProposePerformanceThresholdGas(rp, newValue, blockNumber, pollard, opts) - if err != nil { - return nil, fmt.Errorf("error estimating gas for proposing PerformanceThreshold: %w", err) - } - - // PerformanceChallengePeriod - case protocol.PerformanceChallengePeriodSettingPath: - newValue, err := cliutils.ValidateBigInt(valueName, value) - if err != nil { - return nil, err - } - response.GasLimits, err = protocol.EstimateProposePerformanceChallengePeriodGas(rp, newValue, blockNumber, pollard, opts) - if err != nil { - return nil, fmt.Errorf("error estimating gas for proposing PerformanceChallengePeriod: %w", err) - } - - // PerformanceChallengeBond - case protocol.PerformanceChallengeBondSettingPath: - newValue, err := cliutils.ValidateBigInt(valueName, value) - if err != nil { - return nil, err - } - response.GasLimits, err = protocol.EstimateProposePerformanceChallengeBondGas(rp, newValue, blockNumber, pollard, opts) - if err != nil { - return nil, fmt.Errorf("error estimating gas for proposing PerformanceChallengeBond: %w", err) - } - } - } // Make sure a setting was actually hit @@ -1364,6 +1361,72 @@ func proposeSetting(c *cli.Command, contractName string, settingName string, val case protocol.NetworkSettingsContractName: switch settingName { + // PerformanceExitsEnabled + case protocol.PerformanceExitsEnabledSettingPath: + newValue, err := cliutils.ValidateBool(valueName, value) + if err != nil { + return nil, err + } + proposalID, hash, err = protocol.ProposePerformanceExitsEnabled(rp, newValue, blockNumber, pollard, opts) + if err != nil { + return nil, fmt.Errorf("error proposing PerformanceExitsEnabled: %w", err) + } + + // PerformancePeriod + case protocol.PerformancePeriodSettingPath: + newValue, err := cliutils.ValidateBigInt(valueName, value) + if err != nil { + return nil, err + } + proposalID, hash, err = protocol.ProposePerformancePeriod(rp, newValue, blockNumber, pollard, opts) + if err != nil { + return nil, fmt.Errorf("error proposing PerformancePeriod: %w", err) + } + + // ProofBuffer + case protocol.ProofBufferSettingPath: + newValue, err := cliutils.ValidateBigInt(valueName, value) + if err != nil { + return nil, err + } + proposalID, hash, err = protocol.ProposeProofBuffer(rp, newValue, blockNumber, pollard, opts) + if err != nil { + return nil, fmt.Errorf("error proposing ProofBuffer: %w", err) + } + + // PerformanceThreshold + case protocol.PerformanceThresholdSettingPath: + newValue, err := cliutils.ValidateBigInt(valueName, value) + if err != nil { + return nil, err + } + proposalID, hash, err = protocol.ProposePerformanceThreshold(rp, newValue, blockNumber, pollard, opts) + if err != nil { + return nil, fmt.Errorf("error proposing PerformanceThreshold: %w", err) + } + + // PerformanceChallengePeriod + case protocol.PerformanceChallengePeriodSettingPath: + newValue, err := cliutils.ValidateBigInt(valueName, value) + if err != nil { + return nil, err + } + proposalID, hash, err = protocol.ProposePerformanceChallengePeriod(rp, newValue, blockNumber, pollard, opts) + if err != nil { + return nil, fmt.Errorf("error proposing PerformanceChallengePeriod: %w", err) + } + + // PerformanceChallengeBond + case protocol.PerformanceChallengeBondSettingPath: + newValue, err := cliutils.ValidateBigInt(valueName, value) + if err != nil { + return nil, err + } + proposalID, hash, err = protocol.ProposePerformanceChallengeBond(rp, newValue, blockNumber, pollard, opts) + if err != nil { + return nil, fmt.Errorf("error proposing PerformanceChallengeBond: %w", err) + } + // CooperativeExitPhase case protocol.CooperativeExitPhaseSettingPath: newValue, err := cliutils.ValidateBigInt(valueName, value) @@ -2026,75 +2089,6 @@ func proposeSetting(c *cli.Command, contractName string, settingName string, val } - case protocol.PerformanceSettingsContractName: - switch settingName { - // PerformanceExitsEnabled - case protocol.PerformanceExitsEnabledSettingPath: - newValue, err := cliutils.ValidateBool(valueName, value) - if err != nil { - return nil, err - } - proposalID, hash, err = protocol.ProposePerformanceExitsEnabled(rp, newValue, blockNumber, pollard, opts) - if err != nil { - return nil, fmt.Errorf("error proposing PerformanceExitsEnabled: %w", err) - } - - // PerformancePeriod - case protocol.PerformancePeriodSettingPath: - newValue, err := cliutils.ValidateBigInt(valueName, value) - if err != nil { - return nil, err - } - proposalID, hash, err = protocol.ProposePerformancePeriod(rp, newValue, blockNumber, pollard, opts) - if err != nil { - return nil, fmt.Errorf("error proposing PerformancePeriod: %w", err) - } - - // ProofBuffer - case protocol.ProofBufferSettingPath: - newValue, err := cliutils.ValidateBigInt(valueName, value) - if err != nil { - return nil, err - } - proposalID, hash, err = protocol.ProposeProofBuffer(rp, newValue, blockNumber, pollard, opts) - if err != nil { - return nil, fmt.Errorf("error proposing ProofBuffer: %w", err) - } - - // PerformanceThreshold - case protocol.PerformanceThresholdSettingPath: - newValue, err := cliutils.ValidateBigInt(valueName, value) - if err != nil { - return nil, err - } - proposalID, hash, err = protocol.ProposePerformanceThreshold(rp, newValue, blockNumber, pollard, opts) - if err != nil { - return nil, fmt.Errorf("error proposing PerformanceThreshold: %w", err) - } - - // PerformanceChallengePeriod - case protocol.PerformanceChallengePeriodSettingPath: - newValue, err := cliutils.ValidateBigInt(valueName, value) - if err != nil { - return nil, err - } - proposalID, hash, err = protocol.ProposePerformanceChallengePeriod(rp, newValue, blockNumber, pollard, opts) - if err != nil { - return nil, fmt.Errorf("error proposing PerformanceChallengePeriod: %w", err) - } - - // PerformanceChallengeBond - case protocol.PerformanceChallengeBondSettingPath: - newValue, err := cliutils.ValidateBigInt(valueName, value) - if err != nil { - return nil, err - } - proposalID, hash, err = protocol.ProposePerformanceChallengeBond(rp, newValue, blockNumber, pollard, opts) - if err != nil { - return nil, fmt.Errorf("error proposing PerformanceChallengeBond: %w", err) - } - } - } // Make sure a setting was actually hit diff --git a/rocketpool/api/security/propose-settings.go b/rocketpool/api/security/propose-settings.go index 7f9c9c7b0..10e063c8b 100644 --- a/rocketpool/api/security/propose-settings.go +++ b/rocketpool/api/security/propose-settings.go @@ -122,6 +122,17 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, case protocol.NetworkSettingsContractName: switch settingName { + // PerformanceExitsEnabled + case protocol.PerformanceExitsEnabledSettingPath: + newValue, err := cliutils.ValidateBool(valueName, value) + if err != nil { + return nil, err + } + response.GasLimits, err = security.EstimateProposePerformanceExitsEnabledGas(rp, newValue, opts) + if err != nil { + return nil, fmt.Errorf("error estimating gas for proposing PerformanceExitsEnabled: %w", err) + } + // SubmitBalancesEnabled case protocol.SubmitBalancesEnabledSettingPath: newValue, err := cliutils.ValidateBool(valueName, value) @@ -203,19 +214,6 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, } } - case protocol.PerformanceSettingsContractName: - switch settingName { - // PerformanceExitsEnabled - case protocol.PerformanceExitsEnabledSettingPath: - newValue, err := cliutils.ValidateBool(valueName, value) - if err != nil { - return nil, err - } - response.GasLimits, err = security.EstimateProposePerformanceExitsEnabledGas(rp, newValue, opts) - if err != nil { - return nil, fmt.Errorf("error estimating gas for proposing PerformanceExitsEnabled: %w", err) - } - } } // Make sure a setting was actually hit @@ -329,6 +327,17 @@ func proposeSetting(c *cli.Command, contractName string, settingName string, val case protocol.NetworkSettingsContractName: switch settingName { + // PerformanceExitsEnabled + case protocol.PerformanceExitsEnabledSettingPath: + newValue, err := cliutils.ValidateBool(valueName, value) + if err != nil { + return nil, err + } + proposalID, hash, err = security.ProposePerformanceExitsEnabled(rp, newValue, opts) + if err != nil { + return nil, fmt.Errorf("error proposing PerformanceExitsEnabled: %w", err) + } + // SubmitBalancesEnabled case protocol.SubmitBalancesEnabledSettingPath: newValue, err := cliutils.ValidateBool(valueName, value) @@ -409,19 +418,6 @@ func proposeSetting(c *cli.Command, contractName string, settingName string, val } } - case protocol.PerformanceSettingsContractName: - switch settingName { - // PerformanceExitsEnabled - case protocol.PerformanceExitsEnabledSettingPath: - newValue, err := cliutils.ValidateBool(valueName, value) - if err != nil { - return nil, err - } - proposalID, hash, err = security.ProposePerformanceExitsEnabled(rp, newValue, opts) - if err != nil { - return nil, fmt.Errorf("error proposing PerformanceExitsEnabled: %w", err) - } - } } // Make sure a setting was actually hit