eth

package
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 23 Imported by: 12

Documentation

Index

Constants

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

Variables

View Source
var ErrBadTransactionOffset = errors.New("transactions offset is smaller than extra data offset, aborting")
View Source
var ErrExtraDataTooLarge = errors.New("extra data too large")

ErrExtraDataTooLarge occurs when the ExecutionPayload's ExtraData field is too large to be properly represented in SSZ.

Functions

func ForkchoiceUpdateErr

func ForkchoiceUpdateErr(payloadStatus PayloadStatusV1) error

func NewPayloadErr

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

func PollBlockChanges

func PollBlockChanges(ctx context.Context, 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 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

Types

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 BlockID

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

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
	ReceiptHash() common.Hash
}

type BlockLabel

type BlockLabel string

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 (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 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 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"`
}

func BlockAsPayload

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

func (*ExecutionPayload) CheckBlockHash

func (payload *ExecutionPayload) CheckBlockHash() (actual common.Hash, ok bool)

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

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(scope uint32, r io.Reader) error

UnmarshalSSZ decodes the ExecutionPayload 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 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 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 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 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"`
	// 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 = beacon.PayloadID

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 StorageProofEntry added in v0.10.5

type StorageProofEntry struct {
	Key   common.Hash     `json:"key"`
	Value hexutil.Bytes   `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"`
}

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, and is passed through opaquely to op-geth.
	Overhead Bytes32 `json:"overhead"`
	// Scalar identifies the L1 fee scalar, and is passed through opaquely to op-geth.
	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.

type Uint256Quantity

type Uint256Quantity = uint256.Int

type Uint64Quantity

type Uint64Quantity = hexutil.Uint64

Jump to

Keyboard shortcuts

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