drivers

package
v0.0.0-...-412688d Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: MIT Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClearPendingRetry = errors.New("retry clear pending txn")

ErrClearPendingRetry signals that a transaction from a previous running instance confirmed rather than our clearing transaction on startup. In this case the caller should retry.

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

Functions

func ClearPendingTx

func ClearPendingTx(
	name string,
	ctx context.Context,
	txMgr txmgr.TxManager,
	l1Client L1Client,
	walletAddr common.Address,
	privKey *ecdsa.PrivateKey,
	chainID *big.Int,
) error

ClearPendingTx publishes a NOOP transaction at the wallet's next unused nonce. This is used on restarts in order to clear the mempool of any prior publications and ensure the batch submitter starts submitting from a clean slate.

func CraftClearingTx

func CraftClearingTx(
	walletAddr common.Address,
	nonce uint64,
	gasFeeCap *big.Int,
	gasTipCap *big.Int,
	gasLimit uint64,
) *types.Transaction

CraftClearingTx creates an unsigned clearing transaction which sends 0 ETH back to the sender's address.

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 SignClearingTx

func SignClearingTx(
	name string,
	ctx context.Context,
	walletAddr common.Address,
	nonce uint64,
	l1Client L1Client,
	privKey *ecdsa.PrivateKey,
	chainID *big.Int,
) (*types.Transaction, error)

SignClearingTx creates a signed clearing tranaction which sends 0 ETH back to the sender's address. EstimateGas is used to set an appropriate gas limit.

Types

type L1Client

type L1Client interface {
	// EstimateGas tries to estimate the gas needed to execute a specific
	// transaction based on the current pending state of the backend blockchain.
	// There is no guarantee that this is the true gas limit requirement as
	// other transactions may be added or removed by miners, but it should
	// provide a basis for setting a reasonable default.
	EstimateGas(context.Context, ethereum.CallMsg) (uint64, error)

	// HeaderByNumber returns a block header from the current canonical chain.
	// If number is nil, the latest known header is returned.
	HeaderByNumber(context.Context, *big.Int) (*types.Header, error)

	// NonceAt returns the account nonce of the given account. The block number
	// can be nil, in which case the nonce is taken from the latest known block.
	NonceAt(context.Context, common.Address, *big.Int) (uint64, error)

	// SendTransaction injects a signed transaction into the pending pool for
	// execution.
	//
	// If the transaction was a contract creation use the TransactionReceipt
	// method to get the contract address after the transaction has been mined.
	SendTransaction(context.Context, *types.Transaction) error

	// SuggestGasTipCap retrieves the currently suggested gas tip cap after 1559
	// to allow a timely execution of a transaction.
	SuggestGasTipCap(context.Context) (*big.Int, error)

	// TransactionReceipt returns the receipt of a transaction by transaction
	// hash. Note that the receipt is not available for pending transactions.
	TransactionReceipt(context.Context, common.Hash) (*types.Receipt, error)
}

L1Client is an abstraction over an L1 Ethereum client functionality required by the batch submitter.

Jump to

Keyboard shortcuts

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