beacon

package
v0.0.0-...-a59e565 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// VALID is returned by the engine API in the following calls:
	//   - newPayloadV1:       if the payload was already known or was just validated and executed
	//   - forkchoiceUpdateV1: if the chain accepted the reorg (might ignore if it's stale)
	VALID = "VALID"

	// INVALID is returned by the engine API in the following calls:
	//   - newPayloadV1:       if the payload failed to execute on top of the local chain
	//   - forkchoiceUpdateV1: if the new head is unknown, pre-merge, or reorg to it fails
	INVALID = "INVALID"

	// SYNCING is returned by the engine API in the following calls:
	//   - newPayloadV1:       if the payload was accepted on top of an active sync
	//   - forkchoiceUpdateV1: if the new head was seen before, but not part of the chain
	SYNCING = "SYNCING"

	// ACCEPTED is returned by the engine API in the following calls:
	//   - newPayloadV1: if the payload was accepted, but not processed (side chain)
	ACCEPTED = "ACCEPTED"

	INVALIDBLOCKHASH = "INVALID_BLOCK_HASH"

	GenericServerError       = &EngineAPIError{code: -32000, msg: "Server error"}
	UnknownPayload           = &EngineAPIError{code: -38001, msg: "Unknown payload"}
	InvalidForkChoiceState   = &EngineAPIError{code: -38002, msg: "Invalid forkchoice state"}
	InvalidPayloadAttributes = &EngineAPIError{code: -38003, msg: "Invalid payload attributes"}

	STATUS_INVALID         = ForkChoiceResponse{PayloadStatus: PayloadStatusV1{Status: INVALID}, PayloadID: nil}
	STATUS_SYNCING         = ForkChoiceResponse{PayloadStatus: PayloadStatusV1{Status: SYNCING}, PayloadID: nil}
	INVALID_TERMINAL_BLOCK = PayloadStatusV1{Status: INVALID, LatestValidHash: &common.Hash{}}
)

Functions

func ExecutableDataToBlock

func ExecutableDataToBlock(params ExecutableDataV1) (*types.Block, error)

ExecutableDataToBlock constructs a block from executable data. It verifies that the following fields:

len(extraData) <= 32
uncleHash = emptyUncleHash
difficulty = 0

and that the blockhash of the constructed block matches the parameters.

Types

type EngineAPIError

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

EngineAPIError is a standardized error message between consensus and execution clients, also containing any custom error message Geth might include.

func (*EngineAPIError) Error

func (e *EngineAPIError) Error() string

func (*EngineAPIError) ErrorCode

func (e *EngineAPIError) ErrorCode() int

func (*EngineAPIError) ErrorData

func (e *EngineAPIError) ErrorData() interface{}

func (*EngineAPIError) With

func (e *EngineAPIError) With(err error) *EngineAPIError

With returns a copy of the error with a new embedded custom data field.

type ExecutableDataV1

type ExecutableDataV1 struct {
	ParentHash    common.Hash    `json:"parentHash"    gencodec:"required"`
	FeeRecipient  common.Address `json:"feeRecipient"  gencodec:"required"`
	StateRoot     common.Hash    `json:"stateRoot"     gencodec:"required"`
	ReceiptsRoot  common.Hash    `json:"receiptsRoot"  gencodec:"required"`
	LogsBloom     []byte         `json:"logsBloom"     gencodec:"required"`
	Random        common.Hash    `json:"prevRandao"    gencodec:"required"`
	Number        uint64         `json:"blockNumber"   gencodec:"required"`
	GasLimit      uint64         `json:"gasLimit"      gencodec:"required"`
	GasUsed       uint64         `json:"gasUsed"       gencodec:"required"`
	Timestamp     uint64         `json:"timestamp"     gencodec:"required"`
	ExtraData     []byte         `json:"extraData"     gencodec:"required"`
	BaseFeePerGas *big.Int       `json:"baseFeePerGas" gencodec:"required"`
	BlockHash     common.Hash    `json:"blockHash"     gencodec:"required"`
	Transactions  [][]byte       `json:"transactions"  gencodec:"required"`
}

ExecutableDataV1 structure described at https://github.com/ethereum/execution-apis/tree/main/src/engine/specification.md

func BlockToExecutableData

func BlockToExecutableData(block *types.Block) *ExecutableDataV1

BlockToExecutableData constructs the executableDataV1 structure by filling the fields from the given block. It assumes the given block is post-merge block.

func (ExecutableDataV1) MarshalJSON

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

MarshalJSON marshals as JSON.

func (*ExecutableDataV1) UnmarshalJSON

func (e *ExecutableDataV1) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type ForkChoiceResponse

type ForkChoiceResponse struct {
	PayloadStatus PayloadStatusV1 `json:"payloadStatus"`
	PayloadID     *PayloadID      `json:"payloadId"`
}

type ForkchoiceStateV1

type ForkchoiceStateV1 struct {
	HeadBlockHash      common.Hash `json:"headBlockHash"`
	SafeBlockHash      common.Hash `json:"safeBlockHash"`
	FinalizedBlockHash common.Hash `json:"finalizedBlockHash"`
}

type PayloadAttributesV1

type PayloadAttributesV1 struct {
	Timestamp             uint64         `json:"timestamp"     gencodec:"required"`
	Random                common.Hash    `json:"prevRandao"        gencodec:"required"`
	SuggestedFeeRecipient common.Address `json:"suggestedFeeRecipient"  gencodec:"required"`
}

PayloadAttributesV1 structure described at https://github.com/ethereum/execution-apis/pull/74

func (PayloadAttributesV1) MarshalJSON

func (p PayloadAttributesV1) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*PayloadAttributesV1) UnmarshalJSON

func (p *PayloadAttributesV1) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type PayloadID

type PayloadID [8]byte

PayloadID is an identifier of the payload build process

func (PayloadID) MarshalText

func (b PayloadID) MarshalText() ([]byte, error)

func (PayloadID) String

func (b PayloadID) String() string

func (*PayloadID) UnmarshalText

func (b *PayloadID) UnmarshalText(input []byte) error

type PayloadStatusV1

type PayloadStatusV1 struct {
	Status          string       `json:"status"`
	LatestValidHash *common.Hash `json:"latestValidHash"`
	ValidationError *string      `json:"validationError"`
}

type TransitionConfigurationV1

type TransitionConfigurationV1 struct {
	TerminalTotalDifficulty *hexutil.Big   `json:"terminalTotalDifficulty"`
	TerminalBlockHash       common.Hash    `json:"terminalBlockHash"`
	TerminalBlockNumber     hexutil.Uint64 `json:"terminalBlockNumber"`
}

Jump to

Keyboard shortcuts

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