ssz_types

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Code generated by fastssz. DO NOT EDIT. Hash: c302f5cab9af79d858415e7e5bc2002568baf2333120ecc30517636a1b041db6 Version: 0.1.3

Index

Constants

View Source
const (
	FormatJSON = iota
	FormatSSZ
)

Variables

View Source
var Magic [4]byte = [4]byte{0x52, 0x50, 0x52, 0x54}

Functions

This section is empty.

Types

type Address

type Address [20]byte

func AddressFromBytes

func AddressFromBytes(b []byte) Address

func (Address) String

func (a Address) String() string

type Format

type Format = uint

type Hash

type Hash [32]byte

func (Hash) MarshalJSON

func (h Hash) MarshalJSON() ([]byte, error)

func (Hash) String

func (h Hash) String() string

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(data []byte) error

type Layer

type Layer = uint64

Layer corresponds to rewards-level Network fields, where 0 means layer 1... Using an alias of uint64 helps serve as documentation rather than function

type MerkleProof

type MerkleProof []Hash

type Network

type Network uint64

Network corresponds to the top-level Network field, where 1 means mainnet

func NetworkFromString

func NetworkFromString(s string) (Network, bool)

func (Network) MarshalJSON

func (n Network) MarshalJSON() ([]byte, error)

func (*Network) UnmarshalJSON

func (n *Network) UnmarshalJSON(data []byte) error

type NetworkReward

type NetworkReward struct {
	// Chain ID (key)
	Network Layer `json:"-"`

	// Amount of RPL sent to the network for Node Operators
	CollateralRpl big.Uint256 `ssz-size:"32" json:"collateralRpl"`
	// Amount of RPL sent to the network for oDAO members
	OracleDaoRpl big.Uint256 `ssz-size:"32" json:"oracleDaoRpl"`
	// Amount of Eth sent to the network for Node Operators
	SmoothingPoolEth big.Uint256 `ssz-size:"32" json:"smoothingPoolEth"`
}

func NewNetworkReward

func NewNetworkReward(network Layer) *NetworkReward

func (*NetworkReward) GetTree

func (n *NetworkReward) GetTree() (*ssz.Node, error)

GetTree ssz hashes the NetworkReward object

func (*NetworkReward) HashTreeRoot

func (n *NetworkReward) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the NetworkReward object

func (*NetworkReward) HashTreeRootWith

func (n *NetworkReward) HashTreeRootWith(hh ssz.HashWalker) (err error)

HashTreeRootWith ssz hashes the NetworkReward object with a hasher

func (*NetworkReward) MarshalSSZ

func (n *NetworkReward) MarshalSSZ() ([]byte, error)

MarshalSSZ ssz marshals the NetworkReward object

func (*NetworkReward) MarshalSSZTo

func (n *NetworkReward) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo ssz marshals the NetworkReward object to a target array

func (*NetworkReward) SizeSSZ

func (n *NetworkReward) SizeSSZ() (size int)

SizeSSZ returns the ssz encoded size in bytes for the NetworkReward object

func (*NetworkReward) UnmarshalSSZ

func (n *NetworkReward) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ ssz unmarshals the NetworkReward object

type NetworkRewards

type NetworkRewards []*NetworkReward

func (NetworkRewards) Len

func (n NetworkRewards) Len() int

NetworkRewards should implement sort.Interface to make it easier to sort.

func (NetworkRewards) Less

func (n NetworkRewards) Less(i, j int) bool

func (NetworkRewards) MarshalJSON

func (n NetworkRewards) MarshalJSON() ([]byte, error)

func (NetworkRewards) Swap

func (n NetworkRewards) Swap(i, j int)

func (*NetworkRewards) UnmarshalJSON

func (n *NetworkRewards) UnmarshalJSON(data []byte) error

type NodeReward

type NodeReward struct {
	// Address of the Node (key)
	Address Address `ssz-size:"20" json:"-"`

	// Chain ID on which the Node will claim
	Network Layer `json:"rewardNetwork"`
	// Amount of staking RPL earned by the Node
	CollateralRpl big.Uint256 `ssz-size:"32" json:"collateralRpl"`
	// Amount of oDAO RPL earned by the Node
	OracleDaoRpl big.Uint256 `ssz-size:"32" json:"oracleDaoRpl"`
	// Amount of Smoothing Pool ETH earned by the Node
	SmoothingPoolEth big.Uint256 `ssz-size:"32" json:"smoothingPoolEth"`
	// Merkle proof for the node claim, sorted with the Merkle root last
	MerkleProof MerkleProof `ssz:"-" json:"merkleProof"`
}

func NewNodeReward

func NewNodeReward(network Layer, address Address) *NodeReward

