proposer

package
v0.10.7 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: MIT Imports: 34 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(version string) func(ctx *cli.Context) error

Main is the entrypoint into the L2 Output Submitter. This method returns a closure that executes the service and blocks until the service exits. The use of a closure allows the parameters bound to the top-level main package, e.g. GitVersion, to be captured and used once the function is executed.

Types

type Config

type Config struct {

	// L1EthRpc is the HTTP provider URL for L1.
	L1EthRpc string

	// RollupRpc is the HTTP provider URL for the rollup node.
	RollupRpc string

	// L2OOAddress is the L2OutputOracle contract address.
	L2OOAddress string

	// PollInterval is the delay between querying L2 for more transaction
	// and creating a new batch.
	PollInterval time.Duration

	// NumConfirmations is the number of confirmations which we will wait after
	// appending new batches.
	NumConfirmations uint64

	// SafeAbortNonceTooLowCount is the number of ErrNonceTooLowObservations
	// required to give up on a tx at a particular nonce without receiving
	// confirmation.
	SafeAbortNonceTooLowCount uint64

	// ResubmissionTimeout is time we will wait before resubmitting a
	// transaction.
	ResubmissionTimeout time.Duration

	// Mnemonic is the HD seed used to derive the wallet private keys for both
	// the sequence and proposer. Must be used in conjunction with
	// SequencerHDPath and ProposerHDPath.
	Mnemonic string

	// L2OutputHDPath is the derivation path used to obtain the private key for
	// the l2output transactions.
	L2OutputHDPath string

	// PrivateKey is the private key used for l2output transactions.
	PrivateKey string

	RPCConfig oprpc.CLIConfig

	// AllowNonFinalized can be set to true to propose outputs
	// for L2 blocks derived from non-finalized L1 data.
	AllowNonFinalized bool

	LogConfig oplog.CLIConfig

	MetricsConfig opmetrics.CLIConfig

	PprofConfig oppprof.CLIConfig
}

func NewConfig

func NewConfig(ctx *cli.Context) Config

NewConfig parses the Config from the provided flags or environment variables.

func (Config) Check

func (c Config) Check() error

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

func NewDriver

func NewDriver(cfg DriverConfig) (*Driver, error)

func (*Driver) CraftTx

func (d *Driver) CraftTx(ctx context.Context, start, end, nonce *big.Int) (*types.Transaction, error)

CraftTx transforms the L2 blocks between start and end into a transaction using the given nonce.

NOTE: This method SHOULD NOT publish the resulting transaction.

func (*Driver) GetBlockRange

func (d *Driver) GetBlockRange(ctx context.Context) (*big.Int, *big.Int, error)

GetBlockRange returns the start and end L2 block heights that need to be processed. Note that the end value is *exclusive*, therefore if the returned values are identical nothing needs to be processed.

func (*Driver) Name

func (d *Driver) Name() string

Name is an identifier used to prefix logs for a particular service.

func (*Driver) SendTransaction

func (d *Driver) SendTransaction(ctx context.Context, tx *types.Transaction) error

SendTransaction injects a signed transaction into the pending pool for execution.

func (*Driver) UpdateGasPrice

func (d *Driver) UpdateGasPrice(ctx context.Context, tx *types.Transaction) (*types.Transaction, error)

UpdateGasPrice signs an otherwise identical txn to the one provided but with updated gas prices sampled from the existing network conditions.

NOTE: This method SHOULD NOT publish the resulting transaction.

func (*Driver) WalletAddr

func (d *Driver) WalletAddr() common.Address

WalletAddr is the wallet address used to pay for transaction fees.

type DriverConfig

type DriverConfig struct {
	Log  log.Logger
	Name string

	// L1Client is used to submit transactions to
	L1Client *ethclient.Client
	// RollupClient is used to retrieve output roots from
	RollupClient *sources.RollupClient

	// AllowNonFinalized enables the proposal of safe, but non-finalized L2 blocks.
	// The L1 block-hash embedded in the proposal TX is checked and should ensure the proposal
	// is never valid on an alternative L1 chain that would produce different L2 data.
	// This option is not necessary when higher proposal latency is acceptable and L1 is healthy.
	AllowNonFinalized bool

	// L2OOAddr is the L1 contract address of the L2 Output Oracle.
	L2OOAddr common.Address

	// From is the address to send transactions from
	From common.Address

	// SignerFn is the function used to sign transactions
	SignerFn SignerFn
}

type DriverInterface

type DriverInterface interface {
	// Name is an identifier used to prefix logs for a particular service.
	Name() string

	// WalletAddr is the wallet address used to pay for transaction fees.
	WalletAddr() common.Address

	// GetBlockRange returns the start and end L2 block heights that need to be
	// processed. Note that the end value is *exclusive*, therefore if the
	// returned values are identical nothing needs to be processed.
	GetBlockRange(ctx context.Context) (*big.Int, *big.Int, error)

	// CraftTx transforms the L2 blocks between start and end into a transaction
	// using the given nonce.
	//
	// NOTE: This method SHOULD NOT publish the resulting transaction.
	CraftTx(
		ctx context.Context,
		start, end, nonce *big.Int,
	) (*types.Transaction, error)

	// UpdateGasPrice signs an otherwise identical txn to the one provided but
	// with updated gas prices sampled from the existing network conditions.
	//
	// NOTE: Thie method SHOULD NOT publish the resulting transaction.
	UpdateGasPrice(
		ctx context.Context,
		tx *types.Transaction,
	) (*types.Transaction, error)

	// SendTransaction injects a signed transaction into the pending pool for
	// execution.
	SendTransaction(ctx context.Context, tx *types.Transaction) error
}

DriverInterface is an interface for creating and submitting transactions for a specific contract.

type L1Client

type L1Client interface {
	// 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.

type L2OutputSubmitter

type L2OutputSubmitter struct {
	// contains filtered or unexported fields
}

L2OutputSubmitter encapsulates a service responsible for submitting L2Outputs to the L2OutputOracle contract.

func NewL2OutputSubmitter

func NewL2OutputSubmitter(
	cfg Config,
	gitVersion string,
	l log.Logger,
) (*L2OutputSubmitter, error)

NewL2OutputSubmitter initializes the L2OutputSubmitter, gathering any resources that will be needed during operation.

func NewL2OutputSubmitterWithSigner

func NewL2OutputSubmitterWithSigner(
	cfg Config,
	from common.Address,
	signer SignerFactory,
	gitVersion string,
	l log.Logger,
) (*L2OutputSubmitter, error)

func (*L2OutputSubmitter) Start

func (l *L2OutputSubmitter) Start() error

func (*L2OutputSubmitter) Stop

func (l *L2OutputSubmitter) Stop()

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(cfg ServiceConfig) *Service

func (*Service) Start

func (s *Service) Start() error

func (*Service) Stop

func (s *Service) Stop() error

type ServiceConfig

type ServiceConfig struct {
	Log             log.Logger
	Context         context.Context
	Driver          DriverInterface
	PollInterval    time.Duration
	L1Client        *ethclient.Client
	TxManagerConfig txmgr.Config
}

type SignerFactory

type SignerFactory func(chainID *big.Int) SignerFn

Jump to

Keyboard shortcuts

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