eth

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 29 Imported by: 75

Documentation

Index

Constants

View Source
const (
	BlobSize        = 4096 * 32
	MaxBlobDataSize = (4*31+3)*1024 - 4
	EncodingVersion = 0
	VersionOffset   = 1    // offset of the version byte in the blob encoding
	Rounds          = 1024 // number of encode/decode rounds
)
View Source
const (
	// Unsafe is:
	// - L1: absolute head of the chain
	// - L2: absolute head of the chain, not confirmed on L1
	Unsafe = "latest"
	// Safe is:
	// - L1: Justified checkpoint, beacon chain: 1 epoch of 2/3 of the validators attesting the epoch.
	// - L2: Derived chain tip from L1 data
	Safe = "safe"
	// Finalized is:
	// - L1: Finalized checkpoint, beacon chain: 2+ justified epochs with "supermajority link" (see FFG docs).
	//       More about FFG: https://ethereum.org/en/developers/docs/consensus-mechanisms/pos/gasper/
	// - L2: Derived chain tip from finalized L1 data
	Finalized = "finalized"
)
View Source
const (
	// L1ScalarBedrock is implied pre-Ecotone, encoding just a regular-gas scalar.
	L1ScalarBedrock = byte(0)
	// L1ScalarEcotone is new in Ecotone, allowing configuration of both a regular and a blobs scalar.
	L1ScalarEcotone = byte(1)
)

The Ecotone upgrade introduces a versioned L1 scalar format that is backward-compatible with pre-Ecotone L1 scalar values.

Variables

View Source
var (
	ErrBlobInvalidFieldElement        = errors.New("invalid field element")
	ErrBlobInvalidEncodingVersion     = errors.New("invalid encoding version")
	ErrBlobInvalidLength              = errors.New("invalid length for blob")
	ErrBlobInputTooLarge              = errors.New("too much data to encode in one blob")
	ErrBlobExtraneousData             = errors.New("non-zero data encountered where blob should be empty")
	ErrBlobExtraneousDataFieldElement = errors.New("non-zero data encountered where field element should be empty")
)
View Source
var (
	ErrInvalidOutput        = errors.New("invalid output")
	ErrInvalidOutputVersion = errors.New("invalid output version")

	OutputVersionV0 = Bytes32{}
)
View Source
var (

	// ErrExtraDataTooLarge occurs when the ExecutionPayload's ExtraData field
	// is too large to be properly represented in SSZ.
	ErrExtraDataTooLarge = errors.New("extra data too large")

	ErrBadTransactionOffset = errors.New("transactions offset is smaller than extra data offset, aborting")
	ErrBadWithdrawalsOffset = errors.New("withdrawals offset is smaller than transaction offset, aborting")

	ErrMissingData = errors.New("execution payload envelope is missing data")
)
View Source
var ErrBedrockScalarPaddingNotEmpty = errors.New("version 0 scalar value has non-empty padding")

Functions

func AddressAsLeftPaddedHash added in v1.4.2

func AddressAsLeftPaddedHash(addr common.Address) (out common.Hash)

AddressAsLeftPaddedHash converts an address to a hash by left-padding it with zeros. No hashing is performed. This was previously known as Address.Hash(), but removed from go-ethereum in PR 28228, because the naming was not clear.

func CheckEcotoneL1SystemConfigScalar added in v1.5.0

func CheckEcotoneL1SystemConfigScalar(scalar [32]byte) error

func CheckRecentTxs added in v1.7.4

func CheckRecentTxs(
	ctx context.Context,
	l1 L1Client,
	depth int,
	addr common.Address,
) (recentBlock uint64, found bool, err error)

CheckRecentTxs checks the depth recent blocks for transactions from the account with address addr and returns the most recent block and true, if any was found, or the oldest block checked and false, if not.

func DecodeRawReceipts

func DecodeRawReceipts(block BlockID, rawReceipts []hexutil.Bytes, txHashes []common.Hash) ([]*types.Receipt, error)

DecodeRawReceipts decodes receipts and adds additional blocks metadata. The contract-deployment addresses are not set however (high cost, depends on nonce values, unused by op-node).

func DecodeTransactions

func DecodeTransactions(data []hexutil.Bytes) ([]*types.Transaction, error)

DecodeTransactions decodes a list of opaque transactions into transactions.

func EncodeReceipts

