oracle

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: GPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAddress = "0x0000000000000000000000000000000000000000"
View Source
const DefaultRoot = "0x0000000000000000000000000000000000000000000000000000000000000000"

Variables

View Source
var StateFolder = "oracle-data"

Default path of persisted state

View Source
var StateJsonName = "state.json"

Functions

func CanValidatorSubscribeToPool

func CanValidatorSubscribeToPool(validator *v1.Validator) bool

Returns true if a given validator can subscribe or not to the pool Accepted states are: -ValidatorStatePendingInitialized -ValidatorStatePendingQueued -ValidatorStateActiveOngoing

func KeccakHash

func KeccakHash(data []byte) ([]byte, error)

Types

type BlockType

type BlockType uint8

Block type

const (
	UnknownBlockType      BlockType = 0
	MissedProposal        BlockType = 1
	WrongFeeRecipient     BlockType = 2
	OkPoolProposal        BlockType = 3
	OkPoolProposalBlsKeys BlockType = 4
)

func (*BlockType) MarshalJSON

func (s *BlockType) MarshalJSON() ([]byte, error)

func (*BlockType) String

func (b *BlockType) String() string

func (*BlockType) UnmarshalJSON

func (s *BlockType) UnmarshalJSON(b []byte) error

type Config

type Config struct {
	ConsensusEndpoint        string   `json:"consensus_endpoint"`
	ExecutionEndpoint        string   `json:"execution_endpoint"`
	Network                  string   `json:"network"`
	PoolAddress              string   `json:"pool_address"`
	DeployedSlot             uint64   `json:"deployed_slot"`
	DeployedBlock            uint64   `json:"deployed_block"`
	CheckPointSizeInSlots    uint64   `json:"checkpoint_size"`
	PoolFeesPercentOver10000 int      `json:"pool_fees_percent"` // With 2 decimals (eg 1.5% = 150)
	PoolFeesAddress          string   `json:"pool_fees_address"`
	DryRun                   bool     `json:"dry_run"`
	NumRetries               int      `json:"num_retries"`
	CollateralInWei          *big.Int `json:"collateral_in_wei"`
	UpdaterKeyPass           string   `json:"-"`
	UpdaterKeyFile           string   `json:"-"`
}

type EpochDuties

type EpochDuties struct {
	Epoch  uint64
	Duties []*api.ProposerDuty
}

This file provides different functions to access the blockchain state from both consensus and execution layer and modifying the its state via smart contract calls.

var ProposalDutyCache EpochDuties

Simple cache storing epoch -> proposer duties This is useful to not query the beacon node for each slot since ProposerDuties returns the duties for the whole epoch Note that the cache is meant to store only one epoch's duties

type Event

type Event uint8

Events in the state machine that trigger transition

const (
	UnknownEvent       Event = 0
	ProposalOk         Event = 1
	ProposalMissed     Event = 2
	ProposalWrongFee   Event = 3
	ManualSubscription Event = 4
	AutoSubscription   Event = 5
	Unsubscribe        Event = 6
)

type Events

type Events struct {
	EtherReceived                []*contract.ContractEtherReceived                `json:"ether_received_events"`
	SubscribeValidator           []*contract.ContractSubscribeValidator           `json:"subscribe_validator_events"`
	ClaimRewards                 []*contract.ContractClaimRewards                 `json:"claim_rewards_events"`
	SetRewardRecipient           []*contract.ContractSetRewardRecipient           `json:"set_reward_recipient_events"`
	UnsubscribeValidator         []*contract.ContractUnsubscribeValidator         `json:"unsubscribe_validator_events"`
	InitSmoothingPool            []*contract.ContractInitSmoothingPool            `json:"init_smoothing_pool_events"`
	UpdatePoolFee                []*contract.ContractUpdatePoolFee                `json:"update_pool_fee_events"`
	PoolFeeRecipient             []*contract.ContractUpdatePoolFeeRecipient       `json:"pool_fee_recipient_events"`
	CheckpointSlotSize           []*contract.ContractUpdateCheckpointSlotSize     `json:"checkpoint_slot_size_events"`
	UpdateSubscriptionCollateral []*contract.ContractUpdateSubscriptionCollateral `json:"update_subscription_collateral_events"`
	SubmitReport                 []*contract.ContractSubmitReport                 `json:"submit_report_events"`
	ReportConsolidated           []*contract.ContractReportConsolidated           `json:"report_consolidated_events"`
	UpdateQuorum                 []*contract.ContractUpdateQuorum                 `json:"update_quorum_events"`
	AddOracleMember              []*contract.ContractAddOracleMember              `json:"add_oracle_member_events"`
	RemoveOracleMember           []*contract.ContractRemoveOracleMember           `json:"remove_oracle_member_events"`
	TransferGovernance           []*contract.ContractTransferGovernance           `json:"transfer_governance_events"`
	AcceptGovernance             []*contract.ContractAcceptGovernance             `json:"accept_governance_events"`
}

