Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
75 changes: 32 additions & 43 deletions bindings/settings/protocol/performance.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package protocol
import (
"fmt"
"math/big"
"sync"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand All @@ -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)
}
14 changes: 6 additions & 8 deletions bindings/settings/protocol/setting-types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions bindings/settings/security/performance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
7 changes: 4 additions & 3 deletions rocketpool-cli/cli/saturn2-check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions rocketpool-cli/pdao/propose-settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion rocketpool-cli/security/propose-settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading