proposer

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 35 Imported by: 5

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 uint8
}

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 added in v1.4.2

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 added in v1.4.2

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 added in v1.4.3

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) ProposeL2OutputDGFTxData added in v1.4.3

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 added in v1.4.2

func (l *L2OutputSubmitter) StartL2OutputSubmitting() error

func (*L2OutputSubmitter) StopL2OutputSubmitting added in v1.4.2

func (l *L2OutputSubmitter) StopL2OutputSubmitting() error

func (*L2OutputSubmitter) StopL2OutputSubmittingIfRunning added in v1.4.2

func (l *L2OutputSubmitter) StopL2OutputSubmittingIfRunning() error

type ProposerConfig added in v1.4.2

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        uint8

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

type ProposerService added in v1.4.2

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 added in v1.4.2

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 added in v1.4.2

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 added in v1.4.2

func (ps *ProposerService) Kill() error

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

func (*ProposerService) Start added in v1.4.2

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 added in v1.4.2

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 added in v1.4.2

func (ps *ProposerService) Stopped() bool

type RollupClient added in v1.4.2

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