Merge pull request #1563 from maticnetwork/raneet10/fix-shadow-fork

Allow mining if DevFakeAuthor is enabled
This commit is contained in:
Raneet Debnath 2025-06-05 09:35:53 +05:30 committed by GitHub
commit bd07cd2fd6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View file

@ -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)

View file

@ -594,11 +594,13 @@ func (w *worker) mainLoop() {
}
}()
bor, isBor := w.engine.(*bor.Bor)
devFakeAuthor := isBor && bor != nil && bor.DevFakeAuthor
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 || devFakeAuthor {
//nolint:contextcheck
w.commitWork(req.interrupt, req.noempty, req.timestamp)
}