engineprimitives

package module
v0.0.0-...-8e558f0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: MIT Imports: 13 Imported by: 3

Documentation

Overview

Code generated by fastssz. DO NOT EDIT. Hash: ffde4e56be9a6b2ce3f8e8f25cdcd31ab614d6a2e90237ebe81190b7b677ab27 Version: 0.1.3

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidTimestamp indicates that the provided timestamp is not valid.
	ErrInvalidTimestamp = errors.New("invalid timestamp")
	// ErrInvalidRandao indicates that the provided RANDAO value is not valid.
	ErrInvalidRandao = errors.New("invalid randao")
	// ErrNilWithdrawals indicates that the withdrawals are in a
	// Capella versioned payload.
	ErrNilWithdrawals = errors.New("nil withdrawals post capella")
	// ErrEmptyPrevRandao indicates that the previous RANDAO value is empty.
	ErrEmptyPrevRandao = errors.New("empty randao")
)
View Source
var (
	// ExecutableDataToBlock constructs a block from executable data.
	ExecutableDataToBlock = engine.ExecutableDataToBlock
)

Functions

This section is empty.

Types

type BlobsBundle

type BlobsBundle interface {
	// GetCommitments returns the commitments in the blobs bundle.
	GetCommitments() []eip4844.KZGCommitment
	// GetProofs returns the proofs in the blobs bundle.
	GetProofs() []eip4844.KZGProof
	// GetBlobs returns the blobs in the blobs bundle.
	GetBlobs() []*eip4844.Blob
}

BlobsBundle is an interface for the blobs bundle.

type BlobsBundleV1

type BlobsBundleV1[
	C, P ~[48]byte, B ~[131072]byte,
] struct {
	// Commitments are the KZG commitments included in the bundle.
	Commitments []C `json:"commitments"`
	// Proofs are the KZG proofs corresponding to the commitments.
	Proofs []P `json:"proofs"`
	// Blobs are arbitrary data blobs included in the bundle.
	Blobs []*B `json:"blobs"`
}

BlobsBundleV1 represents a collection of commitments, proofs, and blobs. Each field is a slice of bytes that are serialized for transmission or storage.

func (*BlobsBundleV1[C, P, B]) GetBlobs

func (b *BlobsBundleV1[C, P, B]) GetBlobs() []*B

GetBlobs returns the slice of data blobs in the bundle.

func (*BlobsBundleV1[C, P, B]) GetCommitments

func (b *BlobsBundleV1[C, P, B]) GetCommitments() []C

GetCommitments returns the slice of commitments in the bundle.

func (*BlobsBundleV1[C, P, B]) GetProofs

func (b *BlobsBundleV1[C, P, B]) GetProofs() []P

GetProofs returns the slice of proofs in the bundle.

type Block

type Block = coretypes.Block

Block represents a block on the execution layer.

type BuiltExecutionPayloadEnv

type BuiltExecutionPayloadEnv interface {
	// GetExecutionPayload retrieves the associated execution payload.
	GetExecutionPayload() ExecutionPayload
	// GetValue returns the Wei value of the block in the execution payload.
	GetValue() math.Wei
	// GetBlobsBundle fetches the associated BlobsBundleV1 if available.
	GetBlobsBundle() BlobsBundle
	// ShouldOverrideBuilder indicates if the builder should be overridden.
	ShouldOverrideBuilder() bool
}

BuiltExecutionPayloadEnv is an interface for the execution payload envelope.

type ClientVersionV1

type ClientVersionV1 = engine.ClientVersionV1

There are some types we can borrow from geth.

type ExecutableData

type ExecutableData = engine.ExecutableData

There are some types we can borrow from geth.

type ExecutionPayload

type ExecutionPayload interface {
	ExecutionPayloadBody
	GetTransactions() [][]byte
	// TODO: decouple from consensus-types
	GetWithdrawals() []*Withdrawal
}

ExecutionPayload represents the execution data of a block.

type ExecutionPayloadBody

type ExecutionPayloadBody interface {
	ssz.Marshaler
	ssz.Unmarshaler
	ssz.HashRoot
	IsNil() bool
	Version() uint32
	IsBlinded() bool
	GetPrevRandao() primitives.Bytes32
	GetBlockHash() common.ExecutionHash
	GetParentHash() common.ExecutionHash
	GetNumber() math.U64
	GetGasLimit() math.U64
	GetGasUsed() math.U64
	GetTimestamp() math.U64
	GetExtraData() []byte
	GetBaseFeePerGas() math.Wei
	GetFeeRecipient() common.ExecutionAddress
	GetStateRoot() primitives.Bytes32
	GetReceiptsRoot() primitives.Bytes32
	GetLogsBloom() []byte
	GetBlobGasUsed() math.U64
	GetExcessBlobGas() math.U64
}

