solid

package
v0.0.0-...-1f8a15b Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

README

Utilizing Flat Buffers for Efficient Data Handling in Ethereum 2.0 Data Types

Introduction The Ethereum 2.0 project requires efficient handling of multiple complex data types including validators, checkpoints, and additional data. One solution for this need is the use of flat buffers. Flat buffers allow for data to be accessed without parsing and unpacking the whole data, leading to efficiency and performance benefits.

Benefits of Using Flat Buffers

A. Memory Efficiency

Flat buffers store data in a serialized format, eliminating the need for additional memory to store object metadata. This approach allows for reduced memory footprint, which is critical in applications like Ethereum 2.0 that can handle large volumes of data.

B. Fast Access

Data stored in flat buffers can be accessed directly without the need for deserialization, which tends to be a computationally expensive operation. This feature allows faster data reads, contributing to overall system performance.

C. Simplified Data Exchange

In a distributed system like Ethereum 2.0, data needs to be transferred between different nodes. Using flat buffers, data can be sent across the network in its serialized form, removing the need for serialization and deserialization at each end, and thereby enhancing data exchange speed.

D. Flexibility

Flat buffers support a flexible schema evolution mechanism. This feature allows developers to add or remove fields without breaking existing functionality, making them adaptable for long-term projects like Ethereum 2.0 where requirements can change over time.

Application to Ethereum 2.0 Data Types

A. Validator Data Type

Validator data type contains multiple fields like Public Key, Withdrawal Credentials, Effective Balance, etc. Storing it as a flat buffer allows quick, direct access to each of these fields. This is particularly important as the Validator data type is heavily used in many parts of the Ethereum 2.0 protocol.

B. Checkpoint Data Type

The Checkpoint data type, containing Block Root and Epoch, is another critical component. It is frequently copied and compared, operations which are more efficient on a flat buffer.

Documentation

Index

Constants

View Source
const (
	IsCurrentMatchingSourceAttesterBit  = 0x0
	IsPreviousMatchingSourceAttesterBit = 0x1
	IsCurrentMatchingTargetAttesterBit  = 0x2
	IsPreviousMatchingTargetAttesterBit = 0x3
	IsCurrentMatchingHeadAttesterBit    = 0x4
	IsPreviousMatchingHeadAttesterBit   = 0x5
)
View Source
const AttestationDataBufferSize = 8 + 8 + 32 + 40*2

slot: 8 bytes validatorIndex: 8 bytes beaconBlockHash: 32 bytes source: 40 bytes target: 40 bytes

View Source
const CheckpointSize = 32 + 8 // BlockRoot(32 bytes) + Epoch(8 bytes)

Constants to represent the size and layout of a Checkpoint

Variables

This section is empty.

Functions

func GetDepth

func GetDepth(v uint64) uint8

func IntersectionOfSortedSets

func IntersectionOfSortedSets(v1, v2 IterableSSZ[uint64]) []uint64

func IsUint64SortedSet

func IsUint64SortedSet(set IterableSSZ[uint64]) bool

Check if it is sorted and check if there are duplicates. O(N) complexity.

func NewUint64Slice

func NewUint64Slice(limit int) *byteBasedUint64Slice

NewUint64Slice creates a new instance of byteBasedUint64Slice with a specified capacity limit.

func RangeErr

func RangeErr[T any](r Ranger[T], fn func(int, T, int) error) (err error)

RangeErr is a multi-purpose function that takes a ranger, but not the kind you're thinking of! Sadly, this isn't a Megazord-ready Power Ranger, but a Ranger of generic type 'T'. The 'T' probably stands for Tyrannosaurus, the coolest Dinozord (change my mind).

Types

type Attestation

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

Attestation type represents a statement or confirmation of some occurrence or phenomenon.

func NewAttestionFromParameters

func NewAttestionFromParameters(
	aggregationBits []byte,
	attestationData AttestationData,
	signature [96]byte,
) *Attestation

NewAttestionFromParameters creates a new Attestation instance using provided parameters

func (*Attestation) AggregationBits

func (a *Attestation) AggregationBits() []byte

AggregationBits returns the aggregation bits buffer of the Attestation instance.

func (*Attestation) AttestantionData

func (a *Attestation) AttestantionData() AttestationData

AttestantionData returns the attestation data of the Attestation instance.

func (*Attestation) Clone

func (*Attestation) Clone() clonable.Clonable

Clone creates a new clone of the Attestation instance. This can be useful for creating copies without changing the original object.

func (*Attestation) CopyHashBufferTo

func (a *Attestation) CopyHashBufferTo(o []byte) error

CopyHashBufferTo copies the hash buffer of the Attestation instance to the provided byte slice.

func (*Attestation) DecodeSSZ

func (a *Attestation) DecodeSSZ(buf []byte, _ int) error

DecodeSSZ decodes the provided buffer into the Attestation instance.

func (*Attestation) EncodeSSZ

func (a *Attestation) EncodeSSZ(dst []byte) ([]byte, error)

