Documentation ¶
Overview ¶
Package sources exports a number of clients used to access ethereum chain data.
There are a number of these exported clients used by the op-node: L1Client wraps an RPC client to retrieve L1 ethereum data. L2Client wraps an RPC client to retrieve L2 ethereum data. RollupClient wraps an RPC client to retrieve rollup data. EngineClient extends the L2Client providing engine API bindings.
Internally, the listed clients wrap an EthClient which itself wraps a specified RPC client.
Index ¶
- Variables
- func LimitRPC(c client.RPC, concurrentRequests int) client.RPC
- func ValidRPCProviderKind(value RPCProviderKind) bool
- type BasicRPCReceiptsFetcher
- type BeaconClient
- type BeaconHTTPClient
- func (cl *BeaconHTTPClient) BeaconBlobSideCars(ctx context.Context, fetchAllSidecars bool, slot uint64, ...) (eth.APIGetBlobSidecarsResponse, error)
- func (cl *BeaconHTTPClient) BeaconGenesis(ctx context.Context) (eth.APIGenesisResponse, error)
- func (cl *BeaconHTTPClient) ConfigSpec(ctx context.Context) (eth.APIConfigResponse, error)
- func (cl *BeaconHTTPClient) NodeVersion(ctx context.Context) (string, error)
- type BlobSideCarsFetcher
- type CachingReceiptsProvider
- type ClientPool
- type DebugClient
- type EngineAPIClient
- func (s *EngineAPIClient) EngineVersionProvider() EngineVersionProvider
- func (s *EngineAPIClient) ForkchoiceUpdate(ctx context.Context, fc *eth.ForkchoiceState, ...) (*eth.ForkchoiceUpdatedResult, error)
- func (s *EngineAPIClient) GetPayload(ctx context.Context, payloadInfo eth.PayloadInfo) (*eth.ExecutionPayloadEnvelope, error)
- func (s *EngineAPIClient) NewPayload(ctx context.Context, payload *eth.ExecutionPayload, ...) (*eth.PayloadStatusV1, error)
- func (s *EngineAPIClient) SignalSuperchainV1(ctx context.Context, recommended, required params.ProtocolVersion) (params.ProtocolVersion, error)
- type EngineClient
- type EngineClientConfig
- type EngineVersionProvider
- type EthClient
- func (s *EthClient) ChainID(ctx context.Context) (*big.Int, error)
- func (s *EthClient) Close()
- func (s *EthClient) ExecutionWitness(ctx context.Context, blockNum uint64) (*eth.ExecutionWitness, error)
- func (s *EthClient) FetchReceipts(ctx context.Context, blockHash common.Hash) (eth.BlockInfo, types.Receipts, error)
- func (s *EthClient) GetProof(ctx context.Context, address common.Address, storage []common.Hash, ...) (*eth.AccountResult, error)
- func (s *EthClient) GetStorageAt(ctx context.Context, address common.Address, storageSlot common.Hash, ...) (common.Hash, error)
- func (s *EthClient) InfoAndTxsByHash(ctx context.Context, hash common.Hash) (eth.BlockInfo, types.Transactions, error)
- func (s *EthClient) InfoAndTxsByLabel(ctx context.Context, label eth.BlockLabel) (eth.BlockInfo, types.Transactions, error)
- func (s *EthClient) InfoAndTxsByNumber(ctx context.Context, number uint64) (eth.BlockInfo, types.Transactions, error)
- func (s *EthClient) InfoByHash(ctx context.Context, hash common.Hash) (eth.BlockInfo, error)
- func (s *EthClient) InfoByLabel(ctx context.Context, label eth.BlockLabel) (eth.BlockInfo, error)
- func (s *EthClient) InfoByNumber(ctx context.Context, number uint64) (eth.BlockInfo, error)
- func (s *EthClient) PayloadByHash(ctx context.Context, hash common.Hash) (*eth.ExecutionPayloadEnvelope, error)
- func (s *EthClient) PayloadByLabel(ctx context.Context, label eth.BlockLabel) (*eth.ExecutionPayloadEnvelope, error)
- func (s *EthClient) PayloadByNumber(ctx context.Context, number uint64) (*eth.ExecutionPayloadEnvelope, error)
- func (s *EthClient) ReadStorageAt(ctx context.Context, address common.Address, storageSlot common.Hash, ...) (common.Hash, error)
- func (s *EthClient) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)
- type EthClientConfig
- type L1BeaconClient
- func (cl *L1BeaconClient) GetBlobSidecars(ctx context.Context, ref eth.L1BlockRef, hashes []eth.IndexedBlobHash) ([]*eth.BlobSidecar, error)
- func (cl *L1BeaconClient) GetBlobs(ctx context.Context, ref eth.L1BlockRef, hashes []eth.IndexedBlobHash) ([]*eth.Blob, error)
- func (cl *L1BeaconClient) GetTimeToSlotFn(ctx context.Context) (TimeToSlotFn, error)
- func (cl *L1BeaconClient) GetVersion(ctx context.Context) (string, error)
- type L1BeaconClientConfig
- type L1Client
- type L1ClientConfig
- type L2Client
- func (s *L2Client) L2BlockRefByHash(ctx context.Context, hash common.Hash) (eth.L2BlockRef, error)
- func (s *L2Client) L2BlockRefByLabel(ctx context.Context, label eth.BlockLabel) (eth.L2BlockRef, error)
- func (s *L2Client) L2BlockRefByNumber(ctx context.Context, num uint64) (eth.L2BlockRef, error)
- func (s *L2Client) OutputV0AtBlock(ctx context.Context, blockHash common.Hash) (*eth.OutputV0, error)
- func (s *L2Client) RollupConfig() *rollup.Config
- func (s *L2Client) SystemConfigByL2Hash(ctx context.Context, hash common.Hash) (eth.SystemConfig, error)
- type L2ClientConfig
- type RPCBlock
- type RPCHeader
- type RPCProviderKind
- type RPCReceiptsConfig
- type RPCReceiptsFetcher
- func (f *RPCReceiptsFetcher) FetchReceipts(ctx context.Context, blockInfo eth.BlockInfo, txHashes []common.Hash) (result types.Receipts, err error)
- func (f *RPCReceiptsFetcher) OnReceiptsMethodErr(m ReceiptsFetchingMethod, err error)
- func (f *RPCReceiptsFetcher) PickReceiptsMethod(txCount int) ReceiptsFetchingMethod
- type ReceiptsFetchingMethod
- type ReceiptsProvider
- type RollupClient
- func (r *RollupClient) Close()
- func (r *RollupClient) ConductorEnabled(ctx context.Context) (bool, error)
- func (r *RollupClient) OutputAtBlock(ctx context.Context, blockNum uint64) (*eth.OutputResponse, error)
- func (r *RollupClient) OverrideLeader(ctx context.Context) error
- func (r *RollupClient) PostUnsafePayload(ctx context.Context, payload *eth.ExecutionPayloadEnvelope) error
- func (r *RollupClient) RollupConfig(ctx context.Context) (*rollup.Config, error)
- func (r *RollupClient) SafeHeadAtL1Block(ctx context.Context, blockNum uint64) (*eth.SafeHeadResponse, error)
- func (r *RollupClient) SequencerActive(ctx context.Context) (bool, error)
- func (r *RollupClient) SetLogLevel(ctx context.Context, lvl slog.Level) error
- func (r *RollupClient) StartSequencer(ctx context.Context, unsafeHead common.Hash) error
- func (r *RollupClient) StopSequencer(ctx context.Context) (common.Hash, error)
- func (r *RollupClient) SyncStatus(ctx context.Context) (*eth.SyncStatus, error)
- func (r *RollupClient) Version(ctx context.Context) (string, error)
- type SupervisorClient
- func (cl *SupervisorClient) AddL2RPC(ctx context.Context, rpc string) error
- func (cl *SupervisorClient) CheckMessage(ctx context.Context, identifier types.Identifier, logHash common.Hash) (types.SafetyLevel, error)
- func (cl *SupervisorClient) Close()
- func (cl *SupervisorClient) CrossDerivedFrom(ctx context.Context, chainID types.ChainID, derived eth.BlockID) (eth.BlockRef, error)
- func (cl *SupervisorClient) Finalized(ctx context.Context, chainID types.ChainID) (eth.BlockID, error)
- func (cl *SupervisorClient) SafeView(ctx context.Context, chainID types.ChainID, safe types.ReferenceView) (types.ReferenceView, error)
- func (cl *SupervisorClient) Start(ctx context.Context) error
- func (cl *SupervisorClient) Stop(ctx context.Context) error
- func (cl *SupervisorClient) UnsafeView(ctx context.Context, chainID types.ChainID, unsafe types.ReferenceView) (types.ReferenceView, error)
- func (cl *SupervisorClient) UpdateFinalizedL1(ctx context.Context, chainID types.ChainID, finalizedL1 eth.L1BlockRef) error
- func (cl *SupervisorClient) UpdateLocalSafe(ctx context.Context, chainID types.ChainID, derivedFrom eth.L1BlockRef, ...) error
- func (cl *SupervisorClient) UpdateLocalUnsafe(ctx context.Context, chainID types.ChainID, head eth.BlockRef) error
- type TimeToSlotFn
Constants ¶
This section is empty.
Variables ¶
var RPCProviderKinds = []RPCProviderKind{ RPCKindAlchemy, RPCKindQuickNode, RPCKindInfura, RPCKindParity, RPCKindNethermind, RPCKindDebugGeth, RPCKindErigon, RPCKindBasic, RPCKindAny, RPCKindStandard, }
Functions ¶
func LimitRPC ¶
LimitRPC limits concurrent RPC requests (excluding subscriptions) to a given number by wrapping the client with a semaphore.
func ValidRPCProviderKind ¶
func ValidRPCProviderKind(value RPCProviderKind) bool
Types ¶
type BasicRPCReceiptsFetcher ¶ added in v1.4.2
type BasicRPCReceiptsFetcher struct {
// contains filtered or unexported fields
}
func NewBasicRPCReceiptsFetcher ¶ added in v1.4.2
func NewBasicRPCReceiptsFetcher(client rpcClient, maxBatchSize int) *BasicRPCReceiptsFetcher
func (*BasicRPCReceiptsFetcher) FetchReceipts ¶ added in v1.4.2
func (f *BasicRPCReceiptsFetcher) FetchReceipts(ctx context.Context, blockInfo eth.BlockInfo, txHashes []common.Hash) (types.Receipts, error)
FetchReceipts fetches receipts for the given block and transaction hashes it does not validate receipts, and expects the caller to do so
type BeaconClient ¶ added in v1.6.1
type BeaconClient interface { NodeVersion(ctx context.Context) (string, error) ConfigSpec(ctx context.Context) (eth.APIConfigResponse, error) BeaconGenesis(ctx context.Context) (eth.APIGenesisResponse, error) BeaconBlobSideCars(ctx context.Context, fetchAllSidecars bool, slot uint64, hashes []eth.IndexedBlobHash) (eth.APIGetBlobSidecarsResponse, error) }
BeaconClient is a thin wrapper over the Beacon APIs.
type BeaconHTTPClient ¶ added in v1.6.1
type BeaconHTTPClient struct {
// contains filtered or unexported fields
}
BeaconHTTPClient implements BeaconClient. It provides golang types over the basic Beacon API.
func NewBeaconHTTPClient ¶ added in v1.6.1
func NewBeaconHTTPClient(cl client.HTTP) *BeaconHTTPClient
func (*BeaconHTTPClient) BeaconBlobSideCars ¶ added in v1.6.1
func (cl *BeaconHTTPClient) BeaconBlobSideCars(ctx context.Context, fetchAllSidecars bool, slot uint64, hashes []eth.IndexedBlobHash) (eth.APIGetBlobSidecarsResponse, error)
func (*BeaconHTTPClient) BeaconGenesis ¶ added in v1.6.1
func (cl *BeaconHTTPClient) BeaconGenesis(ctx context.Context) (eth.APIGenesisResponse, error)
func (*BeaconHTTPClient) ConfigSpec ¶ added in v1.6.1
func (cl *BeaconHTTPClient) ConfigSpec(ctx context.Context) (eth.APIConfigResponse, error)
func (*BeaconHTTPClient) NodeVersion ¶ added in v1.6.1
func (cl *BeaconHTTPClient) NodeVersion(ctx context.Context) (string, error)
type BlobSideCarsFetcher ¶ added in v1.6.1
type BlobSideCarsFetcher interface {
BeaconBlobSideCars(ctx context.Context, fetchAllSidecars bool, slot uint64, hashes []eth.IndexedBlobHash) (eth.APIGetBlobSidecarsResponse, error)
}
BlobSideCarsFetcher is a thin wrapper over the Beacon APIs.
type CachingReceiptsProvider ¶ added in v1.4.2
type CachingReceiptsProvider struct {
// contains filtered or unexported fields
}
A CachingReceiptsProvider caches successful receipt fetches from the inner ReceiptsProvider. It also avoids duplicate in-flight requests per block hash.
func NewCachingRPCReceiptsProvider ¶ added in v1.4.2
func NewCachingRPCReceiptsProvider(client rpcClient, log log.Logger, config RPCReceiptsConfig, m caching.Metrics, cacheSize int) *CachingReceiptsProvider
func NewCachingReceiptsProvider ¶ added in v1.4.2
func NewCachingReceiptsProvider(inner ReceiptsProvider, m caching.Metrics, cacheSize int) *CachingReceiptsProvider
func (*CachingReceiptsProvider) FetchReceipts ¶ added in v1.4.2
func (p *CachingReceiptsProvider) FetchReceipts(ctx context.Context, blockInfo eth.BlockInfo, txHashes []common.Hash) (types.Receipts, error)
FetchReceipts fetches receipts for the given block and transaction hashes it expects that the inner FetchReceipts implementation handles validation
type ClientPool ¶ added in v1.6.1
type ClientPool[T any] struct { // contains filtered or unexported fields }
func NewClientPool ¶ added in v1.6.1
func NewClientPool[T any](clients ...T) *ClientPool[T]
func (*ClientPool[T]) Get ¶ added in v1.6.1
func (p *ClientPool[T]) Get() T
func (*ClientPool[T]) Len ¶ added in v1.6.1
func (p *ClientPool[T]) Len() int
func (*ClientPool[T]) MoveToNext ¶ added in v1.6.1
func (p *ClientPool[T]) MoveToNext()
type DebugClient ¶
type DebugClient struct {
// contains filtered or unexported fields
}
func NewDebugClient ¶
func NewDebugClient(callContext batching.CallContextFn) *DebugClient
func (*DebugClient) CodeByHash ¶
func (*DebugClient) NodeByHash ¶
type EngineAPIClient ¶ added in v1.7.2
EngineAPIClient is an RPC client for the Engine API functions.
func NewEngineAPIClient ¶ added in v1.7.2
func NewEngineAPIClient(rpc client.RPC, l log.Logger, evp EngineVersionProvider) *EngineAPIClient
func NewEngineAPIClientWithTimeout ¶ added in v1.9.3
func NewEngineAPIClientWithTimeout(rpc client.RPC, l log.Logger, evp EngineVersionProvider, timeout time.Duration) *EngineAPIClient
func (*EngineAPIClient) EngineVersionProvider ¶ added in v1.7.2
func (s *EngineAPIClient) EngineVersionProvider() EngineVersionProvider
EngineVersionProvider returns the underlying engine version provider used for resolving the correct Engine API versions.
func (*EngineAPIClient) ForkchoiceUpdate ¶ added in v1.7.2
func (s *EngineAPIClient) ForkchoiceUpdate(ctx context.Context, fc *eth.ForkchoiceState, attributes *eth.PayloadAttributes) (*eth.ForkchoiceUpdatedResult, error)
ForkchoiceUpdate updates the forkchoice on the execution client. If attributes is not nil, the engine client will also begin building a block based on attributes after the new head block and return the payload ID. It's the caller's responsibility to check the error type, and in case of an rpc.Error, check the ErrorCode.
func (*EngineAPIClient) GetPayload ¶ added in v1.7.2
func (s *EngineAPIClient) GetPayload(ctx context.Context, payloadInfo eth.PayloadInfo) (*eth.ExecutionPayloadEnvelope, error)
GetPayload gets the execution payload associated with the PayloadId. It's the caller's responsibility to check the error type, and in case of an rpc.Error, check the ErrorCode.
func (*EngineAPIClient) NewPayload ¶ added in v1.7.2
func (s *EngineAPIClient) NewPayload(ctx context.Context, payload *eth.ExecutionPayload, parentBeaconBlockRoot *common.Hash) (*eth.PayloadStatusV1, error)
NewPayload executes a full block on the execution engine. This returns a PayloadStatusV1 which encodes any validation/processing error, and this type of error is kept separate from the returned `error` used for RPC errors, like timeouts.
func (*EngineAPIClient) SignalSuperchainV1 ¶ added in v1.7.2
func (s *EngineAPIClient) SignalSuperchainV1(ctx context.Context, recommended, required params.ProtocolVersion) (params.ProtocolVersion, error)
type EngineClient ¶
type EngineClient struct { *L2Client *EngineAPIClient }
EngineClient extends L2Client with engine API bindings.
func NewEngineClient ¶
func NewEngineClient(client client.RPC, log log.Logger, metrics caching.Metrics, config *EngineClientConfig) (*EngineClient, error)
type EngineClientConfig ¶
type EngineClientConfig struct {
L2ClientConfig
}
func EngineClientDefaultConfig ¶
func EngineClientDefaultConfig(config *rollup.Config) *EngineClientConfig
type EngineVersionProvider ¶ added in v1.7.2
type EngineVersionProvider interface { ForkchoiceUpdatedVersion(attr *eth.PayloadAttributes) eth.EngineAPIMethod NewPayloadVersion(timestamp uint64) eth.EngineAPIMethod GetPayloadVersion(timestamp uint64) eth.EngineAPIMethod }
type EthClient ¶
type EthClient struct {
// contains filtered or unexported fields
}
EthClient retrieves ethereum data with optimized batch requests, cached results, and flag to not trust the RPC.
func NewEthClient ¶
func NewEthClient(client client.RPC, log log.Logger, metrics caching.Metrics, config *EthClientConfig) (*EthClient, error)
NewEthClient returns an EthClient, wrapping an RPC with bindings to fetch ethereum data with added error logging, metric tracking, and caching. The EthClient uses a LimitRPC wrapper to limit the number of concurrent RPC requests.
func (*EthClient) ExecutionWitness ¶ added in v1.9.5
func (s *EthClient) ExecutionWitness(ctx context.Context, blockNum uint64) (*eth.ExecutionWitness, error)
ExecutionWitness fetches execution witness data for a block number.
func (*EthClient) FetchReceipts ¶
func (s *EthClient) FetchReceipts(ctx context.Context, blockHash common.Hash) (eth.BlockInfo, types.Receipts, error)
FetchReceipts returns a block info and all of the receipts associated with transactions in the block. It verifies the receipt hash in the block header against the receipt hash of the fetched receipts to ensure that the execution engine did not fail to return any receipts.
func (*EthClient) GetProof ¶
func (s *EthClient) GetProof(ctx context.Context, address common.Address, storage []common.Hash, blockTag string) (*eth.AccountResult, error)
GetProof returns an account proof result, with any optional requested storage proofs. The retrieval does sanity-check that storage proofs for the expected keys are present in the response, but does not verify the result. Call accountResult.Verify(stateRoot) to verify the result.
func (*EthClient) GetStorageAt ¶
func (s *EthClient) GetStorageAt(ctx context.Context, address common.Address, storageSlot common.Hash, blockTag string) (common.Hash, error)
GetStorageAt returns the storage value at the given address and storage slot, **without verifying the correctness of the result**. This should only ever be used as alternative to GetProof when the user opts in. E.g. Erigon L1 node users may have to use this, since Erigon does not support eth_getProof, see https://github.com/ledgerwatch/erigon/issues/1349
func (*EthClient) InfoAndTxsByHash ¶
func (*EthClient) InfoAndTxsByLabel ¶
func (s *EthClient) InfoAndTxsByLabel(ctx context.Context, label eth.BlockLabel) (eth.BlockInfo, types.Transactions, error)
func (*EthClient) InfoAndTxsByNumber ¶
func (*EthClient) InfoByHash ¶
func (*EthClient) InfoByLabel ¶
func (*EthClient) InfoByNumber ¶
func (*EthClient) PayloadByHash ¶
func (*EthClient) PayloadByLabel ¶
func (s *EthClient) PayloadByLabel(ctx context.Context, label eth.BlockLabel) (*eth.ExecutionPayloadEnvelope, error)
func (*EthClient) PayloadByNumber ¶
func (*EthClient) ReadStorageAt ¶
func (s *EthClient) ReadStorageAt(ctx context.Context, address common.Address, storageSlot common.Hash, blockHash common.Hash) (common.Hash, error)
ReadStorageAt is a convenience method to read a single storage value at the given slot in the given account. The storage slot value is verified against the state-root of the given block if we do not trust the RPC provider, or directly retrieved without proof if we do trust the RPC.
type EthClientConfig ¶
type EthClientConfig struct { // Maximum number of requests to make per batch MaxRequestsPerBatch int // limit concurrent requests, applies to the source as a whole MaxConcurrentRequests int // Number of blocks worth of receipts to cache ReceiptsCacheSize int // Number of blocks worth of transactions to cache TransactionsCacheSize int // Number of block headers to cache HeadersCacheSize int // Number of payloads to cache PayloadsCacheSize int // If the RPC is untrusted, then we should not use cached information from responses, // and instead verify against the block-hash. // Of real L1 blocks no deposits can be missed/faked, no batches can be missed/faked, // only the wrong L1 blocks can be retrieved. TrustRPC bool // If the RPC must ensure that the results fit the ExecutionPayload(Header) format. // If this is not checked, disabled header fields like the nonce or difficulty // may be used to get a different block-hash. MustBePostMerge bool // RPCProviderKind is a hint at what type of RPC provider we are dealing with RPCProviderKind RPCProviderKind // Method reset duration defines how long we stick to available RPC methods, // till we re-attempt the user-preferred methods. // If this is 0 then the client does not fall back to less optimal but available methods. MethodResetDuration time.Duration }
func (*EthClientConfig) Check ¶
func (c *EthClientConfig) Check() error
type L1BeaconClient ¶ added in v1.4.3
type L1BeaconClient struct {
// contains filtered or unexported fields
}
L1BeaconClient is a high level golang client for the Beacon API.
func NewL1BeaconClient ¶ added in v1.4.3
func NewL1BeaconClient(cl BeaconClient, cfg L1BeaconClientConfig, fallbacks ...BlobSideCarsFetcher) *L1BeaconClient
NewL1BeaconClient returns a client for making requests to an L1 consensus layer node. Fallbacks are optional clients that will be used for fetching blobs. L1BeaconClient will rotate between the `cl` and the fallbacks whenever a client runs into an error while fetching blobs.
func (*L1BeaconClient) GetBlobSidecars ¶ added in v1.4.3
func (cl *L1BeaconClient) GetBlobSidecars(ctx context.Context, ref eth.L1BlockRef, hashes []eth.IndexedBlobHash) ([]*eth.BlobSidecar, error)
GetBlobSidecars fetches blob sidecars that were confirmed in the specified L1 block with the given indexed hashes. Order of the returned sidecars is guaranteed to be that of the hashes. Blob data is not checked for validity.
func (*L1BeaconClient) GetBlobs ¶ added in v1.4.3
func (cl *L1BeaconClient) GetBlobs(ctx context.Context, ref eth.L1BlockRef, hashes []eth.IndexedBlobHash) ([]*eth.Blob, error)
GetBlobs fetches blobs that were confirmed in the specified L1 block with the given indexed hashes. The order of the returned blobs will match the order of `hashes`. Confirms each blob's validity by checking its proof against the commitment, and confirming the commitment hashes to the expected value. Returns error if any blob is found invalid.
func (*L1BeaconClient) GetTimeToSlotFn ¶ added in v1.4.3
func (cl *L1BeaconClient) GetTimeToSlotFn(ctx context.Context) (TimeToSlotFn, error)
GetTimeToSlotFn returns a function that converts a timestamp to a slot number.
func (*L1BeaconClient) GetVersion ¶ added in v1.5.0
func (cl *L1BeaconClient) GetVersion(ctx context.Context) (string, error)
GetVersion fetches the version of the Beacon-node.
type L1BeaconClientConfig ¶ added in v1.5.0
type L1BeaconClientConfig struct {
FetchAllSidecars bool
}
type L1Client ¶
type L1Client struct { *EthClient // contains filtered or unexported fields }
L1Client provides typed bindings to retrieve L1 data from an RPC source, with optimized batch requests, cached results, and flag to not trust the RPC (i.e. to verify all returned contents against corresponding block hashes).
func NewL1Client ¶
func NewL1Client(client client.RPC, log log.Logger, metrics caching.Metrics, config *L1ClientConfig) (*L1Client, error)
NewL1Client wraps a RPC with bindings to fetch L1 data, while logging errors, tracking metrics (optional), and caching.
func (*L1Client) L1BlockRefByHash ¶
L1BlockRefByHash returns the eth.L1BlockRef for the given block hash. We cache the block reference by hash as it is safe to assume collision will not occur.
func (*L1Client) L1BlockRefByLabel ¶
func (s *L1Client) L1BlockRefByLabel(ctx context.Context, label eth.BlockLabel) (eth.L1BlockRef, error)
L1BlockRefByLabel returns the eth.L1BlockRef for the given block label. Notice, we cannot cache a block reference by label because labels are not guaranteed to be unique.
func (*L1Client) L1BlockRefByNumber ¶
L1BlockRefByNumber returns an eth.L1BlockRef for the given block number. Notice, we cannot cache a block reference by number because L1 re-orgs can invalidate the cached block reference.
type L1ClientConfig ¶
type L1ClientConfig struct { EthClientConfig L1BlockRefsCacheSize int }
func L1ClientDefaultConfig ¶
func L1ClientDefaultConfig(config *rollup.Config, trustRPC bool, kind RPCProviderKind) *L1ClientConfig
func L1ClientSimpleConfig ¶ added in v1.8.0
func L1ClientSimpleConfig(trustRPC bool, kind RPCProviderKind, cacheSize int) *L1ClientConfig
type L2Client ¶
type L2Client struct { *EthClient // contains filtered or unexported fields }
L2Client extends EthClient with functions to fetch and cache eth.L2BlockRef values.
func NewL2Client ¶
func NewL2Client(client client.RPC, log log.Logger, metrics caching.Metrics, config *L2ClientConfig) (*L2Client, error)
NewL2Client constructs a new L2Client instance. The L2Client is a thin wrapper around the EthClient with added functions for fetching and caching eth.L2BlockRef values. This includes fetching an L2BlockRef by block number, label, or hash. See: [L2BlockRefByLabel], [L2BlockRefByNumber], [L2BlockRefByHash]
func (*L2Client) L2BlockRefByHash ¶
L2BlockRefByHash returns the eth.L2BlockRef for the given block hash. The returned BlockRef may not be in the canonical chain.
func (*L2Client) L2BlockRefByLabel ¶
func (s *L2Client) L2BlockRefByLabel(ctx context.Context, label eth.BlockLabel) (eth.L2BlockRef, error)
L2BlockRefByLabel returns the eth.L2BlockRef for the given block label.
func (*L2Client) L2BlockRefByNumber ¶
L2BlockRefByNumber returns the eth.L2BlockRef for the given block number.
func (*L2Client) OutputV0AtBlock ¶
func (*L2Client) RollupConfig ¶ added in v1.5.0
func (*L2Client) SystemConfigByL2Hash ¶
func (s *L2Client) SystemConfigByL2Hash(ctx context.Context, hash common.Hash) (eth.SystemConfig, error)
SystemConfigByL2Hash returns the eth.SystemConfig (matching the config updates up to and including the L1 origin) for the given L2 block hash. The returned eth.SystemConfig may not be in the canonical chain when the hash is not canonical.
type L2ClientConfig ¶
type L2ClientConfig struct { EthClientConfig L2BlockRefsCacheSize int L1ConfigsCacheSize int RollupCfg *rollup.Config }
func L2ClientDefaultConfig ¶
func L2ClientDefaultConfig(config *rollup.Config, trustRPC bool) *L2ClientConfig
type RPCBlock ¶ added in v1.5.0
type RPCBlock struct { RPCHeader Transactions []*types.Transaction `json:"transactions"` Withdrawals *types.Withdrawals `json:"withdrawals,omitempty"` }
func (*RPCBlock) ExecutionPayloadEnvelope ¶ added in v1.5.0
func (block *RPCBlock) ExecutionPayloadEnvelope(trustCache bool) (*eth.ExecutionPayloadEnvelope, error)
type RPCHeader ¶ added in v1.5.0
type RPCHeader struct { ParentHash common.Hash `json:"parentHash"` UncleHash common.Hash `json:"sha3Uncles"` Coinbase common.Address `json:"miner"` Root common.Hash `json:"stateRoot"` TxHash common.Hash `json:"transactionsRoot"` ReceiptHash common.Hash `json:"receiptsRoot"` Bloom eth.Bytes256 `json:"logsBloom"` Difficulty hexutil.Big `json:"difficulty"` Number hexutil.Uint64 `json:"number"` GasLimit hexutil.Uint64 `json:"gasLimit"` GasUsed hexutil.Uint64 `json:"gasUsed"` Time hexutil.Uint64 `json:"timestamp"` Extra hexutil.Bytes `json:"extraData"` MixDigest common.Hash `json:"mixHash"` Nonce types.BlockNonce `json:"nonce"` // BaseFee was added by EIP-1559 and is ignored in legacy headers. BaseFee *hexutil.Big `json:"baseFeePerGas"` // WithdrawalsRoot was added by EIP-4895 and is ignored in legacy headers. WithdrawalsRoot *common.Hash `json:"withdrawalsRoot,omitempty"` // BlobGasUsed was added by EIP-4844 and is ignored in legacy headers. BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed,omitempty"` // ExcessBlobGas was added by EIP-4844 and is ignored in legacy headers. ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas,omitempty"` // ParentBeaconRoot was added by EIP-4788 and is ignored in legacy headers. ParentBeaconRoot *common.Hash `json:"parentBeaconBlockRoot,omitempty"` // untrusted info included by RPC, may have to be checked Hash common.Hash `json:"hash"` }
type RPCProviderKind ¶
type RPCProviderKind string
RPCProviderKind identifies an RPC provider, used to hint at the optimal receipt fetching approach.
const ( RPCKindAlchemy RPCProviderKind = "alchemy" RPCKindQuickNode RPCProviderKind = "quicknode" RPCKindInfura RPCProviderKind = "infura" RPCKindParity RPCProviderKind = "parity" RPCKindNethermind RPCProviderKind = "nethermind" RPCKindDebugGeth RPCProviderKind = "debug_geth" RPCKindErigon RPCProviderKind = "erigon" RPCKindBasic RPCProviderKind = "basic" // try only the standard most basic receipt fetching RPCKindAny RPCProviderKind = "any" // try any method available RPCKindStandard RPCProviderKind = "standard" // try standard methods, including newer optimized standard RPC methods )
func (*RPCProviderKind) Clone ¶
func (kind *RPCProviderKind) Clone() any
func (*RPCProviderKind) Set ¶
func (kind *RPCProviderKind) Set(value string) error
func (RPCProviderKind) String ¶
func (kind RPCProviderKind) String() string
type RPCReceiptsConfig ¶ added in v1.4.2
type RPCReceiptsConfig struct { MaxBatchSize int ProviderKind RPCProviderKind MethodResetDuration time.Duration }
type RPCReceiptsFetcher ¶ added in v1.4.2
type RPCReceiptsFetcher struct {
// contains filtered or unexported fields
}
func NewRPCReceiptsFetcher ¶ added in v1.4.2
func NewRPCReceiptsFetcher(client rpcClient, log log.Logger, config RPCReceiptsConfig) *RPCReceiptsFetcher
func (*RPCReceiptsFetcher) FetchReceipts ¶ added in v1.4.2
func (*RPCReceiptsFetcher) OnReceiptsMethodErr ¶ added in v1.4.2
func (f *RPCReceiptsFetcher) OnReceiptsMethodErr(m ReceiptsFetchingMethod, err error)
func (*RPCReceiptsFetcher) PickReceiptsMethod ¶ added in v1.4.2
func (f *RPCReceiptsFetcher) PickReceiptsMethod(txCount int) ReceiptsFetchingMethod
type ReceiptsFetchingMethod ¶
type ReceiptsFetchingMethod uint64
ReceiptsFetchingMethod is a bitfield with 1 bit for each receipts fetching type. Depending on errors, tx counts and preferences the code may select different sets of fetching methods.
const ( // EthGetTransactionReceiptBatch is standard per-tx receipt fetching with JSON-RPC batches. // Available in: standard, everywhere. // - Alchemy: 15 CU / tx // - Quicknode: 2 credits / tx // Method: eth_getTransactionReceipt // See: https://ethereum.github.io/execution-apis/api-documentation/ EthGetTransactionReceiptBatch ReceiptsFetchingMethod = 1 << iota // AlchemyGetTransactionReceipts is a special receipt fetching method provided by Alchemy. // Available in: // - Alchemy: 250 CU total // Method: alchemy_getTransactionReceipts // Params: // - object with "blockNumber" or "blockHash" field // Returns: "array of receipts" - docs lie, array is wrapped in a struct with single "receipts" field // See: https://docs.alchemy.com/reference/alchemy-gettransactionreceipts#alchemy_gettransactionreceipts AlchemyGetTransactionReceipts // DebugGetRawReceipts is a debug method from Geth, faster by avoiding serialization and metadata overhead. // Ideal for fast syncing from a local geth node. // Available in: // - Geth: free // - QuickNode: 22 credits maybe? Unknown price, undocumented ("debug_getblockreceipts" exists in table though?) // Method: debug_getRawReceipts // Params: // - string presenting a block number or hash // Returns: list of strings, hex encoded RLP of receipts data. "consensus-encoding of all receipts in a single block" // See: https://geth.ethereum.org/docs/rpc/ns-debug#debug_getrawreceipts DebugGetRawReceipts // ParityGetBlockReceipts is an old parity method, which has been adopted by Nethermind and some RPC providers. // Available in: // - Alchemy: 500 CU total // - QuickNode: 59 credits - docs are wrong, not actually available anymore. // - Any open-ethereum/parity legacy: free // - Nethermind: free // Method: parity_getBlockReceipts // Params: // Parity: "quantity or tag" // Alchemy: string with block hash, number in hex, or block tag. // Nethermind: very flexible: tag, number, hex or object with "requireCanonical"/"blockHash" fields. // Returns: array of receipts // See: // - Parity: https://openethereum.github.io/JSONRPC-parity-module#parity_getblockreceipts // - QuickNode: undocumented. // - Alchemy: https://docs.alchemy.com/reference/eth-getblockreceipts // - Nethermind: https://docs.nethermind.io/nethermind/ethereum-client/json-rpc/parity#parity_getblockreceipts ParityGetBlockReceipts // EthGetBlockReceipts is a previously non-standard receipt fetching method in the eth namespace, // supported by some RPC platforms. // This since has been standardized in https://github.com/ethereum/execution-apis/pull/438 and adopted in Geth: // https://github.com/ethereum/go-ethereum/pull/27702 // Available in: // - Alchemy: 500 CU total (and deprecated) // - QuickNode: 59 credits total (does not seem to work with block hash arg, inaccurate docs) // - Standard, incl. Geth, Besu and Reth, and Nethermind has a PR in review. // Method: eth_getBlockReceipts // Params: // - QuickNode: string, "quantity or tag", docs say incl. block hash, but API does not actually accept it. // - Alchemy: string, block hash / num (hex) / block tag // Returns: array of receipts // See: // - QuickNode: https://www.quicknode.com/docs/ethereum/eth_getBlockReceipts // - Alchemy: https://docs.alchemy.com/reference/eth-getblockreceipts // Erigon has this available, but does not support block-hash argument to the method: // https://github.com/ledgerwatch/erigon/blob/287a3d1d6c90fc6a7a088b5ae320f93600d5a167/cmd/rpcdaemon/commands/eth_receipts.go#L571 EthGetBlockReceipts // ErigonGetBlockReceiptsByBlockHash is an Erigon-specific receipt fetching method, // the same as EthGetBlockReceipts but supporting a block-hash argument. // Available in: // - Erigon // Method: erigon_getBlockReceiptsByBlockHash // Params: // - Erigon: string, hex-encoded block hash // Returns: // - Erigon: array of json-ified receipts // See: // https://github.com/ledgerwatch/erigon/blob/287a3d1d6c90fc6a7a088b5ae320f93600d5a167/cmd/rpcdaemon/commands/erigon_receipts.go#LL391C24-L391C51 ErigonGetBlockReceiptsByBlockHash )
func AvailableReceiptsFetchingMethods ¶
func AvailableReceiptsFetchingMethods(kind RPCProviderKind) ReceiptsFetchingMethod
AvailableReceiptsFetchingMethods selects receipt fetching methods based on the RPC provider kind.
func PickBestReceiptsFetchingMethod ¶
func PickBestReceiptsFetchingMethod(kind RPCProviderKind, available ReceiptsFetchingMethod, txCount uint64) ReceiptsFetchingMethod
PickBestReceiptsFetchingMethod selects an RPC method that is still available, and optimal for fetching the given number of tx receipts from the specified provider kind.
func (ReceiptsFetchingMethod) String ¶
func (r ReceiptsFetchingMethod) String() string
type ReceiptsProvider ¶ added in v1.4.2
type ReceiptsProvider interface { // FetchReceipts returns a block info and all of the receipts associated with transactions in the block. // It verifies the receipt hash in the block header against the receipt hash of the fetched receipts // to ensure that the execution engine did not fail to return any receipts. FetchReceipts(ctx context.Context, blockInfo eth.BlockInfo, txHashes []common.Hash) (types.Receipts, error) }
type RollupClient ¶
type RollupClient struct {
// contains filtered or unexported fields
}
func NewRollupClient ¶
func NewRollupClient(rpc client.RPC) *RollupClient
func (*RollupClient) Close ¶ added in v1.4.2
func (r *RollupClient) Close()
func (*RollupClient) ConductorEnabled ¶ added in v1.9.4
func (r *RollupClient) ConductorEnabled(ctx context.Context) (bool, error)
func (*RollupClient) OutputAtBlock ¶
func (r *RollupClient) OutputAtBlock(ctx context.Context, blockNum uint64) (*eth.OutputResponse, error)
func (*RollupClient) OverrideLeader ¶ added in v1.8.0
func (r *RollupClient) OverrideLeader(ctx context.Context) error
func (*RollupClient) PostUnsafePayload ¶ added in v1.4.3
func (r *RollupClient) PostUnsafePayload(ctx context.Context, payload *eth.ExecutionPayloadEnvelope) error
func (*RollupClient) RollupConfig ¶
func (*RollupClient) SafeHeadAtL1Block ¶ added in v1.7.2
func (r *RollupClient) SafeHeadAtL1Block(ctx context.Context, blockNum uint64) (*eth.SafeHeadResponse, error)
func (*RollupClient) SequencerActive ¶
func (r *RollupClient) SequencerActive(ctx context.Context) (bool, error)
func (*RollupClient) SetLogLevel ¶
func (*RollupClient) StartSequencer ¶
func (*RollupClient) StopSequencer ¶
func (*RollupClient) SyncStatus ¶
func (r *RollupClient) SyncStatus(ctx context.Context) (*eth.SyncStatus, error)
type SupervisorClient ¶ added in v1.9.3
type SupervisorClient struct {
// contains filtered or unexported fields
}
func NewSupervisorClient ¶ added in v1.9.3
func NewSupervisorClient(client client.RPC) *SupervisorClient
func (*SupervisorClient) AddL2RPC ¶ added in v1.9.3
func (cl *SupervisorClient) AddL2RPC(ctx context.Context, rpc string) error
func (*SupervisorClient) CheckMessage ¶ added in v1.9.5
func (cl *SupervisorClient) CheckMessage(ctx context.Context, identifier types.Identifier, logHash common.Hash) (types.SafetyLevel, error)
func (*SupervisorClient) Close ¶ added in v1.9.3
func (cl *SupervisorClient) Close()
func (*SupervisorClient) CrossDerivedFrom ¶ added in v1.9.5
func (*SupervisorClient) SafeView ¶ added in v1.9.5
func (cl *SupervisorClient) SafeView(ctx context.Context, chainID types.ChainID, safe types.ReferenceView) (types.ReferenceView, error)
func (*SupervisorClient) Start ¶ added in v1.9.3
func (cl *SupervisorClient) Start(ctx context.Context) error
func (*SupervisorClient) Stop ¶ added in v1.9.3
func (cl *SupervisorClient) Stop(ctx context.Context) error
func (*SupervisorClient) UnsafeView ¶ added in v1.9.5
func (cl *SupervisorClient) UnsafeView(ctx context.Context, chainID types.ChainID, unsafe types.ReferenceView) (types.ReferenceView, error)
func (*SupervisorClient) UpdateFinalizedL1 ¶ added in v1.9.5
func (cl *SupervisorClient) UpdateFinalizedL1(ctx context.Context, chainID types.ChainID, finalizedL1 eth.L1BlockRef) error
func (*SupervisorClient) UpdateLocalSafe ¶ added in v1.9.5
func (cl *SupervisorClient) UpdateLocalSafe(ctx context.Context, chainID types.ChainID, derivedFrom eth.L1BlockRef, lastDerived eth.BlockRef) error