mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 15:46:43 +00:00
fix(miner): fix acc_rows for empty block (#431)
* Revert "fix(worker): set row consumption for genesis and empty blocks (#428)"
This reverts commit b51736fd3c.
* fix: fix accRows for empty block
* bump version
* remove log
* fix
* set default accRows as nil explicitly
* fix genesis block
* fix
This commit is contained in:
parent
21d430f018
commit
ef67ff8bbb
6 changed files with 21 additions and 24 deletions
|
|
@ -280,9 +280,6 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
|
|||
// initialize L1 message index for genesis block
|
||||
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
|
||||
bc.currentBlock.Store(nilBlock)
|
||||
bc.currentFastBlock.Store(nilBlock)
|
||||
|
|
@ -702,7 +699,6 @@ func (bc *BlockChain) ResetWithGenesisBlock(genesis *types.Block) error {
|
|||
rawdb.WriteTd(batch, genesis.Hash(), genesis.NumberU64(), genesis.Difficulty())
|
||||
rawdb.WriteBlock(batch, genesis)
|
||||
rawdb.WriteFirstQueueIndexNotInL2Block(batch, genesis.Hash(), 0)
|
||||
rawdb.WriteBlockRowConsumption(batch, genesis.Hash(), &types.RowConsumption{})
|
||||
if err := batch.Write(); err != nil {
|
||||
log.Crit("Failed to write genesis block", "err", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -353,7 +353,6 @@ func (g *Genesis) Commit(db ethdb.Database) (*types.Block, error) {
|
|||
rawdb.WriteHeadHeaderHash(db, block.Hash())
|
||||
rawdb.WriteChainConfig(db, block.Hash(), config)
|
||||
rawdb.WriteFirstQueueIndexNotInL2Block(db, block.Hash(), 0)
|
||||
rawdb.WriteBlockRowConsumption(db, block.Hash(), &types.RowConsumption{})
|
||||
return block, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -447,8 +447,12 @@ func (env *TraceEnv) fillBlockTrace(block *types.Block) (*types.BlockTrace, erro
|
|||
}
|
||||
}
|
||||
|
||||
var chainID uint64
|
||||
if env.chainConfig.ChainID != nil {
|
||||
chainID = env.chainConfig.ChainID.Uint64()
|
||||
}
|
||||
blockTrace := &types.BlockTrace{
|
||||
ChainID: env.chainConfig.ChainID.Uint64(),
|
||||
ChainID: chainID,
|
||||
Version: params.ArchiveVersion(params.CommitHash),
|
||||
Coinbase: &types.AccountWrapper{
|
||||
Address: env.coinbase,
|
||||
|
|
|
|||
|
|
@ -753,6 +753,7 @@ func (w *worker) makeCurrent(parent *types.Block, header *types.Header) error {
|
|||
uncles: mapset.NewSet(),
|
||||
header: header,
|
||||
traceEnv: traceEnv,
|
||||
accRows: nil,
|
||||
}
|
||||
// when 08 is processed ancestors contain 07 (quick block)
|
||||
for _, ancestor := range w.chain.GetBlocksFromHash(parent.Hash(), 7) {
|
||||
|
|
@ -768,9 +769,6 @@ func (w *worker) makeCurrent(parent *types.Block, header *types.Header) error {
|
|||
env.l1TxCount = 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
|
||||
// processes in the mean time and starting a new one.
|
||||
if w.current != nil && w.current.state != nil {
|
||||
|
|
@ -1226,6 +1224,20 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64)
|
|||
// commit runs any post-transaction state modifications, assembles the final block
|
||||
// and commits new work if consensus engine is running.
|
||||
func (w *worker) commit(uncles []*types.Header, interval func(), update bool, start time.Time) error {
|
||||
// set w.current.accRows for empty-but-not-genesis block
|
||||
if (w.current.header.Number.Uint64() != 0) &&
|
||||
(w.current.accRows == nil || len(*w.current.accRows) == 0) {
|
||||
traces, err := w.current.traceEnv.GetBlockTrace(types.NewBlockWithHeader(w.current.header))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
accRows, err := w.circuitCapacityChecker.ApplyBlock(traces)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
w.current.accRows = accRows
|
||||
}
|
||||
|
||||
// Deep copy receipts here to avoid interaction between different tasks.
|
||||
receipts := copyReceipts(w.current.receipts)
|
||||
s := w.current.state.Copy()
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
const (
|
||||
VersionMajor = 4 // Major version component of the current release
|
||||
VersionMinor = 3 // Minor version component of the current release
|
||||
VersionPatch = 11 // Patch version component of the current release
|
||||
VersionPatch = 12 // Patch version component of the current release
|
||||
VersionMeta = "sepolia" // Version metadata to append to the version string
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -60,13 +60,6 @@ pub mod checker {
|
|||
pub unsafe extern "C" fn apply_tx(id: u64, tx_traces: *const c_char) -> *const c_char {
|
||||
let result = panic::catch_unwind(|| {
|
||||
let tx_traces_vec = c_char_to_vec(tx_traces);
|
||||
|
||||
log::debug!(
|
||||
"ccc apply_tx raw input, id: {:?}, tx_traces: {:?}",
|
||||
id,
|
||||
String::from(tx_traces_vec)
|
||||
);
|
||||
|
||||
let traces = serde_json::from_slice::<BlockTrace>(&tx_traces_vec)
|
||||
.unwrap_or_else(|_| panic!("id: {id:?}, fail to deserialize tx_traces"));
|
||||
if traces.transactions.len() != 1 {
|
||||
|
|
@ -121,13 +114,6 @@ pub mod checker {
|
|||
pub unsafe extern "C" fn apply_block(id: u64, block_trace: *const c_char) -> *const c_char {
|
||||
let result = panic::catch_unwind(|| {
|
||||
let block_trace = c_char_to_vec(block_trace);
|
||||
|
||||
log::debug!(
|
||||
"ccc apply_block raw input, id: {:?}, block_trace: {:?}",
|
||||
id,
|
||||
String::from(block_trace)
|
||||
);
|
||||
|
||||
let traces = serde_json::from_slice::<BlockTrace>(&block_trace)
|
||||
.unwrap_or_else(|_| panic!("id: {id:?}, fail to deserialize block_trace"));
|
||||
CHECKERS
|
||||
|
|
|
|||
Loading…
Reference in a new issue