EncodeSSZ encodes the Attestation instance into the provided buffer.

func (*Attestation) EncodingSizeSSZ

func (a *Attestation) EncodingSizeSSZ() (size int)

EncodingSizeSSZ returns the size of the Attestation instance when encoded in SSZ format.

func (*Attestation) HashSSZ

func (a *Attestation) HashSSZ() (o [32]byte, err error)

HashSSZ hashes the Attestation instance using SSZ. It creates a byte slice `leaves` with a size based on length.Hash, then fills this slice with the values from the Attestation's hash buffer.

func (Attestation) MarshalJSON

func (a Attestation) MarshalJSON() ([]byte, error)

func (*Attestation) SetAggregationBits

func (a *Attestation) SetAggregationBits(bits []byte)

SetAggregationBits sets the aggregation bits buffer of the Attestation instance.

func (*Attestation) SetAttestationData

func (a *Attestation) SetAttestationData(d AttestationData)

SetAttestationData sets the attestation data of the Attestation instance.

func (*Attestation) SetSignature

func (a *Attestation) SetSignature(signature [96]byte)

SetSignature sets the signature of the Attestation instance.

func (*Attestation) Signature

func (a *Attestation) Signature() (o [96]byte)

Signature returns the signature of the Attestation instance.

func (*Attestation) Static

func (*Attestation) Static() bool

Static returns whether the attestation is static or not. For Attestation, it's always false.

func (*Attestation) UnmarshalJSON

func (a *Attestation) UnmarshalJSON(buf []byte) error

type AttestationData

type AttestationData []byte

AttestantionData contains information about attestantion, including finalized/attested checkpoints.

func NewAttestationData

func NewAttestationData() AttestationData

func NewAttestionDataFromParameters

func NewAttestionDataFromParameters(
	slot uint64,
	validatorIndex uint64,
	beaconBlockRoot libcommon.Hash,
	source Checkpoint,
	target Checkpoint,
) AttestationData

func (AttestationData) BeaconBlockRoot

func (a AttestationData) BeaconBlockRoot() (o libcommon.Hash)

func (AttestationData) Clone

func (a AttestationData) Clone() clonable.Clonable

func (AttestationData) CopyHashBufferTo

func (a AttestationData) CopyHashBufferTo(o []byte) error

func (AttestationData) DecodeSSZ

func (a AttestationData) DecodeSSZ(buf []byte, _ int) error

func (AttestationData) EncodeSSZ

func (a AttestationData) EncodeSSZ(dst []byte) ([]byte, error)

func (AttestationData) EncodingSizeSSZ

func (a AttestationData) EncodingSizeSSZ() int

func (AttestationData) Equal

func (a AttestationData) Equal(other AttestationData) bool

func (AttestationData) HashSSZ

func (a AttestationData) HashSSZ() (o [32]byte, err error)

func (AttestationData) MarshalJSON

func (a AttestationData) MarshalJSON() ([]byte, error)

func (AttestationData) RawBeaconBlockRoot

func (a AttestationData) RawBeaconBlockRoot() []byte

func (AttestationData) RawSlot

func (a AttestationData) RawSlot() []byte

func (AttestationData) RawValidatorIndex

func (a AttestationData) RawValidatorIndex() []byte

func (AttestationData) SetBeaconBlockRoot

func (a AttestationData) SetBeaconBlockRoot(beaconBlockRoot libcommon.Hash)

func (AttestationData) SetBeaconBlockRootWithRawBytes

func (a AttestationData) SetBeaconBlockRootWithRawBytes(b []byte)

func (AttestationData) SetSlot

func (a AttestationData) SetSlot(slot uint64)

func (AttestationData) SetSlotWithRawBytes

func (a AttestationData) SetSlotWithRawBytes(b []byte)

func (AttestationData) SetSource

func (a AttestationData) SetSource(c Checkpoint)

func (AttestationData) SetTarget

func (a AttestationData) SetTarget(c Checkpoint)

func (AttestationData) SetValidatorIndex

func (a AttestationData) SetValidatorIndex(validatorIndex uint64)

func (AttestationData) SetValidatorIndexWithRawBytes

func (a AttestationData) SetValidatorIndexWithRawBytes(b []byte)

func (AttestationData) Slot

func (a AttestationData) Slot() uint64

func (AttestationData) Source

func (a AttestationData) Source() Checkpoint

func (AttestationData) Static

func (a AttestationData) Static() bool

func (AttestationData) Target

func (a AttestationData) Target() Checkpoint

func (AttestationData) UnmarshalJSON

func (a AttestationData) UnmarshalJSON(buf []byte) error

func (AttestationData) ValidatorIndex

func (a AttestationData) ValidatorIndex() uint64

type BitList

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

BitList is like a dynamic binary string. It's like a flipbook of 1s and 0s! And just like a flipbook, we can add (Append), remove (Pop), or look at any bit (Get) we want.

func BitlistFromBytes

func BitlistFromBytes(xs []byte, c int) *BitList