func (*NodeReward) GetTree

func (n *NodeReward) GetTree() (*ssz.Node, error)

GetTree ssz hashes the NodeReward object

func (*NodeReward) HashTreeRoot

func (n *NodeReward) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the NodeReward object

func (*NodeReward) HashTreeRootWith

func (n *NodeReward) HashTreeRootWith(hh ssz.HashWalker) (err error)

HashTreeRootWith ssz hashes the NodeReward object with a hasher

func (*NodeReward) MarshalSSZ

func (n *NodeReward) MarshalSSZ() ([]byte, error)

MarshalSSZ ssz marshals the NodeReward object

func (*NodeReward) MarshalSSZTo

func (n *NodeReward) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo ssz marshals the NodeReward object to a target array

func (*NodeReward) SizeSSZ

func (n *NodeReward) SizeSSZ() (size int)

SizeSSZ returns the ssz encoded size in bytes for the NodeReward object

func (*NodeReward) UnmarshalSSZ

func (n *NodeReward) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ ssz unmarshals the NodeReward object

type NodeRewards

type NodeRewards []*NodeReward

func (NodeRewards) Find

func (n NodeRewards) Find(addr Address) *NodeReward

func (NodeRewards) Len

func (n NodeRewards) Len() int

NodeRewards should implement sort.Interface to make it easier to sort.

func (NodeRewards) Less

func (n NodeRewards) Less(i, j int) bool

func (NodeRewards) MarshalJSON

func (n NodeRewards) MarshalJSON() ([]byte, error)

func (NodeRewards) Swap

func (n NodeRewards) Swap(i, j int)

func (*NodeRewards) UnmarshalJSON

func (n *NodeRewards) UnmarshalJSON(data []byte) error

type SSZFile_v1

type SSZFile_v1 struct {

	// A magic header. Four bytes. Helps immediately verify what follows is a rewards tree.
	// 0x52505254 - it's RPRT in ASCII and easy to recognize
	Magic [4]byte `ssz-size:"4" json:"-"`
	// Version is first- parsers can check the first 12 bytes of the file to make sure they're
	// parsing a rewards tree and it is a version they know how to parse.
	RewardsFileVersion uint64 `json:"rewardsFileVersion"`

	// RulesetVersion is the version of the ruleset used to generate the tree, e.g., v9 for the first
	// ruleset to use ssz
	RulesetVersion uint64 `json:"rulesetVersion"`
	// Network is the chain id for which the tree is generated
	Network Network `json:"network"`
	// Index is the rewards interval index
	Index uint64 `json:"index"`
	// StartTime is the time of the first slot of the interval
	StartTime time.Time `json:"startTime"`
	// EndTime is the time fo the last slot of the interval
	EndTime time.Time `json:"endTime"`
	// ConsensusStartBlock is the first non-empty slot of the interval
	ConsensusStartBlock uint64 `json:"consensusStartBlock,omitempty"`
	// ConsensusEndBlock is the last non-empty slot of the interval
	ConsensusEndBlock uint64 `json:"consensusEndBlock"`
	// ExecutionBlock is the execution block number included in ConsensusStartBlock
	ExecutionStartBlock uint64 `json:"executionStartBlock,omitempty"`
	// ExecutionEndBlock is the execution block number included in ConsensusEndBlock
	ExecutionEndBlock uint64 `json:"executionEndBlock"`
	// IntervalsPassed is the number of rewards intervals contained in this tree
	IntervalsPassed uint64 `json:"intervalsPassed"`
	// MerkleRoot is the root of the merkle tree of all the nodes in this tree.
	MerkleRoot Hash `ssz-size:"32" json:"merkleRoot,omitempty"`
	// TotalRewards is aggregate data on how many rewards this tree contains
	TotalRewards *TotalRewards `json:"totalRewards"`
	// NetworkRewards is the destinations and aggregate amounts for each network
	// this tree distributes to.
	// Must be sorted by Chain ID ascending
	NetworkRewards NetworkRewards `ssz-max:"128" json:"networkRewards"`

	// NodeRewards are the objects that make up the merkle tree.
	// Must be sorted by Node Address ascending
	NodeRewards NodeRewards `ssz-max:"9223372036854775807" json:"nodeRewards"`
	// contains filtered or unexported fields
}

func NewSSZFile_v1

func NewSSZFile_v1() *SSZFile_v1

func ParseSSZFile

func ParseSSZFile(buf []byte) (*SSZFile_v1, error)

Parsing wrapper that adds verification to the merkle root and magic header

func (*SSZFile_v1) Deserialize

func (f *SSZFile_v1) Deserialize(data []byte) error

Functions to implement IRewardsFile

