Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
feat: support 1.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
emilianobonassi committed Mar 29, 2024
1 parent 0f07c5d commit 85b04f3
Show file tree
Hide file tree
Showing 22 changed files with 179 additions and 437 deletions.
3 changes: 3 additions & 0 deletions op-batcher/batcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ethereum-optimism/optimism/op-batcher/compressor"
"github.com/ethereum-optimism/optimism/op-batcher/flags"
plasma "github.com/ethereum-optimism/optimism/op-plasma"
"github.com/ethereum-optimism/optimism/op-service/eigenda"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
"github.com/ethereum-optimism/optimism/op-service/oppprof"
Expand Down Expand Up @@ -88,6 +89,7 @@ type CLIConfig struct {
PprofConfig oppprof.CLIConfig
RPC oprpc.CLIConfig
PlasmaDA plasma.CLIConfig
DAConfig eigenda.CLIConfig
}

func (c *CLIConfig) Check() error {
Expand Down Expand Up @@ -166,5 +168,6 @@ func NewConfig(ctx *cli.Context) *CLIConfig {
PprofConfig: oppprof.ReadCLIConfig(ctx),
RPC: oprpc.ReadCLIConfig(ctx),
PlasmaDA: plasma.ReadCLIConfig(ctx),
DAConfig: eigenda.ReadCLIConfig(ctx),
}
}
19 changes: 19 additions & 0 deletions op-batcher/batcher/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
plasma "github.com/ethereum-optimism/optimism/op-plasma"
"github.com/ethereum-optimism/optimism/op-service/cliapp"
"github.com/ethereum-optimism/optimism/op-service/dial"
"github.com/ethereum-optimism/optimism/op-service/eigenda"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-service/httputil"
opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
Expand Down Expand Up @@ -73,6 +74,8 @@ type BatcherService struct {
stopped atomic.Bool

NotSubmittingOnStart bool

DA eigenda.IEigenDA
}

// BatcherServiceFromCLIConfig creates a new BatcherService from a CLIConfig.
Expand Down Expand Up @@ -119,6 +122,9 @@ func (bs *BatcherService) initFromCLIConfig(ctx context.Context, version string,
if err := bs.initPlasmaDA(cfg); err != nil {
return fmt.Errorf("failed to init plasma DA: %w", err)
}
if err := bs.initDA(cfg); err != nil {
return fmt.Errorf("failed to init DA: %w", err)
}
bs.initDriver()
if err := bs.initRPCServer(cfg); err != nil {
return fmt.Errorf("failed to start RPC server: %w", err)
Expand Down Expand Up @@ -296,9 +302,22 @@ func (bs *BatcherService) initDriver() {
EndpointProvider: bs.EndpointProvider,
ChannelConfig: bs.ChannelConfig,
PlasmaDA: bs.PlasmaDA,
DA: bs.DA,
})
}

func (bs *BatcherService) initDA(cfg *CLIConfig) error {
bs.DA = &eigenda.EigenDA{
Config: eigenda.Config{
RPC: cfg.DAConfig.RPC,
StatusQueryTimeout: cfg.DAConfig.StatusQueryTimeout,
StatusQueryRetryInterval: cfg.DAConfig.StatusQueryRetryInterval,
},
Log: bs.Log,
}
return nil
}