BitlistFromBytes is like getting a new Power Ranger from a civilian - we already have the bits!

func NewBitList

func NewBitList(l int, c int) *BitList

NewBitList creates a brand new BitList, just like when Zordon created the Power Rangers! We make sure to set its length and capacity first.

func (*BitList) Append

func (u *BitList) Append(v byte)

Append is like adding a new Power Ranger to the team - the bitlist gets bigger!

func (*BitList) Bits

func (u *BitList) Bits() int

getBitlistLength return the amount of bits in given bitlist.

func (*BitList) Bytes

func (u *BitList) Bytes() []byte

func (*BitList) Cap

func (u *BitList) Cap() int

Cap gives capacity of the bitlist

func (*BitList) Clear

func (u *BitList) Clear()

Clear wipes the BitList clean, just like the memory wipe spell from a particularly forgetful wizard.

func (*BitList) Clone

func (u *BitList) Clone() clonable.Clonable

Clone creates a new BitList with the same length and capacity as the original. Note that the underlying byte slice is not copied.

func (*BitList) CopyTo

func (u *BitList) CopyTo(target IterableSSZ[byte])

CopyTo is like a Power Rangers team up episode - we get the bits from another list!

func (*BitList) DecodeSSZ

func (u *BitList) DecodeSSZ(dst []byte, _ int) error

DecodeSSZ replaces the underlying byte slice of the BitList with a copy of the input byte slice. It then updates the length of the BitList to match the length of the new byte slice.

func (*BitList) EncodeSSZ

func (u *BitList) EncodeSSZ(dst []byte) ([]byte, error)

EncodeSSZ appends the underlying byte slice of the BitList to the destination byte slice. It returns the resulting byte slice.

func (*BitList) EncodingSizeSSZ

func (u *BitList) EncodingSizeSSZ() int

EncodingSizeSSZ returns the current length of the BitList. This is the number of bytes that would be written out when EncodeSSZ is called.

func (*BitList) Get

func (u *BitList) Get(index int) byte

Get lets us peek at a bit in the list, like when the team uses their sensors to spot the monster.

func (*BitList) HashSSZ

func (u *BitList) HashSSZ() ([32]byte, error)

func (*BitList) Length

func (u *BitList) Length() int

Length gives us the length of the bitlist, just like a roll call tells us how many Rangers there are.

func (*BitList) MarshalJSON

func (u *BitList) MarshalJSON() ([]byte, error)

func (*BitList) Pop

func (u *BitList) Pop() (x byte)

Pop removes the first bit from the list, like when the Red Ranger takes the first hit.

func (*BitList) Range

func (u *BitList) Range(fn func(index int, value byte, length int) bool)

Range allows us to do something to each bit in the list, just like a Power Rangers roll call.

func (*BitList) Set

func (u *BitList) Set(index int, v byte)

Set is like the Red Ranger giving an order - we set a bit to a certain value.

func (*BitList) Static

func (*BitList) Static() bool

Static returns false, because BitLists, like Power Rangers, are dynamic!

func (*BitList) UnmarshalJSON

func (u *BitList) UnmarshalJSON(input []byte) error

type Checkpoint

type Checkpoint []byte // Define Checkpoint as a byte slice

func NewCheckpoint

func NewCheckpoint() Checkpoint

NewCheckpoint returns a new Checkpoint with the underlying byte slice initialized to zeros

func NewCheckpointFromParameters

func NewCheckpointFromParameters(
	blockRoot libcommon.Hash,
	epoch uint64,
) Checkpoint

NewCheckpointFromParameters returns a new Checkpoint constructed from the given blockRoot and epoch

func (Checkpoint) BlockRoot

func (c Checkpoint) BlockRoot() (o libcommon.Hash)

BlockRoot returns the block root encoded within the Checkpoint

func (Checkpoint) Clone

func (c Checkpoint) Clone() clonable.Clonable

Clone returns a new Checkpoint object that is a copy of the current object.

func (Checkpoint) Copy

func (c Checkpoint) Copy() Checkpoint

Copy returns a copy of the Checkpoint object.

func (Checkpoint) CopyHashBufferTo

func (c Checkpoint) CopyHashBufferTo(o []byte) error

CopyHashBufferTo copies the hash of the Checkpoint to the buffer 'o'.

func (Checkpoint) DecodeSSZ

func (c Checkpoint) DecodeSSZ(buf []byte, _ int) error

DecodeSSZ decodes the Checkpoint object from SSZ-encoded data.

func (Checkpoint) EncodeSSZ

func (c Checkpoint) EncodeSSZ(dst []byte) ([]byte, error)

EncodeSSZ encodes the Checkpoint object into SSZ format.

func (Checkpoint) EncodingSizeSSZ

func (Checkpoint) EncodingSizeSSZ() int

EncodingSizeSSZ returns the size of the Checkpoint object when encoded as SSZ.

func (Checkpoint) Epoch

func (c Checkpoint) Epoch() uint64

Epoch returns the epoch encoded within the Checkpoint