ExecutionPayloadBody is the interface for the execution data of a block. It contains all the fields that are part of both an execution payload header and a full execution payload.

type ExecutionPayloadEnvelope

type ExecutionPayloadEnvelope[
	ExecutionPayloadT ExecutionPayload,
	BlobsBundleT BlobsBundle,
] struct {
	ExecutionPayload ExecutionPayloadT `json:"executionPayload"`
	BlockValue       math.Wei          `json:"blockValue"`
	BlobsBundle      BlobsBundleT      `json:"blobsBundle"`
	Override         bool              `json:"shouldOverrideBuilder"`
}

ExecutionPayloadEnvelope is a struct that holds the execution payload and its associated data. It utilizes a generic type ExecutionData to allow for different types of execution payloads depending on the active hard fork.

func (*ExecutionPayloadEnvelope[ExecutionPayloadT, BlobsBundleT]) GetBlobsBundle

func (e *ExecutionPayloadEnvelope[
	ExecutionPayloadT, BlobsBundleT,
]) GetBlobsBundle() BlobsBundle

GetBlobsBundle returns the blobs bundle of the ExecutionPayloadEnvelope.

func (*ExecutionPayloadEnvelope[ExecutionPayloadT, BlobsBundleT]) GetExecutionPayload

func (e *ExecutionPayloadEnvelope[
	ExecutionPayloadT, BlobsBundleT,
]) GetExecutionPayload() ExecutionPayload

GetExecutionPayload returns the execution payload of the ExecutionPayloadEnvelope.

func (*ExecutionPayloadEnvelope[ExecutionPayloadT, BlobsBundleT]) GetValue

func (e *ExecutionPayloadEnvelope[
	ExecutionPayloadT, BlobsBundleT,
]) GetValue() math.Wei

GetValue returns the value of the ExecutionPayloadEnvelope.

func (*ExecutionPayloadEnvelope[ExecutionPayloadT, BlobsBundleT]) ShouldOverrideBuilder

func (e *ExecutionPayloadEnvelope[
	ExecutionPayloadT, BlobsBundleT,
]) ShouldOverrideBuilder() bool

ShouldOverrideBuilder returns whether the builder should be overridden.

type ExecutionPayloadHeader

type ExecutionPayloadHeader interface {
	ExecutionPayloadBody
	GetTransactionsRoot() primitives.Root
	GetWithdrawalsRoot() primitives.Root
}

ExecutionPayloadHeader represents the execution header of a block.

type ForkchoiceResponseV1

type ForkchoiceResponseV1 struct {
	// PayloadStatus is the payload status.
	PayloadStatus PayloadStatusV1 `json:"payloadStatus"`

	// PayloadID isthe identifier of the payload build process, it
	// can also be `nil`.
	PayloadID *PayloadID `json:"payloadId"`
}

ForkchoiceResponseV1 as per the EngineAPI Specification: https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#response-2

type ForkchoiceStateV1

type ForkchoiceStateV1 struct {
	// HeadBlockHash is the desired block hash of the head of the canonical
	// chain.
	HeadBlockHash common.ExecutionHash `json:"headBlockHash"`

	// SafeBlockHash is  the "safe" block hash of the canonical chain under
	// certain
	// synchrony and honesty assumptions. This value MUST be either equal to
	// or an ancestor of `HeadBlockHash`.
	SafeBlockHash common.ExecutionHash `json:"safeBlockHash"`

	// FinalizedBlockHash is the desired block hash of the most recent finalized
	// block
	FinalizedBlockHash common.ExecutionHash `json:"finalizedBlockHash"`
}

ForkchoicStateV1 as per the EngineAPI Specification: https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#forkchoicestatev1

type ForkchoiceUpdateRequest

type ForkchoiceUpdateRequest struct {
	// State is the forkchoice state.
	State *ForkchoiceStateV1
	// PayloadAttributes is the payload attributer.
	PayloadAttributes PayloadAttributer
	// ForkVersion is the fork version that we
	// are going to be submitting for.
	ForkVersion uint32
}

ForkchoiceUpdateRequest.

func BuildForkchoiceUpdateRequest

func BuildForkchoiceUpdateRequest(
	state *ForkchoiceStateV1,
	payloadAttributes PayloadAttributer,
	forkVersion uint32,
) *ForkchoiceUpdateRequest

BuildForkchoiceUpdateRequest builds a forkchoice update request.

type GetPayloadRequest

type GetPayloadRequest struct {
	// PayloadID is the payload ID.
	PayloadID PayloadID
	// ForkVersion is the fork version that we are
	// currently on.
	ForkVersion uint32
}

GetPayloadRequest represents a request to get a payload.

