Skip to content

Commit 540ba62

Browse files
committed
Performance settings are in the networkSettingsContract
1 parent cf59bb7 commit 540ba62

8 files changed

Lines changed: 206 additions & 232 deletions

File tree

‎bindings/settings/protocol/performance.go‎

Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package protocol
33
import (
44
"fmt"
55
"math/big"
6-
"sync"
76
"time"
87

98
"github.com/ethereum/go-ethereum/accounts/abi/bind"
@@ -17,134 +16,124 @@ import (
1716

1817
// Config
1918
const (
20-
PerformanceSettingsContractName string = "rocketDAOProtocolSettingsPerformance"
21-
PerformanceExitsEnabledSettingPath string = "performance.exits.enabled"
22-
PerformancePeriodSettingPath string = "performance.period"
23-
ProofBufferSettingPath string = "proof.buffer"
24-
PerformanceThresholdSettingPath string = "performance.threshold"
25-
PerformanceChallengePeriodSettingPath string = "performance.challenge.period"
26-
PerformanceChallengeBondSettingPath string = "performance.challenge.bond"
19+
PerformanceExitsEnabledSettingPath string = "network.performance.exits.enabled"
20+
PerformancePeriodSettingPath string = "network.performance.period"
21+
ProofBufferSettingPath string = "network.performance.proof.buffer"
22+
PerformanceThresholdSettingPath string = "network.performance.threshold"
23+
PerformanceChallengePeriodSettingPath string = "network.performance.challenge.period"
24+
PerformanceChallengeBondSettingPath string = "network.performance.challenge.bond"
2725
)
2826

2927
// Performance exits currently enabled
3028
func GetPerformanceExitsEnabled(rp *rocketpool.RocketPool, opts *bind.CallOpts) (bool, error) {
31-
performanceSettingsContract, err := getPerformanceSettingsContract(rp, opts)
29+
networkSettingsContract, err := getNetworkSettingsContract(rp, opts)
3230
if err != nil {
3331
return false, err
3432
}
3533
value := new(bool)
36-
if err := performanceSettingsContract.Call(opts, value, "getPerformanceExitsEnabled"); err != nil {
34+
if err := networkSettingsContract.Call(opts, value, "getPerformanceExitsEnabled"); err != nil {
3735
return false, fmt.Errorf("error getting performance exits enabled status: %w", err)
3836
}
3937
return *value, nil
4038
}
4139
func ProposePerformanceExitsEnabled(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) {
42-
return protocol.ProposeSetBool(rp, fmt.Sprintf("set %s", PerformanceExitsEnabledSettingPath), PerformanceSettingsContractName, PerformanceExitsEnabledSettingPath, value, blockNumber, treeNodes, opts)
40+
return protocol.ProposeSetBool(rp, fmt.Sprintf("set %s", PerformanceExitsEnabledSettingPath), NetworkSettingsContractName, PerformanceExitsEnabledSettingPath, value, blockNumber, treeNodes, opts)
4341
}
4442
func EstimateProposePerformanceExitsEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) {
45-
return protocol.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", PerformanceExitsEnabledSettingPath), PerformanceSettingsContractName, PerformanceExitsEnabledSettingPath, value, blockNumber, treeNodes, opts)
43+
return protocol.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", PerformanceExitsEnabledSettingPath), NetworkSettingsContractName, PerformanceExitsEnabledSettingPath, value, blockNumber, treeNodes, opts)
4644
}
4745

4846
// Number of epochs over which attestation performance is measured
4947
func GetPerformancePeriod(rp *rocketpool.RocketPool, opts *bind.CallOpts) (uint64, error) {
50-
performanceSettingsContract, err := getPerformanceSettingsContract(rp, opts)
48+
networkSettingsContract, err := getNetworkSettingsContract(rp, opts)
5149
if err != nil {
5250
return 0, err
5351
}
5452
value := new(*big.Int)
55-
if err := performanceSettingsContract.Call(opts, value, "getPerformancePeriod"); err != nil {
53+
if err := networkSettingsContract.Call(opts, value, "getPerformancePeriod"); err != nil {
5654
return 0, fmt.Errorf("error getting performance period: %w", err)
5755
}
5856
return (*value).Uint64(), nil
5957
}
6058
func ProposePerformancePeriod(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) {
61-
return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", PerformancePeriodSettingPath), PerformanceSettingsContractName, PerformancePeriodSettingPath, value, blockNumber, treeNodes, opts)
59+
return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", PerformancePeriodSettingPath), NetworkSettingsContractName, PerformancePeriodSettingPath, value, blockNumber, treeNodes, opts)
6260
}
6361
func EstimateProposePerformancePeriodGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) {
64-
return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", PerformancePeriodSettingPath), PerformanceSettingsContractName, PerformancePeriodSettingPath, value, blockNumber, treeNodes, opts)
62+
return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", PerformancePeriodSettingPath), NetworkSettingsContractName, PerformancePeriodSettingPath, value, blockNumber, treeNodes, opts)
6563
}
6664

6765
// Buffer to detect underperformance and generate proofs before a validator can be challenged (epochs)
6866
func GetProofBuffer(rp *rocketpool.RocketPool, opts *bind.CallOpts) (uint64, error) {
69-
performanceSettingsContract, err := getPerformanceSettingsContract(rp, opts)
67+
networkSettingsContract, err := getNetworkSettingsContract(rp, opts)
7068
if err != nil {
7169
return 0, err
7270
}
7371
value := new(*big.Int)
74-
if err := performanceSettingsContract.Call(opts, value, "getProofBuffer"); err != nil {
72+
if err := networkSettingsContract.Call(opts, value, "getPerformanceProofBuffer"); err != nil {
7573
return 0, fmt.Errorf("error getting proof buffer: %w", err)
7674
}
7775
return (*value).Uint64(), nil
7876
}
7977
func ProposeProofBuffer(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) {
80-
return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", ProofBufferSettingPath), PerformanceSettingsContractName, ProofBufferSettingPath, value, blockNumber, treeNodes, opts)
78+
return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", ProofBufferSettingPath), NetworkSettingsContractName, ProofBufferSettingPath, value, blockNumber, treeNodes, opts)
8179
}
8280
func EstimateProposeProofBufferGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) {
83-
return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ProofBufferSettingPath), PerformanceSettingsContractName, ProofBufferSettingPath, value, blockNumber, treeNodes, opts)
81+
return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ProofBufferSettingPath), NetworkSettingsContractName, ProofBufferSettingPath, value, blockNumber, treeNodes, opts)
8482
}
8583