All the events that the contract can emit

type FullBlock

type FullBlock struct {

	// consensus data: duty (mandatory, who should propose the block)
	ConsensusDuty *api.ProposerDuty `json:"consensus_duty"`

	// consensus data: validator (mandatory, who should propose the block)
	Validator *v1.Validator `json:"validator"`

	// consensus data: block (optional, only when not missed)
	ConsensusBlock *spec.VersionedSignedBeaconBlock `json:"consensus_block"`

	// execution data: txs (optional, only when interested in vanila reward)
	ExecutionHeader   *types.Header    `json:"execution_header"`
	ExecutionReceipts []*types.Receipt `json:"execution_receipts"`

	// execution data: events (optional, only when the block was not missed)
	Events *Events `json:"events"`
}

Information of every block from the blockchain. Some fields are optional eg: if the block is not relevant to the pool

func NewFullBlock

func NewFullBlock(
	consensusDuty *api.ProposerDuty,
	validator *v1.Validator) *FullBlock

Create a new block with the bare minimum information

func (*FullBlock) GetBaseFeePerGas

func (b *FullBlock) GetBaseFeePerGas() [32]byte

Returns the base fee per gas depending on the fork version

func (*FullBlock) GetBlockNumber

func (b *FullBlock) GetBlockNumber() uint64

Returns the block number depending on the fork version (as uint64)

func (*FullBlock) GetBlockNumberBigInt

func (b *FullBlock) GetBlockNumberBigInt() *big.Int

Returns the block number depending on the fork version (as big.Int)

func (*FullBlock) GetBlockTransactions

func (b *FullBlock) GetBlockTransactions() []bellatrix.Transaction

Returns the transactions of the block depending on the fork version

func (*FullBlock) GetDonations

func (b *FullBlock) GetDonations(poolAddress string) []*contract.ContractEtherReceived

Returns the donations sent to the pool. There are two types of donations: normal tx: https://goerli.etherscan.io/tx/0xfeda23c2e9db46e69615a8bec74c4a9f3f9f7eb650659a13c9ad1f394c13698d via sc: https://goerli.etherscan.io/tx/0x277cec5bcb60852b160a29dc9082b7e18a44333194cbe9c7d7b664e4b89b8c46 This fuction detects both by checking the tx and the EtherReceived event

func (*FullBlock) GetFeeRecipient

func (b *FullBlock) GetFeeRecipient() string

Returns the fee recipient of the block, depending on the fork version

func (*FullBlock) GetGasUsed

func (b *FullBlock) GetGasUsed() uint64

Returns the gas used depending on the fork version

func (*FullBlock) GetProposerIndex

func (b *FullBlock) GetProposerIndex() phase0.ValidatorIndex

Returns the proposed index depending on the fork version

func (*FullBlock) GetProposerIndexUint64

func (b *FullBlock) GetProposerIndexUint64() uint64

func (*FullBlock) GetProposerTip

func (b *FullBlock) GetProposerTip() (*big.Int, error)

The reward for vanila block has to be calculated by iterating all txs and getting the individual tips as per EIP1559. Note that to calculate this we need the execution header and receipts

func (*FullBlock) GetSentRewardAndType

func (b *FullBlock) GetSentRewardAndType(
	poolAddress string,
	isSubscriber bool) (*big.Int, bool, RewardType)

Returns if the address received any reward, its amount and its type. A reward can be i) mev (MEV reward) or ii) vanila (just fees as per EIP1559) For the oracle, a reward is either one type or the other. It cannot be both

func (*FullBlock) GetSlot

func (b *FullBlock) GetSlot() phase0.Slot

Returns the slot depending on the fork version

func (*FullBlock) GetSlotUint64

func (b *FullBlock) GetSlotUint64() uint64

func (*FullBlock) MevRewardInWei

func (b *FullBlock) MevRewardInWei() (*big.Int, bool, string)

