proposer

package
v0.0.1-rc3 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 44 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 {
	*proposer.CLIConfig
	L2EthRpc            string
	L2Reth              bool
	EnclaveRpc          string
	MinProposalInterval uint64
}

func NewConfig

func NewConfig(ctx *cli.Context) *CLIConfig

type Client

type Client interface {
	L1Client
	L2Client
}

func NewClient

func NewClient(client *ethclient.Client, metrics caching.Metrics) Client

func NewRethClient

func NewRethClient(client *ethclient.Client, metrics caching.Metrics) Client

type DriverSetup

type DriverSetup struct {
	Log           log.Logger
	Metr          metrics.Metricer
	Cfg           ProposerConfig
	Txmgr         txmgr.TxManager
	L1Client      L1Client
	L2Client      L2Client
	RollupClient  RollupClient
	EnclaveClient enclave.RPC
}

type L1Client

type L1Client interface {
	BlockNumber(ctx context.Context) (uint64, error)
	HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
	HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
	BlockReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error)
	CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
	CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
	Close()
}

type L2Client

type L2Client interface {
	ChainConfig(ctx context.Context) (*params.ChainConfig, error)
	GetProof(ctx context.Context, address common.Address, hash common.Hash) (*eth.AccountResult, error)
	HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
	BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
	BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
	ExecutionWitness(ctx context.Context, hash common.Hash) ([]byte, error)
	Close()
}

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

func (l *L2OutputSubmitter) IsRunning() bool

func (*L2OutputSubmitter) ProposeL2OutputTxData

func (l *L2OutputSubmitter) ProposeL2OutputTxData(proposal *Proposal) ([]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 OOContract

type OOContract interface {
	Version(*bind.CallOpts) (string, error)
	LatestL2Output(opts *bind.CallOpts) (bindings.TypesOutputProposal, error)
}

type Proposal

type Proposal struct {
	Output      *enclave.Proposal
	From        eth.L2BlockRef
	To          eth.L2BlockRef
	Withdrawals bool
}

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

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

	MinProposalInterval uint64
}

type ProposerService

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

	ProposerConfig

	TxManager     txmgr.TxManager
	L1Client      *ethclient.Client
	L2Client      *ethclient.Client
	L2Reth        bool
	RollupClient  *gethrpc.Client
	EnclaveClient *gethrpc.Client

	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 Prover

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

func NewProver

func NewProver(
	ctx context.Context,
	l1 L1Client,
	l2 L2Client,
	rollup RollupClient,
	enclav enclave.RPC,
) (*Prover, error)

func (*Prover) Aggregate

func (o *Prover) Aggregate(ctx context.Context, prevOutputRoot common.Hash, proposals []*Proposal) (*Proposal, error)

func (*Prover) Generate

func (o *Prover) Generate(ctx context.Context, block *types.Block) (*Proposal, error)

type RollupClient

type RollupClient interface {
	RollupConfig(ctx context.Context) (*rollup.Config, error)
	SyncStatus(ctx context.Context) (*eth.SyncStatus, error)
}

func NewRollupClient

func NewRollupClient(client *rpc.Client, metrics caching.Metrics) RollupClient

Jump to

Keyboard shortcuts

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