From b65f3b5b4ec60fe024bbcce3c6c5226e500a46e8 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Wed, 4 Jun 2025 10:40:32 +0530 Subject: [PATCH] consensus,miner: allow mining in case of no peers if DevFakeAuthor is enabled --- consensus/bor/bor.go | 6 +++--- miner/worker.go | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/consensus/bor/bor.go b/consensus/bor/bor.go index 5303be53e2..8128dba111 100644 --- a/consensus/bor/bor.go +++ b/consensus/bor/bor.go @@ -231,7 +231,7 @@ type Bor struct { // The fields below are for testing only fakeDiff bool // Skip difficulty verifications - devFakeAuthor bool + DevFakeAuthor bool closeOnce sync.Once } @@ -276,7 +276,7 @@ func New( GenesisContractsClient: genesisContracts, HeimdallClient: heimdallClient, spanStore: spanStore, - devFakeAuthor: devFakeAuthor, + DevFakeAuthor: devFakeAuthor, } c.authorizedSigner.Store(&signer{ @@ -539,7 +539,7 @@ func (c *Bor) verifyCascadingFields(chain consensus.ChainHeaderReader, header *t func (c *Bor) snapshot(chain consensus.ChainHeaderReader, number uint64, hash common.Hash, parents []*types.Header) (*Snapshot, error) { // Search for a snapshot in memory or on disk for checkpoints signer := common.BytesToAddress(c.authorizedSigner.Load().signer.Bytes()) - if c.devFakeAuthor && signer.String() != "0x0000000000000000000000000000000000000000" { + if c.DevFakeAuthor && signer.String() != "0x0000000000000000000000000000000000000000" { log.Info("👨‍💻Using DevFakeAuthor", "signer", signer) val := valset.NewValidator(signer, 1000) diff --git a/miner/worker.go b/miner/worker.go index 94a99a7a16..77185b24d6 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -594,11 +594,12 @@ func (w *worker) mainLoop() { } }() + bor, _ := w.engine.(*bor.Bor) for { select { case req := <-w.newWorkCh: if w.chainConfig.ChainID.Cmp(params.BorMainnetChainConfig.ChainID) == 0 || w.chainConfig.ChainID.Cmp(params.MumbaiChainConfig.ChainID) == 0 || w.chainConfig.ChainID.Cmp(params.AmoyChainConfig.ChainID) == 0 { - if w.eth.PeerCount() > 0 { + if w.eth.PeerCount() > 0 || bor.DevFakeAuthor { //nolint:contextcheck w.commitWork(req.interrupt, req.noempty, req.timestamp) }