Returns if there was an mev reward and its amount and fee recipient if any Example: https://prater.beaconcha.in/slot/5307417 (0.53166 Eth)

func (*FullBlock) SetConsensusBlock

func (b *FullBlock) SetConsensusBlock(consensusBlock *spec.VersionedSignedBeaconBlock)

Add consensus data the the full block. Done always unless when the block is missed

func (*FullBlock) SetEvents

func (b *FullBlock) SetEvents(events *Events)

Set the events that were triggered in this block. This shall be done always unless the block was missed.

func (*FullBlock) SetHeaderAndReceipts

func (b *FullBlock) SetHeaderAndReceipts(header *types.Header, receipts []*types.Receipt)

Add header and receipts. Only needeed when the block i) sends reward to pool (auto/manual sub) or ii) the block belongs to a member of the pool. In blocks we are not interested, this can be skipped as fecthing this information is too expensive to do it for every single block.

func (*FullBlock) SummarizedBlock

func (b *FullBlock) SummarizedBlock(oracle *Oracle, poolAddress string) SummarizedBlock

Since storing the full block is expensive, we store a summarized version of it

type Merklelizer

type Merklelizer struct {
}

func NewMerklelizer

func NewMerklelizer() *Merklelizer

func (*Merklelizer) AggregateValidatorsIndexes

func (merklelizer *Merklelizer) AggregateValidatorsIndexes(state *OracleState) []RawLeaf

Aggregates all validators indexes that belong to the same withdrawal address. This allows the merkle tree to hold all validators balance belonging to the same set of validators, that makes claiming cheaper since only one proof is needed for n validators belonging to the same withdrawal address

func (*Merklelizer) GenerateTreeFromState

func (merklelizer *Merklelizer) GenerateTreeFromState(state *OracleState) (map[string]mt.DataBlock, map[string]RawLeaf, *mt.MerkleTree, bool)

Returns a map of withdrawal address to the hashed leaf and raw leaf. It also returns the merkle tree and false if there was not enough information to create a tree

func (*Merklelizer) OrderByWithdrawalAddress

func (merklelizer *Merklelizer) OrderByWithdrawalAddress(leafs []RawLeaf) []RawLeaf

Sort by withdrawal address

type Onchain

type Onchain struct {
	ConsensusClient *http.Service
	ExecutionClient *ethclient.Client
	Contract        *contract.Contract
	NumRetries      int

	UpdaterAddress common.Address
	PoolAddress    string
	// contains filtered or unexported fields
}

func NewOnchain

func NewOnchain(cliCfg *config.CliConfig, updaterKey *ecdsa.PrivateKey) (*Onchain, error)

func (*Onchain) AreNodesInSync

func (o *Onchain) AreNodesInSync(opts ...retry.Option) (bool, error)

func (*Onchain) BlockByNumber

func (o *Onchain) BlockByNumber(blockNumber *big.Int, opts ...retry.Option) (*types.Block, error)

func (*Onchain) FetchFullBlock

func (o *Onchain) FetchFullBlock(slot uint64, oracle *Oracle, opt ...bool) *FullBlock

Oracle dependancy is injected here since we need to know wether the validator proposing the block at this slot is i) subscribed to the pool or ii) its reward goes to the pool. This allows to fetch less information on the blocks that are not relevant to the pool. If fetchAll is enabled, the whole content of the block is fetched no matter what, just for debugging purposes, will slow down sync

func (*Onchain) GetAcceptGovernanceEvents

func (o *Onchain) GetAcceptGovernanceEvents(
	blockNumber uint64,
	opts ...retry.Option) ([]*contract.ContractAcceptGovernance, error)

func (*Onchain) GetAddOracleMemberEvents

func (o *Onchain) GetAddOracleMemberEvents(
	blockNumber uint64,
	opts ...retry.Option) ([]*contract.ContractAddOracleMember, error)

func (*Onchain) GetAddressEthBalance

func (o *Onchain) GetAddressEthBalance(account common.Address, opts ...retry.Option) (*big.Int, error)

func (*Onchain) GetAddressToVotedReport

func (o *Onchain) GetAddressToVotedReport(address common.Address, opts ...retry.Option) (ReportType, error)

func (*Onchain) GetAllOracleMembers

func (o *Onchain) GetAllOracleMembers(opts ...retry.Option) ([]common.Address, error)

func (*Onchain) GetCheckpointSlotSizeEvents

