rewards

package
v1.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2023 License: GPL-3.0 Imports: 53 Imported by: 3

Documentation

Index

Constants

View Source
const (
	SmoothingPoolDetailsBatchSize uint64 = 8
	TestingInterval               uint64 = 1000000000 // A large number that won't ever actually be hit

	// Mainnet intervals
	MainnetV2Interval uint64 = 4
	MainnetV3Interval uint64 = 5
	MainnetV4Interval uint64 = 6
	MainnetV5Interval uint64 = 8
	MainnetV6Interval uint64 = 12

	// Prater intervals
	PraterV2Interval uint64 = 37
	PraterV3Interval uint64 = 49
	PraterV4Interval uint64 = 60
	PraterV5Interval uint64 = 76
	PraterV6Interval uint64 = 118
)

Settings

View Source
const (
	FarEpoch uint64 = 18446744073709551615
)

Variables

This section is empty.

Functions

func DownloadRewardsFile

func DownloadRewardsFile(cfg *config.RocketPoolConfig, interval uint64, cid string, isDaemon bool) error

Downloads a single rewards file

func GetCidForRewardsFile added in v1.10.0

func GetCidForRewardsFile(rewardsFile *RewardsFile, filename string) (cid.Cid, error)

Get the IPFS CID for a blob of data

func GetClaimStatus

func GetClaimStatus(rp *rocketpool.RocketPool, nodeAddress common.Address) (unclaimed []uint64, claimed []uint64, err error)

Gets the intervals the node can claim and the intervals that have already been claimed

func GetELBlockHeaderForTime

func GetELBlockHeaderForTime(targetTime time.Time, rp *rocketpool.RocketPool) (*types.Header, error)

Get the number of the latest EL block that was created before the given timestamp

func GetRewardSnapshotEvent added in v1.6.2

func GetRewardSnapshotEvent(rp *rocketpool.RocketPool, cfg *config.RocketPoolConfig, interval uint64, opts *bind.CallOpts) (rewards.RewardsEvent, error)

Get the event for a rewards snapshot

func GetStartSlotForInterval added in v1.10.1

func GetStartSlotForInterval(previousIntervalEvent rewards.RewardsEvent, bc beacon.Client, beaconConfig beacon.Eth2Config) (uint64, error)

Gets the start slot for the given interval

Types

type CommitteeInfo

type CommitteeInfo struct {
	Index     uint64
	Positions map[int]*MinipoolInfo
}

type IntervalDutiesInfo

type IntervalDutiesInfo struct {
	Index uint64
	Slots map[uint64]*SlotInfo
}

type IntervalInfo

type IntervalInfo struct {
	Index                  uint64        `json:"index"`
	TreeFilePath           string        `json:"treeFilePath"`
	TreeFileExists         bool          `json:"treeFileExists"`
	MerkleRootValid        bool          `json:"merkleRootValid"`
	CID                    string        `json:"cid"`
	StartTime              time.Time     `json:"startTime"`
	EndTime                time.Time     `json:"endTime"`
	NodeExists             bool          `json:"nodeExists"`
	CollateralRplAmount    *QuotedBigInt `json:"collateralRplAmount"`
	ODaoRplAmount          *QuotedBigInt `json:"oDaoRplAmount"`
	SmoothingPoolEthAmount *QuotedBigInt `json:"smoothingPoolEthAmount"`
	MerkleProof            []common.Hash `json:"merkleProof"`
}

Information about an interval

func GetIntervalInfo

func GetIntervalInfo(rp *rocketpool.RocketPool, cfg *config.RocketPoolConfig, nodeAddress common.Address, interval uint64, opts *bind.CallOpts) (info IntervalInfo, err error)

Gets the information for an interval including the file status, the validity, and the node's rewards

type MinipoolInfo

type MinipoolInfo struct {
	Address                 common.Address
	ValidatorPubkey         types.ValidatorPubkey
	ValidatorIndex          string
	NodeAddress             common.Address
	NodeIndex               uint64
	Fee                     *big.Int
	MissedAttestations      uint64
	GoodAttestations        uint64
	MinipoolShare           *big.Int
	MissingAttestationSlots map[uint64]bool
	WasActive               bool
	StartSlot               uint64
	EndSlot                 uint64
	AttestationScore        *big.Int
	CompletedAttestations   map[uint64]bool
	AttestationCount        int
}