func EncodeReceipts(elems []*types.Receipt) ([]hexutil.Bytes, error)

EncodeReceipts encodes a list of receipts into raw receipts. Some non-consensus meta-data may be lost.

func EncodeScalar added in v1.7.3

func EncodeScalar(scalars EcostoneScalars) (scalar [32]byte)

EncodeScalar encodes the EcostoneScalars into a 32-byte scalar value for the Ecotone serialization format.

func EncodeTransactions

func EncodeTransactions(elems []*types.Transaction) ([]hexutil.Bytes, error)

EncodeTransactions encodes a list of transactions into opaque transactions.

func ForkchoiceUpdateErr

func ForkchoiceUpdateErr(payloadStatus PayloadStatusV1) error

func GweiToWei added in v1.4.3

func GweiToWei(gwei float64) (*big.Int, error)

func KZGToVersionedHash added in v1.4.2

func KZGToVersionedHash(commitment kzg4844.Commitment) (out common.Hash)

KZGToVersionedHash computes the "blob hash" (a.k.a. versioned-hash) of a blob-commitment, as used in a blob-tx. We implement it here because it is unfortunately not (currently) exposed by geth.

func NewPayloadErr

func NewPayloadErr(payload *ExecutionPayload, payloadStatus *PayloadStatusV1) error

func PollBlockChanges

func PollBlockChanges(log log.Logger, src L1BlockRefsSource, fn HeadSignalFn,
	label BlockLabel, interval time.Duration, timeout time.Duration) ethereum.Subscription

PollBlockChanges opens a polling loop to fetch the L1 block reference with the given label, on provided interval and with request timeout. Results are returned with provided callback fn, which may block to pause/back-pressure polling.

func TransactionsToHashes

func TransactionsToHashes(elems []*types.Transaction) []common.Hash

TransactionsToHashes computes the transaction-hash for every transaction in the input.

func VerifyBlobProof added in v1.4.2

func VerifyBlobProof(blob *Blob, commitment kzg4844.Commitment, proof kzg4844.Proof) error

VerifyBlobProof verifies that the given blob and proof corresponds to the given commitment, returning error if the verification fails.

func WatchHeadChanges

func WatchHeadChanges(ctx context.Context, src NewHeadSource, fn HeadSignalFn) (ethereum.Subscription, error)

WatchHeadChanges wraps a new-head subscription from NewHeadSource to feed the given Tracker. The ctx is only used to create the subscription, and does not affect the returned subscription.

Types

type APIBlobSidecar added in v1.5.0

type APIBlobSidecar struct {
	Index             Uint64String            `json:"index"`
	Blob              Blob                    `json:"blob"`
	KZGCommitment     Bytes48                 `json:"kzg_commitment"`
	KZGProof          Bytes48                 `json:"kzg_proof"`
	SignedBlockHeader SignedBeaconBlockHeader `json:"signed_block_header"`
}

func (*APIBlobSidecar) BlobSidecar added in v1.5.0

func (sc *APIBlobSidecar) BlobSidecar() *BlobSidecar

type APIConfigResponse added in v1.4.2

type APIConfigResponse struct {
	Data ReducedConfigData `json:"data"`
}

type APIGenesisResponse added in v1.4.2

type APIGenesisResponse struct {
	Data ReducedGenesisData `json:"data"`
}

type APIGetBlobSidecarsResponse added in v1.4.2

type APIGetBlobSidecarsResponse struct {
	Data []*APIBlobSidecar `json:"data"`
}

type APIVersionResponse added in v1.5.0

type APIVersionResponse struct {
	Data VersionInformation `json:"data"`
}

type AccountResult

type AccountResult struct {
	AccountProof []hexutil.Bytes `json:"accountProof"`

	Address     common.Address `json:"address"`
	Balance     *hexutil.Big   `json:"balance"`
	CodeHash    common.Hash    `json:"codeHash"`
	Nonce       hexutil.Uint64 `json:"nonce"`
	StorageHash common.Hash    `json:"storageHash"`

	// Optional
	StorageProof []StorageProofEntry `json:"storageProof,omitempty"`
}

func (*AccountResult) Verify

func (res *AccountResult) Verify(stateRoot common.Hash) error

Verify an account (and optionally storage) proof from the getProof RPC. See https://eips.ethereum.org/EIPS/eip-1186

type BeaconBlockHeader added in v1.5.0

type BeaconBlockHeader struct {
	Slot          Uint64String `json:"slot"`
	ProposerIndex Uint64String `json:"proposer_index"`
	ParentRoot    Bytes32      `json:"parent_root"`
	StateRoot     Bytes32      `json:"state_root"`
	BodyRoot      Bytes32      `json:"body_root"`
}

type Blob added in v1.4.2

type Blob [BlobSize]byte

func (*Blob) Clear added in v1.4.3

func (b *Blob) Clear()

func (*Blob) ComputeKZGCommitment added in v1.4.2

func (b *Blob) ComputeKZGCommitment() (kzg4844.Commitment, error)

func (*Blob) FromData added in v1.4.3

func (b *Blob) FromData(data Data) error

FromData encodes the given input data into this blob. The encoding scheme is as follows:

In each round we perform 7 reads of input of lengths (31,1,31,1,31,1,31) bytes respectively for a total of 127 bytes. This data is encoded into the next 4 field elements of the output by placing each of the 4x31 byte chunks into bytes [1:32] of its respective field element. The three single byte chunks (24 bits) are split into 4x6-bit chunks, each of which is written into the top most byte of its respective field element, leaving the top 2 bits of each field element empty to avoid modulus overflow. This process is repeated for up to 1024 rounds until all data is encoded.

For only the very first output field, bytes [1:5] are used to encode the version and the length of the data.

func (*Blob) KZGBlob added in v1.4.2

func (b *Blob) KZGBlob() *kzg4844.Blob

func (*Blob) MarshalText added in v1.4.2

func (b *Blob) MarshalText() ([]byte, error)

func (*Blob) String added in v1.4.2

func (b *Blob) String() string

func (*Blob) TerminalString added in v1.4.2

func (b *Blob) TerminalString() string

TerminalString implements log.TerminalStringer, formatting a string for console output during logging.

func (*Blob) ToData added in v1.4.3

func (b *Blob) ToData() (Data, error)

ToData decodes the blob into raw byte data. See FromData above for details on the encoding format. If error is returned it will be one of InvalidFieldElementError, InvalidEncodingVersionError and InvalidLengthError.

func (*Blob) UnmarshalJSON added in v1.4.2

func (b *Blob) UnmarshalJSON(text []byte) error

func (*Blob) UnmarshalText added in v1.4.2

func (b *Blob) UnmarshalText(text []byte) error

type BlobSidecar added in v1.4.2

type BlobSidecar struct {
	Blob          Blob         `json:"blob"`
	Index         Uint64String `json:"index"`
	KZGCommitment Bytes48      `json:"kzg_commitment"`
	KZGProof      Bytes48      `json:"kzg_proof"`
}

type BlockID

type BlockID struct {
	Hash   common.Hash `json:"hash"`
	Number uint64      `json:"number"`
}

func HeaderBlockID added in v1.4.3

func HeaderBlockID(h *types.Header) BlockID

func ReceiptBlockID added in v1.4.3

func ReceiptBlockID(r *types.Receipt) BlockID

func ToBlockID

func ToBlockID(b NumberAndHash) BlockID

func (BlockID) String

func (id BlockID) String() string

func (BlockID) TerminalString

func (id BlockID) TerminalString() string

TerminalString implements log.TerminalStringer, formatting a string for console output during logging.

type BlockInfo

type BlockInfo interface {
	Hash() common.Hash
	ParentHash() common.Hash
	Coinbase() common.Address
	Root() common.Hash // state-root
	NumberU64() uint64
	Time() uint64
	// MixDigest field, reused for randomness after The Merge (Bellatrix hardfork)
	MixDigest() common.Hash
	BaseFee() *big.Int
	// BlobBaseFee returns the result of computing the blob fee from excessDataGas, or nil if the
	// block isn't a Dencun (4844 capable) block
	BlobBaseFee() *big.Int
	ReceiptHash() common.Hash
	GasUsed() uint64
	GasLimit() uint64
	ParentBeaconRoot() *common.Hash // Dencun extension

	// HeaderRLP returns the RLP of the block header as per consensus rules
	// Returns an error if the header RLP could not be written
	HeaderRLP() ([]byte, error)
}

func BlockToInfo

func BlockToInfo(b *types.Block) BlockInfo

func HeaderBlockInfo

func HeaderBlockInfo(h *types.Header) BlockInfo

HeaderBlockInfo returns h as a BlockInfo implementation.

type BlockLabel

type BlockLabel string

func (BlockLabel) Arg

func (label BlockLabel) Arg() any

func (BlockLabel) CheckID

func (BlockLabel) CheckID(id BlockID) error

type BlockVersion added in v1.4.2

type BlockVersion int
const (
	BlockV1 BlockVersion = iota
	BlockV2
	BlockV3
)

func (BlockVersion) HasBlobProperties added in v1.5.0

func (v BlockVersion) HasBlobProperties() bool

func (BlockVersion) HasParentBeaconBlockRoot added in v1.5.0

func (v BlockVersion) HasParentBeaconBlockRoot() bool

func (BlockVersion) HasWithdrawals added in v1.5.0

func (v BlockVersion) HasWithdrawals() bool

type Bytes256

type Bytes256 [256]byte

func (Bytes256) MarshalText

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

func (Bytes256) String

func (b Bytes256) String() string

func (Bytes256) TerminalString

func (b Bytes256) TerminalString() string

TerminalString implements log.TerminalStringer, formatting a string for console output during logging.

func (*Bytes256) UnmarshalJSON

func (b *Bytes256) UnmarshalJSON(text []byte) error

func (*Bytes256) UnmarshalText

func (b *Bytes256) UnmarshalText(text []byte) error

type Bytes32

type Bytes32 [32]byte

func OutputRoot

func OutputRoot(output Output) Bytes32

OutputRoot returns the keccak256 hash of the marshaled L2 output

func (Bytes32) MarshalText

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

func (Bytes32) String

func (b Bytes32) String() string

func (Bytes32) TerminalString

func (b Bytes32) TerminalString() string

TerminalString implements log.TerminalStringer, formatting a string for console output during logging.

func (*Bytes32) UnmarshalJSON

func (b *Bytes32) UnmarshalJSON(text []byte) error

func (*Bytes32) UnmarshalText

func (b *Bytes32) UnmarshalText(text []byte) error

type Bytes48 added in v1.4.2

type Bytes48 [48]byte

func (Bytes48) MarshalText added in v1.4.2

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

func (Bytes48) String added in v1.4.2

func (b Bytes48) String() string

func (Bytes48) TerminalString added in v1.4.2

func (b Bytes48) TerminalString() string

TerminalString implements log.TerminalStringer, formatting a string for console output during logging.

func (*Bytes48) UnmarshalJSON added in v1.4.2

func (b *Bytes48) UnmarshalJSON(text []byte) error

func (*Bytes48) UnmarshalText added in v1.4.2

func (b *Bytes48) UnmarshalText(text []byte) error

type Bytes96 added in v1.5.0

type Bytes96 [96]byte

func (Bytes96) MarshalText added in v1.5.0

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

func (Bytes96) String added in v1.5.0

func (b Bytes96) String() string

func (Bytes96) TerminalString added in v1.5.0

func (b Bytes96) TerminalString() string

TerminalString implements log.TerminalStringer, formatting a string for console output during logging.

func (*Bytes96) UnmarshalJSON added in v1.5.0

func (b *Bytes96) UnmarshalJSON(text []byte) error

func (*Bytes96) UnmarshalText added in v1.5.0

func (b *Bytes96) UnmarshalText(text []byte) error

type BytesMax32

type BytesMax32 []byte

func (BytesMax32) MarshalText

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

func (BytesMax32) String

func (b BytesMax32) String() string

func (*BytesMax32) UnmarshalJSON

func (b *BytesMax32) UnmarshalJSON(text []byte) error

func (*BytesMax32) UnmarshalText

func (b *BytesMax32) UnmarshalText(text []byte) error

type Data

type Data = hexutil.Bytes

type EcostoneScalars added in v1.7.3

type EcostoneScalars struct {
	BlobBaseFeeScalar uint32
	BaseFeeScalar     uint32
}

func DecodeScalar added in v1.7.3

func DecodeScalar(scalar [32]byte) (EcostoneScalars, error)

DecodeScalar decodes the blobBaseFeeScalar and baseFeeScalar from a 32-byte scalar value. It uses the first byte to determine the scalar format.

type EngineAPIMethod added in v1.5.1