func BuildGetPayloadRequest

func BuildGetPayloadRequest(
	payloadID PayloadID,
	forkVersion uint32,
) *GetPayloadRequest

BuildGetPayloadRequest builds a get payload request.

type Header = coretypes.Header

Header represents a header on the execution layer.

type Log

type Log = coretypes.Log

Log represents a log on the execution layer.

type NewPayloadRequest

type NewPayloadRequest[
	ExecutionPayloadT interface {
		GetTransactions() [][]byte
		Version() uint32
	},
] struct {
	// ExecutionPayload is the payload to the execution client.
	ExecutionPayload ExecutionPayloadT
	// VersionedHashes is the versioned hashes of the execution payload.
	VersionedHashes []common.ExecutionHash
	// ParentBeaconBlockRoot is the root of the parent beacon block.
	ParentBeaconBlockRoot *primitives.Root
	// SkipIfExists is a flag that indicates if the payload should be skipped
	// if it alreadyexists in the database of the execution client.
	SkipIfExists bool
	// Optimistic is a flag that indicates if the payload should be
	// optimistically deemed valid. This is useful during syncing.
	Optimistic bool
}

NewPayloadRequest as per the Ethereum 2.0 specification: https://github.com/ethereum/consensus-specs/blob/dev/specs/deneb/beacon-chain.md#modified-newpayloadrequest

func BuildNewPayloadRequest

func BuildNewPayloadRequest[
	ExecutionPayloadT interface {
		GetTransactions() [][]byte
		Version() uint32
	},
](
	executionPayload ExecutionPayloadT,
	versionedHashes []common.ExecutionHash,
	parentBeaconBlockRoot *primitives.Root,
	skipIfExists bool,
	optimistic bool,
) *NewPayloadRequest[ExecutionPayloadT]

BuildNewPayloadRequest builds a new payload request.

func (*NewPayloadRequest[ExecutionPayloadT]) HasValidVersionedAndBlockHashes

func (n *NewPayloadRequest[ExecutionPayloadT]) HasValidVersionedAndBlockHashes() error

HasHValidVersionAndBlockHashes checks if the version and block hashes are valid. As per the Ethereum 2.0 specification: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/beacon-chain.md#is_valid_block_hash https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/beacon-chain.md#is_valid_versioned_hashes

type PayloadAttributer

type PayloadAttributer interface {
	// IsNil returns true if the PayloadAttributer is nil.
	IsNil() bool

	// Version returns the version of the PayloadAttributer.
	Version() uint32

	// Validate checks if the PayloadAttributer is valid and returns an error if
	// it is not.
	Validate() error

	// GetSuggestedFeeRecipient returns the suggested fee recipient for the
	// block.
	GetSuggestedFeeRecipient() common.ExecutionAddress
}

PayloadAttributer represents payload attributes of a block.

type PayloadAttributes

type PayloadAttributes[
	Withdrawal SSZMarshallable,
] struct {

	// Timestamp is the timestamp at which the block will be built at.
	Timestamp math.U64 `json:"timestamp"`
	// PrevRandao is the previous Randao value from the beacon chain as
	// per EIP-4399.
	PrevRandao primitives.Bytes32 `json:"prevRandao"`
	// SuggestedFeeRecipient is the suggested fee recipient for the block. If
	// the execution client has a different fee recipient, it will typically
	// ignore this value.
	SuggestedFeeRecipient common.ExecutionAddress `json:"suggestedFeeRecipient"`
	// Withdrawals is the list of withdrawals to be included in the block as per
	// EIP-4895
	Withdrawals []Withdrawal `json:"withdrawals"`
	// ParentBeaconBlockRoot is the root of the parent beacon block. (The block
	// prior)
	// to the block currently being processed. This field was added for
	// EIP-4788.
	ParentBeaconBlockRoot primitives.Root `json:"parentBeaconBlockRoot"`
	// contains filtered or unexported fields
}

func NewPayloadAttributes

func NewPayloadAttributes[
	Withdrawal SSZMarshallable,
](
	forkVersion uint32,
	timestamp uint64,
	prevRandao primitives.Bytes32,
	suggestedFeeRecipient common.ExecutionAddress,
	withdrawals []Withdrawal,
	parentBeaconBlockRoot primitives.Root,
) (*PayloadAttributes[Withdrawal], error)

NewPayloadAttributes creates a new PayloadAttributes.

func (*PayloadAttributes[Withdrawal]) GetSuggestedFeeRecipient

func (p *PayloadAttributes[Withdrawal]) GetSuggestedFeeRecipient() common.ExecutionAddress

GetSuggestionsFeeRecipient returns the suggested fee recipient.

func (*PayloadAttributes[Withdrawal]) IsNil