func (o *Onchain) GetCheckpointSlotSizeEvents(
	blockNumber uint64,
	opts ...retry.Option) ([]*contract.ContractUpdateCheckpointSlotSize, error)

func (*Onchain) GetClaimRewardsEvents

func (o *Onchain) GetClaimRewardsEvents(
	blockNumber uint64,
	opts ...retry.Option) ([]*contract.ContractClaimRewards, error)

func (*Onchain) GetClaimedPerWithdrawalAddress

func (o *Onchain) GetClaimedPerWithdrawalAddress(addresses []string, finalizedBlock uint64) map[string]*big.Int

func (*Onchain) GetConfigFromContract

func (onchain *Onchain) GetConfigFromContract(
	cliCfg *config.CliConfig) *Config

func (*Onchain) GetConsensusBlockAtSlot

func (o *Onchain) GetConsensusBlockAtSlot(slot uint64, opts ...retry.Option) (*spec.VersionedSignedBeaconBlock, error)

func (*Onchain) GetContractClaimedBalance

func (o *Onchain) GetContractClaimedBalance(withdrawalAddress string, blockNumber *big.Int, opts ...retry.Option) (*big.Int, error)

Returns the claimed balance of each address. Note that when using this for reconciliation you must run it in finalized blocks to be able to compare apples with apples.

func (*Onchain) GetContractCollateral

func (o *Onchain) GetContractCollateral(opts ...retry.Option) (*big.Int, error)

func (*Onchain) GetContractDeploymentBlock

func (o *Onchain) GetContractDeploymentBlock(opts ...retry.Option) (*big.Int, error)

func (*Onchain) GetEtherReceivedEvents

func (o *Onchain) GetEtherReceivedEvents(
	blockNumber uint64,
	opts ...retry.Option) ([]*contract.ContractEtherReceived, error)

Wrappers to fetch every event with the retrial logic

func (*Onchain) GetExecHeaderAndReceipts

func (o *Onchain) GetExecHeaderAndReceipts(
	blockNumber *big.Int,
	rawTxs []bellatrix.Transaction,
	opts ...retry.Option) (*types.Header, []*types.Receipt, error)

This function is expensive as gets every tx receipt from the block. Use only if needed

func (*Onchain) GetFinalizedValidators

func (o *Onchain) GetFinalizedValidators(opts ...retry.Option) (map[phase0.ValidatorIndex]*api.Validator, error)

func (*Onchain) GetInitSmoothingPoolEvents

func (o *Onchain) GetInitSmoothingPoolEvents(
	blockNumber uint64,
	opts ...retry.Option) ([]*contract.ContractInitSmoothingPool, error)

func (*Onchain) GetLastConsolidatedSlot

func (o *Onchain) GetLastConsolidatedSlot(opts ...retry.Option) (uint64, error)

func (*Onchain) GetOnchainSlotAndRoot

func (o *Onchain) GetOnchainSlotAndRoot(opts ...retry.Option) (string, uint64, error)

func (*Onchain) GetPoolEthBalance

func (o *Onchain) GetPoolEthBalance(blockNumber *big.Int, opts ...retry.Option) (*big.Int, error)

func (*Onchain) GetPoolFee

func (o *Onchain) GetPoolFee(opts ...retry.Option) (*big.Int, error)

func (*Onchain) GetPoolFeeAddress

func (o *Onchain) GetPoolFeeAddress(opts ...retry.Option) (string, error)

func (*Onchain) GetPoolFeeRecipientEvents

func (o *Onchain) GetPoolFeeRecipientEvents(
	blockNumber uint64,
	opts ...retry.Option) ([]*contract.ContractUpdatePoolFeeRecipient, error)

func (*Onchain) GetProposalDuty

func (o *Onchain) GetProposalDuty(slot uint64, opts ...retry.Option) (*api.ProposerDuty, error)

func (*Onchain) GetQuorum

func (o *Onchain) GetQuorum(opts ...retry.Option) (uint64, error)

func (*Onchain) GetRemoveOracleMemberEvents

func (o *Onchain) GetRemoveOracleMemberEvents(
	blockNumber uint64,
	opts ...retry.Option) ([]*contract.ContractRemoveOracleMember, error)

func (*Onchain) GetReportConsolidatedEvents

func (o *Onchain) GetReportConsolidatedEvents(
	blockNumber uint64,
	opts ...retry.Option) ([]*contract.ContractReportConsolidated, error)