func (Checkpoint) Equal

func (c Checkpoint) Equal(other Checkpoint) bool

Equal checks if the Checkpoint object is equal to another Checkpoint object.

func (Checkpoint) HashSSZ

func (c Checkpoint) HashSSZ() (o [32]byte, err error)

HashSSZ returns the hash of the Checkpoint object when encoded as SSZ.

func (Checkpoint) MarshalJSON

func (c Checkpoint) MarshalJSON() ([]byte, error)

func (Checkpoint) RawBlockRoot

func (c Checkpoint) RawBlockRoot() []byte

func (Checkpoint) RawEpoch

func (c Checkpoint) RawEpoch() []byte

func (Checkpoint) SetBlockRoot

func (c Checkpoint) SetBlockRoot(blockRoot libcommon.Hash)

SetBlockRoot copies the given blockRoot into the correct location within the Checkpoint

func (Checkpoint) SetEpoch

func (c Checkpoint) SetEpoch(epoch uint64)

SetEpoch encodes the given epoch into the correct location within the Checkpoint

func (Checkpoint) SetRawBlockRoot

func (c Checkpoint) SetRawBlockRoot(b []byte)

func (Checkpoint) SetRawEpoch

func (c Checkpoint) SetRawEpoch(b []byte)

func (Checkpoint) Static

func (c Checkpoint) Static() bool

Static always returns true, indicating that the Checkpoint object is static.

func (Checkpoint) UnmarshalJSON

func (c Checkpoint) UnmarshalJSON(buf []byte) error

type ExtraData

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

ExtraData type stores data as a byte slice and its length.

func NewExtraData

func NewExtraData() *ExtraData

NewExtraData creates a new instance of ExtraData type with initialized byte slice of length 32.

func (*ExtraData) Bytes

func (e *ExtraData) Bytes() []byte

Bytes returns a copy of the ExtraData bytes.

func (*ExtraData) Clone

func (*ExtraData) Clone() clonable.Clonable

Clone creates a new instance of ExtraData.

func (*ExtraData) DecodeSSZ

func (e *ExtraData) DecodeSSZ(buf []byte, _ int) error

DecodeSSZ sets the ExtraData bytes from the provided buffer.

func (*ExtraData) EncodeSSZ

func (e *ExtraData) EncodeSSZ(buf []byte) ([]byte, error)

EncodeSSZ appends ExtraData bytes to the provided buffer.

func (*ExtraData) EncodingSizeSSZ

func (e *ExtraData) EncodingSizeSSZ() int

EncodingSizeSSZ returns the length of ExtraData.

func (*ExtraData) HashSSZ

func (e *ExtraData) HashSSZ() ([32]byte, error)

HashSSZ returns the Merkle Root of the ExtraData byte slice.

func (ExtraData) MarshalJSON

func (e ExtraData) MarshalJSON() ([]byte, error)

func (*ExtraData) SetBytes

func (e *ExtraData) SetBytes(buf []byte)

SetBytes sets the ExtraData bytes from the provided byte slice.

func (*ExtraData) Static

func (*ExtraData) Static() bool

Static always returns false, indicating that the ExtraData object is not static.

func (*ExtraData) UnmarshalJSON

func (e *ExtraData) UnmarshalJSON(buf []byte) error

type HashListSSZ

type HashListSSZ interface {
	IterableSSZ[common.Hash]
	json.Marshaler
	json.Unmarshaler
}

func NewHashList

func NewHashList(c int) HashListSSZ

type HashVectorSSZ

type HashVectorSSZ interface {
	IterableSSZ[common.Hash]
	json.Marshaler
	json.Unmarshaler
}

func NewHashVector

func NewHashVector(s int) HashVectorSSZ

type IterableSSZ

type IterableSSZ[T any] interface {
	Clear()
	CopyTo(IterableSSZ[T])
	Range(fn func(index int, value T, length int) bool)
	Get(index int) T
	Set(index int, v T)
	Length() int
	Cap() int
	Bytes() []byte
	Pop() T
	Append(v T)

	ssz2.Sized
	ssz.EncodableSSZ
	ssz.HashableSSZ
}

type ListSSZ

type ListSSZ[T encodableHashableSSZ] struct {
	// contains filtered or unexported fields
}

func NewDynamicListSSZ

func NewDynamicListSSZ[T encodableHashableSSZ](limit int) *ListSSZ[T]

func NewDynamicListSSZFromList

func NewDynamicListSSZFromList[T encodableHashableSSZ](list []T, limit int) *ListSSZ[T]

func NewStaticListSSZ

func NewStaticListSSZ[T encodableHashableSSZ](limit int, bytesPerElement int) *ListSSZ[T]

func NewStaticListSSZFromList

func NewStaticListSSZFromList[T encodableHashableSSZ](list []T, limit int, bytesPerElement int) *ListSSZ[T]

func NewStatucListSSZFromList

func NewStatucListSSZFromList[T encodableHashableSSZ](list []T, limit int, bytesPerElement int) *ListSSZ[T]

