proposer

package
v0.0.0-...-011bec4 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyStopped = errors.New("already stopped")
View Source
var (
	ErrProposerNotRunning = errors.New("proposer is not running")
)

Functions

func Main

func Main(version string) cliapp.LifecycleAction

Main is the entrypoint into the L2OutputSubmitter. This method returns a cliapp.LifecycleAction, to create an op-service CLI-lifecycle-managed L2Output-submitter

Types

type CLIConfig

type CLIConfig struct {

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

	// RollupRpc is the HTTP provider URL for the rollup node. A comma-separated list enables the active rollup provider.
	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

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

	TxMgrConfig txmgr.CLIConfig

	RPCConfig oprpc.CLIConfig

	LogConfig oplog.CLIConfig

	MetricsConfig opmetrics.CLIConfig

	PprofConfig oppprof.CLIConfig

	// DGFAddress is the DisputeGameFactory contract address.
	DGFAddress string

	// ProposalInterval is the delay between submitting L2 output proposals when the DGFAddress is set.
	ProposalInterval time.Duration

	// DisputeGameType is the type of dispute game to create when submitting an output proposal.
	DisputeGameType uint32

	// ActiveSequencerCheckDuration is the duration between checks to determine the active sequencer endpoint.
	ActiveSequencerCheckDuration time.Duration

	// Whether to wait for the sequencer to sync to a recent block at startup.
	WaitNodeSync bool
}

CLIConfig is a well typed config that is parsed from the CLI params. This also contains config options for auxiliary services. It is transformed into a `Config` before the L2 output submitter is started.

func NewConfig

func NewConfig(ctx *cli.Context) *CLIConfig

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

func (*CLIConfig) Check

func (c *CLIConfig) Check() error

type DriverSetup

type DriverSetup struct {
	Log      log.Logger
	Metr     metrics.Metricer
	Cfg      ProposerConfig
	Txmgr    txmgr.TxManager
	L1Client L1Client

	// RollupProvider's RollupClient() is used to retrieve output roots from
	RollupProvider dial.RollupProvider
}

type L1Client

type L1Client interface {
	HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
	// CodeAt returns the code of the given account. This is needed to differentiate
	// between contract internal errors and the local chain being out of sync.
	CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)

	// CallContract executes an Ethereum contract call with the specified data as the
	// input.
	CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
}

type L2OutputSubmitter

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

L2OutputSubmitter is responsible for proposing outputs

func NewL2OutputSubmitter

func NewL2OutputSubmitter(setup DriverSetup) (_ *L2OutputSubmitter, err error)

NewL2OutputSubmitter creates a new L2 Output Submitter

func (*L2OutputSubmitter) FetchCurrentBlockNumber

func (l *L2OutputSubmitter) FetchCurrentBlockNumber(ctx context.Context) (*big.Int, error)

FetchCurrentBlockNumber gets the current block number from the L2OutputSubmitter's RollupClient. If the `AllowNonFinalized` configuration option is set, it will return the safe head block number, and if not, it will return the finalized head block number.

func (*L2OutputSubmitter) FetchNextOutputInfo

func (l *L2OutputSubmitter) FetchNextOutputInfo(ctx context.Context) (*eth.OutputResponse, bool, error)

FetchNextOutputInfo gets the block number of the next proposal. It returns: the next block number, if the proposal should be made, error

func (*L2OutputSubmitter) FetchOutput

func (l *L2OutputSubmitter) FetchOutput(ctx context.Context, block *big.Int) (*eth.OutputResponse, bool, error)

func (*L2OutputSubmitter) ProposeL2OutputDGFTxData

func (l *L2OutputSubmitter) ProposeL2OutputDGFTxData(output *eth.OutputResponse) ([]byte, *big.Int, error)

func (*L2OutputSubmitter) ProposeL2OutputTxData

func (l *L2OutputSubmitter) ProposeL2OutputTxData(output *eth.OutputResponse) ([]byte, error)

ProposeL2OutputTxData creates the transaction data for the ProposeL2Output function

func (*L2OutputSubmitter) StartL2OutputSubmitting

func (l *L2OutputSubmitter) StartL2OutputSubmitting() error

func (*L2OutputSubmitter) StopL2OutputSubmitting

func (l *L2OutputSubmitter) StopL2OutputSubmitting() error

func (*L2OutputSubmitter) StopL2OutputSubmittingIfRunning

func (l *L2OutputSubmitter) StopL2OutputSubmittingIfRunning() error

type ProposerConfig

type ProposerConfig struct {
	// How frequently to poll L2 for new finalized outputs
	PollInterval   time.Duration
	NetworkTimeout time.Duration

	// How frequently to post L2 outputs when the DisputeGameFactory is configured
	ProposalInterval time.Duration

	L2OutputOracleAddr     *common.Address
	DisputeGameFactoryAddr *common.Address
	DisputeGameType        uint32

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

	WaitNodeSync bool
}

type ProposerService

type ProposerService struct {
	Log     log.Logger
	Metrics metrics.Metricer

	ProposerConfig

	TxManager      txmgr.TxManager
	L1Client       *ethclient.Client
	RollupProvider dial.RollupProvider

	Version string
	// contains filtered or unexported fields
}

func ProposerServiceFromCLIConfig

func ProposerServiceFromCLIConfig(ctx context.Context, version string, cfg *CLIConfig, log log.Logger) (*ProposerService, error)

ProposerServiceFromCLIConfig creates a new ProposerService from a CLIConfig. The service components are fully started, except for the driver, which will not be submitting state (if it was configured to) until the Start part of the lifecycle.

func (*ProposerService) Driver

func (ps *ProposerService) Driver() rpc.ProposerDriver

Driver returns the handler on the L2Output-submitter driver element, to start/stop/restart the L2Output-submission work, for use in testing.

func (*ProposerService) Kill

func (ps *ProposerService) Kill() error

Kill is a convenience method to forcefully, non-gracefully, stop the ProposerService.

func (*ProposerService) Start

func (ps *ProposerService) Start(_ context.Context) error

Start runs once upon start of the proposer lifecycle, and starts L2Output-submission work if the proposer is configured to start submit data on startup.

func (*ProposerService) Stop

func (ps *ProposerService) Stop(ctx context.Context) error

Stop fully stops the L2Output-submitter and all its resources gracefully. After stopping, it cannot be restarted. See driver.StopL2OutputSubmitting to temporarily stop the L2Output submitter.

func (*ProposerService) Stopped

func (ps *ProposerService) Stopped() bool

type RollupClient

type RollupClient interface {
	SyncStatus(ctx context.Context) (*eth.SyncStatus, error)
	OutputAtBlock(ctx context.Context, blockNum uint64) (*eth.OutputResponse, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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