Skip to content

Commit

Permalink
Remove batcher <> proposer link
Browse files Browse the repository at this point in the history
Switch to eager proving unsafe blocks
  • Loading branch information
mdehoog committed Oct 5, 2024
1 parent a7cf583 commit b091b97
Show file tree
Hide file tree
Showing 11 changed files with 164 additions and 284 deletions.
13 changes: 2 additions & 11 deletions op-batcher/batcher/batch_submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
opservice "github.com/ethereum-optimism/optimism/op-service"
"github.com/ethereum-optimism/optimism/op-service/cliapp"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum/go-ethereum/rpc"
thisflags "github.com/mdehoog/op-enclave/op-batcher/flags"
"github.com/urfave/cli/v2"
)

Expand All @@ -28,18 +26,11 @@ func Main(version string) cliapp.LifecycleAction {

l := oplog.NewLogger(oplog.AppOut(cliCtx), cfg.LogConfig)
oplog.SetGlobalLogHandler(l.Handler())
opservice.ValidateEnvVars(flags.EnvVarPrefix, thisflags.Flags, l)

proposerClient, err := rpc.DialContext(cliCtx.Context, cliCtx.String(thisflags.ProposerRpcFlag.Name))
if err != nil {
return nil, fmt.Errorf("failed to connect to Proposer: %w", err)
}
opservice.ValidateEnvVars(flags.EnvVarPrefix, flags.Flags, l)

l.Info("Initializing Batch Submitter")
channelFactoryOpt := func(setup *batcher.DriverSetup) {
metricer := NewMetricer(setup.Metr, setup.Log, proposerClient)
setup.Metr = metricer
setup.ChannelOutFactory = ChannelOutFactory(metricer)
setup.ChannelOutFactory = NewChannelOut
}
return batcher.BatcherServiceFromCLIConfig(cliCtx.Context, version, cfg, l, channelFactoryOpt)
}
Expand Down
29 changes: 7 additions & 22 deletions op-batcher/batcher/channel_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,22 @@ import (

var ErrWithdrawalDetected = errors.New("withdrawal detected")

type ChannelOut interface {
derive.ChannelOut
Blocks() []*types.Block
}

func ChannelOutFactory(metricer Metricer) batcher.ChannelOutFactory {
return func(cfg batcher.ChannelConfig, rollupCfg *rollup.Config) (derive.ChannelOut, error) {
co, err := batcher.NewChannelOut(cfg, rollupCfg)
if err != nil {
return nil, err
}
wrapped := &channelOut{
ChannelOut: co,
}
metricer.RegisterChannel(wrapped)
return wrapped, nil
func NewChannelOut(cfg batcher.ChannelConfig, rollupCfg *rollup.Config) (derive.ChannelOut, error) {
co, err := batcher.NewChannelOut(cfg, rollupCfg)
if err != nil {
return nil, err
}
return &channelOut{
ChannelOut: co,
}, nil
}

type channelOut struct {
derive.ChannelOut
fullErr error
blocks []*types.Block
}

func (c *channelOut) Blocks() []*types.Block {
return c.blocks
}

func (c *channelOut) AddBlock(config *rollup.Config, block *types.Block) (*derive.L1BlockInfo, error) {
c.blocks = append(c.blocks, block)
if block.Bloom().Test(predeploys.L2ToL1MessagePasserAddr.Bytes()) {
c.fullErr = ErrWithdrawalDetected
}
Expand Down
55 changes: 0 additions & 55 deletions op-batcher/batcher/metricer.go

This file was deleted.

2 changes: 1 addition & 1 deletion op-batcher/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"os"

"github.com/ethereum-optimism/optimism/op-batcher/flags"
"github.com/mdehoog/op-enclave/op-batcher/batcher"
"github.com/mdehoog/op-enclave/op-batcher/flags"
"github.com/urfave/cli/v2"

opservice "github.com/ethereum-optimism/optimism/op-service"
Expand Down
30 changes: 0 additions & 30 deletions op-batcher/flags/flags.go

This file was deleted.

7 changes: 7 additions & 0 deletions op-enclave/enclave/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,13 @@ func (s *Server) ExecuteStateless(
}

func (s *Server) Aggregate(ctx context.Context, configHash common.Hash, prevOutputRoot common.Hash, proposals []*Proposal) (*Proposal, error) {
if len(proposals) == 0 {
return nil, errors.New("no proposals")
}
if len(proposals) == 1 {
return proposals[0], nil
}

outputRoot := prevOutputRoot
var l1OriginHash common.Hash
for _, p := range proposals {
Expand Down
5 changes: 5 additions & 0 deletions op-proposer/proposer/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
)

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)
Expand Down Expand Up @@ -73,6 +74,10 @@ func (e *ethClient) ChainConfig(ctx context.Context) (*params.ChainConfig, error
return &config, nil
}

func (e *ethClient) BlockNumber(ctx context.Context) (uint64, error) {
return e.client.BlockNumber(ctx)
}

func (e *ethClient) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
if header, ok := e.headersCache.Get(hash); ok {
return header, nil
Expand Down
Loading

0 comments on commit b091b97

Please sign in to comment.