func (*ListSSZ[T]) Append

func (l *ListSSZ[T]) Append(obj T)

func (*ListSSZ[T]) Clear

func (l *ListSSZ[T]) Clear()

func (*ListSSZ[T]) Clone

func (l *ListSSZ[T]) Clone() clonable.Clonable

func (*ListSSZ[T]) DecodeSSZ

func (l *ListSSZ[T]) DecodeSSZ(buf []byte, version int) (err error)

func (*ListSSZ[T]) EncodeSSZ

func (l *ListSSZ[T]) EncodeSSZ(buf []byte) (dst []byte, err error)

func (*ListSSZ[T]) EncodingSizeSSZ

func (l *ListSSZ[T]) EncodingSizeSSZ() (size int)

func (*ListSSZ[T]) Get

func (l *ListSSZ[T]) Get(index int) T

func (*ListSSZ[T]) HashSSZ

func (l *ListSSZ[T]) HashSSZ() ([32]byte, error)

func (*ListSSZ[T]) Len

func (l *ListSSZ[T]) Len() int

func (ListSSZ[T]) MarshalJSON

func (l ListSSZ[T]) MarshalJSON() ([]byte, error)

func (*ListSSZ[T]) Range

func (l *ListSSZ[T]) Range(fn func(index int, value T, length int) bool)

func (*ListSSZ[T]) Static

func (l *ListSSZ[T]) Static() bool

func (*ListSSZ[T]) Truncate

func (l *ListSSZ[T]) Truncate(length int)

func (*ListSSZ[T]) UnmarshalJSON

func (l *ListSSZ[T]) UnmarshalJSON(data []byte) error

type PendingAttestation

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

func NewPendingAttestionFromParameters

func NewPendingAttestionFromParameters(
	aggregationBits []byte,
	attestationData AttestationData,
	inclusionDelay uint64,
	proposerIndex uint64,
) *PendingAttestation

func (*PendingAttestation) AggregationBits

func (a *PendingAttestation) AggregationBits() []byte

func (*PendingAttestation) AttestantionData

func (a *PendingAttestation) AttestantionData() AttestationData

func (*PendingAttestation) Clone

func (*PendingAttestation) DecodeSSZ

func (a *PendingAttestation) DecodeSSZ(buf []byte, _ int) error

func (*PendingAttestation) EncodeSSZ

func (a *PendingAttestation) EncodeSSZ(dst []byte) ([]byte, error)

func (*PendingAttestation) EncodingSizeSSZ

func (a *PendingAttestation) EncodingSizeSSZ() (size int)

func (*PendingAttestation) HashSSZ

func (a *PendingAttestation) HashSSZ() (o [32]byte, err error)

func (*PendingAttestation) InclusionDelay

func (a *PendingAttestation) InclusionDelay() uint64

func (*PendingAttestation) MarshalJSON

func (a *PendingAttestation) MarshalJSON() ([]byte, error)

func (*PendingAttestation) ProposerIndex

func (a *PendingAttestation) ProposerIndex() uint64

func (*PendingAttestation) SetAggregationBits

func (a *PendingAttestation) SetAggregationBits(bits []byte)

func (*PendingAttestation) SetAttestationData

func (a *PendingAttestation) SetAttestationData(d AttestationData)

func (*PendingAttestation) SetInclusionDelay

func (a *PendingAttestation) SetInclusionDelay(inclusionDelay uint64)

func (*PendingAttestation) SetProposerIndex

func (a *PendingAttestation) SetProposerIndex(proposerIndex uint64)

func (*PendingAttestation) UnmarshalJSON

func (a *PendingAttestation) UnmarshalJSON(input []byte) error

type Phase0Data

type Phase0Data struct {
	// MinInclusionDelay
	MinCurrentInclusionDelayAttestation  *PendingAttestation
	MinPreviousInclusionDelayAttestation *PendingAttestation
}

This is all stuff used by phase0 state transition. It makes many operations faster.

type Ranger

type Ranger[T any] interface {
	Range(func(idx int, v T, leng int) bool)
}

Define a method with Range method for iteration

type RawUint64List

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

func NewRawUint64List

func NewRawUint64List(limit int, u []uint64) *RawUint64List

func (*RawUint64List) Append

func (arr *RawUint64List) Append(value uint64)

func (*RawUint64List) Bytes

func (arr *RawUint64List) Bytes() []byte

func (*RawUint64List) Cap

func (arr *RawUint64List) Cap() int

func (*RawUint64List) Clear

func (arr *RawUint64List) Clear()

func (*RawUint64List) Clone

func (arr *RawUint64List) Clone() clonable.Clonable

func (*RawUint64List) CopyTo

func (arr *RawUint64List) CopyTo(target IterableSSZ[uint64])

func (*RawUint64List) DecodeSSZ

func (arr *RawUint64List) DecodeSSZ(buf []byte, _ int) error

func (*RawUint64List) EncodeSSZ

