Skip to content

Commit e7e4cd3

Browse files
authored
Merge pull request #982 from jshufro/jms/v11-updates
Delete v8, fix v9-10 and v11
2 parents 465b66e + 680736a commit e7e4cd3

File tree

14 files changed

+94
-1818
lines changed

14 files changed

+94
-1818
lines changed

bindings/utils/state/node.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ type NativeNodeDetails struct {
2929
FeeDistributorInitialised bool `json:"fee_distributor_initialised"`
3030
FeeDistributorAddress common.Address `json:"fee_distributor_address"`
3131
RewardNetwork *big.Int `json:"reward_network"`
32-
RplStake *big.Int `json:"rpl_stake"`
3332
EffectiveRPLStake *big.Int `json:"effective_rpl_stake"`
3433
MinimumRPLStake *big.Int `json:"minimum_rpl_stake"`
3534
MaximumRPLStake *big.Int `json:"maximum_rpl_stake"`
@@ -355,7 +354,7 @@ func addNodeDetailsCalls(contracts *NetworkContracts, mc *multicall.MultiCaller,
355354
mc.AddCall(contracts.RocketNodeDistributorFactory, &details.FeeDistributorAddress, "getProxyAddress", address)
356355
mc.AddCall(contracts.RocketNodeManager, &details.RewardNetwork, "getRewardNetwork", address)
357356
if !contracts.isSaturnDeployed() {
358-
mc.AddCall(contracts.RocketNodeStaking, &details.RplStake, "getNodeRPLStake", address)
357+
mc.AddCall(contracts.RocketNodeStaking, &details.LegacyStakedRPL, "getNodeRPLStake", address)
359358
mc.AddCall(contracts.RocketNodeStaking, &details.EffectiveRPLStake, "getNodeEffectiveRPLStake", address)
360359
mc.AddCall(contracts.RocketNodeStaking, &details.MinimumRPLStake, "getNodeMinimumRPLStake", address)
361360
mc.AddCall(contracts.RocketNodeStaking, &details.MaximumRPLStake, "getNodeMaximumRPLStake", address)
@@ -391,8 +390,6 @@ func addNodeDetailsCalls(contracts *NetworkContracts, mc *multicall.MultiCaller,
391390
mc.AddCall(contracts.RocketNodeStaking, &details.MegapoolEthBonded, "getNodeMegapoolETHBonded", address)
392391
// the amount of a node operator's minipool bonded ETH
393392
mc.AddCall(contracts.RocketNodeStaking, &details.MinipoolETHBonded, "getNodeMinipoolETHBonded", address)
394-
// the total amount of RPL staked by a node operator (both legacy and megapool staked RPL)
395-
mc.AddCall(contracts.RocketNodeStaking, &details.RplStake, "getNodeStakedRPL", address)
396393
// the amount of megapool staked RPL for a node operator
397394
mc.AddCall(contracts.RocketNodeStaking, &details.MegapoolStakedRPL, "getNodeMegapoolStakedRPL", address)
398395
// the amount of legacy staked RPL for a node operator

rocketpool/node/collectors/node-collector.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) {
269269

270270
// Sync
271271
var wg errgroup.Group
272-
stakedRpl := eth.WeiToEth(nd.RplStake)
272+
stakedRpl := eth.WeiToEth(nd.LegacyStakedRPL) // TODO: update all metrics to account for saturn
273273
effectiveStakedRpl := eth.WeiToEth(nd.EffectiveRPLStake)
274274
rewardsInterval := state.NetworkDetails.IntervalDuration
275275
inflationInterval := state.NetworkDetails.RPLInflationIntervalRate
@@ -280,7 +280,7 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) {
280280
oldRplBalance := eth.WeiToEth(nd.BalanceOldRPL)
281281
newRplBalance := eth.WeiToEth(nd.BalanceRPL)
282282
rethBalance := eth.WeiToEth(nd.BalanceRETH)
283-
eligibleBorrowedEth := state.GetEligibleBorrowedEth(nd)
283+
eligibleBorrowedEth := state.GetMinipoolEligibleBorrowedEth(nd)
284284
var activeMinipoolCount float64
285285
rplPriceRaw := state.NetworkDetails.RplPrice
286286
rplPrice := eth.WeiToEth(rplPriceRaw)
@@ -443,8 +443,8 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) {
443443

444444
nodeWeight := big.NewInt(0)
445445
// The node must satisfy collateral requirements and have eligible ETH from which to earn rewards.
446-
if nd.RplStake.Cmp(minCollateral) != -1 && eligibleBorrowedEth.Sign() > 0 {
447-
nodeWeight = state.GetNodeWeight(eligibleBorrowedEth, nd.RplStake)
446+
if nd.LegacyStakedRPL.Cmp(minCollateral) != -1 && eligibleBorrowedEth.Sign() > 0 {
447+
nodeWeight = state.GetNodeWeight(eligibleBorrowedEth, nd.LegacyStakedRPL)
448448
}
449449

450450
// Calculate the rewardable RPL
@@ -510,7 +510,7 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) {
510510
rewardableMaximumStake.Div(rewardableMaximumStake, rplPriceRaw)
511511

512512
// Calculate the actual "rewardable" amount
513-
rewardableRplStake := big.NewInt(0).Set(nd.RplStake)
513+
rewardableRplStake := big.NewInt(0).Set(nd.LegacyStakedRPL)
514514
if rewardableRplStake.Cmp(rewardableMinimumStake) < 0 {
515515
rewardableRplStake.SetUint64(0)
516516
} else if rewardableRplStake.Cmp(rewardableMaximumStake) > 0 {

shared/services/rewards/generator-impl-v11.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,7 @@ func (r *treeGeneratorImpl_v11) calculateEthRewards(checkBeaconPerformance bool)
549549
for _, nodeInfo := range r.nodeDetails {
550550
// Check if the node is currently opted in for simplicity
551551
if nodeInfo.IsEligible && nodeInfo.IsOptedIn && r.elEndTime.After(nodeInfo.OptInTime) {
552-
eligibleBorrowedEth := nodeInfo.EligibleBorrowedEth
553-
_, percentOfBorrowedEth := r.networkState.GetStakedRplValueInEthAndPercentOfBorrowedEth(eligibleBorrowedEth, nodeInfo.RplStake)
552+
_, percentOfBorrowedEth := r.networkState.GetStakedRplValueInEthAndPercentOfBorrowedEth(nodeInfo.MinipoolEligibleBorrowedEth, nodeInfo.LegacyStakedRpl)
554553
for _, minipool := range nodeInfo.Minipools {
555554
minipool.CompletedAttestations = map[uint64]bool{0: true}
556555

@@ -789,8 +788,7 @@ func (r *treeGeneratorImpl_v11) calculateNodeBonuses() (*big.Int, error) {
789788
}
790789

791790
// Get the nodeDetails from the network state
792-
eligibleBorrowedEth := nsd.EligibleBorrowedEth
793-
_, percentOfBorrowedEth := r.networkState.GetStakedRplValueInEthAndPercentOfBorrowedEth(eligibleBorrowedEth, nsd.RplStake)
791+
_, percentOfBorrowedEth := r.networkState.GetStakedRplValueInEthAndPercentOfBorrowedEth(nsd.MinipoolEligibleBorrowedEth, nsd.LegacyStakedRpl)
794792
for _, mpd := range nsd.Minipools {
795793
mpi := r.networkState.MinipoolDetailsByAddress[mpd.Address]
796794
if !mpi.IsEligibleForBonuses(eligibleEnd) {
@@ -1250,13 +1248,12 @@ func (r *treeGeneratorImpl_v11) checkAttestations(attestations []beacon.Attestat
12501248
continue
12511249
}
12521250

1253-
eligibleBorrowedEth := nodeDetails.EligibleBorrowedEth
1254-
_, percentOfBorrowedEth := r.networkState.GetStakedRplValueInEthAndPercentOfBorrowedEth(eligibleBorrowedEth, nodeDetails.RplStake)
1255-
12561251
// Mark this duty as completed
12571252
positionInfo.MarkAttestationCompleted(attestation.SlotIndex)
12581253

12591254
if positionInfo.MinipoolInfo != nil {
1255+
_, percentOfBorrowedEth := r.networkState.GetStakedRplValueInEthAndPercentOfBorrowedEth(nodeDetails.MinipoolEligibleBorrowedEth, nodeDetails.LegacyStakedRpl)
1256+
12601257
validator := positionInfo.MinipoolInfo
12611258

12621259
// Get the pseudoscore for this attestation
@@ -1572,7 +1569,8 @@ func (r *treeGeneratorImpl_v11) getSmoothingPoolNodeDetails() error {
15721569
SmoothingPoolEth: big.NewInt(0),
15731570
BonusEth: big.NewInt(0),
15741571
RewardsNetwork: nativeNodeDetails.RewardNetwork.Uint64(),
1575-
RplStake: nativeNodeDetails.RplStake,
1572+
LegacyStakedRpl: nativeNodeDetails.LegacyStakedRPL,
1573+
MegapoolStakedRpl: nativeNodeDetails.MegapoolStakedRPL,
15761574
MegapoolVoteEligibleRpl: big.NewInt(0),
15771575
VoterShareEth: big.NewInt(0),
15781576
}
@@ -1693,7 +1691,7 @@ func (r *treeGeneratorImpl_v11) getSmoothingPoolNodeDetails() error {
16931691
// Populate the eligible borrowed ETH field for all nodes
16941692
for _, nodeDetails := range r.nodeDetails {
16951693
nnd := r.networkState.NodeDetailsByAddress[nodeDetails.Address]
1696-
nodeDetails.EligibleBorrowedEth = r.networkState.GetEligibleBorrowedEth(nnd)
1694+
nodeDetails.MinipoolEligibleBorrowedEth = r.networkState.GetMinipoolEligibleBorrowedEth(nnd)
16971695
}
16981696

16991697
return nil

0 commit comments

Comments
 (0)