type MinipoolPerformanceFile

type MinipoolPerformanceFile struct {
	Index               uint64                                               `json:"index"`
	Network             string                                               `json:"network"`
	StartTime           time.Time                                            `json:"startTime,omitempty"`
	EndTime             time.Time                                            `json:"endTime,omitempty"`
	ConsensusStartBlock uint64                                               `json:"consensusStartBlock,omitempty"`
	ConsensusEndBlock   uint64                                               `json:"consensusEndBlock,omitempty"`
	ExecutionStartBlock uint64                                               `json:"executionStartBlock,omitempty"`
	ExecutionEndBlock   uint64                                               `json:"executionEndBlock,omitempty"`
	MinipoolPerformance map[common.Address]*SmoothingPoolMinipoolPerformance `json:"minipoolPerformance"`
}

Holds information

type NetworkRewardsInfo

type NetworkRewardsInfo struct {
	CollateralRpl    *QuotedBigInt `json:"collateralRpl"`
	OracleDaoRpl     *QuotedBigInt `json:"oracleDaoRpl"`
	SmoothingPoolEth *QuotedBigInt `json:"smoothingPoolEth"`
}

Rewards per network

type NodeRewardsInfo

type NodeRewardsInfo struct {
	RewardNetwork                uint64        `json:"rewardNetwork"`
	CollateralRpl                *QuotedBigInt `json:"collateralRpl"`
	OracleDaoRpl                 *QuotedBigInt `json:"oracleDaoRpl"`
	SmoothingPoolEth             *QuotedBigInt `json:"smoothingPoolEth"`
	SmoothingPoolEligibilityRate float64       `json:"smoothingPoolEligibilityRate"`
	MerkleData                   []byte        `json:"-"`
	MerkleProof                  []string      `json:"merkleProof"`
}

Node operator rewards

func (*NodeRewardsInfo) GetMerkleProof

func (n *NodeRewardsInfo) GetMerkleProof() ([]common.Hash, error)

Get the deserialized Merkle Proof bytes

type NodeSmoothingDetails

type NodeSmoothingDetails struct {
	Address          common.Address
	IsEligible       bool
	IsOptedIn        bool
	StatusChangeTime time.Time
	Minipools        []*MinipoolInfo
	EligibleSeconds  *big.Int
	StartSlot        uint64
	EndSlot          uint64
	SmoothingPoolEth *big.Int
	RewardsNetwork   uint64

	// v2 Fields
	OptInTime  time.Time
	OptOutTime time.Time
}

Details about a node for the Smoothing Pool

type QuotedBigInt

type QuotedBigInt struct {
	big.Int
}

func NewQuotedBigInt

func NewQuotedBigInt(x int64) *QuotedBigInt

func (*QuotedBigInt) MarshalJSON

func (b *QuotedBigInt) MarshalJSON() ([]byte, error)

func (*QuotedBigInt) UnmarshalJSON

func (b *QuotedBigInt) UnmarshalJSON(p []byte) error

type RecordFileInfo added in v1.10.0

type RecordFileInfo struct {
	StartSlot uint64   `json:"startSlot"`
	EndSlot   uint64   `json:"endSlot"`
	Filename  string   `json:"filename"`
	Version   int      `json:"version"`
	Checksum  [48]byte `json:"checksum"`
}

Information about a saved rolling record

type RewardsFile