type EngineAPIMethod string
const (
	FCUV1 EngineAPIMethod = "engine_forkchoiceUpdatedV1"
	FCUV2 EngineAPIMethod = "engine_forkchoiceUpdatedV2"
	FCUV3 EngineAPIMethod = "engine_forkchoiceUpdatedV3"

	NewPayloadV2 EngineAPIMethod = "engine_newPayloadV2"
	NewPayloadV3 EngineAPIMethod = "engine_newPayloadV3"

	GetPayloadV2 EngineAPIMethod = "engine_getPayloadV2"
	GetPayloadV3 EngineAPIMethod = "engine_getPayloadV3"
)

type ErrorCode

type ErrorCode int
const (
	UnknownPayload           ErrorCode = -32001 // Payload does not exist / is not available.
	InvalidForkchoiceState   ErrorCode = -38002 // Forkchoice state is invalid / inconsistent.
	InvalidPayloadAttributes ErrorCode = -38003 // Payload attributes are invalid / inconsistent.
)

type ExecutePayloadStatus

type ExecutePayloadStatus string
const (
	// given payload is valid
	ExecutionValid ExecutePayloadStatus = "VALID"
	// given payload is invalid
	ExecutionInvalid ExecutePayloadStatus = "INVALID"
	// sync process is in progress
	ExecutionSyncing ExecutePayloadStatus = "SYNCING"
	// returned if the payload is not fully validated, and does not extend the canonical chain,
	// but will be remembered for later (on reorgs or sync updates and such)
	ExecutionAccepted ExecutePayloadStatus = "ACCEPTED"
	// if the block-hash in the payload is not correct
	ExecutionInvalidBlockHash ExecutePayloadStatus = "INVALID_BLOCK_HASH"
	// proof-of-stake transition only, not used in rollup
	ExecutionInvalidTerminalBlock ExecutePayloadStatus = "INVALID_TERMINAL_BLOCK"
)

type ExecutionPayload

type ExecutionPayload struct {
	ParentHash    common.Hash     `json:"parentHash"`
	FeeRecipient  common.Address  `json:"feeRecipient"`
	StateRoot     Bytes32         `json:"stateRoot"`
	ReceiptsRoot  Bytes32         `json:"receiptsRoot"`
	LogsBloom     Bytes256        `json:"logsBloom"`
	PrevRandao    Bytes32         `json:"prevRandao"`
	BlockNumber   Uint64Quantity  `json:"blockNumber"`
	GasLimit      Uint64Quantity  `json:"gasLimit"`
	GasUsed       Uint64Quantity  `json:"gasUsed"`
	Timestamp     Uint64Quantity  `json:"timestamp"`
	ExtraData     BytesMax32      `json:"extraData"`
	BaseFeePerGas Uint256Quantity `json:"baseFeePerGas"`
	BlockHash     common.Hash     `json:"blockHash"`
	// Array of transaction objects, each object is a byte list (DATA) representing
	// TransactionType || TransactionPayload or LegacyTransaction as defined in EIP-2718
	Transactions []Data `json:"transactions"`
	// Nil if not present (Bedrock)
	Withdrawals *types.Withdrawals `json:"withdrawals,omitempty"`
	// Nil if not present (Bedrock, Canyon, Delta)
	BlobGasUsed *Uint64Quantity `json:"blobGasUsed,omitempty"`
	// Nil if not present (Bedrock, Canyon, Delta)
	ExcessBlobGas *Uint64Quantity `json:"excessBlobGas,omitempty"`
}

func BlockAsPayload

func BlockAsPayload(bl *types.Block, canyonForkTime *uint64) (*ExecutionPayload, error)

func (*ExecutionPayload) CanyonBlock added in v1.4.2

func (payload *ExecutionPayload) CanyonBlock() bool

func (*ExecutionPayload) ID

func (payload *ExecutionPayload) ID() BlockID

func (*ExecutionPayload) MarshalSSZ

func (payload *ExecutionPayload) MarshalSSZ(w io.Writer) (n int, err error)

MarshalSSZ encodes the ExecutionPayload as SSZ type

func (*ExecutionPayload) ParentID

func (payload *ExecutionPayload) ParentID() BlockID

func (*ExecutionPayload) SizeSSZ

func (payload *ExecutionPayload) SizeSSZ() (full uint32)

func (*ExecutionPayload) UnmarshalSSZ