func (p *PayloadAttributes[Withdrawal]) IsNil() bool

IsNil returns true if the PayloadAttributes is nil.

func (*PayloadAttributes[Withdrawal]) Validate

func (p *PayloadAttributes[Withdrawal]) Validate() error

Validate validates the PayloadAttributes.

func (*PayloadAttributes[Withdrawal]) Version

func (p *PayloadAttributes[Withdrawal]) Version() uint32

Version returns the version of the PayloadAttributes.

type PayloadID

type PayloadID = bytes.B8

PayloadID is an identifier for the payload build process.

type PayloadStatusStr

type PayloadStatusStr = string
var (
	// PayloadStatusValid is the status of a valid payload.
	PayloadStatusValid PayloadStatusStr = "VALID"
	// PayloadStatusInvalid is the status of an invalid payload.
	PayloadStatusInvalid PayloadStatusStr = "INVALID"
	// PayloadStatusSyncing is the status returned when the EL is syncing.
	PayloadStatusSyncing PayloadStatusStr = "SYNCING"
	// PayloadStatusAccepted is the status returned when the EL has accepted the
	// payload.
	PayloadStatusAccepted PayloadStatusStr = "ACCEPTED"
)

type PayloadStatusV1

type PayloadStatusV1 struct {
	// Status string of the payload.
	Status string `json:"status"`

	// LatestValidHash is the hash of the most recent valid block
	// in the branch defined by payload and its ancestors
	LatestValidHash *common.ExecutionHash `json:"latestValidHash"`

	// ValidationError is a message providing additional details on
	// the validation error if the payload is classified as
	// INVALID or INVALID_BLOCK_HASH
	ValidationError *string `json:"validationError"`
}

PayloadStatusV1 represents the status of a payload as per the EngineAPI Specification. For more details, see: https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#payloadstatusv1

type SSZMarshallable

type SSZMarshallable interface {
	// MarshalSSZTo marshals the object into the provided byte slice and returns
	// it along with any error.
	MarshalSSZTo([]byte) ([]byte, error)
	// MarshalSSZ marshals the object into a new byte slice and returns it along
	// with any error.
	MarshalSSZ() ([]byte, error)
	// UnmarshalSSZ unmarshals the object from the provided byte slice and
	// returns an error if the unmarshaling fails.
	UnmarshalSSZ([]byte) error
	// SizeSSZ returns the size in bytes that the object would take when
	// marshaled.
	SizeSSZ() int
}

Marshallable is an interface that combines the ssz.Marshaler and ssz.Unmarshaler interfaces.

type Transactions

type Transactions [][]byte

Transactions is a typealias for [][]byte, which is how transactions are received in the execution payload.

func (Transactions) HashTreeRoot

func (txs Transactions) HashTreeRoot() (primitives.Root, error)

HashTreeRoot returns the hash tree root of the Transactions list.

type Withdrawal

type Withdrawal struct {
	Index     math.U64                `json:"index"`
	Validator math.ValidatorIndex     `json:"validatorIndex"`
	Address   common.ExecutionAddress `json:"address"        ssz-size:"20"`
	Amount    math.Gwei               `json:"amount"`
}

Withdrawal represents a validator withdrawal from the consensus layer.

func (*Withdrawal) Equals

func (w *Withdrawal) Equals(other *Withdrawal) bool

Equals returns true if the Withdrawal is equal to the other.

func (*Withdrawal) GetTree

func (w *Withdrawal) GetTree() (*ssz.Node, error)

GetTree ssz hashes the Withdrawal object

func (*Withdrawal) HashTreeRoot

func (w *Withdrawal) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the Withdrawal object

func (*Withdrawal) HashTreeRootWith

func (w *Withdrawal) HashTreeRootWith(hh ssz.HashWalker) (err error)

HashTreeRootWith ssz hashes the Withdrawal object with a hasher

func (*Withdrawal) MarshalSSZ

func (w *Withdrawal) MarshalSSZ() ([]byte, error)

MarshalSSZ ssz marshals the Withdrawal object

func (*Withdrawal) MarshalSSZTo

func (w *Withdrawal) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo ssz marshals the Withdrawal object to a target array

func (*Withdrawal) SizeSSZ

func (w *Withdrawal) SizeSSZ() (size int)

SizeSSZ returns the ssz encoded size in bytes for the Withdrawal object

func (*Withdrawal) UnmarshalSSZ

func (w *Withdrawal) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ ssz unmarshals the Withdrawal object

type Withdrawals

type Withdrawals []*Withdrawal

Withdrawals represents a slice of withdrawals.

func (Withdrawals) HashTreeRoot

func (w Withdrawals) HashTreeRoot() (common.Root, error)

HashTreeRoot returns the hash tree root of the Withdrawals list.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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