func (arr *RawUint64List) EncodeSSZ(buf []byte) (dst []byte, err error)

func (*RawUint64List) EncodingSizeSSZ

func (arr *RawUint64List) EncodingSizeSSZ() int

func (*RawUint64List) Get

func (arr *RawUint64List) Get(index int) uint64

func (*RawUint64List) HashSSZ

func (arr *RawUint64List) HashSSZ() ([32]byte, error)

func (*RawUint64List) Length

func (arr *RawUint64List) Length() int

func (*RawUint64List) MarshalJSON

func (arr *RawUint64List) MarshalJSON() ([]byte, error)

func (*RawUint64List) Pop

func (arr *RawUint64List) Pop() uint64

func (*RawUint64List) Range

func (arr *RawUint64List) Range(fn func(index int, value uint64, length int) bool)

func (*RawUint64List) Set

func (arr *RawUint64List) Set(index int, v uint64)

func (*RawUint64List) SetReusableHashBuffer

func (arr *RawUint64List) SetReusableHashBuffer(buf []byte)

func (*RawUint64List) Static

func (arr *RawUint64List) Static() bool

func (*RawUint64List) UnmarshalJSON

func (arr *RawUint64List) UnmarshalJSON(data []byte) error

type SyncCommittee

type SyncCommittee [syncCommitteeSize]byte

func NewSyncCommitteeFromParameters

func NewSyncCommitteeFromParameters(
	committee []libcommon.Bytes48,
	aggregatePublicKey libcommon.Bytes48,
) *SyncCommittee

func (*SyncCommittee) AggregatePublicKey

func (s *SyncCommittee) AggregatePublicKey() (out libcommon.Bytes48)

func (*SyncCommittee) Clone

func (s *SyncCommittee) Clone() clonable.Clonable

func (*SyncCommittee) Copy

func (s *SyncCommittee) Copy() *SyncCommittee

func (*SyncCommittee) DecodeSSZ

func (s *SyncCommittee) DecodeSSZ(buf []byte, _ int) error

func (*SyncCommittee) EncodeSSZ

func (s *SyncCommittee) EncodeSSZ(dst []byte) ([]byte, error)

func (*SyncCommittee) EncodingSizeSSZ

func (s *SyncCommittee) EncodingSizeSSZ() int

func (*SyncCommittee) Equal

func (s *SyncCommittee) Equal(o *SyncCommittee) bool

func (*SyncCommittee) GetCommittee

func (s *SyncCommittee) GetCommittee() []libcommon.Bytes48

func (*SyncCommittee) HashSSZ

func (s *SyncCommittee) HashSSZ() ([32]byte, error)

func (*SyncCommittee) MarshalJSON

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

func (*SyncCommittee) SetAggregatePublicKey

func (s *SyncCommittee) SetAggregatePublicKey(k libcommon.Bytes48)

func (*SyncCommittee) SetCommittee

func (s *SyncCommittee) SetCommittee(committee []libcommon.Bytes48)

func (*SyncCommittee) Static

func (s *SyncCommittee) Static() bool

func (*SyncCommittee) UnmarshalJSON

func (s *SyncCommittee) UnmarshalJSON(input []byte) error

type TransactionsSSZ

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

func NewTransactionsSSZFromTransactions

func NewTransactionsSSZFromTransactions(txs [][]byte) *TransactionsSSZ

func (*TransactionsSSZ) Clone

func (*TransactionsSSZ) DecodeSSZ

func (t *TransactionsSSZ) DecodeSSZ(buf []byte, _ int) error

func (*TransactionsSSZ) EncodeSSZ

func (t *TransactionsSSZ) EncodeSSZ(buf []byte) (dst []byte, err error)

func (*TransactionsSSZ) EncodingSizeSSZ

func (t *TransactionsSSZ) EncodingSizeSSZ() (size int)

func (*TransactionsSSZ) ForEach

func (t *TransactionsSSZ) ForEach(fn func(tx []byte, idx int, total int) bool)

func (*TransactionsSSZ) HashSSZ

func (t *TransactionsSSZ) HashSSZ() ([32]byte, error)

func (TransactionsSSZ) MarshalJSON

func (t TransactionsSSZ) MarshalJSON() ([]byte, error)

func (*TransactionsSSZ) Static

func (*TransactionsSSZ) Static() bool

func (*TransactionsSSZ) UnderlyngReference

func (t *TransactionsSSZ) UnderlyngReference() [][]byte

func (*TransactionsSSZ) UnmarshalJSON

func (t *TransactionsSSZ) UnmarshalJSON(buf []byte) error

type Uint64ListSSZ

type Uint64ListSSZ interface {
	IterableSSZ[uint64]
	json.Marshaler
	json.Unmarshaler
}

func NewUint64ListSSZ

func NewUint64ListSSZ(limit int) Uint64ListSSZ

func NewUint64ListSSZFromSlice

func NewUint64ListSSZFromSlice(limit int, slice []uint64) Uint64ListSSZ

type Uint64VectorSSZ