8684
// Minimum target attestation timeliness percentage required to avoid exit
8785
func GetPerformanceThreshold(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.Int, error) {
88-
performanceSettingsContract, err := getPerformanceSettingsContract(rp, opts)
86+
networkSettingsContract, err := getNetworkSettingsContract(rp, opts)
8987
if err != nil {
9088
return nil, err
9189
}
9290
value := new(*big.Int)
93-
if err := performanceSettingsContract.Call(opts, value, "getPerformanceThreshold"); err != nil {
91+
if err := networkSettingsContract.Call(opts, value, "getPerformanceThreshold"); err != nil {
9492
return nil, fmt.Errorf("error getting performance threshold: %w", err)
9593
}
9694
return *value, nil
9795
}
9896
func ProposePerformanceThreshold(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) {
99-
return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", PerformanceThresholdSettingPath), PerformanceSettingsContractName, PerformanceThresholdSettingPath, value, blockNumber, treeNodes, opts)
97+
return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", PerformanceThresholdSettingPath), NetworkSettingsContractName, PerformanceThresholdSettingPath, value, blockNumber, treeNodes, opts)
10098
}
10199
func EstimateProposePerformanceThresholdGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) {
102-
return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", PerformanceThresholdSettingPath), PerformanceSettingsContractName, PerformanceThresholdSettingPath, value, blockNumber, treeNodes, opts)
100+
return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", PerformanceThresholdSettingPath), NetworkSettingsContractName, PerformanceThresholdSettingPath, value, blockNumber, treeNodes, opts)
103101
}
104102

