blocks

package
v3.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: GPL-3.0 Imports: 17 Imported by: 5

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 (
	// ErrUnsupportedGetter is returned when a getter access is not supported for a specific beacon block version.
	ErrUnsupportedGetter = errors.New("unsupported getter")
	// ErrUnsupportedVersion for beacon block methods.
	ErrUnsupportedVersion = errors.New("unsupported beacon block version")
	// ErrNilObjectWrapped is returned in a constructor when the underlying object is nil.
	ErrNilObjectWrapped = errors.New("attempted to wrap nil object")
)

Functions

func BeaconBlockContainerToSignedBeaconBlock added in v3.2.0

func BeaconBlockContainerToSignedBeaconBlock(obj *eth.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 ErrNotSupported added in v3.2.0

func ErrNotSupported(funcName string, ver int) error

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 added in v3.1.2

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

PayloadToHeaderCapella converts `payload` into execution payload header format.

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 added in v3.1.2

func WrappedExecutionPayloadCapella(p *enginev1.ExecutionPayloadCapella, value *big.Int) (interfaces.ExecutionData, error)

WrappedExecutionPayloadCapella 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 added in v3.1.2

func WrappedExecutionPayloadHeaderCapella(p *enginev1.ExecutionPayloadHeaderCapella, value *big.Int) (interfaces.ExecutionData, error)

WrappedExecutionPayloadHeaderCapella 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 added in v3.2.1

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() []*eth.Attestation

Attestations returns the stored attestations in the block.

func (*BeaconBlockBody) AttesterSlashings

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

AttesterSlashings returns the attester slashings in the block.

func (*BeaconBlockBody) BLSToExecutionChanges added in v3.2.0

func (b *BeaconBlockBody) BLSToExecutionChanges() ([]*eth.SignedBLSToExecutionChange, error)

func (*BeaconBlockBody) Deposits

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

Deposits returns the stored deposits in the block.

func (*BeaconBlockBody) Eth1Data

func (b *BeaconBlockBody) Eth1Data() *eth.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() []*eth.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

RandaoReveal returns the randao reveal from the block body.

func (*BeaconBlockBody) SyncAggregate

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

SyncAggregate returns the sync aggregate in the block.

func (*BeaconBlockBody) VoluntaryExits

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

VoluntaryExits returns the voluntary exits in the block.

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

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() (*eth.SignedBeaconBlockAltair, error)

PbAltairBlock returns the underlying protobuf object.

func (*SignedBeaconBlock) PbBellatrixBlock

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

PbBellatrixBlock returns the underlying protobuf object.

func (*SignedBeaconBlock) PbBlindedBellatrixBlock

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

PbBlindedBellatrixBlock returns the underlying protobuf object.

func (*SignedBeaconBlock) PbBlindedCapellaBlock added in v3.2.0

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

PbBlindedCapellaBlock returns the underlying protobuf object.

func (*SignedBeaconBlock) PbCapellaBlock added in v3.2.0

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

PbCapellaBlock returns the underlying protobuf object.

func (*SignedBeaconBlock) PbGenericBlock

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

PbGenericBlock returns a generic signed beacon block.

func (*SignedBeaconBlock) PbPhase0Block

func (b *SignedBeaconBlock) PbPhase0Block() (*eth.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 added in v3.2.2

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

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

func (*SignedBeaconBlock) SetAttesterSlashings added in v3.2.2

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

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

func (*SignedBeaconBlock) SetBLSToExecutionChanges added in v3.2.2

func (b *SignedBeaconBlock) SetBLSToExecutionChanges(blsToExecutionChanges []*eth.SignedBLSToExecutionChange) error

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

func (*SignedBeaconBlock) SetBlinded added in v3.2.2

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) SetDeposits added in v3.2.2

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

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

func (*SignedBeaconBlock) SetEth1Data added in v3.2.2

func (b *SignedBeaconBlock) SetEth1Data(e *eth.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 added in v3.2.2

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 added in v3.2.2

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 added in v3.2.2

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 added in v3.2.2

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 added in v3.2.2

func (b *SignedBeaconBlock) SetProposerSlashings(p []*eth.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 added in v3.2.2

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 added in v3.2.1

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 added in v3.2.2

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 added in v3.2.2

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 added in v3.2.2

func (b *SignedBeaconBlock) SetSyncAggregate(s *eth.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 added in v3.2.2

func (b *SignedBeaconBlock) SetVoluntaryExits(v []*eth.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

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) 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