type Uint64VectorSSZ interface {
	IterableSSZ[uint64]
	json.Marshaler
	json.Unmarshaler
}

func NewUint64VectorSSZ

func NewUint64VectorSSZ(size int) Uint64VectorSSZ

type Validator

type Validator []byte

The Validator type represents an Ethereum 2.0 validator. It is stored as a flat buffer, which is a serialized representation of the struct. A flat buffer enables efficient read and write operations, as well as memory storage, without the need for serialization or deserialization.

func NewValidator

func NewValidator() Validator

func NewValidatorFromParameters

func NewValidatorFromParameters(
	PublicKey [48]byte,
	WithdrawalCredentials [32]byte,
	EffectiveBalance uint64,
	Slashed bool,
	ActivationEligibilityEpoch uint64,
	ActivationEpoch uint64,
	ExitEpoch uint64,
	WithdrawableEpoch uint64,
) Validator

NewValidatorFromParameters creates a new Validator object from the provided parameters. It is represented as a flat buffer.

func (Validator) ActivationEligibilityEpoch

func (v Validator) ActivationEligibilityEpoch() uint64

func (Validator) ActivationEpoch

func (v Validator) ActivationEpoch() uint64

func (Validator) Active

func (v Validator) Active(epoch uint64) bool

Active returns if validator is active for given epoch

func (Validator) Clone

func (v Validator) Clone() clonable.Clonable

func (Validator) CopyHashBufferTo

func (v Validator) CopyHashBufferTo(o []byte) error

func (Validator) CopyTo

func (v Validator) CopyTo(dst Validator)

func (Validator) DecodeSSZ

func (v Validator) DecodeSSZ(buf []byte, _ int) error

func (Validator) EffectiveBalance

func (v Validator) EffectiveBalance() uint64

func (Validator) EncodeSSZ

func (v Validator) EncodeSSZ(dst []byte) ([]byte, error)

func (Validator) EncodingSizeSSZ

func (v Validator) EncodingSizeSSZ() int

func (Validator) ExitEpoch

func (v Validator) ExitEpoch() uint64

func (Validator) HashSSZ

func (v Validator) HashSSZ() ([32]byte, error)

func (Validator) IsSlashable

func (v Validator) IsSlashable(epoch uint64) bool

func (Validator) MarshalJSON

func (v Validator) MarshalJSON() ([]byte, error)

func (Validator) PublicKey

func (v Validator) PublicKey() (o [48]byte)

func (Validator) PublicKeyBytes

func (v Validator) PublicKeyBytes() (o []byte)

func (Validator) SetActivationEligibilityEpoch

func (v Validator) SetActivationEligibilityEpoch(i uint64)

func (Validator) SetActivationEpoch

func (v Validator) SetActivationEpoch(i uint64)

func (Validator) SetEffectiveBalance

func (v Validator) SetEffectiveBalance(i uint64)

func (Validator) SetEffectiveBalanceFromBytes

func (v Validator) SetEffectiveBalanceFromBytes(b []byte)

func (Validator) SetExitEpoch

func (v Validator) SetExitEpoch(i uint64)

func (Validator) SetPublicKey

func (v Validator) SetPublicKey(o [48]byte)

func (Validator) SetSlashed

func (v Validator) SetSlashed(b bool)

func (Validator) SetWithdrawableEpoch

func (v Validator) SetWithdrawableEpoch(i uint64)

func (Validator) SetWithdrawalCredentials

func (v Validator) SetWithdrawalCredentials(o common.Hash)

func (Validator) Slashed

func (v Validator) Slashed() bool

func (*Validator) UnmarshalJSON

func (v *Validator) UnmarshalJSON(input []byte) error

func (Validator) WithdrawableEpoch

func (v Validator) WithdrawableEpoch() uint64

func (Validator) WithdrawalCredentials

func (v Validator) WithdrawalCredentials() (o common.Hash)

type ValidatorSet

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

func NewValidatorSet

func NewValidatorSet(c int) *ValidatorSet

func NewValidatorSetWithLength

func NewValidatorSetWithLength(c int, l int) *ValidatorSet

func (*ValidatorSet) Append

func (v *ValidatorSet) Append(val Validator)

func (*ValidatorSet) Bytes

func (v *ValidatorSet) Bytes() []byte

func (*ValidatorSet) Cap

func (v *ValidatorSet) Cap() int

func (*ValidatorSet) Clear

func (v *ValidatorSet) Clear()

func (*ValidatorSet) Clone

func (v *ValidatorSet) Clone() clonable.Clonable

func (*ValidatorSet) CopyTo

func (v *ValidatorSet) CopyTo(t *ValidatorSet)

func (*ValidatorSet) DecodeSSZ

func (v *ValidatorSet) DecodeSSZ(buf []byte, _ int) error

func (*ValidatorSet) EncodeSSZ

func (v *ValidatorSet) EncodeSSZ(buf []byte) ([]byte, error)

func (*ValidatorSet) EncodingSizeSSZ

