fix: use correct hash for ccc write in worker (#438)

This commit is contained in:
Péter Garamvölgyi 2023-08-04 04:22:47 +02:00 committed by GitHub
parent 5611b8296a
commit 26eeb40ea3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 20 deletions

View file

@ -111,7 +111,8 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
log.Trace( log.Trace(
"Validator write block row consumption", "Validator write block row consumption",
"id", v.circuitCapacityChecker.ID, "id", v.circuitCapacityChecker.ID,
"sealHash", block.Hash().String(), "number", block.NumberU64(),
"hash", block.Hash().String(),
"rowConsumption", rowConsumption, "rowConsumption", rowConsumption,
) )
rawdb.WriteBlockRowConsumption(v.db, block.Hash(), rowConsumption) rawdb.WriteBlockRowConsumption(v.db, block.Hash(), rowConsumption)
@ -272,7 +273,7 @@ func (v *BlockValidator) validateCircuitRowConsumption(block *types.Block) (*typ
log.Trace( log.Trace(
"Validator apply ccc for block", "Validator apply ccc for block",
"id", v.circuitCapacityChecker.ID, "id", v.circuitCapacityChecker.ID,
"number", block.Number(), "number", block.NumberU64(),
"hash", block.Hash().String(), "hash", block.Hash().String(),
"len(txs)", block.Transactions().Len(), "len(txs)", block.Transactions().Len(),
) )
@ -291,13 +292,13 @@ func (v *BlockValidator) validateCircuitRowConsumption(block *types.Block) (*typ
defer v.cMu.Unlock() defer v.cMu.Unlock()
v.circuitCapacityChecker.Reset() v.circuitCapacityChecker.Reset()
log.Trace("Validator reset ccc") log.Trace("Validator reset ccc", "id", v.circuitCapacityChecker.ID)
rc, err := v.circuitCapacityChecker.ApplyBlock(traces) rc, err := v.circuitCapacityChecker.ApplyBlock(traces)
log.Trace( log.Trace(
"Validator apply ccc for block result", "Validator apply ccc for block result",
"id", v.circuitCapacityChecker.ID, "id", v.circuitCapacityChecker.ID,
"number", block.Number(), "number", block.NumberU64(),
"hash", block.Hash().String(), "hash", block.Hash().String(),
"len(txs)", block.Transactions().Len(), "len(txs)", block.Transactions().Len(),
"rc", rc, "rc", rc,

View file

@ -637,20 +637,6 @@ func (w *worker) taskLoop() {
w.pendingMu.Lock() w.pendingMu.Lock()
delete(w.pendingTasks, sealHash) delete(w.pendingTasks, sealHash)
w.pendingMu.Unlock() w.pendingMu.Unlock()
} else {
// Store highest L1 queue index processed by this block. This includes both
// included and skipped messages. This way, if a block only skips messages,
// we won't reprocess the same messages from the next block.
rawdb.WriteFirstQueueIndexNotInL2Block(w.eth.ChainDb(), sealHash, task.maxL1Index+1)
// Store circuit row consumption.
log.Trace(
"Worker write block row consumption",
"id", w.circuitCapacityChecker.ID,
"sealHash", sealHash.String(),
"accRows", task.accRows,
)
rawdb.WriteBlockRowConsumption(w.eth.ChainDb(), sealHash, task.accRows)
} }
case <-w.exitCh: case <-w.exitCh:
interrupt() interrupt()
@ -678,6 +664,7 @@ func (w *worker) resultLoop() {
sealhash = w.engine.SealHash(block.Header()) sealhash = w.engine.SealHash(block.Header())
hash = block.Hash() hash = block.Hash()
) )
w.pendingMu.RLock() w.pendingMu.RLock()
task, exist := w.pendingTasks[sealhash] task, exist := w.pendingTasks[sealhash]
w.pendingMu.RUnlock() w.pendingMu.RUnlock()
@ -711,6 +698,19 @@ func (w *worker) resultLoop() {
} }
logs = append(logs, receipt.Logs...) logs = append(logs, receipt.Logs...)
} }
// Store highest L1 queue index processed by this block. This includes both
// included and skipped messages. This way, if a block only skips messages,
// we won't reprocess the same messages from the next block.
rawdb.WriteFirstQueueIndexNotInL2Block(w.eth.ChainDb(), hash, task.maxL1Index+1)
// Store circuit row consumption.
log.Trace(
"Worker write block row consumption",
"id", w.circuitCapacityChecker.ID,
"number", block.Number(),
"hash", hash.String(),
"accRows", task.accRows,
)
rawdb.WriteBlockRowConsumption(w.eth.ChainDb(), hash, task.accRows)
// Commit block and state to database. // Commit block and state to database.
_, err := w.chain.WriteBlockWithState(block, receipts, logs, task.state, true) _, err := w.chain.WriteBlockWithState(block, receipts, logs, task.state, true)
if err != nil { if err != nil {
@ -1079,7 +1079,7 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64)
tstart := time.Now() tstart := time.Now()
parent := w.chain.CurrentBlock() parent := w.chain.CurrentBlock()
w.circuitCapacityChecker.Reset() w.circuitCapacityChecker.Reset()
log.Trace("Worker reset ccc") log.Trace("Worker reset ccc", "id", w.circuitCapacityChecker.ID)
if parent.Time() >= uint64(timestamp) { if parent.Time() >= uint64(timestamp) {
timestamp = int64(parent.Time() + 1) timestamp = int64(parent.Time() + 1)

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 = 17 // Patch version component of the current release VersionPatch = 18 // 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
) )