From 6939d274251c0e52c8d467f472cecc9711081934 Mon Sep 17 00:00:00 2001 From: Sunny Date: Wed, 7 Aug 2024 18:48:47 +0800 Subject: [PATCH] feat: add more debug log for issue analysis --- core/parallel_state_processor.go | 3 ++- core/state/parallel_statedb.go | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/core/parallel_state_processor.go b/core/parallel_state_processor.go index 26f0637c37..566dd12b7c 100644 --- a/core/parallel_state_processor.go +++ b/core/parallel_state_processor.go @@ -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 @@ -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 diff --git a/core/state/parallel_statedb.go b/core/state/parallel_statedb.go index ebe07b8297..cc4310c6eb 100644 --- a/core/state/parallel_statedb.go +++ b/core/state/parallel_statedb.go @@ -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 } } @@ -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 } } @@ -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 } @@ -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 } } @@ -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 } } @@ -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 } } @@ -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 } } @@ -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 @@ -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 } }