func (*SSZFile_v1) FinalizeSSZ

func (f *SSZFile_v1) FinalizeSSZ() ([]byte, error)

Marshal wrappers that adds the magic header if absent and sets or validators merkle root

func (*SSZFile_v1) FinalizeSSZTo

func (f *SSZFile_v1) FinalizeSSZTo(buf []byte) ([]byte, error)

func (*SSZFile_v1) GenerateMerkleTree

func (f *SSZFile_v1) GenerateMerkleTree() error

func (*SSZFile_v1) GetConsensusEndBlock

func (f *SSZFile_v1) GetConsensusEndBlock() uint64

func (*SSZFile_v1) GetConsensusStartBlock

func (f *SSZFile_v1) GetConsensusStartBlock() uint64

func (*SSZFile_v1) GetEndTime

func (f *SSZFile_v1) GetEndTime() time.Time

func (*SSZFile_v1) GetExecutionEndBlock

func (f *SSZFile_v1) GetExecutionEndBlock() uint64

func (*SSZFile_v1) GetExecutionStartBlock

func (f *SSZFile_v1) GetExecutionStartBlock() uint64

func (*SSZFile_v1) GetIndex

func (f *SSZFile_v1) GetIndex() uint64

func (*SSZFile_v1) GetIntervalsPassed

func (f *SSZFile_v1) GetIntervalsPassed() uint64

func (*SSZFile_v1) GetMerkleProof

func (f *SSZFile_v1) GetMerkleProof(address common.Address) ([]common.Hash, error)

func (*SSZFile_v1) GetMerkleRoot

func (f *SSZFile_v1) GetMerkleRoot() string

func (*SSZFile_v1) GetNetworkCollateralRpl

func (f *SSZFile_v1) GetNetworkCollateralRpl(network uint64) *stdbig.Int

func (*SSZFile_v1) GetNetworkOracleDaoRpl

func (f *SSZFile_v1) GetNetworkOracleDaoRpl(network uint64) *stdbig.Int

func (*SSZFile_v1) GetNetworkSmoothingPoolEth

func (f *SSZFile_v1) GetNetworkSmoothingPoolEth(network uint64) *stdbig.Int

func (*SSZFile_v1) GetNodeAddresses

func (f *SSZFile_v1) GetNodeAddresses() []common.Address

func (*SSZFile_v1) GetNodeCollateralRpl

func (f *SSZFile_v1) GetNodeCollateralRpl(addr common.Address) *stdbig.Int

func (*SSZFile_v1) GetNodeOracleDaoRpl

func (f *SSZFile_v1) GetNodeOracleDaoRpl(addr common.Address) *stdbig.Int

func (*SSZFile_v1) GetNodeSmoothingPoolEth

func (f *SSZFile_v1) GetNodeSmoothingPoolEth(addr common.Address) *stdbig.Int

func (*SSZFile_v1) GetRewardsFileVersion

func (f *SSZFile_v1) GetRewardsFileVersion() uint64

func (*SSZFile_v1) GetStartTime

func (f *SSZFile_v1) GetStartTime() time.Time

func (*SSZFile_v1) GetTotalCollateralRpl

func (f *SSZFile_v1) GetTotalCollateralRpl() *stdbig.Int

func (*SSZFile_v1) GetTotalNodeOperatorSmoothingPoolEth

func (f *SSZFile_v1) GetTotalNodeOperatorSmoothingPoolEth() *stdbig.Int

func (*SSZFile_v1) GetTotalNodeWeight

func (f *SSZFile_v1) GetTotalNodeWeight() *stdbig.Int

func (*SSZFile_v1) GetTotalOracleDaoRpl

func (f *SSZFile_v1) GetTotalOracleDaoRpl() *stdbig.Int

func (*SSZFile_v1) GetTotalPoolStakerSmoothingPoolEth

func (f *SSZFile_v1) GetTotalPoolStakerSmoothingPoolEth() *stdbig.Int

func (*SSZFile_v1) GetTotalProtocolDaoRpl

func (f *SSZFile_v1) GetTotalProtocolDaoRpl() *stdbig.Int

func (*SSZFile_v1) GetTree

func (s *SSZFile_v1) GetTree() (*ssz.Node, error)

GetTree ssz hashes the SSZFile_v1 object

func (*SSZFile_v1) HasRewardsFor

func (f *SSZFile_v1) HasRewardsFor(addr common.Address) bool

func (*SSZFile_v1) HasRewardsForNetwork

func (f *SSZFile_v1) HasRewardsForNetwork(network uint64) bool

func (*SSZFile_v1) HashTreeRoot

func (s *SSZFile_v1) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the SSZFile_v1 object

func (*SSZFile_v1) HashTreeRootWith

