Skip to content

Commit 9533eab

Browse files
committed
rebase #1087 to new base branch
1 parent e6af5b6 commit 9533eab

File tree

6 files changed

+61
-31
lines changed

6 files changed

+61
-31
lines changed

cmd/geth/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ var (
182182
utils.DARecoveryInitialBatchFlag,
183183
utils.DARecoverySignBlocksFlag,
184184
utils.DARecoveryL2EndBlockFlag,
185+
utils.DARecoveryProduceBlocksFlag,
185186
}
186187

187188
rpcFlags = []cli.Flag{

cmd/utils/flags.go

+7
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,10 @@ var (
922922
Name: "da.recovery.l2endblock",
923923
Usage: "End L2 block to recover to",
924924
}
925+
DARecoveryProduceBlocksFlag = cli.BoolFlag{
926+
Name: "da.recovery.produceblocks",
927+
Usage: "Produce unsigned blocks after L1 recovery for permissionless batch submission",
928+
}
925929
)
926930

927931
// MakeDataDir retrieves the currently requested data directory, terminating
@@ -1686,6 +1690,9 @@ func setDA(ctx *cli.Context, cfg *ethconfig.Config) {
16861690
if ctx.IsSet(DARecoveryL2EndBlockFlag.Name) {
16871691
cfg.DA.L2EndBlock = ctx.Uint64(DARecoveryL2EndBlockFlag.Name)
16881692
}
1693+
if ctx.IsSet(DARecoveryProduceBlocksFlag.Name) {
1694+
cfg.DA.ProduceBlocks = ctx.Bool(DARecoveryProduceBlocksFlag.Name)
1695+
}
16891696
}
16901697

