blocks

package
v3.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: GPL-3.0 Imports: 15 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 BeaconBlockIsNil

func BeaconBlockIsNil(b interfaces.SignedBeaconBlock) 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.BeaconBlock, signature []byte) (interfaces.SignedBeaconBlock, error)

BuildSignedBeaconBlock assembles a block.SignedBeaconBlock 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.SignedBeaconBlock, payload *enginev1.ExecutionPayload,
) (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.BeaconBlock, error)

NewBeaconBlock creates a beacon block from a protobuf beacon block.

func NewBeaconBlockBody

func NewBeaconBlockBody(i interface{}) (interfaces.BeaconBlockBody, 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 WrappedExecutionPayload

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

WrappedExecutionPayload 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.

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

func (b *BeaconBlock) HashTreeRoot() ([32]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() []byte

ParentRoot returns the parent root of beacon block.

func (*BeaconBlock) ProposerIndex

func (b *BeaconBlock) ProposerIndex() types.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() types.Slot

Slot returns the respective slot of the block.

func (*BeaconBlock) StateRoot

func (b *BeaconBlock) StateRoot() []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) 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

func (b *BeaconBlockBody) Graffiti() []byte

Graffiti returns the graffiti in the block.

func (*BeaconBlockBody) HashTreeRoot

func (b *BeaconBlockBody) HashTreeRoot() ([32]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

func (b *BeaconBlockBody) RandaoReveal() []byte

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

func (b *SignedBeaconBlock) Signature() []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) 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