Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions op-proposer/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ var (
}

// Optional flags
L2OOAddressFlag = &cli.StringFlag{
Name: "l2oo-address",
Usage: "Address of the L2OutputOracle contract",
EnvVars: prefixEnvVars("L2OO_ADDRESS"),
}
PollIntervalFlag = &cli.DurationFlag{
Name: "poll-interval",
Usage: "Delay between periodic checks on whether it is time to load an output root and propose it.",
Expand Down Expand Up @@ -95,7 +90,6 @@ var requiredFlags = []cli.Flag{
var optionalFlags = []cli.Flag{
RollupRpcFlag,
SupervisorRpcsFlag,
L2OOAddressFlag,
PollIntervalFlag,
AllowNonFinalizedFlag,
L2OutputHDPathFlag,
Expand Down
87 changes: 0 additions & 87 deletions op-proposer/proposer/abi_test.go

This file was deleted.

1 change: 0 additions & 1 deletion op-proposer/proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ func NewConfig(ctx *cli.Context) *CLIConfig {
L1EthRpc: ctx.String(flags.L1EthRpcFlag.Name),
RollupRpc: ctx.String(flags.RollupRpcFlag.Name),
SupervisorRpcs: ctx.StringSlice(flags.SupervisorRpcsFlag.Name),
L2OOAddress: ctx.String(flags.L2OOAddressFlag.Name),
PollInterval: ctx.Duration(flags.PollIntervalFlag.Name),
TxMgrConfig: txmgr.ReadCLIConfig(ctx),
AllowNonFinalized: ctx.Bool(flags.AllowNonFinalizedFlag.Name),
Expand Down
126 changes: 13 additions & 113 deletions op-proposer/proposer/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"sync/atomic"
"time"

"github.com/ethereum-optimism/optimism/op-proposer/bindings"
"github.com/ethereum-optimism/optimism/op-proposer/contracts"
"github.com/ethereum-optimism/optimism/op-proposer/metrics"
"github.com/ethereum-optimism/optimism/op-proposer/proposer/source"
Expand All @@ -25,9 +24,7 @@ import (
"github.com/ethereum/go-ethereum/log"
)

var (
ErrProposerNotRunning = errors.New("proposer is not running")
)
var ErrProposerNotRunning = errors.New("proposer is not running")

type L1Client interface {
HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
Expand Down Expand Up @@ -98,46 +95,11 @@ func NewL2OutputSubmitter(setup DriverSetup) (_ *L2OutputSubmitter, err error) {
}
}()

if setup.Cfg.L2OutputOracleAddr != nil {
return newL2OOSubmitter(ctx, cancel, setup)
} else if setup.Cfg.DisputeGameFactoryAddr != nil {
return newDGFSubmitter(ctx, cancel, setup)
} else {
return nil, errors.New("neither the `L2OutputOracle` nor `DisputeGameFactory` addresses were provided")
}
}

func newL2OOSubmitter(ctx context.Context, cancel context.CancelFunc, setup DriverSetup) (*L2OutputSubmitter, error) {
l2ooContract, err := bindings.NewL2OutputOracleCaller(*setup.Cfg.L2OutputOracleAddr, setup.L1Client)
if err != nil {
cancel()
return nil, fmt.Errorf("failed to create L2OO at address %s: %w", setup.Cfg.L2OutputOracleAddr, err)
}

cCtx, cCancel := context.WithTimeout(ctx, setup.Cfg.NetworkTimeout)
defer cCancel()
version, err := l2ooContract.Version(&bind.CallOpts{Context: cCtx})
if err != nil {
cancel()
return nil, err
}
log.Info("Connected to L2OutputOracle", "address", setup.Cfg.L2OutputOracleAddr, "version", version)

parsed, err := bindings.L2OutputOracleMetaData.GetAbi()
if err != nil {
cancel()
return nil, err
if setup.Cfg.DisputeGameFactoryAddr == nil {
return nil, errors.New("missing DisputeGameFactory address")
}

return &L2OutputSubmitter{
DriverSetup: setup,
done: make(chan struct{}),
ctx: ctx,
cancel: cancel,

l2ooContract: l2ooContract,
l2ooABI: parsed,
}, nil
return newDGFSubmitter(ctx, cancel, setup)
}

func newDGFSubmitter(ctx context.Context, cancel context.CancelFunc, setup DriverSetup) (*L2OutputSubmitter, error) {
Expand Down Expand Up @@ -326,85 +288,24 @@ func (l *L2OutputSubmitter) FetchOutput(ctx context.Context, block uint64) (sour
return proposal, nil
}

// ProposeL2OutputTxData creates the transaction data for the ProposeL2Output function
func (l *L2OutputSubmitter) ProposeL2OutputTxData(output source.Proposal) ([]byte, error) {
return proposeL2OutputTxData(l.l2ooABI, output)
}

// proposeL2OutputTxData creates the transaction data for the ProposeL2Output function
func proposeL2OutputTxData(abi *abi.ABI, output source.Proposal) ([]byte, error) {
return abi.Pack(
"proposeL2Output",
output.Root,
new(big.Int).SetUint64(output.SequenceNum),
output.CurrentL1.Hash,
new(big.Int).SetUint64(output.CurrentL1.Number))
}

func (l *L2OutputSubmitter) ProposeL2OutputDGFTxCandidate(ctx context.Context, output source.Proposal) (txmgr.TxCandidate, error) {
cCtx, cancel := context.WithTimeout(ctx, l.Cfg.NetworkTimeout)
defer cancel()
return l.dgfContract.ProposalTx(cCtx, l.Cfg.DisputeGameType, output.Root, output.ExtraData())
}

// We wait until l1head advances beyond blocknum. This is used to make sure proposal tx won't
// immediately fail when checking the l1 blockhash. Note that EstimateGas uses "latest" state to
// execute the transaction by default, meaning inside the call, the head block is considered
// "pending" instead of committed. In the case l1blocknum == l1head then, blockhash(l1blocknum)
// will produce a value of 0 within EstimateGas, and the call will fail when the contract checks
// that l1blockhash matches blockhash(l1blocknum).
func (l *L2OutputSubmitter) waitForL1Head(ctx context.Context, blockNum uint64) error {
ticker := time.NewTicker(l.Cfg.PollInterval)
defer ticker.Stop()
l1head, err := l.Txmgr.BlockNumber(ctx)
if err != nil {
return err
}
for l1head <= blockNum {
l.Log.Debug("Waiting for l1 head > l1blocknum1+1", "l1head", l1head, "l1blocknum", blockNum)
select {
case <-ticker.C:
l1head, err = l.Txmgr.BlockNumber(ctx)
if err != nil {
return err
}
case <-l.done:
return fmt.Errorf("L2OutputSubmitter is done()")
}
}
return nil
}

// sendTransaction creates & sends transactions through the underlying transaction manager.
func (l *L2OutputSubmitter) sendTransaction(ctx context.Context, output source.Proposal) error {
l.Log.Info("Proposing output root", "output", output.Root, "sequenceNum", output.SequenceNum, "extraData", output.ExtraData())
var receipt *types.Receipt
if l.Cfg.DisputeGameFactoryAddr != nil {
candidate, err := l.ProposeL2OutputDGFTxCandidate(ctx, output)
if err != nil {
return err
}
receipt, err = l.Txmgr.Send(ctx, candidate)
if err != nil {
return err
}
} else {
err := l.waitForL1Head(ctx, output.Legacy.HeadL1.Number+1)
if err != nil {
return err
}
data, err := l.ProposeL2OutputTxData(output)
if err != nil {
return err
}
receipt, err = l.Txmgr.Send(ctx, txmgr.TxCandidate{
TxData: data,
To: l.Cfg.L2OutputOracleAddr,
GasLimit: 0,
})
if err != nil {
return err
}

candidate, err := l.ProposeL2OutputDGFTxCandidate(ctx, output)
if err != nil {
return fmt.Errorf("failed to create DGF tx candidate: %w", err)
}

receipt, err := l.Txmgr.Send(ctx, candidate)
if err != nil {
return fmt.Errorf("failed to send proposal tx: %w", err)
}

if receipt.Status == types.ReceiptStatusFailed {
Expand Down Expand Up @@ -460,7 +361,6 @@ func (l *L2OutputSubmitter) loop() {
return
}
}

}

func (l *L2OutputSubmitter) waitNodeSync() error {
Expand Down
Loading