105-
// How long a performance exit challenge remains open
103+
// How long a performance exit challenge remains open (stored on-chain in seconds)
106104
func GetPerformanceChallengePeriod(rp *rocketpool.RocketPool, opts *bind.CallOpts) (time.Duration, error) {
107-
performanceSettingsContract, err := getPerformanceSettingsContract(rp, opts)
105+
networkSettingsContract, err := getNetworkSettingsContract(rp, opts)
108106
if err != nil {
109107
return 0, err
110108
}
111109
value := new(*big.Int)
112-
if err := performanceSettingsContract.Call(opts, value, "getPerformanceChallengePeriod"); err != nil {
110+
if err := networkSettingsContract.Call(opts, value, "getPerformanceChallengePeriod"); err != nil {
113111
return 0, fmt.Errorf("error getting performance challenge period: %w", err)
114112
}
115-
return time.Duration((*value).Int64()) * time.Hour, nil
113+
return time.Duration((*value).Int64()) * time.Second, nil
116114
}
117115
func ProposePerformanceChallengePeriod(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) {
118-
return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", PerformanceChallengePeriodSettingPath), PerformanceSettingsContractName, PerformanceChallengePeriodSettingPath, value, blockNumber, treeNodes, opts)
116+
return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", PerformanceChallengePeriodSettingPath), NetworkSettingsContractName, PerformanceChallengePeriodSettingPath, value, blockNumber, treeNodes, opts)
119117
}
120118
func EstimateProposePerformanceChallengePeriodGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) {
121-
return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", PerformanceChallengePeriodSettingPath), PerformanceSettingsContractName, PerformanceChallengePeriodSettingPath, value, blockNumber, treeNodes, opts)
119+
return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", PerformanceChallengePeriodSettingPath), NetworkSettingsContractName, PerformanceChallengePeriodSettingPath, value, blockNumber, treeNodes, opts)
122120
}
123121

124122
// RPL bond required to propose a performance exit
125123
func GetPerformanceChallengeBond(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.Int, error) {
126-
performanceSettingsContract, err := getPerformanceSettingsContract(rp, opts)
124+
networkSettingsContract, err := getNetworkSettingsContract(rp, opts)
127125
if err != nil {
128126
return nil, err
129127
}
130128
value := new(*big.Int)
131-
if err := performanceSettingsContract.Call(opts, value, "getPerformanceChallengeBond"); err != nil {
129+
if err := networkSettingsContract.Call(opts, value, "getPerformanceChallengeBond"); err != nil {
132130
return nil, fmt.Errorf("error getting performance challenge bond: %w", err)
133131
}
134132
return *value, nil
135133
}
136134
func ProposePerformanceChallengeBond(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) {
137-
return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", PerformanceChallengeBondSettingPath), PerformanceSettingsContractName, PerformanceChallengeBondSettingPath, value, blockNumber, treeNodes, opts)
135+
return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", PerformanceChallengeBondSettingPath), NetworkSettingsContractName, PerformanceChallengeBondSettingPath, value, blockNumber, treeNodes, opts)
138136
}
139137
func EstimateProposePerformanceChallengeBondGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) {
140-
return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", PerformanceChallengeBondSettingPath), PerformanceSettingsContractName, PerformanceChallengeBondSettingPath, value, blockNumber, treeNodes, opts)
141-
}
142-
143-
// Get contracts
144-
var performanceSettingsContractLock sync.Mutex
145-
146-
func getPerformanceSettingsContract(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*rocketpool.Contract, error) {
147-
performanceSettingsContractLock.Lock()
148-
defer performanceSettingsContractLock.Unlock()
149-
return rp.GetContract(PerformanceSettingsContractName, opts)
138+
return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", PerformanceChallengeBondSettingPath), NetworkSettingsContractName, PerformanceChallengeBondSettingPath, value, blockNumber, treeNodes, opts)
150139
}

