Documentation
¶
Index ¶
- Constants
- Variables
- func CanValidatorSubscribeToPool(validator *v1.Validator) bool
- func KeccakHash(data []byte) ([]byte, error)
- type BlockType
- type Config
- type EpochDuties
- type Event
- type Events
- type FullBlock
- func (b *FullBlock) GetBaseFeePerGas() [32]byte
- func (b *FullBlock) GetBlockNumber() uint64
- func (b *FullBlock) GetBlockNumberBigInt() *big.Int
- func (b *FullBlock) GetBlockTransactions() []bellatrix.Transaction
- func (b *FullBlock) GetDonations(poolAddress string) []*contract.ContractEtherReceived
- func (b *FullBlock) GetFeeRecipient() string
- func (b *FullBlock) GetGasUsed() uint64
- func (b *FullBlock) GetProposerIndex() phase0.ValidatorIndex
- func (b *FullBlock) GetProposerIndexUint64() uint64
- func (b *FullBlock) GetProposerTip() (*big.Int, error)
- func (b *FullBlock) GetSentRewardAndType(poolAddress string, isSubscriber bool) (*big.Int, bool, RewardType)
- func (b *FullBlock) GetSlot() phase0.Slot
- func (b *FullBlock) GetSlotUint64() uint64
- func (b *FullBlock) MevRewardInWei() (*big.Int, bool, string)
- func (b *FullBlock) SetConsensusBlock(consensusBlock *spec.VersionedSignedBeaconBlock)
- func (b *FullBlock) SetEvents(events *Events)
- func (b *FullBlock) SetHeaderAndReceipts(header *types.Header, receipts []*types.Receipt)
- func (b *FullBlock) SummarizedBlock(oracle *Oracle, poolAddress string) SummarizedBlock
- type Merklelizer
- func (merklelizer *Merklelizer) AggregateValidatorsIndexes(state *OracleState) []RawLeaf
- func (merklelizer *Merklelizer) GenerateTreeFromState(state *OracleState) (map[string]mt.DataBlock, map[string]RawLeaf, *mt.MerkleTree, bool)
- func (merklelizer *Merklelizer) OrderByWithdrawalAddress(leafs []RawLeaf) []RawLeaf
- type Onchain
- func (o *Onchain) AreNodesInSync(opts ...retry.Option) (bool, error)
- func (o *Onchain) BlockByNumber(blockNumber *big.Int, opts ...retry.Option) (*types.Block, error)
- func (o *Onchain) FetchFullBlock(slot uint64, oracle *Oracle, opt ...bool) *FullBlock
- func (o *Onchain) GetAcceptGovernanceEvents(blockNumber uint64, opts ...retry.Option) ([]*contract.ContractAcceptGovernance, error)
- func (o *Onchain) GetAddOracleMemberEvents(blockNumber uint64, opts ...retry.Option) ([]*contract.ContractAddOracleMember, error)
- func (o *Onchain) GetAddressEthBalance(account common.Address, opts ...retry.Option) (*big.Int, error)
- func (o *Onchain) GetAddressToVotedReport(address common.Address, opts ...retry.Option) (ReportType, error)
- func (o *Onchain) GetAllOracleMembers(opts ...retry.Option) ([]common.Address, error)
- func (o *Onchain) GetCheckpointSlotSizeEvents(blockNumber uint64, opts ...retry.Option) ([]*contract.ContractUpdateCheckpointSlotSize, error)
- func (o *Onchain) GetClaimRewardsEvents(blockNumber uint64, opts ...retry.Option) ([]*contract.ContractClaimRewards, error)
- func (o *Onchain) GetClaimedPerWithdrawalAddress(addresses []string, finalizedBlock uint64) map[string]*big.Int
- func (onchain *Onchain) GetConfigFromContract(cliCfg *config.CliConfig) *Config
- func (o *Onchain) GetConsensusBlockAtSlot(slot uint64, opts ...retry.Option) (*spec.VersionedSignedBeaconBlock, error)
- func (o *Onchain) GetContractClaimedBalance(withdrawalAddress string, blockNumber *big.Int, opts ...retry.Option) (*big.Int, error)
- func (o *Onchain) GetContractCollateral(opts ...retry.Option) (*big.Int, error)
- func (o *Onchain) GetContractDeploymentBlock(opts ...retry.Option) (*big.Int, error)
- func (o *Onchain) GetEtherReceivedEvents(blockNumber uint64, opts ...retry.Option) ([]*contract.ContractEtherReceived, error)
- func (o *Onchain) GetExecHeaderAndReceipts(blockNumber *big.Int, rawTxs []bellatrix.Transaction, opts ...retry.Option) (*types.Header, []*types.Receipt, error)
- func (o *Onchain) GetFinalizedValidators(opts ...retry.Option) (map[phase0.ValidatorIndex]*api.Validator, error)
- func (o *Onchain) GetInitSmoothingPoolEvents(blockNumber uint64, opts ...retry.Option) ([]*contract.ContractInitSmoothingPool, error)
- func (o *Onchain) GetLastConsolidatedSlot(opts ...retry.Option) (uint64, error)
- func (o *Onchain) GetOnchainSlotAndRoot(opts ...retry.Option) (string, uint64, error)
- func (o *Onchain) GetPoolEthBalance(blockNumber *big.Int, opts ...retry.Option) (*big.Int, error)
- func (o *Onchain) GetPoolFee(opts ...retry.Option) (*big.Int, error)
- func (o *Onchain) GetPoolFeeAddress(opts ...retry.Option) (string, error)
- func (o *Onchain) GetPoolFeeRecipientEvents(blockNumber uint64, opts ...retry.Option) ([]*contract.ContractUpdatePoolFeeRecipient, error)
- func (o *Onchain) GetProposalDuty(slot uint64, opts ...retry.Option) (*api.ProposerDuty, error)
- func (o *Onchain) GetQuorum(opts ...retry.Option) (uint64, error)
- func (o *Onchain) GetRemoveOracleMemberEvents(blockNumber uint64, opts ...retry.Option) ([]*contract.ContractRemoveOracleMember, error)
- func (o *Onchain) GetReportConsolidatedEvents(blockNumber uint64, opts ...retry.Option) ([]*contract.ContractReportConsolidated, error)
- func (o *Onchain) GetRetryOpts(opts []retry.Option) []retry.Option
- func (o *Onchain) GetRewardsRoot(opts ...retry.Option) (string, error)
- func (o *Onchain) GetSetRewardRecipientEvents(blockNumber uint64, opts ...retry.Option) ([]*contract.ContractSetRewardRecipient, error)
- func (o *Onchain) GetSingleValidator(valIndex phase0.ValidatorIndex, opts ...retry.Option) (*api.Validator, error)
- func (o *Onchain) GetSlotCheckpointSize(opts ...retry.Option) (uint64, error)
- func (o *Onchain) GetSubmitReportEvents(blockNumber uint64, opts ...retry.Option) ([]*contract.ContractSubmitReport, error)
- func (o *Onchain) GetSubscribeValidatorEvents(blockNumber uint64, opts ...retry.Option) ([]*contract.ContractSubscribeValidator, error)
- func (o *Onchain) GetTransferGovernanceEvents(blockNumber uint64, opts ...retry.Option) ([]*contract.ContractTransferGovernance, error)
- func (o *Onchain) GetUnsubscribeValidatorEvents(blockNumber uint64, opts ...retry.Option) ([]*contract.ContractUnsubscribeValidator, error)
- func (o *Onchain) GetUpdatePoolFeeEvents(blockNumber uint64, opts ...retry.Option) ([]*contract.ContractUpdatePoolFee, error)
- func (o *Onchain) GetUpdateQuorumEvents(blockNumber uint64, opts ...retry.Option) ([]*contract.ContractUpdateQuorum, error)
- func (o *Onchain) GetUpdateSubscriptionCollateralEvents(blockNumber uint64, opts ...retry.Option) ([]*contract.ContractUpdateSubscriptionCollateral, error)
- func (o *Onchain) IsAddressWhitelisted(address common.Address, opts ...retry.Option) (bool, error)
- func (o *Onchain) RefreshBeaconValidators()
- func (o *Onchain) UpdateContractMerkleRoot(slot uint64, newMerkleRoot string) error
- func (o *Onchain) Validators() map[phase0.ValidatorIndex]*v1.Validator
- type OnchainState
- type Oracle
- func (or *Oracle) AdvanceStateToNextSlot(fullBlock *FullBlock) (uint64, error)
- func (or *Oracle) FreezeCheckpoint() bool
- func (or *Oracle) GetUniqueWithdrawalAddresses() []string
- func (or *Oracle) IsOracleInSyncWithChain(onchainRoot string, onchainSlot uint64) (bool, error)
- func (or *Oracle) LatestCommitedSlot() (uint64, bool)
- func (or *Oracle) LatestCommitedState() *OnchainState
- func (or *Oracle) LoadFromBytes(rawBytes []byte) (bool, error)
- func (or *Oracle) LoadFromJson() (bool, error)
- func (or *Oracle) LoadFromPath(path string) (bool, error)
- func (or *Oracle) LoadGivenState(slotCheckpoint uint64) (bool, error)
- func (or *Oracle) RunOffchainReconciliation() error
- func (or *Oracle) RunOnchainReconciliation(contractBalanceWei *big.Int, claimedAmountsWei map[string]*big.Int) error
- func (or *Oracle) SaveToJson(saveSlot bool) error
- func (or *Oracle) SetBeaconValidators(validators map[phase0.ValidatorIndex]*v1.Validator)
- func (or *Oracle) State() *OracleState
- func (or *Oracle) StateWithHash() (*OracleState, error)
- type OracleState
- type RawLeaf
- type ReportType
- type RewardType
- type SubscriptionType
- type SummarizedBlock
- type ValidatorInfo
- type ValidatorStatus
- type WithdrawalType
Constants ¶
const DefaultAddress = "0x0000000000000000000000000000000000000000"
const DefaultRoot = "0x0000000000000000000000000000000000000000000000000000000000000000"
Variables ¶
var StateFolder = "oracle-data"
Default path of persisted state
var StateJsonName = "state.json"
Functions ¶
func CanValidatorSubscribeToPool ¶
Returns true if a given validator can subscribe or not to the pool Accepted states are: -ValidatorStatePendingInitialized -ValidatorStatePendingQueued -ValidatorStateActiveOngoing
func KeccakHash ¶
Types ¶
type BlockType ¶
type BlockType uint8
Block type
func (*BlockType) MarshalJSON ¶
func (*BlockType) UnmarshalJSON ¶
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 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 ¶
Returns the base fee per gas depending on the fork version
func (*FullBlock) GetBlockNumber ¶
Returns the block number depending on the fork version (as uint64)
func (*FullBlock) GetBlockNumberBigInt ¶
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 ¶
Returns the fee recipient of the block, depending on the fork version
func (*FullBlock) GetGasUsed ¶
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 (*FullBlock) GetProposerTip ¶
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) GetSlotUint64 ¶
func (*FullBlock) MevRewardInWei ¶
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 ¶
Set the events that were triggered in this block. This shall be done always unless the block was missed.
func (*FullBlock) SetHeaderAndReceipts ¶
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 (*Onchain) AreNodesInSync ¶
func (*Onchain) BlockByNumber ¶
func (*Onchain) FetchFullBlock ¶
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 (*Onchain) GetAddOracleMemberEvents ¶
func (*Onchain) GetAddressEthBalance ¶
func (*Onchain) GetAddressToVotedReport ¶
func (*Onchain) GetAllOracleMembers ¶
func (*Onchain) GetCheckpointSlotSizeEvents ¶
func (*Onchain) GetClaimRewardsEvents ¶
func (*Onchain) GetClaimedPerWithdrawalAddress ¶
func (*Onchain) GetConfigFromContract ¶
func (*Onchain) GetConsensusBlockAtSlot ¶
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 (*Onchain) GetContractDeploymentBlock ¶
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 (*Onchain) GetInitSmoothingPoolEvents ¶
func (*Onchain) GetLastConsolidatedSlot ¶
func (*Onchain) GetOnchainSlotAndRoot ¶
func (*Onchain) GetPoolEthBalance ¶
func (*Onchain) GetPoolFeeAddress ¶
func (*Onchain) GetPoolFeeRecipientEvents ¶
func (*Onchain) GetProposalDuty ¶
func (*Onchain) GetRemoveOracleMemberEvents ¶
func (*Onchain) GetReportConsolidatedEvents ¶
func (*Onchain) GetRewardsRoot ¶
func (*Onchain) GetSetRewardRecipientEvents ¶
func (*Onchain) GetSingleValidator ¶
func (*Onchain) GetSlotCheckpointSize ¶
func (*Onchain) GetSubmitReportEvents ¶
func (*Onchain) GetSubscribeValidatorEvents ¶
func (*Onchain) GetTransferGovernanceEvents ¶
func (*Onchain) GetUnsubscribeValidatorEvents ¶
func (*Onchain) GetUpdatePoolFeeEvents ¶
func (*Onchain) GetUpdateQuorumEvents ¶
func (*Onchain) GetUpdateSubscriptionCollateralEvents ¶
func (*Onchain) IsAddressWhitelisted ¶
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 (*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 (*Oracle) AdvanceStateToNextSlot ¶
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 ¶
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 (*Oracle) IsOracleInSyncWithChain ¶
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 ¶
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) LoadFromJson ¶
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) LoadGivenState ¶
func (*Oracle) RunOffchainReconciliation ¶
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 ¶
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 ReportType ¶
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