func (payload *ExecutionPayload) UnmarshalSSZ(version BlockVersion, scope uint32, r io.Reader) error

UnmarshalSSZ decodes the ExecutionPayload as SSZ type

type ExecutionPayloadEnvelope added in v1.4.2

type ExecutionPayloadEnvelope struct {
	ParentBeaconBlockRoot *common.Hash      `json:"parentBeaconBlockRoot,omitempty"`
	ExecutionPayload      *ExecutionPayload `json:"executionPayload"`
}

func BlockAsPayloadEnv added in v1.7.2

func BlockAsPayloadEnv(bl *types.Block, canyonForkTime *uint64) (*ExecutionPayloadEnvelope, error)

func (*ExecutionPayloadEnvelope) CheckBlockHash added in v1.5.0

func (envelope *ExecutionPayloadEnvelope) CheckBlockHash() (actual common.Hash, ok bool)

CheckBlockHash recomputes the block hash and returns if the embedded block hash matches.

func (*ExecutionPayloadEnvelope) MarshalSSZ added in v1.5.0

func (envelope *ExecutionPayloadEnvelope) MarshalSSZ(w io.Writer) (n int, err error)

MarshalSSZ encodes the ExecutionPayload as SSZ type

func (*ExecutionPayloadEnvelope) UnmarshalSSZ added in v1.5.0

func (envelope *ExecutionPayloadEnvelope) UnmarshalSSZ(scope uint32, r io.Reader) error

UnmarshalSSZ decodes the ExecutionPayloadEnvelope as SSZ type

type ForkchoiceState

type ForkchoiceState struct {
	// block hash of the head of the canonical chain
	HeadBlockHash common.Hash `json:"headBlockHash"`
	// safe block hash in the canonical chain
	SafeBlockHash common.Hash `json:"safeBlockHash"`
	// block hash of the most recent finalized block
	FinalizedBlockHash common.Hash `json:"finalizedBlockHash"`
}

type ForkchoiceUpdatedResult

type ForkchoiceUpdatedResult struct {
	// the result of the payload execution
	PayloadStatus PayloadStatusV1 `json:"payloadStatus"`
	// the payload id if requested
	PayloadID *PayloadID `json:"payloadId"`
}

type HeadSignalFn

type HeadSignalFn func(ctx context.Context, sig L1BlockRef)

HeadSignalFn is used as callback function to accept head-signals

type IndexedBlobHash added in v1.4.3

type IndexedBlobHash struct {
	Index uint64      // absolute index in the block, a.k.a. position in sidecar blobs array
	Hash  common.Hash // hash of the blob, used for consistency checks
}

IndexedBlobHash represents a blob hash that commits to a single blob confirmed in a block. The index helps us avoid unnecessary blob to blob hash conversions to find the right content in a sidecar.

type InputError

type InputError struct {
	Inner error
	Code  ErrorCode
}

InputError distinguishes an user-input error from regular rpc errors, to help the (Engine) API user divert from accidental input mistakes.

func (InputError) Error

func (ie InputError) Error() string

func (InputError) Is

func (ie InputError) Is(target error) bool

Is checks if the error is the given target type. Any type of InputError counts, regardless of code.

func (InputError) Unwrap

func (ie InputError) Unwrap() error

type L1BlockRef

type L1BlockRef struct {
	Hash       common.Hash `json:"hash"`
	Number     uint64      `json:"number"`
	ParentHash common.Hash `json:"parentHash"`
	Time       uint64      `json:"timestamp"`
}

func InfoToL1BlockRef

func InfoToL1BlockRef(info BlockInfo) L1BlockRef

func (L1BlockRef) ID

func (id L1BlockRef) ID() BlockID

func (L1BlockRef) ParentID

func (id L1BlockRef) ParentID() BlockID

func (L1BlockRef) String

func (id L1BlockRef) String() string

func (L1BlockRef) TerminalString

func (id L1BlockRef) TerminalString() string

TerminalString implements log.TerminalStringer, formatting a string for console output during logging.

type L1BlockRefsSource

type L1BlockRefsSource interface {
	L1BlockRefByLabel(ctx context.Context, label BlockLabel) (L1BlockRef, error)
}

type L1Client added in v1.7.4

type L1Client interface {
	HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
	NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
}

type L2BlockRef

