Skip to content
Open
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
5 changes: 1 addition & 4 deletions bindings/utils/state/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ type NativeNodeDetails struct {
FeeDistributorInitialised bool `json:"fee_distributor_initialised"`
FeeDistributorAddress common.Address `json:"fee_distributor_address"`
RewardNetwork *big.Int `json:"reward_network"`
RplStake *big.Int `json:"rpl_stake"`
EffectiveRPLStake *big.Int `json:"effective_rpl_stake"`
MinimumRPLStake *big.Int `json:"minimum_rpl_stake"`
MaximumRPLStake *big.Int `json:"maximum_rpl_stake"`
Expand Down Expand Up @@ -355,7 +354,7 @@ func addNodeDetailsCalls(contracts *NetworkContracts, mc *multicall.MultiCaller,
mc.AddCall(contracts.RocketNodeDistributorFactory, &details.FeeDistributorAddress, "getProxyAddress", address)
mc.AddCall(contracts.RocketNodeManager, &details.RewardNetwork, "getRewardNetwork", address)
if !contracts.isSaturnDeployed() {
mc.AddCall(contracts.RocketNodeStaking, &details.RplStake, "getNodeRPLStake", address)
mc.AddCall(contracts.RocketNodeStaking, &details.LegacyStakedRPL, "getNodeRPLStake", address)
mc.AddCall(contracts.RocketNodeStaking, &details.EffectiveRPLStake, "getNodeEffectiveRPLStake", address)
mc.AddCall(contracts.RocketNodeStaking, &details.MinimumRPLStake, "getNodeMinimumRPLStake", address)
mc.AddCall(contracts.RocketNodeStaking, &details.MaximumRPLStake, "getNodeMaximumRPLStake", address)
Expand Down Expand Up @@ -391,8 +390,6 @@ func addNodeDetailsCalls(contracts *NetworkContracts, mc *multicall.MultiCaller,
mc.AddCall(contracts.RocketNodeStaking, &details.MegapoolEthBonded, "getNodeMegapoolETHBonded", address)
// the amount of a node operator's minipool bonded ETH
mc.AddCall(contracts.RocketNodeStaking, &details.MinipoolETHBonded, "getNodeMinipoolETHBonded", address)
// the total amount of RPL staked by a node operator (both legacy and megapool staked RPL)
mc.AddCall(contracts.RocketNodeStaking, &details.RplStake, "getNodeStakedRPL", address)
// the amount of megapool staked RPL for a node operator
mc.AddCall(contracts.RocketNodeStaking, &details.MegapoolStakedRPL, "getNodeMegapoolStakedRPL", address)
// the amount of legacy staked RPL for a node operator
Expand Down
10 changes: 5 additions & 5 deletions rocketpool/node/collectors/node-collector.go
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire file needs someone to rethink what it should emit in saturn

Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) {

// Sync
var wg errgroup.Group
stakedRpl := eth.WeiToEth(nd.RplStake)
stakedRpl := eth.WeiToEth(nd.LegacyStakedRPL) // TODO: update all metrics to account for saturn
effectiveStakedRpl := eth.WeiToEth(nd.EffectiveRPLStake)
rewardsInterval := state.NetworkDetails.IntervalDuration
inflationInterval := state.NetworkDetails.RPLInflationIntervalRate
Expand All @@ -280,7 +280,7 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) {
oldRplBalance := eth.WeiToEth(nd.BalanceOldRPL)
newRplBalance := eth.WeiToEth(nd.BalanceRPL)
rethBalance := eth.WeiToEth(nd.BalanceRETH)
eligibleBorrowedEth := state.GetEligibleBorrowedEth(nd)
eligibleBorrowedEth := state.GetMinipoolEligibleBorrowedEth(nd)
var activeMinipoolCount float64
rplPriceRaw := state.NetworkDetails.RplPrice
rplPrice := eth.WeiToEth(rplPriceRaw)
Expand Down Expand Up @@ -443,8 +443,8 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) {

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

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

// Calculate the actual "rewardable" amount
rewardableRplStake := big.NewInt(0).Set(nd.RplStake)
rewardableRplStake := big.NewInt(0).Set(nd.LegacyStakedRPL)
if rewardableRplStake.Cmp(rewardableMinimumStake) < 0 {
rewardableRplStake.SetUint64(0)
} else if rewardableRplStake.Cmp(rewardableMaximumStake) > 0 {
Expand Down
16 changes: 7 additions & 9 deletions shared/services/rewards/generator-impl-v11.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,7 @@ func (r *treeGeneratorImpl_v11) calculateEthRewards(checkBeaconPerformance bool)
for _, nodeInfo := range r.nodeDetails {
// Check if the node is currently opted in for simplicity
if nodeInfo.IsEligible && nodeInfo.IsOptedIn && r.elEndTime.After(nodeInfo.OptInTime) {
eligibleBorrowedEth := nodeInfo.EligibleBorrowedEth
_, percentOfBorrowedEth := r.networkState.GetStakedRplValueInEthAndPercentOfBorrowedEth(eligibleBorrowedEth, nodeInfo.RplStake)
_, percentOfBorrowedEth := r.networkState.GetStakedRplValueInEthAndPercentOfBorrowedEth(nodeInfo.MinipoolEligibleBorrowedEth, nodeInfo.LegacyStakedRpl)
for _, minipool := range nodeInfo.Minipools {
minipool.CompletedAttestations = map[uint64]bool{0: true}

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

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

eligibleBorrowedEth := nodeDetails.EligibleBorrowedEth
_, percentOfBorrowedEth := r.networkState.GetStakedRplValueInEthAndPercentOfBorrowedEth(eligibleBorrowedEth, nodeDetails.RplStake)

// Mark this duty as completed
positionInfo.MarkAttestationCompleted(attestation.SlotIndex)

if positionInfo.MinipoolInfo != nil {
_, percentOfBorrowedEth := r.networkState.GetStakedRplValueInEthAndPercentOfBorrowedEth(nodeDetails.MinipoolEligibleBorrowedEth, nodeDetails.LegacyStakedRpl)

validator := positionInfo.MinipoolInfo

// Get the pseudoscore for this attestation
Expand Down Expand Up @@ -1572,7 +1569,8 @@ func (r *treeGeneratorImpl_v11) getSmoothingPoolNodeDetails() error {
SmoothingPoolEth: big.NewInt(0),
BonusEth: big.NewInt(0),
RewardsNetwork: nativeNodeDetails.RewardNetwork.Uint64(),
RplStake: nativeNodeDetails.RplStake,
LegacyStakedRpl: nativeNodeDetails.LegacyStakedRPL,
MegapoolStakedRpl: nativeNodeDetails.MegapoolStakedRPL,
MegapoolVoteEligibleRpl: big.NewInt(0),
VoterShareEth: big.NewInt(0),
}
Expand Down Expand Up @@ -1693,7 +1691,7 @@ func (r *treeGeneratorImpl_v11) getSmoothingPoolNodeDetails() error {
// Populate the eligible borrowed ETH field for all nodes
for _, nodeDetails := range r.nodeDetails {
nnd := r.networkState.NodeDetailsByAddress[nodeDetails.Address]
nodeDetails.EligibleBorrowedEth = r.networkState.GetEligibleBorrowedEth(nnd)
nodeDetails.MinipoolEligibleBorrowedEth = r.networkState.GetMinipoolEligibleBorrowedEth(nnd)
}

return nil
Expand Down
Loading
Loading