fix(worker): set row consumption for genesis and empty blocks (#428)

* fix: initialize row consumption for genesis and empty blocks

* bump version
This commit is contained in:
Péter Garamvölgyi 2023-08-03 09:48:03 +02:00 committed by GitHub
parent 096e7b527a
commit b51736fd3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 1 deletions

View file

@ -280,6 +280,9 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
// initialize L1 message index for genesis block // initialize L1 message index for genesis block
rawdb.WriteFirstQueueIndexNotInL2Block(db, bc.genesisBlock.Hash(), 0) rawdb.WriteFirstQueueIndexNotInL2Block(db, bc.genesisBlock.Hash(), 0)
// initialize row consumption for genesis block
rawdb.WriteBlockRowConsumption(db, bc.genesisBlock.Hash(), &types.RowConsumption{})
var nilBlock *types.Block var nilBlock *types.Block
bc.currentBlock.Store(nilBlock) bc.currentBlock.Store(nilBlock)
bc.currentFastBlock.Store(nilBlock) bc.currentFastBlock.Store(nilBlock)
@ -699,6 +702,7 @@ func (bc *BlockChain) ResetWithGenesisBlock(genesis *types.Block) error {
rawdb.WriteTd(batch, genesis.Hash(), genesis.NumberU64(), genesis.Difficulty()) rawdb.WriteTd(batch, genesis.Hash(), genesis.NumberU64(), genesis.Difficulty())
rawdb.WriteBlock(batch, genesis) rawdb.WriteBlock(batch, genesis)
rawdb.WriteFirstQueueIndexNotInL2Block(batch, genesis.Hash(), 0) rawdb.WriteFirstQueueIndexNotInL2Block(batch, genesis.Hash(), 0)
rawdb.WriteBlockRowConsumption(batch, genesis.Hash(), &types.RowConsumption{})
if err := batch.Write(); err != nil { if err := batch.Write(); err != nil {
log.Crit("Failed to write genesis block", "err", err) log.Crit("Failed to write genesis block", "err", err)
} }

View file

@ -353,6 +353,7 @@ func (g *Genesis) Commit(db ethdb.Database) (*types.Block, error) {
rawdb.WriteHeadHeaderHash(db, block.Hash()) rawdb.WriteHeadHeaderHash(db, block.Hash())
rawdb.WriteChainConfig(db, block.Hash(), config) rawdb.WriteChainConfig(db, block.Hash(), config)
rawdb.WriteFirstQueueIndexNotInL2Block(db, block.Hash(), 0) rawdb.WriteFirstQueueIndexNotInL2Block(db, block.Hash(), 0)
rawdb.WriteBlockRowConsumption(db, block.Hash(), &types.RowConsumption{})
return block, nil return block, nil
} }

View file

@ -768,6 +768,9 @@ func (w *worker) makeCurrent(parent *types.Block, header *types.Header) error {
env.l1TxCount = 0 env.l1TxCount = 0
env.maxL1Index = 0 env.maxL1Index = 0
// make sure accRows is not nil, even for empty blocks
env.accRows = &types.RowConsumption{}
// Swap out the old work with the new one, terminating any leftover prefetcher // Swap out the old work with the new one, terminating any leftover prefetcher
// processes in the mean time and starting a new one. // processes in the mean time and starting a new one.
if w.current != nil && w.current.state != nil { if w.current != nil && w.current.state != nil {

View file

@ -24,7 +24,7 @@ import (
const ( const (
VersionMajor = 4 // Major version component of the current release VersionMajor = 4 // Major version component of the current release
VersionMinor = 3 // Minor version component of the current release VersionMinor = 3 // Minor version component of the current release
VersionPatch = 8 // Patch version component of the current release VersionPatch = 9 // Patch version component of the current release
VersionMeta = "sepolia" // Version metadata to append to the version string VersionMeta = "sepolia" // Version metadata to append to the version string
) )