From 8f443af444d59c512d0983c30b82ad14dd4eab8d Mon Sep 17 00:00:00 2001 From: dmarz Date: Tue, 19 Sep 2023 15:10:34 +0200 Subject: [PATCH] miner, core, params: enable empty blocks + Developer Chain Config (#36) * miner: remove empty block breaks * core, params: Suave Developer chain config --------- Co-authored-by: dmarzzz --- core/genesis.go | 2 +- miner/worker.go | 6 +----- params/config.go | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/core/genesis.go b/core/genesis.go index 0d77fe6ce..6496a7127 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -597,7 +597,7 @@ func DefaultSepoliaGenesisBlock() *Genesis { // DeveloperGenesisBlock returns the 'geth --dev' genesis block. func DeveloperGenesisBlock(period uint64, gasLimit uint64, faucet common.Address) *Genesis { // Override the default period to the user requested one - config := *params.SuaveChainConfig + config := *params.DeveloperSuaveChainConfig // Assemble and return the genesis with the precompiles and faucet pre-funded return &Genesis{ diff --git a/miner/worker.go b/miner/worker.go index 124a87d78..fb63054f7 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -648,8 +648,7 @@ func (w *worker) mainLoop() { // Special case, if the consensus engine is 0 period clique(dev mode), // submit sealing work here since all empty submission will be rejected // by clique. Of course the advance sealing(empty submission) is disabled. - if w.chainConfig.Clique != nil && false { // && w.chainConfig.Clique.Period == 0 { - // Don't commit empty! + if w.chainConfig.Clique != nil && w.chainConfig.Clique.Period == 0 { w.commitWork(nil, true, time.Now().Unix()) } } @@ -730,9 +729,6 @@ func (w *worker) resultLoop() { if block == nil { continue } - if block.Transactions().Len() == 0 { - continue - } // Short circuit when receiving duplicate result caused by resubmitting. if w.chain.HasBlock(block.Hash(), block.NumberU64()) { continue diff --git a/params/config.go b/params/config.go index a01d47fed..2cbcd1630 100644 --- a/params/config.go +++ b/params/config.go @@ -152,6 +152,30 @@ var ( Epoch: 30000, }, } + + // SuaveChainConfig for development with 0 period to avoid mining empty blocks + DeveloperSuaveChainConfig = &ChainConfig{ + ChainID: big.NewInt(424242), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: false, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + SuaveBlock: big.NewInt(0), + ArrowGlacierBlock: nil, + Clique: &CliqueConfig{ + Period: 0, + Epoch: 30000, + }, + } // AllEthashProtocolChanges contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers into the Ethash consensus. AllEthashProtocolChanges = &ChainConfig{