Skip to content

Commit

Permalink
Regular info tree updates (#1399)
Browse files Browse the repository at this point in the history
* starting work on info tree updates during execution

* info tree updater in sequencer loop

* logging latest index for info tree updates
  • Loading branch information
hexoscott authored Nov 4, 2024
1 parent 5187e6f commit 7cfc631
Show file tree
Hide file tree
Showing 11 changed files with 360 additions and 251 deletions.
7 changes: 6 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,9 +738,14 @@ var (
Usage: "The file that contains the initial (injected) batch data.",
Value: "",
}
InfoTreeUpdateInterval = cli.DurationFlag{
Name: "zkevm.info-tree-update-interval",
Usage: "The interval at which the sequencer checks the L1 for new GER information",
Value: 1 * time.Minute,
}
ACLPrintHistory = cli.IntFlag{
Name: "acl.print-history",
Usage: "Number of entries to print from the ACL history on node startup",
Usage: "Number of entries to print from the ACL history on node start up",
Value: 10,
}
DebugTimers = cli.BoolFlag{
Expand Down
7 changes: 5 additions & 2 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ import (
"github.com/ledgerwatch/erigon/zk/utils"
"github.com/ledgerwatch/erigon/zk/witness"
"github.com/ledgerwatch/erigon/zkevm/etherman"
"github.com/ledgerwatch/erigon/zk/l1infotree"
)

// Config contains the configuration options of the ETH protocol.
Expand Down Expand Up @@ -1097,6 +1098,8 @@ func New(ctx context.Context, stack *node.Node, config *ethconfig.Config, logger
cfg.L1HighestBlockType,
)

l1InfoTreeUpdater := l1infotree.NewUpdater(cfg.Zk, l1InfoTreeSyncer)

if isSequencer {
// if we are sequencing transactions, we do the sequencing loop...
witnessGenerator := witness.NewGenerator(
Expand Down Expand Up @@ -1167,11 +1170,11 @@ func New(ctx context.Context, stack *node.Node, config *ethconfig.Config, logger
backend.dataStream,
backend.l1Syncer,
seqVerSyncer,
l1InfoTreeSyncer,
l1BlockSyncer,
backend.txPool2,
backend.txPool2DB,
verifier,
l1InfoTreeUpdater,
)

backend.syncUnwindOrder = zkStages.ZkSequencerUnwindOrder
Expand Down Expand Up @@ -1205,9 +1208,9 @@ func New(ctx context.Context, stack *node.Node, config *ethconfig.Config, logger
backend.forkValidator,
backend.engine,
backend.l1Syncer,
l1InfoTreeSyncer,
streamClient,
backend.dataStream,
l1InfoTreeUpdater,
)

backend.syncUnwindOrder = zkStages.ZkUnwindOrder
Expand Down
5 changes: 3 additions & 2 deletions eth/ethconfig/config_zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ type Zk struct {

TxPoolRejectSmartContractDeployments bool

InitialBatchCfgFile string
ACLPrintHistory int
InitialBatchCfgFile string
ACLPrintHistory int
InfoTreeUpdateInterval time.Duration
}

var DefaultZkConfig = &Zk{}
Expand Down
1 change: 1 addition & 0 deletions turbo/cli/default_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,5 @@ var DefaultFlags = []cli.Flag{
&utils.InitialBatchCfgFile,

&utils.ACLPrintHistory,
&utils.InfoTreeUpdateInterval,
}
1 change: 1 addition & 0 deletions turbo/cli/flags_zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ func ApplyFlagsForZkConfig(ctx *cli.Context, cfg *ethconfig.Config) {
VirtualCountersSmtReduction: ctx.Float64(utils.VirtualCountersSmtReduction.Name),
InitialBatchCfgFile: ctx.String(utils.InitialBatchCfgFile.Name),
ACLPrintHistory: ctx.Int(utils.ACLPrintHistory.Name),
InfoTreeUpdateInterval: ctx.Duration(utils.InfoTreeUpdateInterval.Name),
}

utils2.EnableTimer(cfg.DebugTimers)
Expand Down
10 changes: 6 additions & 4 deletions turbo/stages/zk_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
zkStages "github.com/ledgerwatch/erigon/zk/stages"
"github.com/ledgerwatch/erigon/zk/syncer"
"github.com/ledgerwatch/erigon/zk/txpool"
"github.com/ledgerwatch/erigon/zk/l1infotree"
)

// NewDefaultZkStages creates stages for zk syncer (RPC mode)
Expand All @@ -34,9 +35,9 @@ func NewDefaultZkStages(ctx context.Context,
forkValidator *engine_helpers.ForkValidator,
engine consensus.Engine,
l1Syncer *syncer.L1Syncer,
l1InfoTreeSyncer *syncer.L1Syncer,
datastreamClient zkStages.DatastreamClient,
datastreamServer *datastreamer.StreamServer,
infoTreeUpdater *l1infotree.Updater,
) []*stagedsync.Stage {
dirs := cfg.Dirs
blockWriter := blockio.NewBlockWriter(cfg.HistoryV3)
Expand All @@ -51,7 +52,7 @@ func NewDefaultZkStages(ctx context.Context,

return zkStages.DefaultZkStages(ctx,
zkStages.StageL1SyncerCfg(db, l1Syncer, cfg.Zk),
zkStages.StageL1InfoTreeCfg(db, cfg.Zk, l1InfoTreeSyncer),
zkStages.StageL1InfoTreeCfg(db, cfg.Zk, infoTreeUpdater),
zkStages.StageBatchesCfg(db, datastreamClient, cfg.Zk, controlServer.ChainConfig, &cfg.Miner),
zkStages.StageDataStreamCatchupCfg(datastreamServer, db, cfg.Genesis.Config.ChainID.Uint64(), cfg.DatastreamVersion, cfg.HasExecutors()),
stagedsync.StageBlockHashesCfg(db, dirs.Tmp, controlServer.ChainConfig, blockWriter),
Expand Down Expand Up @@ -101,11 +102,11 @@ func NewSequencerZkStages(ctx context.Context,
datastreamServer *datastreamer.StreamServer,
sequencerStageSyncer *syncer.L1Syncer,
l1Syncer *syncer.L1Syncer,
l1InfoTreeSyncer *syncer.L1Syncer,
l1BlockSyncer *syncer.L1Syncer,
txPool *txpool.TxPool,
txPoolDb kv.RwDB,
verifier *legacy_executor_verifier.LegacyExecutorVerifier,
infoTreeUpdater *l1infotree.Updater,
) []*stagedsync.Stage {
dirs := cfg.Dirs
blockReader := freezeblocks.NewBlockReader(snapshots, nil)
Expand All @@ -117,7 +118,7 @@ func NewSequencerZkStages(ctx context.Context,
return zkStages.SequencerZkStages(ctx,
zkStages.StageL1SyncerCfg(db, l1Syncer, cfg.Zk),
zkStages.StageL1SequencerSyncCfg(db, cfg.Zk, sequencerStageSyncer),
zkStages.StageL1InfoTreeCfg(db, cfg.Zk, l1InfoTreeSyncer),
zkStages.StageL1InfoTreeCfg(db, cfg.Zk, infoTreeUpdater),
zkStages.StageSequencerL1BlockSyncCfg(db, cfg.Zk, l1BlockSyncer),
zkStages.StageDataStreamCatchupCfg(datastreamServer, db, cfg.Genesis.Config.ChainID.Uint64(), cfg.DatastreamVersion, cfg.HasExecutors()),
zkStages.StageSequenceBlocksCfg(
Expand All @@ -144,6 +145,7 @@ func NewSequencerZkStages(ctx context.Context,
txPoolDb,
verifier,
uint16(cfg.YieldSize),
infoTreeUpdater,
),
stagedsync.StageHashStateCfg(db, dirs, cfg.HistoryV3, agg),
zkStages.StageZkInterHashesCfg(db, true, true, false, dirs.Tmp, blockReader, controlServer.Hd, cfg.HistoryV3, agg, cfg.Zk),
Expand Down
Loading

0 comments on commit 7cfc631

Please sign in to comment.