diff --git a/bindings/settings/protocol/network.go b/bindings/settings/protocol/network.go index 1ac7e3a92..6db7b4f90 100644 --- a/bindings/settings/protocol/network.go +++ b/bindings/settings/protocol/network.go @@ -27,7 +27,6 @@ const ( TargetNodeFeeSettingPath string = "network.node.fee.target" MaximumNodeFeeSettingPath string = "network.node.fee.maximum" NodeFeeDemandRangeSettingPath string = "network.node.fee.demand.range" - NodeComissionShareSecurityCouncilAdder string = "network.node.commission.share.security.council.adder" TargetRethCollateralRateSettingPath string = "network.reth.collateral.target" NetworkPenaltyThresholdSettingPath string = "network.penalty.threshold" NetworkPenaltyPerRateSettingPath string = "network.penalty.per.rate" diff --git a/bindings/settings/security/network.go b/bindings/settings/security/network.go index 45b133a00..b18a5899b 100644 --- a/bindings/settings/security/network.go +++ b/bindings/settings/security/network.go @@ -33,8 +33,8 @@ func EstimateProposeSubmitRewardsEnabledGas(rp *rocketpool.RocketPool, value boo } func ProposeNodeComissionShareSecurityCouncilAdder(rp *rocketpool.RocketPool, value *big.Int, opts *bind.TransactOpts) (uint64, common.Hash, error) { - return security.ProposeSetUint(rp, fmt.Sprintf("set %s", psettings.NodeComissionShareSecurityCouncilAdder), networkNamespace, psettings.NodeComissionShareSecurityCouncilAdder, value, opts) + return security.ProposeSetUint(rp, fmt.Sprintf("set %s", psettings.NetworkNodeCommissionShareSecurityCouncilAdderPath), networkNamespace, psettings.NetworkNodeCommissionShareSecurityCouncilAdderPath, value, opts) } func EstimateProposeNodeComissionShareSecurityCouncilAdder(rp *rocketpool.RocketPool, value *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { - return security.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", psettings.NodeComissionShareSecurityCouncilAdder), networkNamespace, psettings.NodeComissionShareSecurityCouncilAdder, value, opts) + return security.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", psettings.NetworkNodeCommissionShareSecurityCouncilAdderPath), networkNamespace, psettings.NetworkNodeCommissionShareSecurityCouncilAdderPath, value, opts) } diff --git a/rocketpool-cli/security/commands.go b/rocketpool-cli/security/commands.go index a17ed9804..e9d6064b9 100644 --- a/rocketpool-cli/security/commands.go +++ b/rocketpool-cli/security/commands.go @@ -385,7 +385,7 @@ func RegisterCommands(app *cli.App, name string, aliases []string) { { Name: "node-commission-share-council-adder", Aliases: []string{"ncsca"}, - Usage: fmt.Sprintf("Propose updating the %s setting; %s", protocol.NodeComissionShareSecurityCouncilAdder, percentUsage), + Usage: fmt.Sprintf("Propose updating the %s setting; %s", protocol.NetworkNodeCommissionShareSecurityCouncilAdderPath, percentUsage), UsageText: "rocketpool security propose setting network node-commission-share-council-adder", Flags: []cli.Flag{ cli.BoolFlag{ diff --git a/rocketpool-cli/security/propose-settings.go b/rocketpool-cli/security/propose-settings.go index 0b6d33dcd..4ef37ec3e 100644 --- a/rocketpool-cli/security/propose-settings.go +++ b/rocketpool-cli/security/propose-settings.go @@ -80,7 +80,7 @@ func proposeSettingNodeAreVacantMinipoolsEnabled(c *cli.Context, value bool) err func proposeSettingNodeComissionShareSecurityCouncilAdder(c *cli.Context, value *big.Int) error { trueValue := fmt.Sprint(value) - return proposeSetting(c, protocol.NetworkSettingsContractName, protocol.NodeComissionShareSecurityCouncilAdder, trueValue) + return proposeSetting(c, protocol.NetworkSettingsContractName, protocol.NetworkNodeCommissionShareSecurityCouncilAdderPath, trueValue) } // Master general proposal function diff --git a/rocketpool/api/security/propose-settings.go b/rocketpool/api/security/propose-settings.go index a25628be1..d29262c87 100644 --- a/rocketpool/api/security/propose-settings.go +++ b/rocketpool/api/security/propose-settings.go @@ -143,7 +143,7 @@ func canProposeSetting(c *cli.Context, contractName string, settingName string, return nil, fmt.Errorf("error estimating gas for proposing SubmitRewardsEnabled: %w", err) } - case protocol.NodeComissionShareSecurityCouncilAdder: + case protocol.NetworkNodeCommissionShareSecurityCouncilAdderPath: newValue, err := cliutils.ValidateBigInt(valueName, value) if err != nil { return nil, err @@ -352,7 +352,7 @@ func proposeSetting(c *cli.Context, contractName string, settingName string, val return nil, fmt.Errorf("error proposing SubmitRewardsEnabled: %w", err) } - case protocol.NodeComissionShareSecurityCouncilAdder: + case protocol.NetworkNodeCommissionShareSecurityCouncilAdderPath: newValue, err := cliutils.ValidateBigInt(valueName, value) if err != nil { return nil, err diff --git a/shared/services/rewards/generator-impl-v11.go b/shared/services/rewards/generator-impl-v11.go index 42c51028e..9d058d717 100644 --- a/shared/services/rewards/generator-impl-v11.go +++ b/shared/services/rewards/generator-impl-v11.go @@ -578,13 +578,9 @@ func (r *treeGeneratorImpl_v11) calculateEthRewards(checkBeaconPerformance bool) details := r.networkState.MegapoolDetails[megapool.Address] bond := details.GetMegapoolBondNormalized() nodeFee := r.networkState.NetworkDetails.MegapoolRevenueSplitTimeWeightedAverages.NodeShare - nodeFeeAdder := r.networkState.NetworkDetails.MegapoolRevenueSplitSettings.NodeOperatorCommissionAdder voterFee := r.networkState.NetworkDetails.MegapoolRevenueSplitTimeWeightedAverages.VoterShare pdaoFee := r.networkState.NetworkDetails.MegapoolRevenueSplitTimeWeightedAverages.PdaoShare - effectiveNodeFee := big.NewInt(0).Add(nodeFee, nodeFeeAdder) - effectiveVoterFee := big.NewInt(0).Sub(voterFee, nodeFeeAdder) - // The megapool score is given by: // (bond + effectiveNodeFee*(32-bond)) / 32 // However, when multiplying eth values, we need to normalize the wei to eth @@ -593,10 +589,10 @@ func (r *treeGeneratorImpl_v11) calculateEthRewards(checkBeaconPerformance bool) // integer math inaccuracy, and when we divide by 32 it is removed. // // (b*1 + 32f - f*b) / 32 - megapoolScore := big.NewInt(0).Mul(oneEth, bond) // b*1 - megapoolScore.Add(megapoolScore, big.NewInt(0).Mul(thirtyTwoEth, effectiveNodeFee)) // b*1 + 32f - megapoolScore.Sub(megapoolScore, big.NewInt(0).Mul(effectiveNodeFee, bond)) // b*1 + 32f - f*b - megapoolScore.Div(megapoolScore, thirtyTwoEth) // (b*1 + 32f - f*b) / 32 + megapoolScore := big.NewInt(0).Mul(oneEth, bond) // b*1 + megapoolScore.Add(megapoolScore, big.NewInt(0).Mul(thirtyTwoEth, nodeFee)) // b*1 + 32f + megapoolScore.Sub(megapoolScore, big.NewInt(0).Mul(nodeFee, bond)) // b*1 + 32f - f*b + megapoolScore.Div(megapoolScore, thirtyTwoEth) // (b*1 + 32f - f*b) / 32 // Add it to the megapool's score and the total score validator.AttestationScore.Add(&validator.AttestationScore.Int, megapoolScore) @@ -605,8 +601,8 @@ func (r *treeGeneratorImpl_v11) calculateEthRewards(checkBeaconPerformance bool) // Calculate the voter share // This is simply (effectiveVoterFee * (32 - bond)) / 32 // Simplify to (32f - f*b) / 32 - voterScore := big.NewInt(0).Mul(thirtyTwoEth, effectiveVoterFee) - voterScore.Sub(voterScore, big.NewInt(0).Mul(effectiveVoterFee, bond)) + voterScore := big.NewInt(0).Mul(thirtyTwoEth, voterFee) + voterScore.Sub(voterScore, big.NewInt(0).Mul(voterFee, bond)) voterScore.Div(voterScore, thirtyTwoEth) r.totalVoterScore.Add(r.totalVoterScore, voterScore) @@ -1283,13 +1279,9 @@ func (r *treeGeneratorImpl_v11) checkAttestations(attestations []beacon.Attestat details := r.networkState.MegapoolDetails[megapool.Info.Address] bond := details.GetMegapoolBondNormalized() nodeFee := r.networkState.NetworkDetails.MegapoolRevenueSplitTimeWeightedAverages.NodeShare - // The node fee adder is added to nodeFee and deducted from voter fee - nodeFeeAdder := r.networkState.NetworkDetails.MegapoolRevenueSplitSettings.NodeOperatorCommissionAdder voterFee := r.networkState.NetworkDetails.MegapoolRevenueSplitTimeWeightedAverages.VoterShare pdaoFee := r.networkState.NetworkDetails.MegapoolRevenueSplitTimeWeightedAverages.PdaoShare - effectiveNodeFee := big.NewInt(0).Add(nodeFee, nodeFeeAdder) - effectiveVoterFee := big.NewInt(0).Sub(voterFee, nodeFeeAdder) // The megapool score is given by: // (bond + effectiveNodeFee*(32-bond)) / 32 // However, when multiplying eth values, we need to normalize the wei to eth @@ -1298,10 +1290,10 @@ func (r *treeGeneratorImpl_v11) checkAttestations(attestations []beacon.Attestat // integer math inaccuracy, and when we divide by 32 it is removed. // // (b*1 + 32f - f*b) / 32 - megapoolScore := big.NewInt(0).Mul(oneEth, bond) // b*1 - megapoolScore.Add(megapoolScore, big.NewInt(0).Mul(thirtyTwoEth, effectiveNodeFee)) // b*1 + 32f - megapoolScore.Sub(megapoolScore, big.NewInt(0).Mul(effectiveNodeFee, bond)) // b*1 + 32f - f*b - megapoolScore.Div(megapoolScore, thirtyTwoEth) // (b*1 + 32f - f*b) / 32 + megapoolScore := big.NewInt(0).Mul(oneEth, bond) // b*1 + megapoolScore.Add(megapoolScore, big.NewInt(0).Mul(thirtyTwoEth, nodeFee)) // b*1 + 32f + megapoolScore.Sub(megapoolScore, big.NewInt(0).Mul(nodeFee, bond)) // b*1 + 32f - f*b + megapoolScore.Div(megapoolScore, thirtyTwoEth) // (b*1 + 32f - f*b) / 32 // Add it to the megapool's score and the total score validator.AttestationScore.Add(&validator.AttestationScore.Int, megapoolScore) @@ -1310,8 +1302,8 @@ func (r *treeGeneratorImpl_v11) checkAttestations(attestations []beacon.Attestat // Calculate the voter share // This is simply (effectiveVoterFee * (32 - bond)) / 32 // Simplify to (32f - f*b) / 32 - voterScore := big.NewInt(0).Mul(thirtyTwoEth, effectiveVoterFee) - voterScore.Sub(voterScore, big.NewInt(0).Mul(effectiveVoterFee, bond)) + voterScore := big.NewInt(0).Mul(thirtyTwoEth, voterFee) + voterScore.Sub(voterScore, big.NewInt(0).Mul(voterFee, bond)) voterScore.Div(voterScore, thirtyTwoEth) r.totalVoterScore.Add(r.totalVoterScore, voterScore) diff --git a/shared/services/rewards/mock_v11_test.go b/shared/services/rewards/mock_v11_test.go index b40717a51..71dcb7d5f 100644 --- a/shared/services/rewards/mock_v11_test.go +++ b/shared/services/rewards/mock_v11_test.go @@ -501,7 +501,7 @@ func TestMockIntervalDefaultsTreegenv11(tt *testing.T) { } // Make sure it got ETH - expectedEthAmount, _ := big.NewInt(0).SetString("858194864048338368", 10) + expectedEthAmount, _ := big.NewInt(0).SetString("813695871097683786", 10) ethAmount := rewardsFile.GetNodeSmoothingPoolEth(node.Address) if ethAmount.Cmp(expectedEthAmount) != 0 { t.Fatalf("ETH amount does not match expected value for node %s: %s != %s", node.Notes, ethAmount.String(), expectedEthAmount.String()) @@ -529,7 +529,7 @@ func TestMockIntervalDefaultsTreegenv11(tt *testing.T) { } // Make sure it got ETH - expectedEthAmount, _ := big.NewInt(0).SetString("3824794394091977170", 10) + expectedEthAmount, _ := big.NewInt(0).SetString("3780295401141322588", 10) ethAmount := rewardsFile.GetNodeSmoothingPoolEth(node.Address) if ethAmount.Cmp(expectedEthAmount) != 0 { t.Fatalf("ETH amount does not match expected value for node %s: %s != %s", node.Notes, ethAmount.String(), expectedEthAmount.String()) @@ -558,7 +558,7 @@ func TestMockIntervalDefaultsTreegenv11(tt *testing.T) { } // Make sure it got ETH - expectedEthAmount, _ := big.NewInt(0).SetString("3873307989258140312", 10) + expectedEthAmount, _ := big.NewInt(0).SetString("3828808996307485730", 10) ethAmount := rewardsFile.GetNodeSmoothingPoolEth(node.Address) if ethAmount.Cmp(expectedEthAmount) != 0 { t.Fatalf("ETH amount does not match expected value for node %s: %s != %s", node.Notes, ethAmount.String(), expectedEthAmount.String()) @@ -602,14 +602,14 @@ func TestMockIntervalDefaultsTreegenv11(tt *testing.T) { } // Make sure it got voter share ETH - exepectedVoterShareEthAmount, _ := big.NewInt(0).SetString("944580815709969788", 10) + expectedVoterShareEthAmount, _ := big.NewInt(0).SetString("966830312185297079", 10) // Multiply by i+1 since the number of validators scales with i+1 - exepectedVoterShareEthAmount.Mul(exepectedVoterShareEthAmount, big.NewInt(int64(validatorCount))) + expectedVoterShareEthAmount.Mul(expectedVoterShareEthAmount, big.NewInt(int64(validatorCount))) voterShareEthAmount := rewardsFile.GetNodeVoterShareEth(node.Address) - diff := new(big.Int).Sub(voterShareEthAmount, exepectedVoterShareEthAmount) + diff := new(big.Int).Sub(voterShareEthAmount, expectedVoterShareEthAmount) diff.Abs(diff) if diff.Cmp(big.NewInt(1)) > 0 { // allow off by one wei - t.Fatalf("Voter share ETH amount does not match expected value for node %s: %s != %s", node.Notes, voterShareEthAmount.String(), exepectedVoterShareEthAmount.String()) + t.Fatalf("Voter share ETH amount does not match expected value for node %s: %s != %s", node.Notes, voterShareEthAmount.String(), expectedVoterShareEthAmount.String()) } } @@ -638,12 +638,12 @@ func TestMockIntervalDefaultsTreegenv11(tt *testing.T) { } // Make sure it got voter share ETH - exepectedVoterShareEthAmount, _ := big.NewInt(0).SetString("944580815709969788", 10) + expectedVoterShareEthAmount, _ := big.NewInt(0).SetString("966830312185297079", 10) // Multiply by i+1 since the number of validators scales with i+1 - exepectedVoterShareEthAmount.Mul(exepectedVoterShareEthAmount, big.NewInt(int64(validatorCount))) + expectedVoterShareEthAmount.Mul(expectedVoterShareEthAmount, big.NewInt(int64(validatorCount))) voterShareEthAmount := rewardsFile.GetNodeVoterShareEth(node.Address) - if voterShareEthAmount.Cmp(exepectedVoterShareEthAmount) != 0 { - t.Fatalf("Voter share ETH amount does not match expected value for node %s: %s != %s", node.Notes, voterShareEthAmount.String(), exepectedVoterShareEthAmount.String()) + if voterShareEthAmount.Cmp(expectedVoterShareEthAmount) != 0 { + t.Fatalf("Voter share ETH amount does not match expected value for node %s: %s != %s", node.Notes, voterShareEthAmount.String(), expectedVoterShareEthAmount.String()) } } @@ -675,14 +675,14 @@ func TestMockIntervalDefaultsTreegenv11(tt *testing.T) { } // Make sure it got voter share ETH - exepectedVoterShareEthAmount, _ := big.NewInt(0).SetString("944580815709969788", 10) + expectedVoterShareEthAmount, _ := big.NewInt(0).SetString("966830312185297080", 10) // Multiply by i+1 since the number of validators scales with i+1 - exepectedVoterShareEthAmount.Mul(exepectedVoterShareEthAmount, big.NewInt(int64(validatorCount))) + expectedVoterShareEthAmount.Mul(expectedVoterShareEthAmount, big.NewInt(int64(validatorCount))) voterShareEthAmount := rewardsFile.GetNodeVoterShareEth(node.Address) - diff := new(big.Int).Sub(voterShareEthAmount, exepectedVoterShareEthAmount) + diff := new(big.Int).Sub(voterShareEthAmount, expectedVoterShareEthAmount) diff.Abs(diff) if diff.Cmp(big.NewInt(1)) > 0 { // allow off by one wei - t.Fatalf("Voter share ETH amount does not match expected value for node %s: %s != %s", node.Notes, voterShareEthAmount.String(), exepectedVoterShareEthAmount.String()) + t.Fatalf("Voter share ETH amount does not match expected value for node %s: %s != %s", node.Notes, voterShareEthAmount.String(), expectedVoterShareEthAmount.String()) } } @@ -699,7 +699,7 @@ func TestMockIntervalDefaultsTreegenv11(tt *testing.T) { } // Make sure it got ETH - expectedEthAmount, _ := big.NewInt(0).SetString("286064954682779456", 10) + expectedEthAmount, _ := big.NewInt(0).SetString("271231957032561262", 10) // Multiply by i+1 since the number of validators scales with i+1 expectedEthAmount.Mul(expectedEthAmount, big.NewInt(int64(validatorCount))) ethAmount := rewardsFile.GetNodeSmoothingPoolEth(node.Address) @@ -714,14 +714,14 @@ func TestMockIntervalDefaultsTreegenv11(tt *testing.T) { } // Make sure it got voter share ETH - exepectedVoterShareEthAmount, _ := big.NewInt(0).SetString("944580815709969788", 10) + expectedVoterShareEthAmount, _ := big.NewInt(0).SetString("966830312185297079", 10) // Multiply by i+1 since the number of validators scales with i+1 - exepectedVoterShareEthAmount.Mul(exepectedVoterShareEthAmount, big.NewInt(int64(validatorCount))) + expectedVoterShareEthAmount.Mul(expectedVoterShareEthAmount, big.NewInt(int64(validatorCount))) voterShareEthAmount := rewardsFile.GetNodeVoterShareEth(node.Address) - diff := new(big.Int).Sub(voterShareEthAmount, exepectedVoterShareEthAmount) + diff := new(big.Int).Sub(voterShareEthAmount, expectedVoterShareEthAmount) diff.Abs(diff) if diff.Cmp(big.NewInt(1)) > 0 { // allow off by one wei - t.Fatalf("Voter share ETH amount does not match expected value for node %s: %s != %s", node.Notes, voterShareEthAmount.String(), exepectedVoterShareEthAmount.String()) + t.Fatalf("Voter share ETH amount does not match expected value for node %s: %s != %s", node.Notes, voterShareEthAmount.String(), expectedVoterShareEthAmount.String()) } } @@ -738,7 +738,7 @@ func TestMockIntervalDefaultsTreegenv11(tt *testing.T) { } // Make sure it got ETH - expectedEthAmount, _ := big.NewInt(0).SetString("3252664484726418258", 10) + expectedEthAmount, _ := big.NewInt(0).SetString("3237831487076200064", 10) // Multiply by i+1 since the number of validators scales with i+1 expectedEthAmount.Mul(expectedEthAmount, big.NewInt(int64(validatorCount))) ethAmount := rewardsFile.GetNodeSmoothingPoolEth(node.Address) @@ -753,7 +753,7 @@ func TestMockIntervalDefaultsTreegenv11(tt *testing.T) { } // Make sure it got voter share ETH - exepectedVoterShareEthAmount, _ := big.NewInt(0).SetString("944580815709969788", 10) + exepectedVoterShareEthAmount, _ := big.NewInt(0).SetString("966830312185297079", 10) // Multiply by i+1 since the number of validators scales with i+1 exepectedVoterShareEthAmount.Mul(exepectedVoterShareEthAmount, big.NewInt(int64(validatorCount))) voterShareEthAmount := rewardsFile.GetNodeVoterShareEth(node.Address) @@ -779,7 +779,7 @@ func TestMockIntervalDefaultsTreegenv11(tt *testing.T) { // Make sure it got ETH minipoolEthAmount, _ := big.NewInt(0).SetString("2698353474320241690", 10) - expectedEthAmount, _ := big.NewInt(0).SetString("444444780127559583", 10) + expectedEthAmount, _ := big.NewInt(0).SetString("429611782477341389", 10) ethAmount := rewardsFile.GetNodeSmoothingPoolEth(node.Address) // Multiply by i+1 since the number of validators scales with i+1 expectedEthAmount.Mul(expectedEthAmount, big.NewInt(int64(validatorCount))) @@ -798,26 +798,26 @@ func TestMockIntervalDefaultsTreegenv11(tt *testing.T) { } // Make sure it got voter share ETH - exepectedVoterShareEthAmount, _ := big.NewInt(0).SetString("944580815709969789", 10) + expectedVoterShareEthAmount, _ := big.NewInt(0).SetString("966830312185297080", 10) // Multiply by i+1 since the number of validators scales with i+1 - exepectedVoterShareEthAmount.Mul(exepectedVoterShareEthAmount, big.NewInt(int64(validatorCount))) + expectedVoterShareEthAmount.Mul(expectedVoterShareEthAmount, big.NewInt(int64(validatorCount))) voterShareEthAmount := rewardsFile.GetNodeVoterShareEth(node.Address) - diff = new(big.Int).Sub(voterShareEthAmount, exepectedVoterShareEthAmount) + diff = new(big.Int).Sub(voterShareEthAmount, expectedVoterShareEthAmount) diff.Abs(diff) if diff.Cmp(big.NewInt(1)) > 0 { // allow off by one wei - t.Fatalf("Voter share ETH amount does not match expected value for node %s: %s != %s", node.Notes, voterShareEthAmount.String(), exepectedVoterShareEthAmount.String()) + t.Fatalf("Voter share ETH amount does not match expected value for node %s: %s != %s", node.Notes, voterShareEthAmount.String(), expectedVoterShareEthAmount.String()) } } // Validate merkle root v11MerkleRoot := v11Artifacts.RewardsFile.GetMerkleRoot() // Expected merkle root: - // 0x45c2300d804f26dd032623948da6696c27ba4c02d3a52c4b44b64c87d68a3ac7 + // 0x069f9bc9acc83fe4f809dac3c16534861a0324839293cc003324ce0dc5460cfc // // If this does not match, it implies either you updated the set of default mock nodes, // or you introduced a regression in treegen. // DO NOT update this value unless you know what you are doing. - expectedMerkleRoot := "0x45c2300d804f26dd032623948da6696c27ba4c02d3a52c4b44b64c87d68a3ac7" + expectedMerkleRoot := "0x069f9bc9acc83fe4f809dac3c16534861a0324839293cc003324ce0dc5460cfc" if !strings.EqualFold(v11MerkleRoot, expectedMerkleRoot) { t.Fatalf("Merkle root does not match expected value %s != %s", v11MerkleRoot, expectedMerkleRoot) } else {