type L2BlockRef struct {
	Hash           common.Hash `json:"hash"`
	Number         uint64      `json:"number"`
	ParentHash     common.Hash `json:"parentHash"`
	Time           uint64      `json:"timestamp"`
	L1Origin       BlockID     `json:"l1origin"`
	SequenceNumber uint64      `json:"sequenceNumber"` // distance to first block of epoch
}

func (L2BlockRef) ID

func (id L2BlockRef) ID() BlockID

func (L2BlockRef) ParentID

func (id L2BlockRef) ParentID() BlockID

func (L2BlockRef) String

func (id L2BlockRef) String() string

func (L2BlockRef) TerminalString

func (id L2BlockRef) TerminalString() string

TerminalString implements log.TerminalStringer, formatting a string for console output during logging.

type NewHeadSource

type NewHeadSource interface {
	SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)
}

type NumberAndHash

type NumberAndHash interface {
	Hash() common.Hash
	NumberU64() uint64
}

type Output

type Output interface {
	// Version returns the version of the L2 output
	Version() Bytes32

	// Marshal a L2 output into a byte slice for hashing
	Marshal() []byte
}

func UnmarshalOutput

func UnmarshalOutput(data []byte) (Output, error)

type OutputResponse

type OutputResponse struct {
	Version               Bytes32     `json:"version"`
	OutputRoot            Bytes32     `json:"outputRoot"`
	BlockRef              L2BlockRef  `json:"blockRef"`
	WithdrawalStorageRoot common.Hash `json:"withdrawalStorageRoot"`
	StateRoot             common.Hash `json:"stateRoot"`
	Status                *SyncStatus `json:"syncStatus"`
}

type OutputV0

type OutputV0 struct {
	StateRoot                Bytes32
	MessagePasserStorageRoot Bytes32
	BlockHash                common.Hash
}

func (*OutputV0) Marshal

func (o *OutputV0) Marshal() []byte

func (*OutputV0) Version

func (o *OutputV0) Version() Bytes32

type PayloadAttributes

type PayloadAttributes struct {
	// value for the timestamp field of the new payload
	Timestamp Uint64Quantity `json:"timestamp"`
	// value for the random field of the new payload
	PrevRandao Bytes32 `json:"prevRandao"`
	// suggested value for the coinbase field of the new payload
	SuggestedFeeRecipient common.Address `json:"suggestedFeeRecipient"`
	// Withdrawals to include into the block -- should be nil or empty depending on Shanghai enablement
	Withdrawals *types.Withdrawals `json:"withdrawals,omitempty"`
	// parentBeaconBlockRoot optional extension in Dencun
	ParentBeaconBlockRoot *common.Hash `json:"parentBeaconBlockRoot,omitempty"`

	// Transactions to force into the block (always at the start of the transactions list).
	Transactions []Data `json:"transactions,omitempty"`
	// NoTxPool to disable adding any transactions from the transaction-pool.
	NoTxPool bool `json:"noTxPool,omitempty"`
	// GasLimit override
	GasLimit *Uint64Quantity `json:"gasLimit,omitempty"`
}

type PayloadID

type PayloadID = engine.PayloadID

type PayloadInfo added in v1.5.1

type PayloadInfo struct {
	ID        PayloadID
	Timestamp uint64
}

type PayloadStatusV1

type PayloadStatusV1 struct {
	// the result of the payload execution
	Status ExecutePayloadStatus `json:"status"`
	// the hash of the most recent valid block in the branch defined by payload and its ancestors (optional field)
	LatestValidHash *common.Hash `json:"latestValidHash,omitempty"`
	// additional details on the result (optional field)
	ValidationError *string `json:"validationError,omitempty"`
}

type ReducedConfigData added in v1.4.2

type ReducedConfigData struct {
	SecondsPerSlot Uint64String `json:"SECONDS_PER_SLOT"`
}

type ReducedGenesisData added in v1.4.2

type ReducedGenesisData struct {
	GenesisTime Uint64String `json:"genesis_time"`
}

type SafeHeadResponse added in v1.7.2

type SafeHeadResponse struct {
	L1Block  BlockID `json:"l1Block"`
	SafeHead BlockID `json:"safeHead"`
}

type SignedBeaconBlockHeader added in v1.5.0

type SignedBeaconBlockHeader struct {
	Message BeaconBlockHeader `json:"message"`
}

type StorageProofEntry