func (*Onchain) GetRetryOpts

func (o *Onchain) GetRetryOpts(opts []retry.Option) []retry.Option

func (*Onchain) GetRewardsRoot

func (o *Onchain) GetRewardsRoot(opts ...retry.Option) (string, error)

func (*Onchain) GetSetRewardRecipientEvents

func (o *Onchain) GetSetRewardRecipientEvents(
	blockNumber uint64,
	opts ...retry.Option) ([]*contract.ContractSetRewardRecipient, error)

func (*Onchain) GetSingleValidator

func (o *Onchain) GetSingleValidator(valIndex phase0.ValidatorIndex, opts ...retry.Option) (*api.Validator, error)

func (*Onchain) GetSlotCheckpointSize

func (o *Onchain) GetSlotCheckpointSize(opts ...retry.Option) (uint64, error)

func (*Onchain) GetSubmitReportEvents

func (o *Onchain) GetSubmitReportEvents(
	blockNumber uint64,
	opts ...retry.Option) ([]*contract.ContractSubmitReport, error)

func (*Onchain) GetSubscribeValidatorEvents

func (o *Onchain) GetSubscribeValidatorEvents(
	blockNumber uint64,
	opts ...retry.Option) ([]*contract.ContractSubscribeValidator, error)

func (*Onchain) GetTransferGovernanceEvents

func (o *Onchain) GetTransferGovernanceEvents(
	blockNumber uint64,
	opts ...retry.Option) ([]*contract.ContractTransferGovernance, error)

func (*Onchain) GetUnsubscribeValidatorEvents

func (o *Onchain) GetUnsubscribeValidatorEvents(
	blockNumber uint64,
	opts ...retry.Option) ([]*contract.ContractUnsubscribeValidator, error)

func (*Onchain) GetUpdatePoolFeeEvents

func (o *Onchain) GetUpdatePoolFeeEvents(
	blockNumber uint64,
	opts ...retry.Option) ([]*contract.ContractUpdatePoolFee, error)

func (*Onchain) GetUpdateQuorumEvents

func (o *Onchain) GetUpdateQuorumEvents(
	blockNumber uint64,
	opts ...retry.Option) ([]*contract.ContractUpdateQuorum, error)

func (*Onchain) GetUpdateSubscriptionCollateralEvents

func (o *Onchain) GetUpdateSubscriptionCollateralEvents(
	blockNumber uint64,
	opts ...retry.Option) ([]*contract.ContractUpdateSubscriptionCollateral, error)

func (*Onchain) IsAddressWhitelisted

func (o *Onchain) IsAddressWhitelisted(address common.Address, opts ...retry.Option) (bool, error)

func (*Onchain) RefreshBeaconValidators

func (o *Onchain) RefreshBeaconValidators()

Loads all validator from the beacon chain into the oracle, must be called periodically

func (*Onchain) UpdateContractMerkleRoot

func (o *Onchain) UpdateContractMerkleRoot(slot uint64, newMerkleRoot string) error

func (*Onchain) Validators

func (o *Onchain) Validators() map[phase0.ValidatorIndex]*v1.Validator

type OnchainState

type OnchainState struct {
	Slot       uint64                    `json:"slot"`
	TxHash     string                    `json:"tx_hash"`
	MerkleRoot string                    `json:"merkle_root"`
	Validators map[uint64]*ValidatorInfo `json:"validators"`
	Leafs      map[string]RawLeaf        `json:"leafs"`
	Proofs     map[string][]string       `json:"proofs"`
}

Represents the latest commited state onchain

type Oracle

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

func NewOracle

func NewOracle(cfg *Config) *Oracle

func (*Oracle) AdvanceStateToNextSlot

func (or *Oracle) AdvanceStateToNextSlot(fullBlock *FullBlock) (uint64, error)

Given a previous or.state, this function applies the new block to it, updating the or.state with the new subscriptions, unsubscriptions, donations, and rewards to the pool, updating the balance of all participating validators. Returns the slot that was processed and if there was an error.

func (*Oracle) FreezeCheckpoint

func (or *Oracle) FreezeCheckpoint() bool

Takes the current state, creates a copy of it and freezes it, storing it in a map slot->state. It also creates a set of merkle proof for each withdrawal address of each validator. Each of these frozen states maps to a commited onchain state, represented by a merkle root. Returns false if there wasnt enough data to create a merkle tree

