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
1 change: 0 additions & 1 deletion bindings/settings/protocol/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions bindings/settings/security/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion rocketpool-cli/security/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
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 @@ -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
Expand Down
4 changes: 2 additions & 2 deletions rocketpool/api/security/propose-settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
32 changes: 12 additions & 20 deletions shared/services/rewards/generator-impl-v11.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)

Expand Down
58 changes: 29 additions & 29 deletions shared/services/rewards/mock_v11_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
}
}

Expand Down Expand Up @@ -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())
}
}

Expand Down Expand Up @@ -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())
}
}

Expand All @@ -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)
Expand All @@ -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())
}
}

Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)))
Expand All @@ -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 {
Expand Down
Loading