rpc

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: MIT Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// FallbackGasTipCap is the default fallback gasTipCap used when we are
	// unable to query an L1 backend for a suggested gasTipCap.
	FallbackGasTipCap = big.NewInt(1500000000)
)

Taken from https://github.com/ethereum-optimism/optimism/blob/develop/bss-core/drivers/max_priority_fee_fallback.go

Functions

func DialClientWithBackoff

func DialClientWithBackoff(ctx context.Context, url string) (*ethclient.Client, error)

DialClientWithBackoff connects a ethereum RPC client at the given URL with a backoff strategy.

func DialEngineClient

func DialEngineClient(ctx context.Context, endpointUrl string, jwtSecret string) (*rpc.Client, error)

DialEngineClient initializes an RPC connection with authentication headers. Taken from https://github.com/prysmaticlabs/prysm/blob/v2.1.4/beacon-chain/execution/rpc_connection.go#L151

func GetReceiptsByBlock

func GetReceiptsByBlock(ctx context.Context, cli *rpc.Client, block *types.Block) (types.Receipts, error)

GetReceiptsByBlock fetches all transaction receipts in a block.

func IsMaxPriorityFeePerGasNotFoundError

func IsMaxPriorityFeePerGasNotFoundError(err error) bool

IsMaxPriorityFeePerGasNotFoundError returns true if the provided error signals that the backend does not support the eth_maxPrirorityFeePerGas method. In this case, the caller should fallback to using the constant above.

func SetHead

func SetHead(ctx context.Context, rpc *rpc.Client, headNum *big.Int) error

SetHead makes a `debug_setHead` RPC call to set the chain's head, should only be used for testing purpose.

func WaitConfirmations

func WaitConfirmations(ctx context.Context, client *ethclient.Client, confirmations uint64, begin uint64) error

WaitConfirmations won't return before N blocks confirmations have been seen on destination chain.

func WaitReceipt

func WaitReceipt(ctx context.Context, client *ethclient.Client, tx *types.Transaction) (*types.Receipt, error)

WaitReceipt keeps waiting until the given transaction has an execution receipt to know whether it was reverted or not.

Types

type Client

type Client struct {
	// Geth ethclient clients
	L1 *ethclient.Client
	L2 *ethclient.Client
	// Geth raw RPC clients
	L1RawRPC *rpc.Client
	L2RawRPC *rpc.Client
	// Geth Engine API clients
	L2Engine *EngineClient
	// Protocol contracts clients
	TaikoL1 *bindings.TaikoL1Client
	TaikoL2 *bindings.V1TaikoL2Client
	// Chain IDs
	L1ChainID *big.Int
	L2ChainID *big.Int
}

Client contains all L1/L2 RPC clients that a driver needs.

func NewClient

func NewClient(ctx context.Context, cfg *ClientConfig) (*Client, error)

NewClient initializes all RPC clients used by Taiko client softwares.

func (*Client) GetBlockMetadataByID

func (c *Client) GetBlockMetadataByID(blockID *big.Int) (*bindings.LibDataBlockMetadata, error)

GetBlockMetadataByID fetches the L2 block metadata with given block ID. TODO: add start height and end height in filter options.

func (*Client) GetGenesisL1Header

func (c *Client) GetGenesisL1Header(ctx context.Context) (*types.Header, error)

GetGenesisL1Header fetches the L1 header that including L2 genesis block.

func (*Client) GetProtocolConstants added in v0.1.6

func (c *Client) GetProtocolConstants(opts *bind.CallOpts) (*bindings.ProtocolConstants, error)

GetProtocolConstants gets the protocol constants from TaikoL1 contract.

func (*Client) L2AccountNonce

func (c *Client) L2AccountNonce(
	ctx context.Context,
	account common.Address,
	height *big.Int,
) (uint64, error)

L2AccountNonce fetches the nonce of the given L2 account at a specified height.

func (*Client) L2ParentByBlockId

func (c *Client) L2ParentByBlockId(ctx context.Context, blockID *big.Int) (*types.Header, error)

L2ParentByBlockId fetches the block header from L2 node with the largest block id that smaller than the given `blockId`.

func (*Client) L2PoolContent

func (c *Client) L2PoolContent(ctx context.Context) (pending PoolContent, queued PoolContent, err error)

L2PoolContent fetches the transaction pool content from L2 node.

func (*Client) LatestL2KnownL1Header

func (c *Client) LatestL2KnownL1Header(ctx context.Context) (*types.Header, error)

LatestL2KnownL1Header fetches the L2 node's latest known L1 header.

func (*Client) WaitL1Origin

func (c *Client) WaitL1Origin(ctx context.Context, blockID *big.Int) (*rawdb.L1Origin, error)

WaitL1Origin keeps waiting until the L1Origin with given block ID appears on the L2 node.

type ClientConfig

type ClientConfig struct {
	L1Endpoint       string
	L2Endpoint       string
	TaikoL1Address   common.Address
	TaikoL2Address   common.Address
	L2EngineEndpoint string
	JwtSecret        string
}

ClientConfig contains all configs which will be used to initializing an RPC client. If not providing L2EngineEndpoint or JwtSecret, then the L2Engine client won't be initialized.

type EngineClient

type EngineClient struct {
	*rpc.Client
}

EngineClient represents a RPC client connecting to an Ethereum Engine API endpoint. ref: https://github.com/ethereum/execution-apis/blob/main/src/engine/specification.md

func DialEngineClientWithBackoff

func DialEngineClientWithBackoff(ctx context.Context, url string, jwtSecret string) (*EngineClient, error)

DialEngineClientWithBackoff connects an ethereum engine RPC client at the given URL with a backoff strategy.

func (*EngineClient) ForkchoiceUpdate

ForkchoiceUpdate updates the forkchoice on the execution client.

func (*EngineClient) GetPayload

func (c *EngineClient) GetPayload(
	ctx context.Context,
	payloadID *beacon.PayloadID,
) (*beacon.ExecutableDataV1, error)

GetPayload gets the execution payload associated with the payload ID.

func (*EngineClient) NewPayload

func (c *EngineClient) NewPayload(
	ctx context.Context,
	payload *beacon.ExecutableDataV1,
) (*beacon.PayloadStatusV1, error)

ExecutePayload executes a built block on the execution engine.

type PoolContent

type PoolContent map[common.Address]map[string]*types.Transaction

PoolContent represents a response body of a `txpool_content` RPC call.

func (PoolContent) ToTxLists

func (pc PoolContent) ToTxLists() TxLists

ToTxLists flattens all transactions in pool content into transactions lists, each list contains transactions from a single account sorted by nonce.

type TxLists

type TxLists []types.Transactions

func (TxLists) Len

func (t TxLists) Len() int

Len returns the number of transactions inside the transactions lists.

Jump to

Keyboard shortcuts

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