+-- 22 lines: package rewards---------------------------------------------------------------------------------------------------------------------
"github.com/rocket-pool/smartnode/v2/shared/config"
"github.com/rocket-pool/smartnode/v2/shared/keys"
sharedtypes "github.com/rocket-pool/smartnode/v2/shared/types"
"golang.org/x/sync/errgroup"
)
var six = big.NewInt(6)
type treeGeneratorImpl_v8 struct {
networkState *state.NetworkState
rewardsFile *RewardsFile_v3
elSnapshotHeader *types.Header
logger *slog.Logger
rp *rocketpool.RocketPool
cfg *config.SmartNodeConfig
+-- 14 lines: bc beacon.IBeaconClient-----------------------------------------------------------------------------------------
totalAttestationScore *big.Int
successfulAttestations uint64
genesisTime time.Time
}
func newTreeGeneratorImpl_v8(logger *slog.Logger, index uint64, startTime time.Time, endTime time.Time, consensusBlock uint64, elSnapshotHeader *types.Header, intervalsPassed uint64, state *state.NetworkState) *treeGeneratorImpl_v8 {
return &treeGeneratorImpl_v8{
rewardsFile: &RewardsFile_v3{
RewardsFileHeader: &sharedtypes.RewardsFileHeader{
RewardsFileVersion: 3,
RulesetVersion: 8,
Index: index,
StartTime: startTime.UTC(),
EndTime: endTime.UTC(),
ConsensusEndBlock: consensusBlock,
ExecutionEndBlock: elSnapshotHeader.Number.Uint64(),
IntervalsPassed: intervalsPassed,
+-- 25 lines: InvalidNetworkNodes: map[common.Address]uint64{},-----------------------------------------------------------------------------------
totalAttestationScore: big.NewInt(0),
networkState: state,
}
}
func (r *treeGeneratorImpl_v8) getRulesetVersion() uint64 {
return r.rewardsFile.RulesetVersion
}
func (r *treeGeneratorImpl_v8) generateTree(context context.Context, rp *rocketpool.RocketPool, cfg *config.SmartNodeConfig, bc beacon.IBeaconClient) (sharedtypes.IRewardsFile, error) {
r.logger.Info("Started rewards tree generation.", slog.Uint64(keys.RulesetKey, r.rewardsFile.RulesetVersion))
r.rp = rp
r.cfg = cfg
r.bc = bc
+-- 58 lines: r.validNetworkCache = map[uint64]bool{----------------------------------------------------------------------------------------------
return r.rewardsFile, nil
}
func (r *treeGeneratorImpl_v8) approximateStakerShareOfSmoothingPool(context context.Context, rp *rocketpool.RocketPool, cfg *config.SmartNodeConfig, bc beacon.IBeaconClient) (*big.Int, error) {
r.logger.Info("Approximating rewards tree.", slog.Uint64(keys.RulesetKey, r.rewardsFile.RulesetVersion))
r.rp = rp
r.cfg = cfg
r.bc = bc
r.validNetworkCache = map[uint64]bool{
+-- 34 lines: 0: true,----------------------------------------------------------------------------------------------------------------------------
}
return &r.rewardsFile.TotalRewards.PoolStakerSmoothingPoolEth.Int, nil
}
func (r *treeGeneratorImpl_v8) updateNetworksAndTotals() {
highestNetworkIndex := uint64(0)
for network := range r.rewardsFile.NetworkRewards {
if network > highestNetworkIndex {
highestNetworkIndex = network
}
+-- 10 lines: }-----------------------------------------------------------------------------------------------------------------------------------
}
r.rewardsFile.NetworkRewards[network] = rewardsForNetwork
}
}
}
func (r *treeGeneratorImpl_v8) calculateNodeRplRewards(
collateralRewards *big.Int,
nodeEffectiveStake *big.Int,
totalEffectiveRplStake *big.Int,
nodeWeight *big.Int,
totalNodeWeight *big.Int,
) *big.Int {
+-- 36 lines: if nodeEffectiveStake.Sign() <= 0 || nodeWeight.Sign() <= 0 {-----------------------------------------------------------------------
return rpip30Rewards.Add(rpip30Rewards, oldRewards)
}
func (r *treeGeneratorImpl_v8) calculateRplRewards() error {
pendingRewards := r.networkState.NetworkDetails.PendingRPLRewards
r.logger.Info("Calculated Pending RPL rewards", slog.String(keys.AmountKey, getRewardsString(pendingRewards)))
if pendingRewards.Cmp(common.Big0) == 0 {
return fmt.Errorf("there are no pending RPL rewards, so this interval cannot be used for rewards submission")
}
+-- 43 lines: Get baseline Protocol DAO rewards---------------------------------------------------------------------------------------------------
totalNodeEffectiveStake,
nodeWeights[nodeDetails.NodeAddress],
totalNodeWeight,
)
--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
if nodeRplRewards.Sign() == 1 {
rewardsForClaimer, exists := r.rewardsFile.ClaimerRewards[nodeDetails.NodeAddress]
if !exists {
network := r.networkState.NodeDetails[i].RewardNetwork.Uint64()
validNetwork, err := r.validateNetwork(network)
if err != nil {
return err
+-- 6 lines: }-----------------------------------------------------------------------------------------------------------------------------------
rewardsForClaimer = &ClaimerRewardsInfo_v3{
RewardNetwork: network,
CollateralRpl: sharedtypes.NewQuotedBigInt(0),
OracleDaoRpl: sharedtypes.NewQuotedBigInt(0),
SmoothingPoolEth: sharedtypes.NewQuotedBigInt(0),
}
r.rewardsFile.ClaimerRewards[nodeDetails.NodeAddress] = rewardsForClaimer
}
rewardsForClaimer.CollateralRpl.Add(&rewardsForClaimer.CollateralRpl.Int, nodeRplRewards)
rewardsForNetwork, exists := r.rewardsFile.NetworkRewards[rewardsForClaimer.RewardNetwork]
if !exists {
+-- 63 lines: rewardsForNetwork = &sharedtypes.NetworkRewardsInfo{--------------------------------------------------------------------------------
individualOdaoRewards := big.NewInt(0)
individualOdaoRewards.Mul(trueODaoNodeTimes[address], totalODaoRewards)
individualOdaoRewards.Div(individualOdaoRewards, totalODaoNodeTime)
rewardsForClaimer, exists := r.rewardsFile.ClaimerRewards[address]
--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
if !exists {
network := r.networkState.NodeDetailsByAddress[address].RewardNetwork.Uint64()
validNetwork, err := r.validateNetwork(network)
if err != nil {
return err
+-- 6 lines: }-----------------------------------------------------------------------------------------------------------------------------------
rewardsForClaimer = &ClaimerRewardsInfo_v3{
RewardNetwork: network,
CollateralRpl: sharedtypes.NewQuotedBigInt(0),
OracleDaoRpl: sharedtypes.NewQuotedBigInt(0),
SmoothingPoolEth: sharedtypes.NewQuotedBigInt(0),
}
r.rewardsFile.ClaimerRewards[address] = rewardsForClaimer
}
rewardsForClaimer.OracleDaoRpl.Add(&rewardsForClaimer.OracleDaoRpl.Int, individualOdaoRewards)
rewardsForNetwork, exists := r.rewardsFile.NetworkRewards[rewardsForClaimer.RewardNetwork]
+-- 30 lines: if !exists {------------------------------------------------------------------------------------------------------------------------
r.logger.Info("Calculated total node weight,", slog.String(keys.TotalNodeWeightKey, totalNodeWeight.String()))
return nil
}
func (r *treeGeneratorImpl_v8) calculateEthRewards(context context.Context, checkBeaconPerformance bool) error {
r.smoothingPoolBalance = r.networkState.NetworkDetails.SmoothingPoolBalance
r.logger.Info("Retrieved Smoothing Pool balance", slog.String(keys.AmountKey, getRewardsString(r.smoothingPoolBalance)))
if r.smoothingPoolBalance.Cmp(common.Big0) == 0 {
+-- 79 lines: return nil--------------------------------------------------------------------------------------------------------------------------
return err
}
for _, nodeInfo := range r.nodeDetails {
if nodeInfo.IsEligible && nodeInfo.SmoothingPoolEth.Cmp(common.Big0) > 0 {
rewardsForClaimer, exists := r.rewardsFile.ClaimerRewards[nodeInfo.Address]
--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
if !exists {
network := nodeInfo.RewardsNetwork
validNetwork, err := r.validateNetwork(network)
if err != nil {
return err
}
+-- 5 lines: if !validNetwork {------------------------------------------------------------------------------------------------------------------
rewardsForClaimer = &ClaimerRewardsInfo_v3{
RewardNetwork: network,
CollateralRpl: sharedtypes.NewQuotedBigInt(0),
OracleDaoRpl: sharedtypes.NewQuotedBigInt(0),
SmoothingPoolEth: sharedtypes.NewQuotedBigInt(0),
}
r.rewardsFile.ClaimerRewards[nodeInfo.Address] = rewardsForClaimer
}
rewardsForClaimer.SmoothingPoolEth.Add(&rewardsForClaimer.SmoothingPoolEth.Int, nodeInfo.SmoothingPoolEth)
for _, minipoolInfo := range nodeInfo.Minipools {
successfulAttestations := uint64(len(minipoolInfo.CompletedAttestations))
+-- 35 lines: missingAttestations := uint64(len(minipoolInfo.MissingAttestationSlots))------------------------------------------------------------
r.rewardsFile.TotalRewards.NodeOperatorSmoothingPoolEth.Int = *nodeOpEth
r.rewardsFile.TotalRewards.TotalSmoothingPoolEth.Int = *r.smoothingPoolBalance
return nil
}
func (r *treeGeneratorImpl_v8) calculateNodeRewards() (*big.Int, *big.Int, error) {
if r.totalAttestationScore.Cmp(common.Big0) == 0 || r.successfulAttestations == 0 {
r.logger.Warn("Sending the whole smoothing pool balance to the pool stakers.", slog.String(keys.TotalScoreKey, r.totalAttestationScore.String()), slog.Uint64(keys.SuccessfulAttestationsKey, r.successfulAttestations))
return r.smoothingPoolBalance, big.NewInt(0), nil
}
+-- 43 lines: totalEthForMinipools := big.NewInt(0)-----------------------------------------------------------------------------------------------
r.logger.Info("Adjusted Pool Staker ETH to account for truncation", slog.String(keys.AmountKey, truePoolStakerAmount.String()))
return truePoolStakerAmount, totalEthForMinipools, nil
}
func (r *treeGeneratorImpl_v8) processAttestationsForInterval(context context.Context) error {
startEpoch := r.rewardsFile.ConsensusStartBlock / r.beaconConfig.SlotsPerEpoch
endEpoch := r.rewardsFile.ConsensusEndBlock / r.beaconConfig.SlotsPerEpoch
err := r.createMinipoolIndexMap()
if err != nil {
+-- 30 lines: return err--------------------------------------------------------------------------------------------------------------------------
r.logger.Info("Finished participation check", slog.Duration(keys.TotalElapsedKey, time.Since(reportStartTime)))
return nil
}
func (r *treeGeneratorImpl_v8) processEpoch(context context.Context, getDuties bool, epoch uint64) error {
var committeeData beacon.Committees
attestationsPerSlot := make([][]beacon.AttestationInfo, r.slotsPerEpoch)
var wg errgroup.Group
+-- 45 lines: if getDuties {----------------------------------------------------------------------------------------------------------------------
return nil
}
func (r *treeGeneratorImpl_v8) checkDutiesForSlot(attestations []beacon.AttestationInfo, slot uint64) error {
one := eth.EthToWei(1)
validatorReq := eth.EthToWei(32)
for _, attestation := range attestations {
+-- 51 lines: Get the RP committees for this attestation's slot and index-------------------------------------------------------------------------
return nil
}
func (r *treeGeneratorImpl_v8) getDutiesForEpoch(committees beacon.Committees) error {
for idx := 0; idx < committees.Count(); idx++ {
slotIndex := committees.Slot(idx)
if slotIndex < r.rewardsFile.ConsensusStartBlock || slotIndex > r.rewardsFile.ConsensusEndBlock {
+-- 51 lines: continue----------------------------------------------------------------------------------------------------------------------------
return nil
}
func (r *treeGeneratorImpl_v8) createMinipoolIndexMap() error {
r.validatorIndexMap = map[string]*MinipoolInfo{}
for _, details := range r.nodeDetails {
if details.IsEligible {
for _, minipoolInfo := range details.Minipools {
+-- 41 lines: status, exists := r.networkState.ValidatorDetails[minipoolInfo.ValidatorPubkey]-----------------------------------------------------
return nil
}
func (r *treeGeneratorImpl_v8) getSmoothingPoolNodeDetails() error {
farFutureTime := time.Unix(1000000000000000000, 0)
farPastTime := time.Unix(0, 0)
r.logger.Info("Getting details of nodes for Smoothing Pool calculation...")
+-- 75 lines: nodeCount := uint64(len(r.networkState.NodeDetails))--------------------------------------------------------------------------------
return nil
}
func (r *treeGeneratorImpl_v8) validateNetwork(network uint64) (bool, error) {
valid, exists := r.validNetworkCache[network]
if !exists {
oMgr, err := oracle.NewOracleDaoManager(r.rp)
if err != nil {
return false, fmt.Errorf("error creating oDAO manager binding: %w", err)
+-- 12 lines: }-----------------------------------------------------------------------------------------------------------------------------------
}
return valid, nil
}
func (r *treeGeneratorImpl_v8) getStartBlocksForInterval(context context.Context, previousIntervalEvent rewards.RewardsEvent) (*types.Header, error) {
_, exists, err := r.bc.GetBeaconBlock(context, previousIntervalEvent.ConsensusBlock.String())
if err != nil {
return nil, fmt.Errorf("error verifying block from previous interval: %w", err)
}
if !exists {
+-- 41 lines: return nil, fmt.Errorf("couldn't retrieve CL block from previous interval (slot %d); this likely means you checkpoint sync'd your Beacon Node and it has not backfilled to the previous interval yet so it cannot be used for tree generation", previousIntervalEvent.ConsensusBlock.Uint64())
}
return startElHeader, nil
}
func (r *treeGeneratorImpl_v8) getMinipoolBondAndNodeFee(details *rpstate.NativeMinipoolDetails, blockTime time.Time) (*big.Int, *big.Int) {
currentBond := details.NodeDepositBalance
currentFee := details.NodeFee
previousBond := details.LastBondReductionPrevValue
previousFee := details.LastBondReductionPrevNodeFee
var reductionTimeBig *big.Int = details.LastBondReductionTime
+-- 17 lines: if reductionTimeBig.Cmp(common.Big0) == 0 {-----------------------------------------------------------------------------------------
|
+-- 22 lines: package rewards---------------------------------------------------------------------------------------------------------------------
"github.com/rocket-pool/smartnode/v2/shared/config"
"github.com/rocket-pool/smartnode/v2/shared/keys"
sharedtypes "github.com/rocket-pool/smartnode/v2/shared/types"
"golang.org/x/sync/errgroup"
)
type treeGeneratorImpl_v10 struct {
--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
networkState *state.NetworkState
rewardsFile *RewardsFile_v3
elSnapshotHeader *types.Header
logger *slog.Logger
rp *rocketpool.RocketPool
cfg *config.SmartNodeConfig
+-- 14 lines: bc beacon.IBeaconClient-----------------------------------------------------------------------------------------
totalAttestationScore *big.Int
successfulAttestations uint64
genesisTime time.Time
}
func newTreeGeneratorImpl_v10(logger *slog.Logger, index uint64, startTime time.Time, endTime time.Time, consensusBlock uint64, elSnapshotHeader *types.Header, intervalsPassed uint64, state *state.NetworkState) *treeGeneratorImpl_v10 {
return &treeGeneratorImpl_v10{
rewardsFile: &RewardsFile_v3{
RewardsFileHeader: &sharedtypes.RewardsFileHeader{
RewardsFileVersion: 3,
RulesetVersion: 10,
Index: index,
StartTime: startTime.UTC(),
EndTime: endTime.UTC(),
ConsensusEndBlock: consensusBlock,
ExecutionEndBlock: elSnapshotHeader.Number.Uint64(),
IntervalsPassed: intervalsPassed,
+-- 25 lines: InvalidNetworkNodes: map[common.Address]uint64{},-----------------------------------------------------------------------------------
totalAttestationScore: big.NewInt(0),
networkState: state,
}
}
func (r *treeGeneratorImpl_v10) getRulesetVersion() uint64 {
return r.rewardsFile.RulesetVersion
}
func (r *treeGeneratorImpl_v10) generateTree(context context.Context, rp *rocketpool.RocketPool, cfg *config.SmartNodeConfig, bc beacon.IBeaconClient) (sharedtypes.IRewardsFile, error) {
r.logger.Info("Started rewards tree generation.", slog.Uint64(keys.RulesetKey, r.rewardsFile.RulesetVersion))
r.rp = rp
r.cfg = cfg
r.bc = bc
+-- 58 lines: r.validNetworkCache = map[uint64]bool{----------------------------------------------------------------------------------------------
return r.rewardsFile, nil
}
func (r *treeGeneratorImpl_v10) approximateStakerShareOfSmoothingPool(context context.Context, rp *rocketpool.RocketPool, cfg *config.SmartNodeConfig, bc beacon.IBeaconClient) (*big.Int, error) {
r.logger.Info("Approximating rewards tree.", slog.Uint64(keys.RulesetKey, r.rewardsFile.RulesetVersion))
r.rp = rp
r.cfg = cfg
r.bc = bc
r.validNetworkCache = map[uint64]bool{
+-- 34 lines: 0: true,----------------------------------------------------------------------------------------------------------------------------
}
return &r.rewardsFile.TotalRewards.PoolStakerSmoothingPoolEth.Int, nil
}
func (r *treeGeneratorImpl_v10) updateNetworksAndTotals() {
highestNetworkIndex := uint64(0)
for network := range r.rewardsFile.NetworkRewards {
if network > highestNetworkIndex {
highestNetworkIndex = network
}
+-- 10 lines: }-----------------------------------------------------------------------------------------------------------------------------------
}
r.rewardsFile.NetworkRewards[network] = rewardsForNetwork
}
}
}
func (r *treeGeneratorImpl_v10) calculateNodeRplRewards(
collateralRewards *big.Int,
nodeEffectiveStake *big.Int,
totalEffectiveRplStake *big.Int,
nodeWeight *big.Int,
totalNodeWeight *big.Int,
) *big.Int {
+-- 36 lines: if nodeEffectiveStake.Sign() <= 0 || nodeWeight.Sign() <= 0 {-----------------------------------------------------------------------
return rpip30Rewards.Add(rpip30Rewards, oldRewards)
}
func (r *treeGeneratorImpl_v10) calculateRplRewards() error {
pendingRewards := r.networkState.NetworkDetails.PendingRPLRewards
r.logger.Info("Calculated Pending RPL rewards", slog.String(keys.AmountKey, getRewardsString(pendingRewards)))
if pendingRewards.Cmp(common.Big0) == 0 {
return fmt.Errorf("there are no pending RPL rewards, so this interval cannot be used for rewards submission")
}
+-- 43 lines: Get baseline Protocol DAO rewards---------------------------------------------------------------------------------------------------
totalNodeEffectiveStake,
nodeWeights[nodeDetails.NodeAddress],
totalNodeWeight,
)
claimer := nodeDetails.NodeAddress
if nodeDetails.IsRplWithdrawalAddressSet && nodeDetails.PrimaryWithdrawalAddress != nodeDetails.NodeAddress {
claimer = nodeDetails.RplWithdrawalAddress
}
if nodeRplRewards.Sign() == 1 {
rewardsForClaimer, exists := r.rewardsFile.ClaimerRewards[claimer]
if !exists {
network := r.networkState.NodeDetails[i].RewardNetwork.Uint64()
validNetwork, err := r.validateNetwork(network)
if err != nil {
return err
+-- 6 lines: }-----------------------------------------------------------------------------------------------------------------------------------
rewardsForClaimer = &ClaimerRewardsInfo_v3{
RewardNetwork: network,
CollateralRpl: sharedtypes.NewQuotedBigInt(0),
OracleDaoRpl: sharedtypes.NewQuotedBigInt(0),
SmoothingPoolEth: sharedtypes.NewQuotedBigInt(0),
}
r.rewardsFile.ClaimerRewards[claimer] = rewardsForClaimer
}
rewardsForClaimer.CollateralRpl.Add(&rewardsForClaimer.CollateralRpl.Int, nodeRplRewards)
rewardsForNetwork, exists := r.rewardsFile.NetworkRewards[rewardsForClaimer.RewardNetwork]
if !exists {
+-- 63 lines: rewardsForNetwork = &sharedtypes.NetworkRewardsInfo{--------------------------------------------------------------------------------
individualOdaoRewards := big.NewInt(0)
individualOdaoRewards.Mul(trueODaoNodeTimes[address], totalODaoRewards)
individualOdaoRewards.Div(individualOdaoRewards, totalODaoNodeTime)
claimer := address
node := r.networkState.NodeDetailsByAddress[address]
if node.IsRplWithdrawalAddressSet && node.PrimaryWithdrawalAddress != node.NodeAddress {
claimer = node.RplWithdrawalAddress
}
rewardsForClaimer, exists := r.rewardsFile.ClaimerRewards[claimer]
if !exists {
network := r.networkState.NodeDetailsByAddress[address].RewardNetwork.Uint64()
validNetwork, err := r.validateNetwork(network)
if err != nil {
return err
+-- 6 lines: }-----------------------------------------------------------------------------------------------------------------------------------
rewardsForClaimer = &ClaimerRewardsInfo_v3{
RewardNetwork: network,
CollateralRpl: sharedtypes.NewQuotedBigInt(0),
OracleDaoRpl: sharedtypes.NewQuotedBigInt(0),
SmoothingPoolEth: sharedtypes.NewQuotedBigInt(0),
}
r.rewardsFile.ClaimerRewards[claimer] = rewardsForClaimer
}
rewardsForClaimer.OracleDaoRpl.Add(&rewardsForClaimer.OracleDaoRpl.Int, individualOdaoRewards)
rewardsForNetwork, exists := r.rewardsFile.NetworkRewards[rewardsForClaimer.RewardNetwork]
+-- 30 lines: if !exists {------------------------------------------------------------------------------------------------------------------------
r.logger.Info("Calculated total node weight,", slog.String(keys.TotalNodeWeightKey, totalNodeWeight.String()))
return nil
}
func (r *treeGeneratorImpl_v10) calculateEthRewards(context context.Context, checkBeaconPerformance bool) error {
r.smoothingPoolBalance = r.networkState.NetworkDetails.SmoothingPoolBalance
r.logger.Info("Retrieved Smoothing Pool balance", slog.String(keys.AmountKey, getRewardsString(r.smoothingPoolBalance)))
if r.smoothingPoolBalance.Cmp(common.Big0) == 0 {
+-- 79 lines: return nil--------------------------------------------------------------------------------------------------------------------------
return err
}
for _, nodeInfo := range r.nodeDetails {
if nodeInfo.IsEligible && nodeInfo.SmoothingPoolEth.Cmp(common.Big0) > 0 {
claimer := nodeInfo.Address
node := r.networkState.NodeDetailsByAddress[nodeInfo.Address]
if node.IsRplWithdrawalAddressSet && node.PrimaryWithdrawalAddress != node.NodeAddress {
claimer = node.PrimaryWithdrawalAddress
}
rewardsForClaimer, exists := r.rewardsFile.ClaimerRewards[claimer]
if !exists {
network := nodeInfo.RewardsNetwork
validNetwork, err := r.validateNetwork(network)
if err != nil {
return err
}
+-- 5 lines: if !validNetwork {------------------------------------------------------------------------------------------------------------------
rewardsForClaimer = &ClaimerRewardsInfo_v3{
RewardNetwork: network,
CollateralRpl: sharedtypes.NewQuotedBigInt(0),
OracleDaoRpl: sharedtypes.NewQuotedBigInt(0),
SmoothingPoolEth: sharedtypes.NewQuotedBigInt(0),
}
r.rewardsFile.ClaimerRewards[claimer] = rewardsForClaimer
}
rewardsForClaimer.SmoothingPoolEth.Add(&rewardsForClaimer.SmoothingPoolEth.Int, nodeInfo.SmoothingPoolEth)
for _, minipoolInfo := range nodeInfo.Minipools {
successfulAttestations := uint64(len(minipoolInfo.CompletedAttestations))
+-- 35 lines: missingAttestations := uint64(len(minipoolInfo.MissingAttestationSlots))------------------------------------------------------------
r.rewardsFile.TotalRewards.NodeOperatorSmoothingPoolEth.Int = *nodeOpEth
r.rewardsFile.TotalRewards.TotalSmoothingPoolEth.Int = *r.smoothingPoolBalance
return nil
}
func (r *treeGeneratorImpl_v10) calculateNodeRewards() (*big.Int, *big.Int, error) {
if r.totalAttestationScore.Cmp(common.Big0) == 0 || r.successfulAttestations == 0 {
r.logger.Warn("Sending the whole smoothing pool balance to the pool stakers.", slog.String(keys.TotalScoreKey, r.totalAttestationScore.String()), slog.Uint64(keys.SuccessfulAttestationsKey, r.successfulAttestations))
return r.smoothingPoolBalance, big.NewInt(0), nil
}
+-- 43 lines: totalEthForMinipools := big.NewInt(0)-----------------------------------------------------------------------------------------------
r.logger.Info("Adjusted Pool Staker ETH to account for truncation", slog.String(keys.AmountKey, truePoolStakerAmount.String()))
return truePoolStakerAmount, totalEthForMinipools, nil
}
func (r *treeGeneratorImpl_v10) processAttestationsForInterval(context context.Context) error {
startEpoch := r.rewardsFile.ConsensusStartBlock / r.beaconConfig.SlotsPerEpoch
endEpoch := r.rewardsFile.ConsensusEndBlock / r.beaconConfig.SlotsPerEpoch
err := r.createMinipoolIndexMap()
if err != nil {
+-- 30 lines: return err--------------------------------------------------------------------------------------------------------------------------
r.logger.Info("Finished participation check", slog.Duration(keys.TotalElapsedKey, time.Since(reportStartTime)))
return nil
}
func (r *treeGeneratorImpl_v10) processEpoch(context context.Context, getDuties bool, epoch uint64) error {
var committeeData beacon.Committees
attestationsPerSlot := make([][]beacon.AttestationInfo, r.slotsPerEpoch)
var wg errgroup.Group
+-- 45 lines: if getDuties {----------------------------------------------------------------------------------------------------------------------
return nil
}
func (r *treeGeneratorImpl_v10) checkDutiesForSlot(attestations []beacon.AttestationInfo, slot uint64) error {
one := eth.EthToWei(1)
validatorReq := eth.EthToWei(32)
for _, attestation := range attestations {
+-- 51 lines: Get the RP committees for this attestation's slot and index-------------------------------------------------------------------------
return nil
}
func (r *treeGeneratorImpl_v10) getDutiesForEpoch(committees beacon.Committees) error {
for idx := 0; idx < committees.Count(); idx++ {
slotIndex := committees.Slot(idx)
if slotIndex < r.rewardsFile.ConsensusStartBlock || slotIndex > r.rewardsFile.ConsensusEndBlock {
+-- 51 lines: continue----------------------------------------------------------------------------------------------------------------------------
return nil
}
func (r *treeGeneratorImpl_v10) createMinipoolIndexMap() error {
r.validatorIndexMap = map[string]*MinipoolInfo{}
for _, details := range r.nodeDetails {
if details.IsEligible {
for _, minipoolInfo := range details.Minipools {
+-- 41 lines: status, exists := r.networkState.ValidatorDetails[minipoolInfo.ValidatorPubkey]-----------------------------------------------------
return nil
}
func (r *treeGeneratorImpl_v10) getSmoothingPoolNodeDetails() error {
farFutureTime := time.Unix(1000000000000000000, 0)
farPastTime := time.Unix(0, 0)
r.logger.Info("Getting details of nodes for Smoothing Pool calculation...")
+-- 75 lines: nodeCount := uint64(len(r.networkState.NodeDetails))--------------------------------------------------------------------------------
return nil
}
func (r *treeGeneratorImpl_v10) validateNetwork(network uint64) (bool, error) {
valid, exists := r.validNetworkCache[network]
if !exists {
oMgr, err := oracle.NewOracleDaoManager(r.rp)
if err != nil {
return false, fmt.Errorf("error creating oDAO manager binding: %w", err)
+-- 12 lines: }-----------------------------------------------------------------------------------------------------------------------------------
}
return valid, nil
}
func (r *treeGeneratorImpl_v10) getStartBlocksForInterval(context context.Context, previousIntervalEvent rewards.RewardsEvent) (*types.Header, error) {
_, exists, err := r.bc.GetBeaconBlock(context, previousIntervalEvent.ConsensusBlock.String())
if err != nil {
return nil, fmt.Errorf("error verifying block from previous interval: %w", err)
}
if !exists {
+-- 41 lines: return nil, fmt.Errorf("couldn't retrieve CL block from previous interval (slot %d); this likely means you checkpoint sync'd your Beacon Node and it has not backfilled to the previous interval yet so it cannot be used for tree generation", previousIntervalEvent.ConsensusBlock.Uint64())
}
return startElHeader, nil
}
func (r *treeGeneratorImpl_v10) getMinipoolBondAndNodeFee(details *rpstate.NativeMinipoolDetails, blockTime time.Time) (*big.Int, *big.Int) {
currentBond := details.NodeDepositBalance
currentFee := details.NodeFee
previousBond := details.LastBondReductionPrevValue
previousFee := details.LastBondReductionPrevNodeFee
var reductionTimeBig *big.Int = details.LastBondReductionTime
+-- 17 lines: if reductionTimeBig.Cmp(common.Big0) == 0 {-----------------------------------------------------------------------------------------
|