diff --git a/consensus/misc/eip1559.go b/consensus/misc/eip1559.go index f10c8346b8d..bbaa27b2e11 100644 --- a/consensus/misc/eip1559.go +++ b/consensus/misc/eip1559.go @@ -22,7 +22,6 @@ import ( "github.com/ledgerwatch/erigon-lib/chain" "github.com/ledgerwatch/erigon-lib/common" - libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/polygon/bor/borcfg" @@ -66,7 +65,7 @@ type eip1559Calculator struct{} func (f eip1559Calculator) CurrentFees(chainConfig *chain.Config, db kv.Getter) (baseFee, blobFee, minBlobGasPrice, blockGasLimit uint64, err error) { hash := rawdb.ReadHeadHeaderHash(db) - if hash == (libcommon.Hash{}) { + if hash == (common.Hash{}) { return 0, 0, 0, 0, fmt.Errorf("can't get head header hash") } @@ -80,7 +79,7 @@ func (f eip1559Calculator) CurrentFees(chainConfig *chain.Config, db kv.Getter) if chainConfig != nil { if currentHeader.BaseFee != nil { - baseFee = CalcBaseFee(chainConfig, currentHeader).Uint64() + baseFee = CalcBaseFeeZk(chainConfig, currentHeader).Uint64() } if currentHeader.ExcessBlobGas != nil { diff --git a/consensus/misc/eip1559_zk.go b/consensus/misc/eip1559_zk.go index 721c08a3150..55f92a8bd29 100644 --- a/consensus/misc/eip1559_zk.go +++ b/consensus/misc/eip1559_zk.go @@ -5,12 +5,19 @@ import ( "github.com/ledgerwatch/erigon-lib/chain" "github.com/ledgerwatch/erigon/core/types" + "github.com/ledgerwatch/erigon/params" ) func CalcBaseFeeZk(config *chain.Config, parent *types.Header) *big.Int { - if config.SupportGasless { + if config.SupportGasless || parent.Number.Cmp(big.NewInt(0)) == 0 { + // If the parent is the genesis block, the next block will include the initial batch transaction, which is a legacy transaction, so the basefee will be set to 0 return big.NewInt(0) } + // If the parent block is injected block from L1 at block 1 (while block 0 is the genesis), it will have base fee of 0 so we will set the basefee of current block to the initial basefee + if parent.Number.Cmp(big.NewInt(1)) == 0 { + return new(big.Int).SetUint64(params.InitialBaseFee) + } + return CalcBaseFee(config, parent) } diff --git a/core/genesis_write.go b/core/genesis_write.go index 56d650117e3..14f7d282837 100644 --- a/core/genesis_write.go +++ b/core/genesis_write.go @@ -191,11 +191,13 @@ func WriteGenesisBlock(tx kv.RwTx, genesis *types.Genesis, overridePragueTime *b } // set unwanted forks block to max number, so they are not activated - maxInt := new(big.Int).SetUint64(math.MaxUint64) - newCfg.LondonBlock = maxInt - newCfg.ShanghaiTime = maxInt - newCfg.CancunTime = maxInt - newCfg.PragueTime = maxInt + if newCfg.NormalcyBlock != nil && newCfg.NormalcyBlock.Cmp(big.NewInt(0)) != 0 { + maxInt := new(big.Int).SetUint64(math.MaxUint64) + newCfg.LondonBlock = maxInt + newCfg.ShanghaiTime = maxInt + newCfg.CancunTime = maxInt + newCfg.PragueTime = maxInt + } return newCfg, storedBlock, nil } diff --git a/eth/ethconfig/config_zkevm.go b/eth/ethconfig/config_zkevm.go index 669100c581b..a3ff4cda097 100644 --- a/eth/ethconfig/config_zkevm.go +++ b/eth/ethconfig/config_zkevm.go @@ -72,7 +72,7 @@ type Zk struct { var DefaultZkConfig = &Zk{} func (c *Zk) ShouldCountersBeUnlimited(l1Recovery bool) bool { - return l1Recovery || (c.DisableVirtualCounters && !c.ExecutorStrictMode && len(c.ExecutorUrls) != 0) + return l1Recovery || (c.DisableVirtualCounters && !c.ExecutorStrictMode && !c.HasExecutors()) } func (c *Zk) HasExecutors() bool { diff --git a/eth/stagedsync/stage_execute.go b/eth/stagedsync/stage_execute.go index 2041ab3c053..265847e46a8 100644 --- a/eth/stagedsync/stage_execute.go +++ b/eth/stagedsync/stage_execute.go @@ -35,6 +35,7 @@ import ( "github.com/ledgerwatch/erigon/common/changeset" "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/consensus" + "github.com/ledgerwatch/erigon/consensus/misc" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/state" @@ -513,6 +514,14 @@ Loop: break } + if cfg.chainConfig.IsLondon(blockNum) { + parentHeader, err := cfg.blockReader.Header(ctx, txc.Tx, header.ParentHash, blockNum-1) + if err != nil { + return err + } + header.BaseFee = misc.CalcBaseFeeZk(cfg.chainConfig, parentHeader) + } + lastLogTx += uint64(block.Transactions().Len()) // Incremental move of next stages depend on fully written ChangeSets, Receipts, CallTraceSet diff --git a/eth/stagedsync/stage_execute_zkevm.go b/eth/stagedsync/stage_execute_zkevm.go index 19b5da70d41..64aa580d87a 100644 --- a/eth/stagedsync/stage_execute_zkevm.go +++ b/eth/stagedsync/stage_execute_zkevm.go @@ -16,6 +16,7 @@ import ( "github.com/ledgerwatch/erigon-lib/kv/membatch" "github.com/ledgerwatch/log/v3" + "github.com/ledgerwatch/erigon/consensus/misc" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/zk/erigon_db" "github.com/ledgerwatch/erigon/zk/hermez_db" @@ -303,6 +304,14 @@ func getPreexecuteValues(cfg ExecuteBlockCfg, ctx context.Context, tx kv.RwTx, b block.HeaderNoCopy().ParentHash = prevBlockHash + if cfg.chainConfig.IsLondon(blockNum) { + parentHeader, err := cfg.blockReader.Header(ctx, tx, prevBlockHash, blockNum-1) + if err != nil { + return common.Hash{}, nil, nil, err + } + block.HeaderNoCopy().BaseFee = misc.CalcBaseFeeZk(cfg.chainConfig, parentHeader) + } + return preExecuteHeaderHash, block, senders, nil } diff --git a/turbo/stages/stageloop.go b/turbo/stages/stageloop.go index 08a9a8cc0c7..e61fe14db64 100644 --- a/turbo/stages/stageloop.go +++ b/turbo/stages/stageloop.go @@ -308,7 +308,7 @@ func (h *Hook) sendNotifications(notifications *shards.Notifications, tx kv.Tx, notifications.Accumulator.StartChange(0, currentHeader.Hash(), nil, false) } - pendingBaseFee := misc.CalcBaseFee(h.chainConfig, currentHeader) + pendingBaseFee := misc.CalcBaseFeeZk(h.chainConfig, currentHeader) pendingBlobFee := h.chainConfig.GetMinBlobGasPrice() if currentHeader.ExcessBlobGas != nil { excessBlobGas := misc.CalcExcessBlobGas(h.chainConfig, currentHeader) diff --git a/turbo/stages/zk_stages.go b/turbo/stages/zk_stages.go index b5fd642d16c..6d02ce472a5 100644 --- a/turbo/stages/zk_stages.go +++ b/turbo/stages/zk_stages.go @@ -52,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.StageBatchesCfg(db, datastreamClient, cfg.Zk), + 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), stagedsync.StageSendersCfg(db, controlServer.ChainConfig, false, dirs.Tmp, cfg.Prune, blockReader, controlServer.Hd, nil), @@ -140,6 +140,7 @@ func NewSequencerZkStages(ctx context.Context, agg, datastreamServer, cfg.Zk, + &cfg.Miner, txPool, txPoolDb, ), diff --git a/zk/erigon_db/db.go b/zk/erigon_db/db.go index 7401b66a267..85916867bde 100644 --- a/zk/erigon_db/db.go +++ b/zk/erigon_db/db.go @@ -4,9 +4,11 @@ import ( "fmt" "math/big" + "github.com/ledgerwatch/erigon-lib/chain" "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/rawdb" ethTypes "github.com/ledgerwatch/erigon/core/types" ) @@ -28,19 +30,28 @@ func (db ErigonDb) WriteHeader( blockHash common.Hash, stateRoot, txHash, parentHash common.Hash, coinbase common.Address, - ts, gasLimit uint64, + ts, gasLimit uint64, chainConfig *chain.Config, ) (*ethTypes.Header, error) { - h := ðTypes.Header{ - ParentHash: parentHash, - UncleHash: sha3UncleHash, - Coinbase: coinbase, - Root: stateRoot, - TxHash: txHash, - Difficulty: big.NewInt(0), - Number: blockNo, - GasLimit: gasLimit, - Time: ts, - Extra: make([]byte, 0), + parentHeader, err := db.GetHeader(blockNo.Uint64() - 1) + if err != nil { + return nil, fmt.Errorf("failed to get parent header: %w", err) + } + + h := core.MakeEmptyHeader(parentHeader, chainConfig, ts, &gasLimit) + + h.ParentHash = parentHash + h.Root = stateRoot + h.TxHash = txHash + h.Coinbase = coinbase + h.UncleHash = sha3UncleHash + h.Extra = make([]byte, 0) + + if chainConfig.IsShanghai(blockNo.Uint64()) { + h.WithdrawalsHash = ðTypes.EmptyRootHash + } + + if !chainConfig.IsNormalcy(blockNo.Uint64()) { + h.GasLimit = gasLimit } if err := rawdb.WriteHeaderWithhash(db.tx, blockHash, h); err != nil { diff --git a/zk/stages/stage_batches.go b/zk/stages/stage_batches.go index 7215250ecd9..ec7b0dbf3fc 100644 --- a/zk/stages/stage_batches.go +++ b/zk/stages/stage_batches.go @@ -7,6 +7,7 @@ import ( "sync/atomic" "time" + "github.com/ledgerwatch/erigon-lib/chain" "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/kv" @@ -14,6 +15,7 @@ import ( ethTypes "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/eth/stagedsync" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" + "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/zk" "github.com/ledgerwatch/erigon/zk/datastream/types" "github.com/ledgerwatch/erigon/zk/erigon_db" @@ -33,7 +35,7 @@ const ( ) type ErigonDb interface { - WriteHeader(batchNo *big.Int, blockHash common.Hash, stateRoot, txHash, parentHash common.Hash, coinbase common.Address, ts, gasLimit uint64) (*ethTypes.Header, error) + WriteHeader(batchNo *big.Int, blockHash common.Hash, stateRoot, txHash, parentHash common.Hash, coinbase common.Address, ts, gasLimit uint64, chainConfig *chain.Config) (*ethTypes.Header, error) WriteBody(batchNo *big.Int, headerHash common.Hash, txs []ethTypes.Transaction) error } @@ -86,14 +88,18 @@ type BatchesCfg struct { blockRoutineStarted bool dsClient DatastreamClient zkCfg *ethconfig.Zk + chainConfig *chain.Config + miningConfig *params.MiningConfig } -func StageBatchesCfg(db kv.RwDB, dsClient DatastreamClient, zkCfg *ethconfig.Zk) BatchesCfg { +func StageBatchesCfg(db kv.RwDB, dsClient DatastreamClient, zkCfg *ethconfig.Zk, chainConfig *chain.Config, miningConfig *params.MiningConfig) BatchesCfg { return BatchesCfg{ db: db, blockRoutineStarted: false, dsClient: dsClient, zkCfg: zkCfg, + chainConfig: chainConfig, + miningConfig: miningConfig, } } @@ -340,7 +346,7 @@ LOOP: l2Block.ParentHash = previousHash } - if err := writeL2Block(eriDb, hermezDb, &l2Block, highestL1InfoTreeIndex); err != nil { + if err := writeL2Block(eriDb, hermezDb, &l2Block, highestL1InfoTreeIndex, cfg.chainConfig, cfg.miningConfig); err != nil { return fmt.Errorf("writeL2Block error: %v", err) } dsClientProgress.Store(l2Block.L2BlockNumber) @@ -756,7 +762,7 @@ func PruneBatchesStage(s *stagedsync.PruneState, tx kv.RwTx, cfg BatchesCfg, ctx // writeL2Block writes L2Block to ErigonDb and HermezDb // writes header, body, forkId and blockBatch -func writeL2Block(eriDb ErigonDb, hermezDb HermezDb, l2Block *types.FullL2Block, highestL1InfoTreeIndex uint64) error { +func writeL2Block(eriDb ErigonDb, hermezDb HermezDb, l2Block *types.FullL2Block, highestL1InfoTreeIndex uint64, chainConfig *chain.Config, miningConfig *params.MiningConfig) error { bn := new(big.Int).SetUint64(l2Block.L2BlockNumber) txs := make([]ethTypes.Transaction, 0, len(l2Block.L2Txs)) for _, transaction := range l2Block.L2Txs { @@ -781,9 +787,15 @@ func writeL2Block(eriDb ErigonDb, hermezDb HermezDb, l2Block *types.FullL2Block, txCollection := ethTypes.Transactions(txs) txHash := ethTypes.DeriveSha(txCollection) - gasLimit := utils.GetBlockGasLimitForFork(l2Block.ForkId) + var gasLimit uint64 - _, err := eriDb.WriteHeader(bn, l2Block.L2Blockhash, l2Block.StateRoot, txHash, l2Block.ParentHash, l2Block.Coinbase, uint64(l2Block.Timestamp), gasLimit) + if !chainConfig.IsNormalcy(l2Block.L2BlockNumber) { + gasLimit = utils.GetBlockGasLimitForFork(l2Block.ForkId) + } else { + gasLimit = miningConfig.GasLimit + } + + _, err := eriDb.WriteHeader(bn, l2Block.L2Blockhash, l2Block.StateRoot, txHash, l2Block.ParentHash, l2Block.Coinbase, uint64(l2Block.Timestamp), gasLimit, chainConfig) if err != nil { return fmt.Errorf("write header error: %v", err) } diff --git a/zk/stages/stage_batches_test.go b/zk/stages/stage_batches_test.go index 7fc84142446..d3f622932ab 100644 --- a/zk/stages/stage_batches_test.go +++ b/zk/stages/stage_batches_test.go @@ -72,7 +72,7 @@ func TestUnwindBatches(t *testing.T) { require.NoError(t, err) dsClient := NewTestDatastreamClient(fullL2Blocks, gerUpdates) - cfg := StageBatchesCfg(db1, dsClient, ðconfig.Zk{}) + cfg := StageBatchesCfg(db1, dsClient, ðconfig.Zk{}, nil) s := &stagedsync.StageState{ID: stages.Batches, BlockNumber: 0} u := &stagedsync.Sync{} diff --git a/zk/stages/stage_sequence_execute.go b/zk/stages/stage_sequence_execute.go index 51caec5ceae..328aa398ebc 100644 --- a/zk/stages/stage_sequence_execute.go +++ b/zk/stages/stage_sequence_execute.go @@ -80,7 +80,7 @@ func SpawnSequencingStage( return err } - header, parentBlock, err := prepareHeader(tx, executionAt, math.MaxUint64, math.MaxUint64, forkId, cfg.zk.AddressSequencer) + header, parentBlock, err := prepareHeader(tx, executionAt, math.MaxUint64, math.MaxUint64, forkId, cfg.zk.AddressSequencer, cfg.chainConfig, cfg.miningConfig) if err != nil { return err } @@ -247,7 +247,7 @@ func SpawnSequencingStage( log.Info(fmt.Sprintf("[%s] Continuing unfinished batch %d from block %d", logPrefix, thisBatch, executionAt)) } - blockDataSizeChecker := NewBlockDataChecker() + blockDataSizeChecker := NewBlockDataChecker(cfg.zk.ShouldCountersBeUnlimited(l1Recovery)) prevHeader := rawdb.ReadHeaderByNumber(tx, executionAt) batchDataOverflow := false @@ -284,7 +284,7 @@ func SpawnSequencingStage( addedReceipts = []*types.Receipt{} addedExecutionResults = []*core.ExecutionResult{} effectiveGases = []uint8{} - header, parentBlock, err = prepareHeader(tx, blockNumber, deltaTimestamp, limboHeaderTimestamp, forkId, nextBatchData.Coinbase) + header, parentBlock, err = prepareHeader(tx, blockNumber, deltaTimestamp, limboHeaderTimestamp, forkId, nextBatchData.Coinbase, cfg.chainConfig, cfg.miningConfig) if err != nil { return err } @@ -299,12 +299,15 @@ func SpawnSequencingStage( // create a copy of the header otherwise the executor will return "state root mismatch error" header = &types.Header{ - ParentHash: header.ParentHash, - Coinbase: header.Coinbase, - Difficulty: header.Difficulty, - Number: header.Number, - GasLimit: header.GasLimit, - Time: header.Time, + ParentHash: header.ParentHash, + Coinbase: header.Coinbase, + Difficulty: header.Difficulty, + Number: header.Number, + GasLimit: header.GasLimit, + Time: header.Time, + BaseFee: header.BaseFee, + BlobGasUsed: header.BlobGasUsed, + ExcessBlobGas: header.ExcessBlobGas, } } diff --git a/zk/stages/stage_sequence_execute_blocks.go b/zk/stages/stage_sequence_execute_blocks.go index 7719c0a0350..31c2f7944af 100644 --- a/zk/stages/stage_sequence_execute_blocks.go +++ b/zk/stages/stage_sequence_execute_blocks.go @@ -20,7 +20,6 @@ import ( "github.com/ledgerwatch/erigon/zk/erigon_db" "github.com/ledgerwatch/erigon/zk/hermez_db" zktypes "github.com/ledgerwatch/erigon/zk/types" - "github.com/ledgerwatch/erigon/zk/utils" "github.com/ledgerwatch/secp256k1" ) @@ -129,6 +128,11 @@ func finaliseBlock( } } + var withdrawals []*types.Withdrawal + if cfg.chainConfig.IsShanghai(newHeader.Number.Uint64()) { + withdrawals = []*types.Withdrawal{} + } + finalBlock, finalTransactions, finalReceipts, err := core.FinalizeBlockExecutionWithHistoryWrite( cfg.engine, sdb.stateReader, @@ -139,7 +143,7 @@ func finaliseBlock( cfg.chainConfig, ibs, receipts, - nil, // no withdrawals + withdrawals, chainReader, true, excessBlobGas, @@ -156,7 +160,6 @@ func finaliseBlock( finalHeader := finalBlock.HeaderNoCopy() finalHeader.Root = newRoot finalHeader.Coinbase = cfg.zk.AddressSequencer - finalHeader.GasLimit = utils.GetBlockGasLimitForFork(forkId) finalHeader.ReceiptHash = types.DeriveSha(receipts) finalHeader.Bloom = types.CreateBloom(receipts) newNum := finalBlock.Number() diff --git a/zk/stages/stage_sequence_execute_transactions.go b/zk/stages/stage_sequence_execute_transactions.go index 3d160034eb8..5eb0213d741 100644 --- a/zk/stages/stage_sequence_execute_transactions.go +++ b/zk/stages/stage_sequence_execute_transactions.go @@ -9,7 +9,6 @@ import ( "github.com/ledgerwatch/erigon-lib/common/length" "github.com/ledgerwatch/erigon-lib/kv" - "bytes" "io" mapset "github.com/deckarep/golang-set/v2" @@ -19,7 +18,6 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/core/vm/evmtypes" - "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/zk/hermez_db" zktx "github.com/ledgerwatch/erigon/zk/tx" "github.com/ledgerwatch/erigon/zk/utils" @@ -152,12 +150,8 @@ func getNextL1BatchData(batchNumber uint64, forkId uint64, hermezDb *hermez_db.H func extractTransactionsFromSlot(slot *types2.TxsRlp) ([]types.Transaction, error) { transactions := make([]types.Transaction, 0, len(slot.Txs)) - reader := bytes.NewReader([]byte{}) - stream := new(rlp.Stream) for idx, txBytes := range slot.Txs { - reader.Reset(txBytes) - stream.Reset(reader, uint64(len(txBytes))) - transaction, err := types.DecodeRLPTransaction(stream, false) + transaction, err := types.DecodeTransaction(txBytes) if err == io.EOF { continue } diff --git a/zk/stages/stage_sequence_execute_utils.go b/zk/stages/stage_sequence_execute_utils.go index bf9343c4080..d1785247846 100644 --- a/zk/stages/stage_sequence_execute_utils.go +++ b/zk/stages/stage_sequence_execute_utils.go @@ -27,6 +27,7 @@ import ( "github.com/ledgerwatch/erigon/eth/stagedsync" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/prune" + "github.com/ledgerwatch/erigon/params" db2 "github.com/ledgerwatch/erigon/smt/pkg/db" smtNs "github.com/ledgerwatch/erigon/smt/pkg/smt" "github.com/ledgerwatch/erigon/turbo/services" @@ -83,6 +84,7 @@ type SequenceBlockCfg struct { stream *datastreamer.StreamServer datastreamServer *server.DataStreamServer zk *ethconfig.Zk + miningConfig *params.MiningConfig txPool *txpool.TxPool txPoolDb kv.RwDB @@ -108,6 +110,7 @@ func StageSequenceBlocksCfg( agg *libstate.Aggregator, stream *datastreamer.StreamServer, zk *ethconfig.Zk, + miningConfig *params.MiningConfig, txPool *txpool.TxPool, txPoolDb kv.RwDB, @@ -133,6 +136,7 @@ func StageSequenceBlocksCfg( stream: stream, datastreamServer: server.NewDataStreamServer(stream, chainConfig.ChainID.Uint64()), zk: zk, + miningConfig: miningConfig, txPool: txPool, txPoolDb: txPoolDb, } @@ -240,7 +244,7 @@ func prepareForkId(lastBatch, executionAt uint64, hermezDb forkDb) (uint64, erro return latest, nil } -func prepareHeader(tx kv.RwTx, previousBlockNumber, deltaTimestamp, forcedTimestamp, forkId uint64, coinbase common.Address) (*types.Header, *types.Block, error) { +func prepareHeader(tx kv.RwTx, previousBlockNumber, deltaTimestamp, forcedTimestamp, forkId uint64, coinbase common.Address, chainConfig *chain.Config, miningConfig *params.MiningConfig) (*types.Header, *types.Block, error) { parentBlock, err := rawdb.ReadBlockByNumber(tx, previousBlockNumber) if err != nil { return nil, nil, err @@ -261,14 +265,20 @@ func prepareHeader(tx kv.RwTx, previousBlockNumber, deltaTimestamp, forcedTimest } } - return &types.Header{ - ParentHash: parentBlock.Hash(), - Coinbase: coinbase, - Difficulty: blockDifficulty, - Number: new(big.Int).SetUint64(previousBlockNumber + 1), - GasLimit: utils.GetBlockGasLimitForFork(forkId), - Time: newBlockTimestamp, - }, parentBlock, nil + var targetGas uint64 + + if chainConfig.IsNormalcy(previousBlockNumber + 1) { + targetGas = miningConfig.GasLimit + } + + header := core.MakeEmptyHeader(parentBlock.Header(), chainConfig, newBlockTimestamp, &targetGas) + + if !chainConfig.IsNormalcy(previousBlockNumber + 1) { + header.GasLimit = utils.GetBlockGasLimitForFork(forkId) + } + + header.Coinbase = coinbase + return header, parentBlock, nil } func prepareL1AndInfoTreeRelatedStuff(sdb *stageDb, decodedBlock *zktx.DecodedBatchL2Data, l1Recovery bool, proposedTimestamp uint64) (uint64, *zktypes.L1InfoTreeUpdate, uint64, common.Hash, common.Hash, bool, error) { @@ -463,9 +473,16 @@ type BlockDataChecker struct { counter uint64 // counter amount of bytes } -func NewBlockDataChecker() *BlockDataChecker { +func NewBlockDataChecker(unlimitedData bool) *BlockDataChecker { + var limit uint64 + if unlimitedData { + limit = math.MaxUint64 + } else { + limit = LIMIT_120_KB + } + return &BlockDataChecker{ - limit: LIMIT_120_KB, + limit: limit, counter: 0, } } diff --git a/zk/txpool/pool.go b/zk/txpool/pool.go index 7b761227b30..602cf06ec56 100644 --- a/zk/txpool/pool.go +++ b/zk/txpool/pool.go @@ -1123,10 +1123,8 @@ func addTxsOnNewBlock(blockNum uint64, cacheView kvcache.CacheView, stateChanges func (p *TxPool) setBaseFee(baseFee uint64) (uint64, bool) { changed := false - if baseFee > 0 { - changed = baseFee != p.pendingBaseFee.Load() - p.pendingBaseFee.Store(baseFee) - } + changed = baseFee != p.pendingBaseFee.Load() + p.pendingBaseFee.Store(baseFee) return p.pendingBaseFee.Load(), changed }