type RewardsFile struct {
	// Serialized fields
	RewardsFileVersion         uint64                              `json:"rewardsFileVersion"`
	RulesetVersion             uint64                              `json:"rulesetVersion,omitempty"`
	Index                      uint64                              `json:"index"`
	Network                    string                              `json:"network"`
	StartTime                  time.Time                           `json:"startTime,omitempty"`
	EndTime                    time.Time                           `json:"endTime"`
	ConsensusStartBlock        uint64                              `json:"consensusStartBlock,omitempty"`
	ConsensusEndBlock          uint64                              `json:"consensusEndBlock"`
	ExecutionStartBlock        uint64                              `json:"executionStartBlock,omitempty"`
	ExecutionEndBlock          uint64                              `json:"executionEndBlock"`
	IntervalsPassed            uint64                              `json:"intervalsPassed"`
	MerkleRoot                 string                              `json:"merkleRoot,omitempty"`
	MinipoolPerformanceFileCID string                              `json:"minipoolPerformanceFileCid,omitempty"`
	TotalRewards               *TotalRewards                       `json:"totalRewards"`
	NetworkRewards             map[uint64]*NetworkRewardsInfo      `json:"networkRewards"`
	NodeRewards                map[common.Address]*NodeRewardsInfo `json:"nodeRewards"`
	MinipoolPerformanceFile    MinipoolPerformanceFile             `json:"-"`

	// Non-serialized fields
	MerkleTree          *merkletree.MerkleTree    `json:"-"`
	InvalidNetworkNodes map[common.Address]uint64 `json:"-"`
}

JSON struct for a complete rewards file

type RollingRecord added in v1.10.0

type RollingRecord struct {
	StartSlot         uint64                   `json:"startSlot"`
	LastDutiesSlot    uint64                   `json:"lastDutiesSlot"`
	ValidatorIndexMap map[string]*MinipoolInfo `json:"validatorIndexMap"`
	RewardsInterval   uint64                   `json:"rewardsInterval"`
	SmartnodeVersion  string                   `json:"smartnodeVersion,omitempty"`
	// contains filtered or unexported fields
}

func DeserializeRollingRecord added in v1.10.0

func DeserializeRollingRecord(log *log.ColorLogger, logPrefix string, bc beacon.Client, beaconConfig *beacon.Eth2Config, bytes []byte) (*RollingRecord, error)

Load an existing record from serialized JSON data

func NewRollingRecord added in v1.10.0

func NewRollingRecord(log *log.ColorLogger, logPrefix string, bc beacon.Client, startSlot uint64, beaconConfig *beacon.Eth2Config, rewardsInterval uint64) *RollingRecord

Create a new rolling record wrapper

func (*RollingRecord) GetScores added in v1.10.0

func (r *RollingRecord) GetScores(cheatingNodes map[common.Address]bool) ([]*MinipoolInfo, *big.Int, uint64)

Get the minipool scores, along with the cumulative total score and count - ignores minipools that belonged to cheaters

func (*RollingRecord) Serialize added in v1.10.0

func (r *RollingRecord) Serialize() ([]byte, error)

Serialize the current record into a byte array

func (*RollingRecord) UpdateToSlot added in v1.10.0

func (r *RollingRecord) UpdateToSlot(slot uint64, state *state.NetworkState) error

Update the record to the requested slot, using the provided state as a reference. Requires the epoch *after* the requested slot to be finalized so it can accurately count attestations.

type RollingRecordManager added in v1.10.0

type RollingRecordManager struct {
	Record                       *RollingRecord
	LatestFinalizedEpoch         uint64
	ExpectedBalancesBlock        uint64
	ExpectedRewardsIntervalBlock uint64
	// contains filtered or unexported fields
}

Manager for RollingRecords

func NewRollingRecordManager added in v1.10.0

func NewRollingRecordManager(log *log.ColorLogger, errLog *log.ColorLogger, cfg *config.RocketPoolConfig, rp *rocketpool.RocketPool, bc beacon.Client, mgr *state.NetworkStateManager, startSlot uint64, beaconCfg beacon.Eth2Config, rewardsInterval uint64) (*RollingRecordManager, error)

Creates a new manager for rolling records.

func (*RollingRecordManager) GenerateRecordForState added in v1.10.0

func (r *RollingRecordManager) GenerateRecordForState(state *state.NetworkState) (*RollingRecord, error)

Generate a new record for the provided slot using the latest viable saved record

func (*RollingRecordManager) LoadBestRecordFromDisk added in v1.10.0

func (r *RollingRecordManager) LoadBestRecordFromDisk(startSlot uint64, targetSlot uint64, rewardsInterval uint64) (*RollingRecord, error)