type StorageProofEntry struct {
	Key   common.Hash     `json:"key"`
	Value hexutil.Big     `json:"value"`
	Proof []hexutil.Bytes `json:"proof"`
}

type SyncStatus

type SyncStatus struct {
	// CurrentL1 is the L1 block that the derivation process is currently at in the inner-most stage.
	// This may not be fully derived into L2 data yet.
	// The safe L2 blocks were produced/included fully from the L1 chain up to and including this L1 block.
	// If the node is synced, this matches the HeadL1, minus the verifier confirmation distance.
	CurrentL1 L1BlockRef `json:"current_l1"`
	// CurrentL1Finalized is the L1 block that the derivation process is currently accepting as finalized
	// in the inner-most stage,
	// This may not be fully derived into L2 data yet.
	// The finalized L2 blocks were produced/included fully from the L1 chain up to and including this L1 block.
	// This may lag behind the FinalizedL1 when the FinalizedL1 could not yet be verified
	// to be canonical w.r.t. the currently derived L2 chain. It may be zeroed if no block could be verified yet.
	CurrentL1Finalized L1BlockRef `json:"current_l1_finalized"`
	// HeadL1 is the perceived head of the L1 chain, no confirmation distance.
	// The head is not guaranteed to build on the other L1 sync status fields,
	// as the node may be in progress of resetting to adapt to a L1 reorg.
	HeadL1      L1BlockRef `json:"head_l1"`
	SafeL1      L1BlockRef `json:"safe_l1"`
	FinalizedL1 L1BlockRef `json:"finalized_l1"`
	// UnsafeL2 is the absolute tip of the L2 chain,
	// pointing to block data that has not been submitted to L1 yet.
	// The sequencer is building this, and verifiers may also be ahead of the
	// SafeL2 block if they sync blocks via p2p or other offchain sources.
	UnsafeL2 L2BlockRef `json:"unsafe_l2"`
	// SafeL2 points to the L2 block that was derived from the L1 chain.
	// This point may still reorg if the L1 chain reorgs.
	SafeL2 L2BlockRef `json:"safe_l2"`
	// FinalizedL2 points to the L2 block that was derived fully from
	// finalized L1 information, thus irreversible.
	FinalizedL2 L2BlockRef `json:"finalized_l2"`
	// PendingSafeL2 points to the L2 block processed from the batch, but not consolidated to the safe block yet.
	PendingSafeL2 L2BlockRef `json:"pending_safe_l2"`
}

SyncStatus is a snapshot of the driver. Values may be zeroed if not yet initialized.

type SystemConfig

type SystemConfig struct {
	// BatcherAddr identifies the batch-sender address used in batch-inbox data-transaction filtering.
	BatcherAddr common.Address `json:"batcherAddr"`
	// Overhead identifies the L1 fee overhead.
	// Pre-Ecotone this is passed as-is to the engine.
	// Post-Ecotone this is always zero, and not passed into the engine.
	Overhead Bytes32 `json:"overhead"`
	// Scalar identifies the L1 fee scalar
	// Pre-Ecotone this is passed as-is to the engine.
	// Post-Ecotone this encodes multiple pieces of scalar data.
	Scalar Bytes32 `json:"scalar"`
	// GasLimit identifies the L2 block gas limit
	GasLimit uint64 `json:"gasLimit"`
}

SystemConfig represents the rollup system configuration that carries over in every L2 block, and may be changed through L1 system config events. The initial SystemConfig at rollup genesis is embedded in the rollup configuration.

func (*SystemConfig) EcotoneScalars added in v1.5.0

func (sysCfg *SystemConfig) EcotoneScalars() (EcostoneScalars, error)

type Uint256Quantity

type Uint256Quantity = hexutil.U256

type Uint64Quantity

type Uint64Quantity = hexutil.Uint64

type Uint64String added in v1.4.2

type Uint64String uint64

Uint64String is a decimal string representation of an uint64, for usage in the Beacon API JSON encoding

func (Uint64String) MarshalText added in v1.4.2

func (v Uint64String) MarshalText() (out []byte, err error)

func (*Uint64String) UnmarshalText added in v1.4.2

func (v *Uint64String) UnmarshalText(b []byte) error

type VersionInformation added in v1.5.0

type VersionInformation struct {
	Version string `json:"version"`
}

Jump to

Keyboard shortcuts

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