Skip to content

Commit

Permalink
feat: add more debug log for issue analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny2022da committed Aug 7, 2024
1 parent 00d3860 commit 6939d27
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion core/parallel_state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ func (p *ParallelStateProcessor) executeInSlot(slotIndex int, txReq *ParallelTxR
atomic.CompareAndSwapInt32(&txReq.runnable, 0, 1)
return nil
}
log.Debug("ExecuteInSlot", "Block", txReq.block.NumberU64(), "txIndex", txReq.txIndex, "conflictIndex", conflictIndex, "mIndex", mIndex)
execNum := txReq.executedNum.Add(1)
slotDB := state.NewSlotDB(txReq.baseStateDB, txReq.txIndex, int(mIndex), p.unconfirmedDBs)
blockContext := NewEVMBlockContext(txReq.block.Header(), p.bc, nil, p.config, slotDB) // can share blockContext within a block for efficiency
Expand Down Expand Up @@ -447,7 +448,7 @@ func (p *ParallelStateProcessor) toConfirmTxIndex(targetTxIndex int, isStage2 bo
func (p *ParallelStateProcessor) toConfirmTxIndexResult(txResult *ParallelTxResult, isStage2 bool) bool {
txReq := txResult.txReq
if p.hasConflict(txResult, isStage2) {
log.Debug("HasConflict!! block: %d, txIndex: %d\n", txResult.txReq.block.NumberU64(), txResult.txReq.txIndex)
log.Debug(fmt.Sprintf("HasConflict!! block: %d, txIndex: %d\n", txResult.txReq.block.NumberU64(), txResult.txReq.txIndex))
return false
}
if isStage2 { // not its turn
Expand Down
18 changes: 9 additions & 9 deletions core/state/parallel_statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func hasKvConflict(slotDB *ParallelStateDB, addr common.Address, key common.Hash
log.Debug("IsSlotDBReadsValid KV read is invalid in unconfirmed", "addr", addr,
"valSlot", val, "valUnconfirm", valUnconfirm,
"SlotIndex", slotDB.parallel.SlotIndex,
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex)
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex, "mainDB.TxIndex", mainDB.TxIndex)
return true
}
}
Expand Down Expand Up @@ -1245,7 +1245,7 @@ func (slotDB *ParallelStateDB) IsParallelReadsValid(isStage2 bool) bool {
if nonceSlot != nonceUnconfirm {
log.Debug("IsSlotDBReadsValid nonce read is invalid in unconfirmed", "addr", addr,
"nonceSlot", nonceSlot, "nonceUnconfirm", nonceUnconfirm, "SlotIndex", slotDB.parallel.SlotIndex,
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex)
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex, "mainDB.TxIndex", mainDB.TxIndex)
return false
}
}
Expand All @@ -1259,7 +1259,7 @@ func (slotDB *ParallelStateDB) IsParallelReadsValid(isStage2 bool) bool {
if nonceSlot != nonceMain {
log.Debug("IsSlotDBReadsValid nonce read is invalid", "addr", addr,
"nonceSlot", nonceSlot, "nonceMain", nonceMain, "SlotIndex", slotDB.parallel.SlotIndex,
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex)
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex, "mainDB.TxIndex", mainDB.TxIndex)

return false
}
Expand All @@ -1284,7 +1284,7 @@ func (slotDB *ParallelStateDB) IsParallelReadsValid(isStage2 bool) bool {
if balanceSlot.Cmp(balanceMain) != 0 {
log.Debug("IsSlotDBReadsValid balance read is invalid", "addr", addr,
"balanceSlot", balanceSlot, "balanceMain", balanceMain, "SlotIndex", slotDB.parallel.SlotIndex,
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex)
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex, "mainDB.TxIndex", mainDB.TxIndex)
return false
}
}
Expand Down Expand Up @@ -1375,7 +1375,7 @@ func (slotDB *ParallelStateDB) IsParallelReadsValid(isStage2 bool) bool {
if !bytes.Equal(codeSlot, codeMain) {
log.Debug("IsSlotDBReadsValid code read is invalid", "addr", addr,
"len codeSlot", len(codeSlot), "len codeMain", len(codeMain), "SlotIndex", slotDB.parallel.SlotIndex,
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex)
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex, "mainDB.TxIndex", mainDB.TxIndex)
return false
}
}
Expand All @@ -1389,7 +1389,7 @@ func (slotDB *ParallelStateDB) IsParallelReadsValid(isStage2 bool) bool {
if !bytes.Equal(codeHashSlot.Bytes(), codeHashMain.Bytes()) {
log.Debug("IsSlotDBReadsValid codehash read is invalid", "addr", addr,
"codeHashSlot", codeHashSlot, "codeHashMain", codeHashMain, "SlotIndex", slotDB.parallel.SlotIndex,
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex)
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex, "mainDB.TxIndex", mainDB.TxIndex)
return false
}
}
Expand All @@ -1403,7 +1403,7 @@ func (slotDB *ParallelStateDB) IsParallelReadsValid(isStage2 bool) bool {
log.Debug("IsSlotDBReadsValid addrState read invalid(true: exist, false: not exist)",
"addr", addr, "stateSlot", stateSlot, "stateMain", stateMain,
"SlotIndex", slotDB.parallel.SlotIndex,
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex)
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex, "mainDB.TxIndex", mainDB.TxIndex)
return false
}
}
Expand All @@ -1414,7 +1414,7 @@ func (slotDB *ParallelStateDB) IsParallelReadsValid(isStage2 bool) bool {
log.Debug("IsSlotDBReadsValid snapshot destructs read invalid, address should exist",
"addr", addr, "destruct", destructRead,
"SlotIndex", slotDB.parallel.SlotIndex,
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex)
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex, "mainDB.TxIndex", mainDB.TxIndex)
return false
}
slotDB.snapParallelLock.RLock() // fixme: this lock is not needed
Expand All @@ -1424,7 +1424,7 @@ func (slotDB *ParallelStateDB) IsParallelReadsValid(isStage2 bool) bool {
log.Debug("IsSlotDBReadsValid snapshot destructs read invalid",
"addr", addr, "destructRead", destructRead, "destructMain", destructMain,
"SlotIndex", slotDB.parallel.SlotIndex,
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex)
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex, "mainDB.TxIndex", mainDB.TxIndex)
return false
}
}
Expand Down

0 comments on commit 6939d27

Please sign in to comment.