‎bindings/settings/protocol/setting-types.go‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ var pdaoSettingKinds = map[string]map[string]settingKind{
6262
MinipoolUserDistributeWindowLengthSettingPath: settingKindUint256,
6363
},
6464
NetworkSettingsContractName: {
65+
PerformanceExitsEnabledSettingPath: settingKindBool,
66+
PerformancePeriodSettingPath: settingKindUint256,
67+
ProofBufferSettingPath: settingKindUint256,
68+
PerformanceThresholdSettingPath: settingKindUint256,
69+
PerformanceChallengePeriodSettingPath: settingKindUint256,
70+
PerformanceChallengeBondSettingPath: settingKindUint256,
6571
CooperativeExitPhaseSettingPath: settingKindUint256,
6672
DidNotExitPenaltyBaseSettingPath: settingKindUint256,
6773
DidNotExitBaseSettingPath: settingKindUint256,
@@ -134,14 +140,6 @@ var pdaoSettingKinds = map[string]map[string]settingKind{
134140
MegapoolPenaltyThreshold: settingKindUint256,
135141
MegapoolPrestakeChallengePeriodPath: settingKindUint256,
136142
},
137-
PerformanceSettingsContractName: {
138-
PerformanceExitsEnabledSettingPath: settingKindBool,
139-
PerformancePeriodSettingPath: settingKindUint256,
140-
ProofBufferSettingPath: settingKindUint256,
141-
PerformanceThresholdSettingPath: settingKindUint256,
142-
PerformanceChallengePeriodSettingPath: settingKindUint256,
143-
PerformanceChallengeBondSettingPath: settingKindUint256,
144-
},
145143
}
146144

147145
// GetProposalSettingType returns the on-chain type used by proposalSettingMulti

‎bindings/settings/security/performance.go‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,10 @@ import (
1212
"github.com/rocket-pool/smartnode/bindings/transactions/gaslimit"
1313
)
1414