func (s *SSZFile_v1) HashTreeRootWith(hh ssz.HashWalker) (err error)

HashTreeRootWith ssz hashes the SSZFile_v1 object with a hasher

func (*SSZFile_v1) MarshalJSON

func (f *SSZFile_v1) MarshalJSON() ([]byte, error)

When writing JSON, we need to compute the merkle tree to populate the proofs

func (*SSZFile_v1) MarshalSSZ

func (s *SSZFile_v1) MarshalSSZ() ([]byte, error)

MarshalSSZ ssz marshals the SSZFile_v1 object

func (*SSZFile_v1) MarshalSSZTo

func (s *SSZFile_v1) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo ssz marshals the SSZFile_v1 object to a target array

func (*SSZFile_v1) Proofs

func (f *SSZFile_v1) Proofs() (map[Address]MerkleProof, error)

This getter lazy-computes the proofs and caches them on the file

func (*SSZFile_v1) Serialize

func (f *SSZFile_v1) Serialize() ([]byte, error)

The "normal" serialize() call is expected to be JSON by ISerializable in files.go

func (*SSZFile_v1) SerializeSSZ

func (f *SSZFile_v1) SerializeSSZ() ([]byte, error)

Write as SSZ

func (*SSZFile_v1) SetMinipoolPerformanceFileCID

func (f *SSZFile_v1) SetMinipoolPerformanceFileCID(cid string)

Minipool Performance CID is deprecated, but we must implement this for the interface

func (*SSZFile_v1) SizeSSZ

func (s *SSZFile_v1) SizeSSZ() (size int)

SizeSSZ returns the ssz encoded size in bytes for the SSZFile_v1 object

func (*SSZFile_v1) UnmarshalJSON

func (f *SSZFile_v1) UnmarshalJSON(data []byte) error

This custom unmarshaler avoids creating a landmine where the user may forget to call NewSSZFile_v1 before unmarshaling into the result, which would cause the Magic header to be unset.

func (*SSZFile_v1) UnmarshalSSZ

func (s *SSZFile_v1) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ ssz unmarshals the SSZFile_v1 object

func (*SSZFile_v1) Verify

func (f *SSZFile_v1) Verify() error

Verify checks that the arrays in the file are appropriately sorted and that the merkle proof, if present, matches.

type TotalRewards

type TotalRewards struct {
	// Total amount of RPL sent to the pDAO
	ProtocolDaoRpl big.Uint256 `ssz-size:"32" json:"protocolDaoRpl"`
	// Total amount of RPL sent to Node Operators
	TotalCollateralRpl big.Uint256 `ssz-size:"32" json:"totalCollateralRpl"`
	// Total amount of RPL sent to the oDAO
	TotalOracleDaoRpl big.Uint256 `ssz-size:"32" json:"totalOracleDaoRpl"`
	// Total amount of ETH in the Smoothing Pool
	TotalSmoothingPoolEth big.Uint256 `ssz-size:"32" json:"totalSmoothingPoolEth"`
	// Total amount of Eth sent to the rETH contract
	PoolStakerSmoothingPoolEth big.Uint256 `ssz-size:"32" json:"poolStakerSmoothingPoolEth"`
	// Total amount of Eth sent to Node Operators in the Smoothing Pool
	NodeOperatorSmoothingPoolEth big.Uint256 `ssz-size:"32" json:"nodeOperatorSmoothingPoolEth"`
	// Total Node Weight as defined by RPIP-30
	TotalNodeWeight big.Uint256 `ssz-size:"32" json:"totalNodeWeight,omitempty"`
}

func (*TotalRewards) GetTree

func (t *TotalRewards) GetTree() (*ssz.Node, error)

GetTree ssz hashes the TotalRewards object

func (*TotalRewards) HashTreeRoot

func (t *TotalRewards) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the TotalRewards object

func (*TotalRewards) HashTreeRootWith

func (t *TotalRewards) HashTreeRootWith(hh ssz.HashWalker) (err error)

HashTreeRootWith ssz hashes the TotalRewards object with a hasher

func (*TotalRewards) MarshalSSZ

func (t *TotalRewards) MarshalSSZ() ([]byte, error)

MarshalSSZ ssz marshals the TotalRewards object

func (*TotalRewards) MarshalSSZTo

func (t *TotalRewards) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo ssz marshals the TotalRewards object to a target array

func (*TotalRewards) SizeSSZ

func (t *TotalRewards) SizeSSZ() (size int)

SizeSSZ returns the ssz encoded size in bytes for the TotalRewards object

func (*TotalRewards) UnmarshalSSZ

func (t *TotalRewards) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ ssz unmarshals the TotalRewards object

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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