stateutil

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2020 License: GPL-3.0 Imports: 16 Imported by: 43

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddInMixin added in v0.3.5

func AddInMixin(root [32]byte, length uint64) ([32]byte, error)

AddInMixin describes a method from which a lenth mixin is added to the provided root.

func BlockHeaderRoot

func BlockHeaderRoot(header *ethpb.BeaconBlockHeader) ([32]byte, error)

BlockHeaderRoot computes the HashTreeRoot Merkleization of a BeaconBlockHeader struct according to the eth2 Simple Serialize specification.

func CheckpointRoot

func CheckpointRoot(checkpoint *ethpb.Checkpoint) ([32]byte, error)

CheckpointRoot computes the HashTreeRoot Merkleization of a Checkpoint struct value according to the eth2 Simple Serialize specification.

func ComputeFieldRoots

func ComputeFieldRoots(state *pb.BeaconState) ([][]byte, error)

ComputeFieldRoots returns the hash tree root computations of every field in the beacon state as a list of 32 byte roots.

func EpochAttestationsRoot

func EpochAttestationsRoot(atts []*pb.PendingAttestation) ([32]byte, error)

EpochAttestationsRoot computes the HashTreeRoot Merkleization of a list of pending attestation values according to the eth2 Simple Serialize specification.

func Eth1DataVotesRoot

func Eth1DataVotesRoot(eth1DataVotes []*ethpb.Eth1Data) ([32]byte, error)

Eth1DataVotesRoot computes the HashTreeRoot Merkleization of a list of Eth1Data structs according to the eth2 Simple Serialize specification.

func Eth1Root

func Eth1Root(eth1Data *ethpb.Eth1Data) ([32]byte, error)

Eth1Root computes the HashTreeRoot Merkleization of a BeaconBlockHeader struct according to the eth2 Simple Serialize specification.

func ForkRoot

func ForkRoot(fork *pb.Fork) ([32]byte, error)

ForkRoot computes the HashTreeRoot Merkleization of a Fork struct value according to the eth2 Simple Serialize specification.

func HashTreeRootState

func HashTreeRootState(state *pb.BeaconState) ([32]byte, error)

HashTreeRootState provides a fully-customized version of ssz.HashTreeRoot for the BeaconState type of the official Ethereum Serenity specification. The reason for this particular function is to optimize for speed and memory allocation at the expense of complete specificity (that is, this function can only be used on the Prysm BeaconState data structure).

func HistoricalRootsRoot

func HistoricalRootsRoot(historicalRoots [][]byte) ([32]byte, error)

HistoricalRootsRoot computes the HashTreeRoot Merkleization of a list of [32]byte historical block roots according to the eth2 Simple Serialize specification.

func PendingAttestationRoot added in v0.3.5

func PendingAttestationRoot(att *pb.PendingAttestation) ([32]byte, error)

PendingAttestationRoot describes a method from which the hash tree root of a pending attestation is returned.

func RecomputeFromLayer added in v0.3.5

func RecomputeFromLayer(changedLeaves [][32]byte, changedIdx []uint64, layer [][]*[32]byte) ([32]byte, [][]*[32]byte, error)

RecomputeFromLayer recomputes specific branches of a fixed sized trie depending on the provided changed indexes.

func RecomputeFromLayerVariable added in v0.3.5

func RecomputeFromLayerVariable(changedLeaves [][32]byte, changedIdx []uint64, layer [][]*[32]byte) ([32]byte, [][]*[32]byte, error)

RecomputeFromLayerVariable recomputes specific branches of a variable sized trie depending on the provided changed indexes.

func ReturnTrieLayer added in v0.3.5

func ReturnTrieLayer(elements [][32]byte, length uint64) [][]*[32]byte

ReturnTrieLayer returns the representation of a merkle trie when provided with the elements of a fixed sized trie and the corresponding depth of it.

func ReturnTrieLayerVariable added in v0.3.5

func ReturnTrieLayerVariable(elements [][32]byte, length uint64) [][]*[32]byte

ReturnTrieLayerVariable returns the representation of a merkle trie when provided with the elements of a variable sized trie and the corresponding depth of it.

func RootsArrayHashTreeRoot

func RootsArrayHashTreeRoot(vals [][]byte, length uint64, fieldName string) ([32]byte, error)

RootsArrayHashTreeRoot computes the Merkle root of arrays of 32-byte hashes, such as [64][32]byte according to the Simple Serialize specification of eth2.

func SlashingsRoot

func SlashingsRoot(slashings []uint64) ([32]byte, error)

SlashingsRoot computes the HashTreeRoot Merkleization of a list of uint64 slashing values according to the eth2 Simple Serialize specification.

func Uint64Root

func Uint64Root(val uint64) [32]byte

Uint64Root computes the HashTreeRoot Merkleization of a simple uint64 value according to the eth2 Simple Serialize specification.

func ValidatorBalancesRoot

func ValidatorBalancesRoot(balances []uint64) ([32]byte, error)

ValidatorBalancesRoot computes the HashTreeRoot Merkleization of a list of validator uint64 balances according to the eth2 Simple Serialize specification.

func ValidatorRegistryRoot

func ValidatorRegistryRoot(vals []*ethpb.Validator) ([32]byte, error)

ValidatorRegistryRoot computes the HashTreeRoot Merkleization of a list of validator structs according to the eth2 Simple Serialize specification.

func ValidatorRoot added in v0.3.5

func ValidatorRoot(validator *ethpb.Validator) ([32]byte, error)

ValidatorRoot describes a method from which the hash tree root of a validator is returned.

Types

type HashFn added in v0.3.4

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

HashFn describes a hash function and its associated bytes buffer

func (HashFn) Combi added in v0.3.4

func (h HashFn) Combi(a [32]byte, b [32]byte) [32]byte

Combi describes a method which merges two 32-byte arrays and hashes them.

func (HashFn) MixIn added in v0.3.4

func (h HashFn) MixIn(a [32]byte, i uint64) [32]byte

MixIn describes a method where we add in the provided integer to the end of the byte array and hash it.

Jump to

Keyboard shortcuts

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