16911698
func setMaxBlockRange(ctx *cli.Context, cfg *ethconfig.Config) {

eth/backend.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,15 @@ func New(stack *node.Node, config *ethconfig.Config, l1Client l1.Client) (*Ether
229229
// simply let them run simultaneously. If messages are missing in DA syncing, it will be handled by the syncing pipeline
230230
// by waiting and retrying.
231231
if config.EnableDASyncing {
232-
eth.syncingPipeline, err = da_syncer.NewSyncingPipeline(context.Background(), eth.blockchain, chainConfig, eth.chainDb, l1Client, stack.Config().L1DeploymentBlock, config.DA)
233-
if err != nil {
234-
return nil, fmt.Errorf("cannot initialize da syncer: %w", err)
232+
// Do not start syncing pipeline if we are producing blocks for permissionless batches.
233+
if !config.DA.ProduceBlocks {
234+
eth.syncingPipeline, err = da_syncer.NewSyncingPipeline(context.Background(), eth.blockchain, chainConfig, eth.chainDb, l1Client, stack.Config().L1DeploymentBlock, config.DA)
235+
if err != nil {
236+
return nil, fmt.Errorf("cannot initialize da syncer: %w", err)
237+
}
238+
239+
eth.syncingPipeline.Start()
235240
}
236-
eth.syncingPipeline.Start()
237241
}
238242

239243
// initialize and start L1 message sync service
@@ -273,7 +277,8 @@ func New(stack *node.Node, config *ethconfig.Config, l1Client l1.Client) (*Ether
273277
return nil, err
274278
}
275279

276-
eth.miner = miner.New(eth, &config.Miner, chainConfig, eth.EventMux(), eth.engine, eth.isLocalBlock, config.EnableDASyncing)
280+
config.Miner.SigningDisabled = config.DA.ProduceBlocks
281+
eth.miner = miner.New(eth, &config.Miner, eth.blockchain.Config(), eth.EventMux(), eth.engine, eth.isLocalBlock, config.EnableDASyncing && !config.DA.ProduceBlocks)
277282
eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData))
278283

279284
eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil}
@@ -632,7 +637,7 @@ func (s *Ethereum) Stop() error {
632637
if s.config.EnableRollupVerify {
633638
s.rollupSyncService.Stop()
634639
}
635-
if s.config.EnableDASyncing {
640+
if s.config.EnableDASyncing && s.syncingPipeline != nil {
636641
s.syncingPipeline.Stop()
637642
}
638643
s.miner.Close()

miner/miner.go

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ type Config struct {
6060
StoreSkippedTxTraces bool // Whether store the wrapped traces when storing a skipped tx
6161
MaxAccountsNum int // Maximum number of accounts that miner will fetch the pending transactions of when building a new block
6262
CCCMaxWorkers int // Maximum number of workers to use for async CCC tasks
63+
64+
SigningDisabled bool // Whether to disable signing blocks with consensus enginek
6365
}
6466

6567
// Miner creates blocks and searches for proof-of-work values.

miner/scroll_worker.go

+38-25
Original file line numberDiff line numberDiff line change
@@ -477,11 +477,19 @@ func (w *worker) newWork(now time.Time, parentHash common.Hash, reorging bool, r
477477
header.Coinbase = w.coinbase
478478
}
479479

480-
prepareStart := time.Now()
481-
if err := w.engine.Prepare(w.chain, header); err != nil {
482-
return fmt.Errorf("failed to prepare header for mining: %w", err)
480+
if w.config.SigningDisabled {
481+
// Need to make sure to set difficulty so that a new canonical chain is detected in Blockchain
482+
header.Difficulty = new(big.Int).SetUint64(1)
483+
header.MixDigest = common.Hash{}
484+
header.Coinbase = common.Address{}
485+
header.Nonce = types.BlockNonce{}
486+
} else {
487+
prepareStart := time.Now()
488+
if err := w.engine.Prepare(w.chain, header); err != nil {
489+
return fmt.Errorf("failed to prepare header for mining: %w", err)
490+
}
491+
prepareTimer.UpdateSince(prepareStart)
483492
}
484-
prepareTimer.UpdateSince(prepareStart)
485493

486494
var nextL1MsgIndex uint64
487495
if dbVal := rawdb.ReadFirstQueueIndexNotInL2Block(w.eth.ChainDb(), header.ParentHash); dbVal != nil {
@@ -828,28 +836,33 @@ func (w *worker) commit() (common.Hash, error) {
828836
return common.Hash{}, err
829837
}
830838

831-
sealHash := w.engine.SealHash(block.Header())
832-
log.Info("Committing new mining work", "number", block.Number(), "sealhash", sealHash,
833-
"txs", w.current.txs.Len(),
834-
"gas", block.GasUsed(), "fees", totalFees(block, w.current.receipts))
835-
836-
resultCh, stopCh := make(chan *types.Block), make(chan struct{})
837-
if err := w.engine.Seal(w.chain, block, resultCh, stopCh); err != nil {
838-
return common.Hash{}, err
839-
}
840-
// Clique.Seal() will only wait for a second before giving up on us. So make sure there is nothing computational heavy
841-
// or a call that blocks between the call to Seal and the line below. Seal might introduce some delay, so we keep track of
842-
// that artificially added delay and subtract it from overall runtime of commit().
843-
sealStart := time.Now()
844-
block = <-resultCh
845-
sealDelay = time.Since(sealStart)
846-
if block == nil {
847-
return common.Hash{}, errors.New("missed seal response from consensus engine")
848-
}
839+
var sealHash common.Hash
840+
if w.config.SigningDisabled {
841+
sealHash = block.Hash()
842+
} else {
843+
sealHash = w.engine.SealHash(block.Header())
844+
log.Info("Committing new mining work", "number", block.Number(), "sealhash", sealHash,
845+
"txs", w.current.txs.Len(),
846+
"gas", block.GasUsed(), "fees", totalFees(block, w.current.receipts))
847+
848+
resultCh, stopCh := make(chan *types.Block), make(chan struct{})
849+
if err := w.engine.Seal(w.chain, block, resultCh, stopCh); err != nil {
850+
return common.Hash{}, err
851+
}
852+
// Clique.Seal() will only wait for a second before giving up on us. So make sure there is nothing computational heavy
853+
// or a call that blocks between the call to Seal and the line below. Seal might introduce some delay, so we keep track of
854+
// that artificially added delay and subtract it from overall runtime of commit().
855+
sealStart := time.Now()
856+
block = <-resultCh
857+
sealDelay = time.Since(sealStart)
858+
if block == nil {
859+
return common.Hash{}, errors.New("missed seal response from consensus engine")
860+
}
849861

850-
// verify the generated block with local consensus engine to make sure everything is as expected
851-
if err = w.engine.VerifyHeader(w.chain, block.Header(), true); err != nil {
852-
return common.Hash{}, retryableCommitError{inner: err}
862+
// verify the generated block with local consensus engine to make sure everything is as expected
863+
if err = w.engine.VerifyHeader(w.chain, block.Header(), true); err != nil {
864+
return common.Hash{}, retryableCommitError{inner: err}
865+
}
853866
}
854867

855868
blockHash := block.Hash()

rollup/da_syncer/syncing_pipeline.go

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ type Config struct {
2929
InitialBatch uint64 // Batch number from which to start syncing and overriding blocks
3030
SignBlocks bool // Whether to sign the blocks after reading them from the pipeline (requires correct Clique signer key) and history of blocks with Clique signatures
3131
L2EndBlock uint64 // L2 block number to sync until
32+
33+
ProduceBlocks bool // Whether to produce blocks in DA recovery mode. The pipeline will be disabled when starting the node with this flag.
3234
}
3335

3436
// SyncingPipeline is a derivation pipeline for syncing data from L1 and DA and transform it into

0 commit comments

Comments
 (0)