func (bs *BatcherService) initRPCServer(cfg *CLIConfig) error {
server := oprpc.NewServer(
cfg.RPC.ListenAddr,
Expand Down
2 changes: 2 additions & 0 deletions op-batcher/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ethereum-optimism/optimism/op-batcher/compressor"
plasma "github.com/ethereum-optimism/optimism/op-plasma"
opservice "github.com/ethereum-optimism/optimism/op-service"
"github.com/ethereum-optimism/optimism/op-service/eigenda"
openum "github.com/ethereum-optimism/optimism/op-service/enum"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
Expand Down Expand Up @@ -160,6 +161,7 @@ func init() {
optionalFlags = append(optionalFlags, oppprof.CLIFlags(EnvVarPrefix)...)
optionalFlags = append(optionalFlags, txmgr.CLIFlags(EnvVarPrefix)...)
optionalFlags = append(optionalFlags, plasma.CLIFlags(EnvVarPrefix, "")...)
optionalFlags = append(optionalFlags, eigenda.CLIFlags(EnvVarPrefix)...)

Flags = append(requiredFlags, optionalFlags...)
}
Expand Down
5 changes: 3 additions & 2 deletions op-e2e/actions/l2_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/ethereum-optimism/optimism/op-node/rollup/driver"
"github.com/ethereum-optimism/optimism/op-node/rollup/sync"
"github.com/ethereum-optimism/optimism/op-service/client"
"github.com/ethereum-optimism/optimism/op-service/eigenda"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-service/sources"
"github.com/ethereum-optimism/optimism/op-service/testutils"
Expand Down Expand Up @@ -63,10 +64,10 @@ type safeDB interface {
node.SafeDBReader
}

func NewL2Verifier(t Testing, log log.Logger, l1 derive.L1Fetcher, blobsSrc derive.L1BlobsFetcher, plasmaSrc derive.PlasmaInputFetcher, eng L2API, cfg *rollup.Config, syncCfg *sync.Config, safeHeadListener safeDB) *L2Verifier {
func NewL2Verifier(t Testing, log log.Logger, l1 derive.L1Fetcher, blobsSrc derive.L1BlobsFetcher, plasmaSrc derive.PlasmaInputFetcher, eng L2API, cfg *rollup.Config, syncCfg *sync.Config, safeHeadListener safeDB, daCfg *eigenda.Config) *L2Verifier {
metrics := &testutils.TestDerivationMetrics{}
engine := derive.NewEngineController(eng, log, metrics, cfg, syncCfg.SyncMode)
pipeline := derive.NewDerivationPipeline(log, cfg, l1, blobsSrc, plasmaSrc, eng, engine, metrics, syncCfg, safeHeadListener)
pipeline := derive.NewDerivationPipeline(log, cfg, l1, blobsSrc, plasmaSrc, eng, engine, metrics, syncCfg, safeHeadListener, daCfg)
pipeline.Reset()

rollupNode := &L2Verifier{
Expand Down
8 changes: 0 additions & 8 deletions op-node/da/da_config.go

This file was deleted.

4 changes: 2 additions & 2 deletions op-node/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ var (
Value: time.Second * 1,
Category: SequencerCategory,
}
DaRPC = &cli.StringFlag{
DARPC = &cli.StringFlag{
Name: "da-rpc",
Usage: "Data Availability RPC",
Value: "http://da:26658",
Expand All @@ -365,7 +365,7 @@ var requiredFlags = []cli.Flag{
L1NodeAddr,
L2EngineAddr,
L2EngineJWTSecret,
DaRPC,
DARPC,
}

var optionalFlags = []cli.Flag{
Expand Down
5 changes: 3 additions & 2 deletions op-node/node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"math"
"time"

"github.com/ethereum-optimism/optimism/op-node/da"
"github.com/ethereum-optimism/optimism/op-node/flags"
"github.com/ethereum-optimism/optimism/op-node/p2p"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup/driver"
"github.com/ethereum-optimism/optimism/op-node/rollup/sync"
plasma "github.com/ethereum-optimism/optimism/op-plasma"
"github.com/ethereum-optimism/optimism/op-service/eigenda"
"github.com/ethereum-optimism/optimism/op-service/oppprof"
"github.com/ethereum/go-ethereum/log"
)
Expand Down Expand Up @@ -53,7 +53,8 @@ type Config struct {
// Runtime config changes should be picked up from log-events,
// but if log-events are not coming in (e.g. not syncing blocks) then the reload ensures the config stays accurate.
RuntimeConfigReloadInterval time.Duration
DAConfig da.DAConfig

DA eigenda.Config

// Optional
Tracer Tracer
Expand Down
12 changes: 1 addition & 11 deletions op-node/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"

"github.com/ethereum-optimism/optimism/op-node/da"
"github.com/ethereum-optimism/optimism/op-node/heartbeat"
"github.com/ethereum-optimism/optimism/op-node/metrics"
"github.com/ethereum-optimism/optimism/op-node/p2p"
Expand Down Expand Up @@ -60,7 +59,6 @@ type OpNode struct {
p2pSigner p2p.Signer // p2p gogssip application messages will be signed with this signer
tracer Tracer // tracer to get events for testing/debugging
runCfg *RuntimeConfig // runtime configurables
daCfg *da.DAConfig // EigenDA client and configuration

safeDB closableSafeDB

Expand Down Expand Up @@ -121,9 +119,6 @@ func New(ctx context.Context, cfg *Config, log log.Logger, snapshotLog log.Logge

func (n *OpNode) init(ctx context.Context, cfg *Config, snapshotLog log.Logger) error {
n.log.Info("Initializing rollup node", "version", n.appVersion)
if err := n.initDA(ctx, cfg); err != nil {
return err
}
if err := n.initTracer(ctx, cfg); err != nil {
return fmt.Errorf("failed to init the trace: %w", err)
}
Expand Down Expand Up @@ -158,12 +153,7 @@ func (n *OpNode) init(ctx context.Context, cfg *Config, snapshotLog log.Logger)
if err := n.initPProf(cfg); err != nil {
return fmt.Errorf("failed to init profiling: %w", err)
}
n.daCfg = &cfg.DAConfig
return nil
}

func (n *OpNode) initDA(ctx context.Context, cfg *Config) error {
n.daCfg = &cfg.DAConfig
return nil
}

Expand Down Expand Up @@ -413,7 +403,7 @@ func (n *OpNode) initL2(ctx context.Context, cfg *Config, snapshotLog log.Logger
} else {
n.safeDB = safedb.Disabled
}
n.l2Driver = driver.NewDriver(&cfg.Driver, &cfg.Rollup, n.daCfg, n.l2Source, n.l1Source, n.beacon, n, n, n.log, snapshotLog, n.metrics, cfg.ConfigPersistence, n.safeDB, &cfg.Sync, sequencerConductor, plasmaDA)
n.l2Driver = driver.NewDriver(&cfg.Driver, &cfg.Rollup, n.l2Source, n.l1Source, n.beacon, n, n, n.log, snapshotLog, n.metrics, cfg.ConfigPersistence, n.safeDB, &cfg.Sync, sequencerConductor, plasmaDA, &cfg.DA)
return nil
}

Expand Down
18 changes: 13 additions & 5 deletions op-node/rollup/derive/blob_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"

"github.com/ethereum-optimism/optimism/op-service/eigenda"
"github.com/ethereum-optimism/optimism/op-service/eth"
)

Expand All @@ -30,17 +31,19 @@ type BlobDataSource struct {
fetcher L1TransactionFetcher
blobsFetcher L1BlobsFetcher
log log.Logger
daClient eigenda.IEigenDA
}

// NewBlobDataSource creates a new blob data source.
func NewBlobDataSource(ctx context.Context, log log.Logger, dsCfg DataSourceConfig, fetcher L1TransactionFetcher, blobsFetcher L1BlobsFetcher, ref eth.L1BlockRef, batcherAddr common.Address) DataIter {
func NewBlobDataSource(ctx context.Context, log log.Logger, dsCfg DataSourceConfig, fetcher L1TransactionFetcher, blobsFetcher L1BlobsFetcher, ref eth.L1BlockRef, batcherAddr common.Address, daClient eigenda.IEigenDA) DataIter {
return &BlobDataSource{
ref: ref,
dsCfg: dsCfg,
fetcher: fetcher,
log: log.New("origin", ref),
batcherAddr: batcherAddr,
blobsFetcher: blobsFetcher,
daClient: daClient,
}
}

Expand Down Expand Up @@ -86,7 +89,7 @@ func (ds *BlobDataSource) open(ctx context.Context) ([]blobOrCalldata, error) {
return nil, NewTemporaryError(fmt.Errorf("failed to open blob data source: %w", err))
}

data, hashes := dataAndHashesFromTxs(txs, &ds.dsCfg, ds.batcherAddr)
data, hashes := dataAndHashesFromTxs(txs, &ds.dsCfg, ds.batcherAddr, ds.daClient)

if len(hashes) == 0 {
// there are no blobs to fetch so we can return immediately
Expand Down Expand Up @@ -115,20 +118,25 @@ func (ds *BlobDataSource) open(ctx context.Context) ([]blobOrCalldata, error) {
// dataAndHashesFromTxs extracts calldata and datahashes from the input transactions and returns them. It
// creates a placeholder blobOrCalldata element for each returned blob hash that must be populated
// by fillBlobPointers after blob bodies are retrieved.
func dataAndHashesFromTxs(txs types.Transactions, config *DataSourceConfig, batcherAddr common.Address) ([]blobOrCalldata, []eth.IndexedBlobHash) {
func dataAndHashesFromTxs(txs types.Transactions, config *DataSourceConfig, batcherAddr common.Address, daClient eigenda.IEigenDA) ([]blobOrCalldata, []eth.IndexedBlobHash) {
data := []blobOrCalldata{}
var hashes []eth.IndexedBlobHash
blobIndex := 0 // index of each blob in the block's blob sidecar
for _, tx := range txs {
logger := log.New("tx", tx.Hash())
// skip any non-batcher transactions
if !isValidBatchTx(tx, config.l1Signer, config.batchInboxAddress, batcherAddr) {
blobIndex += len(tx.BlobHashes())
continue
}
// handle non-blob batcher transactions by extracting their calldata
if tx.Type() != types.BlobTxType {
calldata := eth.Data(tx.Data())
data = append(data, blobOrCalldata{nil, &calldata})
calldata := DataFromEVMTransactions(*config, batcherAddr, types.Transactions{tx}, logger, daClient)
if len(calldata) == 0 {
log.Warn("eigenda: skipping empty calldata")
continue
}
data = append(data, blobOrCalldata{nil, &calldata[0]})
continue
}
// handle blob batcher transactions by extracting their blob hashes, ignoring any calldata.
Expand Down
10 changes: 5 additions & 5 deletions op-node/rollup/derive/blob_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestDataAndHashesFromTxs(t *testing.T) {
}
calldataTx, _ := types.SignNewTx(privateKey, signer, txData)
txs := types.Transactions{calldataTx}
data, blobHashes := dataAndHashesFromTxs(txs, &config, batcherAddr)
data, blobHashes := dataAndHashesFromTxs(txs, &config, batcherAddr, nil)
require.Equal(t, 1, len(data))
require.Equal(t, 0, len(blobHashes))

Expand All @@ -57,22 +57,22 @@ func TestDataAndHashesFromTxs(t *testing.T) {
}
blobTx, _ := types.SignNewTx(privateKey, signer, blobTxData)
txs = types.Transactions{blobTx}
data, blobHashes = dataAndHashesFromTxs(txs, &config, batcherAddr)
data, blobHashes = dataAndHashesFromTxs(txs, &config, batcherAddr, nil)
require.Equal(t, 1, len(data))
require.Equal(t, 1, len(blobHashes))
require.Nil(t, data[0].calldata)

// try again with both the blob & calldata transactions and make sure both are picked up
txs = types.Transactions{blobTx, calldataTx}
data, blobHashes = dataAndHashesFromTxs(txs, &config, batcherAddr)
data, blobHashes = dataAndHashesFromTxs(txs, &config, batcherAddr, nil)
require.Equal(t, 2, len(data))
require.Equal(t, 1, len(blobHashes))
require.NotNil(t, data[1].calldata)

// make sure blob tx to the batch inbox is ignored if not signed by the batcher
blobTx, _ = types.SignNewTx(testutils.RandomKey(), signer, blobTxData)
txs = types.Transactions{blobTx}
data, blobHashes = dataAndHashesFromTxs(txs, &config, batcherAddr)
data, blobHashes = dataAndHashesFromTxs(txs, &config, batcherAddr, nil)
require.Equal(t, 0, len(data))
require.Equal(t, 0, len(blobHashes))

Expand All @@ -81,7 +81,7 @@ func TestDataAndHashesFromTxs(t *testing.T) {
blobTxData.To = testutils.RandomAddress(rng)
blobTx, _ = types.SignNewTx(privateKey, signer, blobTxData)
txs = types.Transactions{blobTx}
data, blobHashes = dataAndHashesFromTxs(txs, &config, batcherAddr)
data, blobHashes = dataAndHashesFromTxs(txs, &config, batcherAddr, nil)
require.Equal(t, 0, len(data))
require.Equal(t, 0, len(blobHashes))
}
Expand Down
Loading

0 comments on commit 85b04f3

Please sign in to comment.