func (*Oracle) GetUniqueWithdrawalAddresses

func (or *Oracle) GetUniqueWithdrawalAddresses() []string

func (*Oracle) IsOracleInSyncWithChain

func (or *Oracle) IsOracleInSyncWithChain(onchainRoot string, onchainSlot uint64) (bool, error)

Check if the oracle is in sync with a given root and slot. Its considered in sync when the latest commited state has the same root and slot as the onchain state

func (*Oracle) LatestCommitedSlot

func (or *Oracle) LatestCommitedSlot() (uint64, bool)

Returns true and the latest commited slot if there is any commited state false otherwise. Note that if there are checkpoints but without enough data to create a tree, it will still return false

func (*Oracle) LatestCommitedState

func (or *Oracle) LatestCommitedState() *OnchainState

Returns the last commited state

func (*Oracle) LoadFromBytes

func (or *Oracle) LoadFromBytes(rawBytes []byte) (bool, error)

func (*Oracle) LoadFromJson

func (or *Oracle) LoadFromJson() (bool, error)

Loads the oracle state from a human readable json file. Multiple check are performed to ensure the state is valid such as checking the hash of the state and ensuring the configuation has not changed

func (*Oracle) LoadFromPath

func (or *Oracle) LoadFromPath(path string) (bool, error)

func (*Oracle) LoadGivenState

func (or *Oracle) LoadGivenState(slotCheckpoint uint64) (bool, error)

func (*Oracle) RunOffchainReconciliation

func (or *Oracle) RunOffchainReconciliation() error

func (*Oracle) RunOnchainReconciliation

func (or *Oracle) RunOnchainReconciliation(
	contractBalanceWei *big.Int,
	claimedAmountsWei map[string]*big.Int) error

Ensures that our liabilities are equal to our assets where: - liabilities: sum of all rewards of all validators + pool fees - assets: sum of all donations + block rewards They must be equal at any point in time and this function ensures so. Note that there are two scenarios to prevent: - liabilities > assets: means we are giving more money than we are receiving which will result in the pool being unable to pay. - assets > liabilities: means less rewards are distributed, and since everything is encoded in the root, this means some funds will be locked forever.

func (*Oracle) SaveToJson

func (or *Oracle) SaveToJson(saveSlot bool) error

Persist the state of the oracle to a JSON file. By default its stored as state.json but if saveSlot is true, it will store two copies, one updating the existing state.json and other as state_<slot>.json. The later is to be used mainly for debugging and recovery purposes.

func (*Oracle) SetBeaconValidators

func (or *Oracle) SetBeaconValidators(
	validators map[phase0.ValidatorIndex]*v1.Validator)

Sets the known validators from the beacon chain, must be updated regularly

func (*Oracle) State

func (or *Oracle) State() *OracleState

Returns the state of the oracle, containing all the information about the validatores, with their state, balances, etc

func (*Oracle) StateWithHash

func (or *Oracle) StateWithHash() (*OracleState, error)

Returns the state of the oracle, recalculating the hash of the state for verification purposes

type OracleState

type OracleState struct {
	StateHash            string   `json:"state_hash"`
	LatestProcessedSlot  uint64   `json:"latest_processed_slot"`
	LatestProcessedBlock uint64   `json:"latest_processed_block"`
	NextSlotToProcess    uint64   `json:"next_slot_to_process"`
	PoolAccumulatedFees  *big.Int `json:"pool_accumulated_fees"`

	// Stores the latest state of the validators at LatestProcessedSlot
	Validators map[uint64]*ValidatorInfo `json:"validators"`

	// Contains frozen checkpoints of the validator state on different slots
	CommitedStates map[uint64]*OnchainState `json:"commited_states"`

	// Stores all events both valid and invalid
	SubscriptionEvents   []*contract.ContractSubscribeValidator   `json:"subscriptions_events"`
	UnsubscriptionEvents []*contract.ContractUnsubscribeValidator `json:"unsubscriptions_events"`

	// Stored all EtherReceived events (MEV rewards and donations)
	EtherReceivedEvents []*contract.ContractEtherReceived `json:"ether_received_events"`

	// Stores a subset of EtherReceived events, just donations
	Donations []*contract.ContractEtherReceived `json:"donations"`

	// Summarized versions of the blocks
	ProposedBlocks []SummarizedBlock `json:"proposed_blocks"`
	MissedBlocks   []SummarizedBlock `json:"missed_blocks"`
	WrongFeeBlocks []SummarizedBlock `json:"wrong_fee_blocks"`

	// Config parameters
	PoolFeesPercentOver10000 int      `json:"pool_fees_percent_over_10000"`
	PoolAddress              string   `json:"pool_address"`
	Network                  string   `json:"network"`
	PoolFeesAddress          string   `json:"pool_fees_address"`
	CheckPointSizeInSlots    uint64   `json:"check_point_size_in_slots"`
	DeployedBlock            uint64   `json:"deployed_block"`
	DeployedSlot             uint64   `json:"deployed_slot"`
	CollateralInWei          *big.Int `json:"collateral_in_wei"`
}