Load the most recent appropriate rolling record from disk, using the checksum table as an index

func (*RollingRecordManager) PrepareRecordForReport added in v1.10.0

func (r *RollingRecordManager) PrepareRecordForReport(state *state.NetworkState) error

Prepares the record for a rewards interval report

func (*RollingRecordManager) SaveRecordToFile added in v1.10.0

func (r *RollingRecordManager) SaveRecordToFile(record *RollingRecord) error

Save the rolling record to a file and update the record info catalog

func (*RollingRecordManager) UpdateRecordToState added in v1.10.0

func (r *RollingRecordManager) UpdateRecordToState(state *state.NetworkState, latestFinalizedSlot uint64) error

Updates the manager's record to the provided state, retrying upon errors until success

type SlotInfo

type SlotInfo struct {
	Index      uint64
	Committees map[uint64]*CommitteeInfo
}

type SmoothingPoolMinipoolPerformance

type SmoothingPoolMinipoolPerformance struct {
	Pubkey                  string   `json:"pubkey"`
	StartSlot               uint64   `json:"startSlot,omitempty"`
	EndSlot                 uint64   `json:"endSlot,omitempty"`
	ActiveFraction          float64  `json:"activeFraction,omitempty"`
	SuccessfulAttestations  uint64   `json:"successfulAttestations"`
	MissedAttestations      uint64   `json:"missedAttestations"`
	ParticipationRate       float64  `json:"participationRate"`
	MissingAttestationSlots []uint64 `json:"missingAttestationSlots"`
	EthEarned               float64  `json:"ethEarned"`
}

Minipool stats

type TotalRewards

type TotalRewards struct {
	ProtocolDaoRpl               *QuotedBigInt `json:"protocolDaoRpl"`
	TotalCollateralRpl           *QuotedBigInt `json:"totalCollateralRpl"`
	TotalOracleDaoRpl            *QuotedBigInt `json:"totalOracleDaoRpl"`
	TotalSmoothingPoolEth        *QuotedBigInt `json:"totalSmoothingPoolEth"`
	PoolStakerSmoothingPoolEth   *QuotedBigInt `json:"poolStakerSmoothingPoolEth"`
	NodeOperatorSmoothingPoolEth *QuotedBigInt `json:"nodeOperatorSmoothingPoolEth"`
}

Total cumulative rewards for an interval

type TreeGenerator added in v1.7.1

type TreeGenerator struct {
	// contains filtered or unexported fields
}

func NewTreeGenerator added in v1.7.1

func NewTreeGenerator(logger *log.ColorLogger, logPrefix string, rp *rocketpool.RocketPool, cfg *config.RocketPoolConfig, bc beacon.Client, index uint64, startTime time.Time, endTime time.Time, consensusBlock uint64, elSnapshotHeader *types.Header, intervalsPassed uint64, state *state.NetworkState, rollingRecord *RollingRecord) (*TreeGenerator, error)

func (*TreeGenerator) ApproximateStakerShareOfSmoothingPool added in v1.7.1

func (t *TreeGenerator) ApproximateStakerShareOfSmoothingPool() (*big.Int, error)

func (*TreeGenerator) ApproximateStakerShareOfSmoothingPoolWithRuleset added in v1.7.2

func (t *TreeGenerator) ApproximateStakerShareOfSmoothingPoolWithRuleset(ruleset uint64) (*big.Int, error)

func (*TreeGenerator) GenerateTree added in v1.7.1

func (t *TreeGenerator) GenerateTree() (*RewardsFile, error)

func (*TreeGenerator) GenerateTreeWithRuleset added in v1.7.2

func (t *TreeGenerator) GenerateTreeWithRuleset(ruleset uint64) (*RewardsFile, error)

func (*TreeGenerator) GetApproximatorRulesetVersion added in v1.7.2

func (t *TreeGenerator) GetApproximatorRulesetVersion() uint64

func (*TreeGenerator) GetGeneratorRulesetVersion added in v1.7.2

func (t *TreeGenerator) GetGeneratorRulesetVersion() uint64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL