blocks

package
v4.0.0-...-b8b0360 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedSignedBeaconBlock is returned when the struct type is not a supported signed
	// beacon block type.
	ErrUnsupportedSignedBeaconBlock = errors.New("unsupported signed beacon block")

	// ErrNilObject is returned in a constructor when the underlying object is nil.
	ErrNilObject = errors.New("received nil object")
	// ErrNilSignedBeaconBlock is returned when a nil signed beacon block is received.
	ErrNilSignedBeaconBlock = errors.New("signed beacon block can't be nil")
)
View Source
var (
	// ErrUnsupportedVersion for beacon block methods.
	ErrUnsupportedVersion = errors.New("unsupported beacon block version")
)

Functions

func BeaconBlockContainerToSignedBeaconBlock

func BeaconBlockContainerToSignedBeaconBlock(obj *zond.BeaconBlockContainer) (interfaces.ReadOnlySignedBeaconBlock, error)

BeaconBlockContainerToSignedBeaconBlock converts BeaconBlockContainer (API response) to a SignedBeaconBlock. This is particularly useful for using the values from API calls.

func BeaconBlockIsNil

func BeaconBlockIsNil(b interfaces.ReadOnlySignedBeaconBlock) error

BeaconBlockIsNil checks if any composite field of input signed beacon block is nil. Access to these nil fields will result in run time panic, it is recommended to run these checks as first line of defense.

func BuildSignedBeaconBlock

func BuildSignedBeaconBlock(blk interfaces.ReadOnlyBeaconBlock, signature []byte) (interfaces.SignedBeaconBlock, error)

BuildSignedBeaconBlock assembles a block.ReadOnlySignedBeaconBlock interface compatible struct from a given beacon block and the appropriate signature. This method may be used to easily create a signed beacon block.

func BuildSignedBeaconBlockFromExecutionPayload

func BuildSignedBeaconBlockFromExecutionPayload(
	blk interfaces.ReadOnlySignedBeaconBlock, payload interface{},
) (interfaces.SignedBeaconBlock, error)

BuildSignedBeaconBlockFromExecutionPayload takes a signed, blinded beacon block and converts into a full, signed beacon block by specifying an execution payload.

func IsEmptyExecutionData

func IsEmptyExecutionData(data interfaces.ExecutionData) (bool, error)

IsEmptyExecutionData checks if an execution data is empty underneath. If a single field has a non-zero value, this function will return false.

func NewBeaconBlock

func NewBeaconBlock(i interface{}) (interfaces.ReadOnlyBeaconBlock, error)

NewBeaconBlock creates a beacon block from a protobuf beacon block.

func NewBeaconBlockBody

func NewBeaconBlockBody(i interface{}) (interfaces.ReadOnlyBeaconBlockBody, error)

NewBeaconBlockBody creates a beacon block body from a protobuf beacon block body.

func NewSignedBeaconBlock

func NewSignedBeaconBlock(i interface{}) (interfaces.SignedBeaconBlock, error)

NewSignedBeaconBlock creates a signed beacon block from a protobuf signed beacon block.

func PayloadToHeader

func PayloadToHeader(payload interfaces.ExecutionData) (*enginev1.ExecutionPayloadHeader, error)

PayloadToHeader converts `payload` into execution payload header format.

func PayloadToHeaderCapella

func PayloadToHeaderCapella(payload interfaces.ExecutionData) (*enginev1.ExecutionPayloadHeaderCapella, error)

PayloadToHeaderCapella converts `payload` into execution payload header format.

func PayloadToHeaderDeneb

func PayloadToHeaderDeneb(payload interfaces.ExecutionData) (*enginev1.ExecutionPayloadHeaderDeneb, error)

PayloadToHeaderDeneb converts `payload` into execution payload header format.

func PayloadValueToGwei

func PayloadValueToGwei(value []byte) math.Gwei

PayloadValueToGwei returns a Gwei value given the payload's value

func WrappedExecutionPayload

func WrappedExecutionPayload(p *enginev1.ExecutionPayload) (interfaces.ExecutionData, error)

WrappedExecutionPayload is a constructor which wraps a protobuf execution payload into an interface.

func WrappedExecutionPayloadCapella

func WrappedExecutionPayloadCapella(p *enginev1.ExecutionPayloadCapella, value math.Gwei) (interfaces.ExecutionData, error)

WrappedExecutionPayloadCapella is a constructor which wraps a protobuf execution payload into an interface.

func WrappedExecutionPayloadDeneb

func WrappedExecutionPayloadDeneb(p *enginev1.ExecutionPayloadDeneb, value math.Gwei) (interfaces.ExecutionData, error)

WrappedExecutionPayloadDeneb is a constructor which wraps a protobuf execution payload into an interface.

func WrappedExecutionPayloadHeader

func WrappedExecutionPayloadHeader(p *enginev1.ExecutionPayloadHeader) (interfaces.ExecutionData, error)

WrappedExecutionPayloadHeader is a constructor which wraps a protobuf execution header into an interface.

func WrappedExecutionPayloadHeaderCapella

func WrappedExecutionPayloadHeaderCapella(p *enginev1.ExecutionPayloadHeaderCapella, value math.Gwei) (interfaces.ExecutionData, error)

WrappedExecutionPayloadHeaderCapella is a constructor which wraps a protobuf execution header into an interface.

func WrappedExecutionPayloadHeaderDeneb

func WrappedExecutionPayloadHeaderDeneb(p *enginev1.ExecutionPayloadHeaderDeneb, value math.Gwei) (interfaces.ExecutionData, error)

WrappedExecutionPayloadHeaderDeneb is a constructor which wraps a protobuf execution header into an interface.

Types

type BeaconBlock

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

BeaconBlock is the main beacon block structure. It can represent any block type.

func (*BeaconBlock) AsSignRequestObject

func (b *BeaconBlock) AsSignRequestObject() (validatorpb.SignRequestObject, error)

AsSignRequestObject returns the underlying sign request object.

func (*BeaconBlock) Body

Body returns the underlying block body.

func (*BeaconBlock) Copy

func (*BeaconBlock) HashTreeRoot

func (b *BeaconBlock) HashTreeRoot() ([field_params.RootLength]byte, error)

HashTreeRoot returns the ssz root of the block.

func (*BeaconBlock) HashTreeRootWith

func (b *BeaconBlock) HashTreeRootWith(h *ssz.Hasher) error

HashTreeRootWith ssz hashes the BeaconBlock object with a hasher.

func (*BeaconBlock) IsBlinded

func (b *BeaconBlock) IsBlinded() bool

IsBlinded checks if the beacon block is a blinded block.

func (*BeaconBlock) IsNil

func (b *BeaconBlock) IsNil() bool

IsNil checks if the beacon block is nil.

func (*BeaconBlock) MarshalSSZ

func (b *BeaconBlock) MarshalSSZ() ([]byte, error)

MarshalSSZ marshals the block into its respective ssz form.

func (*BeaconBlock) MarshalSSZTo

func (b *BeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error)

MarshalSSZTo marshals the beacon block's ssz form to the provided byte buffer.

func (*BeaconBlock) ParentRoot

func (b *BeaconBlock) ParentRoot() [field_params.RootLength]byte

ParentRoot returns the parent root of beacon block.

func (*BeaconBlock) ProposerIndex

func (b *BeaconBlock) ProposerIndex() primitives.ValidatorIndex

ProposerIndex returns the proposer index of the beacon block.

func (*BeaconBlock) Proto

func (b *BeaconBlock) Proto() (proto.Message, error)

Proto converts the beacon block to a protobuf object.

func (*BeaconBlock) SizeSSZ

func (b *BeaconBlock) SizeSSZ() int

SizeSSZ returns the size of the serialized block.

WARNING: This function panics. It is required to change the signature of fastssz's SizeSSZ() interface function to avoid panicking. Changing the signature causes very problematic issues with wealdtech deps. For the time being panicking is preferable.

func (*BeaconBlock) Slot

func (b *BeaconBlock) Slot() primitives.Slot

Slot returns the respective slot of the block.

func (*BeaconBlock) StateRoot

func (b *BeaconBlock) StateRoot() [field_params.RootLength]byte

StateRoot returns the state root of the beacon block.

func (*BeaconBlock) UnmarshalSSZ

func (b *BeaconBlock) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ unmarshals the beacon block from its relevant ssz form.

func (*BeaconBlock) Version

func (b *BeaconBlock) Version() int

Version of the underlying protobuf object.

type BeaconBlockBody

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

BeaconBlockBody is the main beacon block body structure. It can represent any block type.

func (*BeaconBlockBody) Attestations

func (b *BeaconBlockBody) Attestations() []*zond.Attestation

Attestations returns the stored attestations in the block.

func (*BeaconBlockBody) AttesterSlashings

func (b *BeaconBlockBody) AttesterSlashings() []*zond.AttesterSlashing

AttesterSlashings returns the attester slashings in the block.

func (*BeaconBlockBody) BlobKzgCommitments

func (b *BeaconBlockBody) BlobKzgCommitments() ([][]byte, error)

BlobKzgCommitments returns the blob kzg commitments in the block.

func (*BeaconBlockBody) Deposits

func (b *BeaconBlockBody) Deposits() []*zond.Deposit

Deposits returns the stored deposits in the block.

func (*BeaconBlockBody) DilithiumToExecutionChanges

func (b *BeaconBlockBody) DilithiumToExecutionChanges() ([]*zond.SignedDilithiumToExecutionChange, error)

func (*BeaconBlockBody) Eth1Data

func (b *BeaconBlockBody) Eth1Data() *zond.Eth1Data

Eth1Data returns the eth1 data in the block.

func (*BeaconBlockBody) Execution

func (b *BeaconBlockBody) Execution() (interfaces.ExecutionData, error)

Execution returns the execution payload of the block body.

func (*BeaconBlockBody) Graffiti

Graffiti returns the graffiti in the block.

func (*BeaconBlockBody) HashTreeRoot

func (b *BeaconBlockBody) HashTreeRoot() ([field_params.RootLength]byte, error)

HashTreeRoot returns the ssz root of the block body.

func (*BeaconBlockBody) IsNil

func (b *BeaconBlockBody) IsNil() bool

IsNil checks if the block body is nil.

func (*BeaconBlockBody) ProposerSlashings

func (b *BeaconBlockBody) ProposerSlashings() []*zond.ProposerSlashing

ProposerSlashings returns the proposer slashings in the block.

func (*BeaconBlockBody) Proto

func (b *BeaconBlockBody) Proto() (proto.Message, error)

Proto converts the beacon block body to a protobuf object.

func (*BeaconBlockBody) RandaoReveal

func (b *BeaconBlockBody) RandaoReveal() [dilithium2.CryptoBytes]byte

RandaoReveal returns the randao reveal from the block body.

func (*BeaconBlockBody) SyncAggregate

func (b *BeaconBlockBody) SyncAggregate() (*zond.SyncAggregate, error)

SyncAggregate returns the sync aggregate in the block.

func (*BeaconBlockBody) VoluntaryExits

func (b *BeaconBlockBody) VoluntaryExits() []*zond.SignedVoluntaryExit

VoluntaryExits returns the voluntary exits in the block.

type BlockWithVerifiedBlobs

type BlockWithVerifiedBlobs struct {
	Block ROBlock
	Blobs []*zond.BlobSidecar
}

type BlockWithVerifiedBlobsSlice

type BlockWithVerifiedBlobsSlice []BlockWithVerifiedBlobs

func (BlockWithVerifiedBlobsSlice) Len

Len is the number of elements in the collection.

func (BlockWithVerifiedBlobsSlice) Less

func (s BlockWithVerifiedBlobsSlice) Less(i, j int) bool

Less reports whether the element with index i must sort before the element with index j. ROBlocks are ordered first by their slot, with a lexicographic sort of roots breaking ties for slots with duplicate blocks.

func (BlockWithVerifiedBlobsSlice) ROBlocks

func (s BlockWithVerifiedBlobsSlice) ROBlocks() []ROBlock

func (BlockWithVerifiedBlobsSlice) Swap

func (s BlockWithVerifiedBlobsSlice) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type ROBlock

type ROBlock struct {
	interfaces.ReadOnlySignedBeaconBlock
	// contains filtered or unexported fields
}

ROBlock is a value that embeds a ReadOnlySignedBeaconBlock along with its block root ([32]byte). This allows the block root to be cached within a value that satisfies the ReadOnlySignedBeaconBlock interface. Since the root and slot for each ROBlock is known, slices can be efficiently sorted using ROBlockSlice.

func NewROBlock

NewROBlock creates a ROBlock from a ReadOnlySignedBeaconBlock. It uses the HashTreeRoot method of the given ReadOnlySignedBeaconBlock.Block to compute the cached root.

func NewROBlockWithRoot

func NewROBlockWithRoot(b interfaces.ReadOnlySignedBeaconBlock, root [32]byte) (ROBlock, error)

NewROBlockWithRoot creates an ROBlock embedding the given block with its root. It accepts the root as parameter rather than computing it internally, because in some cases a block is retrieved by its root and recomputing it is a waste.

func (ROBlock) Root

func (b ROBlock) Root() [32]byte

Root returns the block hash_tree_root for the embedded ReadOnlySignedBeaconBlock.Block().

type ROBlockSlice

type ROBlockSlice []ROBlock

ROBlockSlice implements sort.Interface so that slices of ROBlocks can be easily sorted. A slice of ROBlock is sorted first by slot, with ties broken by cached block roots.

func (ROBlockSlice) Len

func (s ROBlockSlice) Len() int

Len is the number of elements in the collection.

func (ROBlockSlice) Less

func (s ROBlockSlice) Less(i, j int) bool

Less reports whether the element with index i must sort before the element with index j. ROBlocks are ordered first by their slot, with a lexicographic sort of roots breaking ties for slots with duplicate blocks.

func (ROBlockSlice) Swap

func (s ROBlockSlice) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type SignedBeaconBlock

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

SignedBeaconBlock is the main signed beacon block structure. It can represent any block type.

func (*SignedBeaconBlock) Block

Block returns the underlying beacon block object.

func (*SignedBeaconBlock) Copy

Copy performs a deep copy of the signed beacon block object.

func (*SignedBeaconBlock) Header

Header converts the underlying protobuf object from blinded block to header format.

func (*SignedBeaconBlock) IsBlinded

func (b *SignedBeaconBlock) IsBlinded() bool

IsBlinded metadata on whether a block is blinded

func (*SignedBeaconBlock) IsNil

func (b *SignedBeaconBlock) IsNil() bool

IsNil checks if the underlying beacon block is nil.

func (*SignedBeaconBlock) MarshalSSZ

func (b *SignedBeaconBlock) MarshalSSZ() ([]byte, error)

MarshalSSZ marshals the signed beacon block to its relevant ssz form.

func (*SignedBeaconBlock) MarshalSSZTo

func (b *SignedBeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error)

MarshalSSZTo marshals the signed beacon block's ssz form to the provided byte buffer.

func (*SignedBeaconBlock) PbAltairBlock

func (b *SignedBeaconBlock) PbAltairBlock() (*zond.SignedBeaconBlockAltair, error)

PbAltairBlock returns the underlying protobuf object.

func (*SignedBeaconBlock) PbBellatrixBlock

func (b *SignedBeaconBlock) PbBellatrixBlock() (*zond.SignedBeaconBlockBellatrix, error)

PbBellatrixBlock returns the underlying protobuf object.

func (*SignedBeaconBlock) PbBlindedBellatrixBlock

func (b *SignedBeaconBlock) PbBlindedBellatrixBlock() (*zond.SignedBlindedBeaconBlockBellatrix, error)

PbBlindedBellatrixBlock returns the underlying protobuf object.

func (*SignedBeaconBlock) PbBlindedCapellaBlock

func (b *SignedBeaconBlock) PbBlindedCapellaBlock() (*zond.SignedBlindedBeaconBlockCapella, error)

PbBlindedCapellaBlock returns the underlying protobuf object.

func (*SignedBeaconBlock) PbBlindedDenebBlock

func (b *SignedBeaconBlock) PbBlindedDenebBlock() (*zond.SignedBlindedBeaconBlockDeneb, error)

PbBlindedDenebBlock returns the underlying protobuf object.

func (*SignedBeaconBlock) PbCapellaBlock

func (b *SignedBeaconBlock) PbCapellaBlock() (*zond.SignedBeaconBlockCapella, error)

PbCapellaBlock returns the underlying protobuf object.

func (*SignedBeaconBlock) PbDenebBlock

func (b *SignedBeaconBlock) PbDenebBlock() (*zond.SignedBeaconBlockDeneb, error)

PbDenebBlock returns the underlying protobuf object.

func (*SignedBeaconBlock) PbGenericBlock

func (b *SignedBeaconBlock) PbGenericBlock() (*zond.GenericSignedBeaconBlock, error)

PbGenericBlock returns a generic signed beacon block.

func (*SignedBeaconBlock) PbPhase0Block

func (b *SignedBeaconBlock) PbPhase0Block() (*zond.SignedBeaconBlock, error)

PbPhase0Block returns the underlying protobuf object.

func (*SignedBeaconBlock) Proto

func (b *SignedBeaconBlock) Proto() (proto.Message, error)

Proto converts the signed beacon block to a protobuf object.

func (*SignedBeaconBlock) SetAttestations

func (b *SignedBeaconBlock) SetAttestations(a []*zond.Attestation)

SetAttestations sets the attestations in the block. This function is not thread safe, it is only used during block creation.

func (*SignedBeaconBlock) SetAttesterSlashings

func (b *SignedBeaconBlock) SetAttesterSlashings(a []*zond.AttesterSlashing)

SetAttesterSlashings sets the attester slashings in the block. This function is not thread safe, it is only used during block creation.

func (*SignedBeaconBlock) SetBlinded

func (b *SignedBeaconBlock) SetBlinded(blinded bool)

SetBlinded sets the blinded flag of the beacon block. This function is not thread safe, it is only used during block creation.

func (*SignedBeaconBlock) SetBlobKzgCommitments

func (b *SignedBeaconBlock) SetBlobKzgCommitments(c [][]byte) error

SetBlobKzgCommitments sets the blob kzg commitments in the block.

func (*SignedBeaconBlock) SetDeposits

func (b *SignedBeaconBlock) SetDeposits(d []*zond.Deposit)

SetDeposits sets the deposits in the block. This function is not thread safe, it is only used during block creation.

func (*SignedBeaconBlock) SetDilithiumToExecutionChanges

func (b *SignedBeaconBlock) SetDilithiumToExecutionChanges(dilithiumToExecutionChanges []*zond.SignedDilithiumToExecutionChange) error

SetDilithiumToExecutionChanges sets the Dilithium to execution changes in the block. This function is not thread safe, it is only used during block creation.

func (*SignedBeaconBlock) SetEth1Data

func (b *SignedBeaconBlock) SetEth1Data(e *zond.Eth1Data)