type RawLeaf

type RawLeaf struct {
	WithdrawalAddress     string   `json:"withdrawal_address"`
	AccumulatedBalanceWei *big.Int `json:"accumulated_balance_wei"`
}

type ReportType

type ReportType struct {
	Slot  uint64
	Votes uint64
}

type RewardType

type RewardType uint8

Types of block rewards

const (
	UnknownRewardType RewardType = 0
	VanilaBlock       RewardType = 1
	MevBlock          RewardType = 2
)

func (*RewardType) MarshalJSON

func (s *RewardType) MarshalJSON() ([]byte, error)

func (*RewardType) String

func (r *RewardType) String() string

func (*RewardType) UnmarshalJSON

func (s *RewardType) UnmarshalJSON(b []byte) error

type SubscriptionType

type SubscriptionType uint8

Type of validator subscription

const (
	Manual SubscriptionType = 0
	Auto   SubscriptionType = 1
)

func (*SubscriptionType) MarshalJSON

func (s *SubscriptionType) MarshalJSON() ([]byte, error)

func (*SubscriptionType) String

func (b *SubscriptionType) String() string

func (*SubscriptionType) UnmarshalJSON

func (s *SubscriptionType) UnmarshalJSON(b []byte) error

type SummarizedBlock

type SummarizedBlock struct {
	Slot              uint64     `json:"slot"`
	Block             uint64     `json:"block"`
	ValidatorIndex    uint64     `json:"validator_index"`
	ValidatorKey      string     `json:"validator_key"`
	BlockType         BlockType  `json:"block_type"`
	Reward            *big.Int   `json:"reward_wei"`
	RewardType        RewardType `json:"reward_type"`
	WithdrawalAddress string     `json:"withdrawal_address"`
}

Represents a block with information relevant for the pool, uses Fullblock but stores a subset of the fields (summarized). Otherwise storing everything in memory may be too much

type ValidatorInfo

type ValidatorInfo struct {
	ValidatorStatus       ValidatorStatus  `json:"status"`
	AccumulatedRewardsWei *big.Int         `json:"accumulated_rewards_wei"`
	PendingRewardsWei     *big.Int         `json:"pending_rewards_wei"`
	CollateralWei         *big.Int         `json:"collateral_wei"`
	WithdrawalAddress     string           `json:"withdrawal_address"`
	ValidatorIndex        uint64           `json:"validator_index"`
	ValidatorKey          string           `json:"validator_key"`
	SubscriptionType      SubscriptionType `json:"subscription_type"`
}

Represents all the information that is stored of a validator

type ValidatorStatus

type ValidatorStatus uint8

States of the state machine

const (
	UnknownState  ValidatorStatus = 0
	Active        ValidatorStatus = 1
	YellowCard    ValidatorStatus = 2
	RedCard       ValidatorStatus = 3
	NotSubscribed ValidatorStatus = 4
	Banned        ValidatorStatus = 5
	Untracked     ValidatorStatus = 6
)

func (*ValidatorStatus) MarshalJSON

func (s *ValidatorStatus) MarshalJSON() ([]byte, error)

func (ValidatorStatus) String

func (v ValidatorStatus) String() string

func (*ValidatorStatus) UnmarshalJSON

func (s *ValidatorStatus) UnmarshalJSON(b []byte) error

type WithdrawalType

type WithdrawalType uint8

Withdrawal credentials type

const (
	BlsWithdrawal  WithdrawalType = 0
	Eth1Withdrawal WithdrawalType = 1
)

func GetWithdrawalAndType

func GetWithdrawalAndType(validator *v1.Validator) (string, WithdrawalType)

Returns the 0x prefixed withdrawal credentials and its type: BlsWithdrawal or Eth1Withdrawal

Jump to

Keyboard shortcuts

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