func (v *ValidatorSet) EncodingSizeSSZ() int

func (*ValidatorSet) Get

func (v *ValidatorSet) Get(idx int) Validator

func (*ValidatorSet) HashSSZ

func (v *ValidatorSet) HashSSZ() ([32]byte, error)

func (*ValidatorSet) IsCurrentMatchingHeadAttester

func (v *ValidatorSet) IsCurrentMatchingHeadAttester(idx int) bool

func (*ValidatorSet) IsCurrentMatchingSourceAttester

func (v *ValidatorSet) IsCurrentMatchingSourceAttester(idx int) bool

func (*ValidatorSet) IsCurrentMatchingTargetAttester

func (v *ValidatorSet) IsCurrentMatchingTargetAttester(idx int) bool

func (*ValidatorSet) IsPreviousMatchingHeadAttester

func (v *ValidatorSet) IsPreviousMatchingHeadAttester(idx int) bool

func (*ValidatorSet) IsPreviousMatchingSourceAttester

func (v *ValidatorSet) IsPreviousMatchingSourceAttester(idx int) bool

func (*ValidatorSet) IsPreviousMatchingTargetAttester

func (v *ValidatorSet) IsPreviousMatchingTargetAttester(idx int) bool

func (*ValidatorSet) Length

func (v *ValidatorSet) Length() int

func (*ValidatorSet) MarshalJSON

func (v *ValidatorSet) MarshalJSON() ([]byte, error)

func (*ValidatorSet) MinCurrentInclusionDelayAttestation

func (v *ValidatorSet) MinCurrentInclusionDelayAttestation(idx int) *PendingAttestation

func (*ValidatorSet) MinPreviousInclusionDelayAttestation

func (v *ValidatorSet) MinPreviousInclusionDelayAttestation(idx int) *PendingAttestation

func (*ValidatorSet) Pop

func (v *ValidatorSet) Pop() Validator

func (*ValidatorSet) Range

func (v *ValidatorSet) Range(fn func(int, Validator, int) bool)

func (*ValidatorSet) Set

func (v *ValidatorSet) Set(idx int, val Validator)

func (*ValidatorSet) SetActivationEligibilityEpochForValidatorAtIndex

func (v *ValidatorSet) SetActivationEligibilityEpochForValidatorAtIndex(index int, epoch uint64)

func (*ValidatorSet) SetActivationEpochForValidatorAtIndex

func (v *ValidatorSet) SetActivationEpochForValidatorAtIndex(index int, epoch uint64)

func (*ValidatorSet) SetEffectiveBalanceForValidatorAtIndex

func (v *ValidatorSet) SetEffectiveBalanceForValidatorAtIndex(index int, balance uint64)

func (*ValidatorSet) SetExitEpochForValidatorAtIndex

func (v *ValidatorSet) SetExitEpochForValidatorAtIndex(index int, epoch uint64)

func (*ValidatorSet) SetIsCurrentMatchingHeadAttester

func (v *ValidatorSet) SetIsCurrentMatchingHeadAttester(idx int, val bool)

func (*ValidatorSet) SetIsCurrentMatchingSourceAttester

func (v *ValidatorSet) SetIsCurrentMatchingSourceAttester(idx int, val bool)

func (*ValidatorSet) SetIsCurrentMatchingTargetAttester

func (v *ValidatorSet) SetIsCurrentMatchingTargetAttester(idx int, val bool)

func (*ValidatorSet) SetIsPreviousMatchingHeadAttester

func (v *ValidatorSet) SetIsPreviousMatchingHeadAttester(idx int, val bool)

func (*ValidatorSet) SetIsPreviousMatchingSourceAttester

func (v *ValidatorSet) SetIsPreviousMatchingSourceAttester(idx int, val bool)

func (*ValidatorSet) SetIsPreviousMatchingTargetAttester

func (v *ValidatorSet) SetIsPreviousMatchingTargetAttester(idx int, val bool)

func (*ValidatorSet) SetMinCurrentInclusionDelayAttestation

func (v *ValidatorSet) SetMinCurrentInclusionDelayAttestation(idx int, val *PendingAttestation)

func (*ValidatorSet) SetMinPreviousInclusionDelayAttestation

func (v *ValidatorSet) SetMinPreviousInclusionDelayAttestation(idx int, val *PendingAttestation)

func (*ValidatorSet) SetValidatorSlashed

func (v *ValidatorSet) SetValidatorSlashed(index int, slashed bool)

func (*ValidatorSet) SetWithdrawableEpochForValidatorAtIndex

func (v *ValidatorSet) SetWithdrawableEpochForValidatorAtIndex(index int, epoch uint64)

func (*ValidatorSet) SetWithdrawalCredentialForValidatorAtIndex

func (v *ValidatorSet) SetWithdrawalCredentialForValidatorAtIndex(index int, creds libcommon.Hash)

func (*ValidatorSet) Static

func (*ValidatorSet) Static() bool

func (*ValidatorSet) UnmarshalJSON

func (v *ValidatorSet) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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