SetEth1Data sets the eth1 data in the block. This function is not thread safe, it is only used during block creation.

func (*SignedBeaconBlock) SetExecution

func (b *SignedBeaconBlock) SetExecution(e interfaces.ExecutionData) error

SetExecution sets the execution payload of the block body. This function is not thread safe, it is only used during block creation.

func (*SignedBeaconBlock) SetGraffiti

func (b *SignedBeaconBlock) SetGraffiti(g []byte)

SetGraffiti sets the graffiti in the block. This function is not thread safe, it is only used during block creation.

func (*SignedBeaconBlock) SetParentRoot

func (b *SignedBeaconBlock) SetParentRoot(parentRoot []byte)

SetParentRoot sets the parent root of beacon block. This function is not thread safe, it is only used during block creation.

func (*SignedBeaconBlock) SetProposerIndex

func (b *SignedBeaconBlock) SetProposerIndex(proposerIndex primitives.ValidatorIndex)

SetProposerIndex sets the proposer index of the beacon block. This function is not thread safe, it is only used during block creation.

func (*SignedBeaconBlock) SetProposerSlashings

func (b *SignedBeaconBlock) SetProposerSlashings(p []*zond.ProposerSlashing)

SetProposerSlashings sets the proposer slashings in the block. This function is not thread safe, it is only used during block creation.

func (*SignedBeaconBlock) SetRandaoReveal

func (b *SignedBeaconBlock) SetRandaoReveal(r []byte)

SetRandaoReveal sets the randao reveal in the block body. This function is not thread safe, it is only used during block creation.

func (*SignedBeaconBlock) SetSignature

func (b *SignedBeaconBlock) SetSignature(sig []byte)

SetSignature sets the signature of the signed beacon block. This function is not thread safe, it is only used during block creation.

func (*SignedBeaconBlock) SetSlot

func (b *SignedBeaconBlock) SetSlot(slot primitives.Slot)

SetSlot sets the respective slot of the block. This function is not thread safe, it is only used during block creation.

func (*SignedBeaconBlock) SetStateRoot

func (b *SignedBeaconBlock) SetStateRoot(root []byte)

SetStateRoot sets the state root of the underlying beacon block This function is not thread safe, it is only used during block creation.

func (*SignedBeaconBlock) SetSyncAggregate

func (b *SignedBeaconBlock) SetSyncAggregate(s *zond.SyncAggregate) error

SetSyncAggregate sets the sync aggregate in the block. This function is not thread safe, it is only used during block creation.

func (*SignedBeaconBlock) SetVoluntaryExits

func (b *SignedBeaconBlock) SetVoluntaryExits(v []*zond.SignedVoluntaryExit)

SetVoluntaryExits sets the voluntary exits in the block. This function is not thread safe, it is only used during block creation.

func (*SignedBeaconBlock) Signature

func (b *SignedBeaconBlock) Signature() [dilithium2.CryptoBytes]byte

Signature returns the respective block signature.

func (*SignedBeaconBlock) SizeSSZ

func (b *SignedBeaconBlock) SizeSSZ() int

SizeSSZ returns the size of the serialized signed block

WARNING: This function panics. It is required to change the signature of fastssz's SizeSSZ() interface function to avoid panicking. Changing the signature causes very problematic issues with wealdtech deps. For the time being panicking is preferable.

func (*SignedBeaconBlock) ToBlinded

ToBlinded converts a non-blinded block to its blinded equivalent.

func (*SignedBeaconBlock) UnmarshalSSZ

func (b *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ unmarshals the signed beacon block from its relevant ssz form.

func (*SignedBeaconBlock) ValueInGwei

func (b *SignedBeaconBlock) ValueInGwei() uint64

ValueInGwei metadata on the payload value returned by the builder. Value is 0 by default if local.

func (*SignedBeaconBlock) Version

func (b *SignedBeaconBlock) Version() int

Version of the underlying protobuf object.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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