15-
const (
16-
performanceNamespace string = "performance"
17-
)
18-
1915
// Performance exits currently enabled
2016
func ProposePerformanceExitsEnabled(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (uint64, common.Hash, error) {
21-
return security.ProposeSetBool(rp, fmt.Sprintf("set %s", psettings.PerformanceExitsEnabledSettingPath), performanceNamespace, psettings.PerformanceExitsEnabledSettingPath, value, opts)
17+
return security.ProposeSetBool(rp, fmt.Sprintf("set %s", psettings.PerformanceExitsEnabledSettingPath), networkNamespace, psettings.PerformanceExitsEnabledSettingPath, value, opts)
2218
}
2319
func EstimateProposePerformanceExitsEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (gaslimit.Limits, error) {
24-
return security.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", psettings.PerformanceExitsEnabledSettingPath), performanceNamespace, psettings.PerformanceExitsEnabledSettingPath, value, opts)
20+
return security.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", psettings.PerformanceExitsEnabledSettingPath), networkNamespace, psettings.PerformanceExitsEnabledSettingPath, value, opts)
2521
}

‎rocketpool-cli/cli/saturn2-check.go‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ const Saturn2NotDeployedMessage = "This command is not available until Saturn 2
1212
// IsSaturn2OnlySetting reports whether a protocol setting exists only after Saturn 2.
1313
func IsSaturn2OnlySetting(contract, setting string) bool {
1414
switch contract {
15-
case protocol.PerformanceSettingsContractName:
16-
return true
1715
case protocol.NetworkSettingsContractName:
1816
switch setting {
1917
case protocol.CooperativeExitPhaseSettingPath, protocol.DidNotExitPenaltyBaseSettingPath,
20-
protocol.DidNotExitBaseSettingPath, protocol.DidNotExitBackoffSettingPath:
18+
protocol.DidNotExitBaseSettingPath, protocol.DidNotExitBackoffSettingPath,
19+
protocol.PerformanceExitsEnabledSettingPath, protocol.PerformancePeriodSettingPath,
20+
protocol.ProofBufferSettingPath, protocol.PerformanceThresholdSettingPath,
21+
protocol.PerformanceChallengePeriodSettingPath, protocol.PerformanceChallengeBondSettingPath:
2122
return true
2223
}
2324
return false

‎rocketpool-cli/pdao/propose-settings.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,32 +372,32 @@ func proposeSettingMegapoolPrestakeChallengePeriod(value uint64, yes bool, toJso
372372

373373
func proposeSettingPerformanceExitsEnabled(value bool, yes bool, toJson string) error {
374374
trueValue := fmt.Sprint(value)
375-
return proposeSetting(protocol.PerformanceSettingsContractName, protocol.PerformanceExitsEnabledSettingPath, trueValue, yes, toJson)
375+
return proposeSetting(protocol.NetworkSettingsContractName, protocol.PerformanceExitsEnabledSettingPath, trueValue, yes, toJson)
376376
}
377377

378378
func proposeSettingPerformancePeriod(value uint64, yes bool, toJson string) error {
379379
trueValue := fmt.Sprint(value)
380-
return proposeSetting(protocol.PerformanceSettingsContractName, protocol.PerformancePeriodSettingPath, trueValue, yes, toJson)
380+
return proposeSetting(protocol.NetworkSettingsContractName, protocol.PerformancePeriodSettingPath, trueValue, yes, toJson)
381381
}
382382

383383
func proposeSettingProofBuffer(value uint64, yes bool, toJson string) error {
384384
trueValue := fmt.Sprint(value)
385-
return proposeSetting(protocol.PerformanceSettingsContractName, protocol.ProofBufferSettingPath, trueValue, yes, toJson)
385+
return proposeSetting(protocol.NetworkSettingsContractName, protocol.ProofBufferSettingPath, trueValue, yes, toJson)
386386
}
387387

388388
func proposeSettingPerformanceThreshold(value *big.Int, yes bool, toJson string) error {
389389
trueValue := value.String()
390-
return proposeSetting(protocol.PerformanceSettingsContractName, protocol.PerformanceThresholdSettingPath, trueValue, yes, toJson)
390+
return proposeSetting(protocol.NetworkSettingsContractName, protocol.PerformanceThresholdSettingPath, trueValue, yes, toJson)
391391
}
392392

393393
func proposeSettingPerformanceChallengePeriod(value time.Duration, yes bool, toJson string) error {
394-
trueValue := fmt.Sprint(uint64(value.Hours()))
395-
return proposeSetting(protocol.PerformanceSettingsContractName, protocol.PerformanceChallengePeriodSettingPath, trueValue, yes, toJson)
394+
trueValue := fmt.Sprint(uint64(value.Seconds()))
395+
return proposeSetting(protocol.NetworkSettingsContractName, protocol.PerformanceChallengePeriodSettingPath, trueValue, yes, toJson)
396396
}
397397

398398
func proposeSettingPerformanceChallengeBond(value *big.Int, yes bool, toJson string) error {
399399
trueValue := value.String()
400-
return proposeSetting(protocol.PerformanceSettingsContractName, protocol.PerformanceChallengeBondSettingPath, trueValue, yes, toJson)
400+
return proposeSetting(protocol.NetworkSettingsContractName, protocol.PerformanceChallengeBondSettingPath, trueValue, yes, toJson)
401401
}
402402

403403
func proposeSettingCooperativeExitPhase(value time.Duration, yes bool, toJson string) error {

‎rocketpool-cli/security/propose-settings.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func proposeSettingNodeComissionShareSecurityCouncilAdder(value *big.Int, yes bo
8484

8585
func proposeSettingPerformanceExitsEnabled(value bool, yes bool) error {
8686
trueValue := fmt.Sprint(value)
87-
return proposeSetting(protocol.PerformanceSettingsContractName, protocol.PerformanceExitsEnabledSettingPath, trueValue, yes)
87+
return proposeSetting(protocol.NetworkSettingsContractName, protocol.PerformanceExitsEnabledSettingPath, trueValue, yes)
8888
}
8989

9090
// Master general proposal function

0 commit comments

Comments
 (0)