Skip to content

Commit

Permalink
clear debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny2022da committed Oct 14, 2024
1 parent 133442e commit 7cd1604
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 80 deletions.
47 changes: 5 additions & 42 deletions core/parallel_state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,6 @@ func (p *ParallelStateProcessor) executeInSlot(slotIndex int, txReq *ParallelTxR

if err == nil {
p.unconfirmedDBs.Store(txReq.txIndex, slotDB)
log.Debug("executeInSlot - store unconfirmedResults", "slotIndex", slotIndex, "txIndex", txReq.txIndex, "conflictIndex", conflictIndex,
"baseIndex", txResult.slotDB.BaseTxIndex(), "gasUsed", txResult.result.UsedGas)
} else {
// the transaction failed at check(nonce or balance), actually it has not been executed yet.
// the error here can be either expected or unexpected.
Expand All @@ -404,8 +402,6 @@ func (p *ParallelStateProcessor) executeInSlot(slotIndex int, txReq *ParallelTxR
conflictIndex = txReq.conflictIndex.Load()
if conflictIndex < mIndex {
if txReq.conflictIndex.CompareAndSwap(conflictIndex, mIndex) {
log.Debug(fmt.Sprintf("Update conflictIndex in execution because of error: %s, mIndex: %d, new conflictIndex: %d, txIndex: %d",
err.Error(), mIndex, txReq.conflictIndex.Load(), txReq.txIndex))
atomic.CompareAndSwapInt32(&txReq.runnable, 0, 1)
// the error could be caused by unconfirmed balance reference,
// the balance could insufficient to pay its gas limit, which cause it preCheck.buyGas() failed
Expand Down Expand Up @@ -595,7 +591,6 @@ func (p *ParallelStateProcessor) runSlotLoop(slotIndex int, slotType int32) {
// execute.
res := p.executeInSlot(slotIndex, nextMergeReq)
if res != nil {
log.Debug("runSlotLoop send result", "result.txReq", res.txReq)
p.txResultChan <- res
}
}
Expand All @@ -611,7 +606,6 @@ func (p *ParallelStateProcessor) runSlotLoop(slotIndex int, slotType int32) {
if res == nil {
continue
}
log.Debug("runSlotLoop send result", "result.txReq", res.txReq)
p.txResultChan <- res
}
}
Expand Down Expand Up @@ -647,7 +641,6 @@ func (p *ParallelStateProcessor) runSlotLoop(slotIndex int, slotType int32) {
// execute.
res := p.executeInSlot(slotIndex, nextMergeReq)
if res != nil {
log.Debug("runSlotLoop send result", "result.txReq", res.txReq)
p.txResultChan <- res
}
}
Expand All @@ -660,7 +653,6 @@ func (p *ParallelStateProcessor) runSlotLoop(slotIndex int, slotType int32) {
}
res := p.executeInSlot(slotIndex, stealTxReq)
if res != nil {
log.Debug("runSlotLoop send result", "result.txReq", res.txReq)
p.txResultChan <- res
}
}
Expand Down Expand Up @@ -709,7 +701,6 @@ func (p *ParallelStateProcessor) runQuickMergeSlotLoop(slotIndex int, slotType i
res := p.executeInSlot(slotIndex, txReq)
if res != nil {
executed--
log.Debug("runQuickMergeSlotLoop send result", "result.txReq", res.txReq)
p.txResultChan <- res
}
}
Expand Down Expand Up @@ -912,8 +903,6 @@ func (p *ParallelStateProcessor) doCleanUp() {
<-p.stopSlotChan
<-p.stopSlotChan
}

//log.Debug("doCleanUp - stopSlotChan")
// 2.make sure the confirmation routine is stopped
p.stopConfirmStage2Chan <- struct{}{}
<-p.stopSlotChan
Expand All @@ -922,8 +911,6 @@ func (p *ParallelStateProcessor) doCleanUp() {
for {
if len(p.txResultChan) > 0 {
<-p.txResultChan
// res := <-p.txResultChan
// log.Debug("doCleanUp - drain txResultChain", "result.txReq", res.txReq)
continue
}
break
Expand Down Expand Up @@ -1145,7 +1132,8 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
if unconfirmedResult.txReq == nil {
// get exit signal from merger.
log.Debug("Process get unconfirmedResult for complete", "unconfirmedResult.txReq", unconfirmedResult.txReq,
"mergeWorkerIdx", unconfirmedResult.slotIndex, "MergedIndex", p.mergedTxIndex.Load(), "Result.err", unconfirmedResult.err, "vmerr", unconfirmedResult.result.Err,
"mergeWorkerIdx", unconfirmedResult.slotIndex, "MergedIndex", p.mergedTxIndex.Load(), "Result.err", unconfirmedResult.err,
"vmerr", unconfirmedResult.result.Err,
"result.gasUsed", unconfirmedResult.result.UsedGas)

cumulativeGasUsedPerMergeWorker[unconfirmedResult.slotIndex] = unconfirmedResult.result.UsedGas
Expand All @@ -1162,24 +1150,13 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
log.Debug("Process get nil Result", "All transactions merged", p.mergedTxIndex.Load())
} else {
// exit from an error
log.Error("Process get nil Result", "result handling abort because of err", unconfirmedResult.err)
log.Debug("Process get nil Result", "result handling abort because of err", unconfirmedResult.err)
}
// jump out of the loop
break
} else {
// normal unconfirmedResult, going to be processed by worker.
if unconfirmedResult.result != nil {
log.Debug("Process get unconfirmedResult", "unconfirmedResult.txReq.txIndex", unconfirmedResult.txReq.txIndex,
"mergeWorkerIdx", unconfirmedResult.slotIndex, "MergedIndex", p.mergedTxIndex.Load(),
"Result.err", unconfirmedResult.err, "vmerr", unconfirmedResult.result.Err,
"result.gasUsed", unconfirmedResult.result.UsedGas)
} else {
log.Debug("Process get unconfirmedResult", "unconfirmedResult.txReq.txIndex", unconfirmedResult.txReq.txIndex,
"mergeWorkerIdx", unconfirmedResult.slotIndex, "MergedIndex", p.mergedTxIndex.Load(),
"Result.err", unconfirmedResult.err)
}
}

// normal unconfirmedResult, going to be processed by worker.
// if it is not byz, it requires root calculation.
// if it doesn't trustDAG, it can not do OOO merge and have to do conflictCheck
OutOfOrderMerge := isByzantium && p.trustDAG
Expand All @@ -1202,17 +1179,14 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
if !ok || prevResult.(*ParallelTxResult).slotDB.BaseTxIndex() < unconfirmedResult.slotDB.BaseTxIndex() {
p.pendingConfirmResults.Store(unconfirmedTxIndex, unconfirmedResult)
// send to handler
log.Debug("Send unconfirmTx to handler", "unconfirmedTxIndex", unconfirmedTxIndex)
p.resultAppendChan <- unconfirmedTxIndex
}
}

// ======================== All result merged ====================== //

// clean up when the block is processed
//log.Debug("doCleanUp - begin")
p.doCleanUp()
//log.Debug("doCleanUp - complete")
if p.error != nil {
return nil, nil, 0, p.error
}
Expand Down Expand Up @@ -1242,9 +1216,6 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
p.engine.Finalize(p.bc, header, statedb, allTxs, block.Uncles(), withdrawals)

//log.Debug("Process - after engine.Finalize()", "block", header.Number, "usedGas", *usedGas,
// "txResultChan size", len(p.txResultChan))

var allLogs []*types.Log
var receipts []*types.Receipt
for _, receipt := range p.receipts {
Expand Down Expand Up @@ -1416,7 +1387,6 @@ func (p *ParallelStateProcessor) handlePendingResultLoop(index int, EnableParall
}

nextToMergeIndex := nextTxIndex
log.Debug(fmt.Sprintf("handlePendingResult get nextToMergeResult, pendingConfirmResult: %p\n", p.pendingConfirmResults))
nextToMergeResult, ok := p.pendingConfirmResults.Load(nextTxIndex)
if !ok {
log.Debug("handlePendingResult - can not load next form pendingConfirmResult", "txIndex", nextTxIndex)
Expand Down Expand Up @@ -1458,9 +1428,7 @@ func (p *ParallelStateProcessor) handlePendingResultLoop(index int, EnableParall
p.resultMutex.Lock()
// update tx result
if result.err != nil {
log.Debug("handlePendingResultLoop result has error",
"txIndex", result.txReq.txIndex, "txBase", result.slotDB.BaseTxIndex(),
"mergedIndex", p.mergedTxIndex.Load())
log.Debug("handlePendingResultLoop result has error", "txIndex", result.txReq.txIndex)
if result.slotDB.BaseTxIndex() >= int(p.mergedTxIndex.Load()) || OutOfOrderMerge {
// should skip the merge phase
log.Error("ProcessParallel a failed tx", "resultSlotIndex", result.slotIndex,
Expand Down Expand Up @@ -1602,10 +1570,5 @@ func applyTransactionStageFinalization(evm *vm.EVM, result *ExecutionResult, msg
receipt.BlockHash = block.Hash()
receipt.BlockNumber = block.Number()
receipt.TransactionIndex = uint(statedb.TxIndex())

// Debug purpose
// b, _ := receipt.MarshalJSON()
// log.Debug("applyTransactionStageFinalization", "receipt", string(b))
//
return receipt, nil
}
8 changes: 0 additions & 8 deletions core/state/parallel_statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,6 @@ func (slotDB *ParallelStateDB) IsParallelReadsValid(isStage2 bool) bool {
})

mainDB := slotDB.parallel.baseStateDB
log.Debug("IsParallelReadsValid", "isStage2", isStage2, "txIndex", slotDB.txIndex)
// conservatively use kvRead size as the initial size.
if isStage2 && slotDB.txIndex < mainDB.TxIndex() {
// already merged, no need to check
Expand Down Expand Up @@ -1833,16 +1832,9 @@ func (s *ParallelStateDB) FinaliseForParallel(deleteEmptyObjects bool, mainDB *S
}
// Invalidate journal because reverting across transactions is not allowed.
s.clearJournalAndRefund()
/*
log.Debug("FinalizeForParallel", "txIndex", s.txIndex,
"s.stateObjectsPending", s.stateObjectsPending,
"s.stateObjectsDirty", s.stateObjectsDirty)
*/
}

func (s *ParallelStateDB) reset() {
log.Debug("slotDB reset", "txIndex", s.txIndex,
"s.parallel", s.parallel, "conflictCheckStateObjectCache", s.parallel.conflictCheckStateObjectCache)
s.StateDB.db = nil
s.StateDB.prefetcher = nil
s.StateDB.trie = nil
Expand Down
21 changes: 0 additions & 21 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,6 @@ func (s *StateDB) GetTransientState(addr common.Address, key common.Hash) common

// updateStateObject writes the given object to the trie.
func (s *StateDB) updateStateObject(obj *stateObject) {
log.Debug("updateStateObject", "addr", obj.address, "data", obj.data)
if !s.noTrie {
// Track the amount of time wasted on updating the account from the trie
if metrics.EnabledExpensive {
Expand Down Expand Up @@ -792,7 +791,6 @@ func (s *StateDB) updateStateObject(obj *stateObject) {

// deleteStateObject removes the given object from the state trie.
func (s *StateDB) deleteStateObject(obj *stateObject) {
log.Debug("deleteStateObject", "addr", obj.address, "data", obj.data)
if s.noTrie {
return
}
Expand Down Expand Up @@ -1468,10 +1466,6 @@ func (s *StateDB) Finalise(deleteEmptyObjects bool) {
}
// Invalidate journal because reverting across transactions is not allowed.
s.clearJournalAndRefund()

log.Debug("Finalize", "txIndex", s.txIndex,
"s.stateObjectsPending", s.stateObjectsPending,
"s.stateObjectsDirty", s.stateObjectsDirty)
}

// IntermediateRoot computes the current root hash of the state trie.
Expand Down Expand Up @@ -1515,7 +1509,6 @@ func (s *StateDB) AccountsIntermediateRoot() {
tasks <- func() {
defer wg.Done()
obj.updateRoot()
log.Debug("AccountsIntermediateRoot", "addr", addr, "obj.data", obj.data)
// Cache the data until commit. Note, this update mechanism is not symmetric
// to the deletion, because whereas it is enough to track account updates
// at commit time, deletions need tracking at transaction boundary level to
Expand All @@ -1531,7 +1524,6 @@ func (s *StateDB) AccountsIntermediateRoot() {
tasks <- func() {
defer wg.Done()
obj.updateRoot()
log.Debug("AccountsIntermediateRoot", "addr", addr, "obj.data", obj.data)
// Cache the data until commit. Note, this update mechanism is not symmetric
// to the deletion, because whereas it is enough to track account updates
// at commit time, deletions need tracking at transaction boundary level to
Expand Down Expand Up @@ -1618,10 +1610,8 @@ func (s *StateDB) StateIntermediateRoot() common.Hash {
}

if s.noTrie {
log.Debug("StateIntermediateRoot", "return", s.expectedRoot)
return s.expectedRoot
} else {
log.Debug("StateIntermediateRoot", "return", s.trie.Hash())
return s.trie.Hash()
}
}
Expand Down Expand Up @@ -2717,17 +2707,6 @@ func (s *StateDB) MergeSlotDB(slotDb *ParallelStateDB, slotReceipt *types.Receip
s.snapDestructs[k] = struct{}{}
s.snapParallelLock.Unlock()
}
/*
s.SetTxContext(slotDb.thash, slotDb.txIndex)
// receipt.Logs use unified log index within a block
// align slotDB's log index to the block stateDB's logSize
for _, l := range slotReceipt.Logs {
l.Index += s.logSize
s.logs[s.thash] = append(s.logs[s.thash], l)
}
s.logSize += slotDb.logSize
*/
return s
}

Expand Down
4 changes: 0 additions & 4 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/holiman/uint256"
)
Expand Down Expand Up @@ -516,9 +515,6 @@ func opSload(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]by
loc := scope.Stack.peek()
hash := common.Hash(loc.Bytes32())
val := interpreter.evm.StateDB.GetState(scope.Contract.Address(), hash)
if interpreter.evm.Context.BlockNumber.Uint64() == 699904 && interpreter.evm.StateDB.TxIndex() == 3 {
log.Debug("opSload", "addr", scope.Contract.Address().Hex(), "hash", hash.Hex(), "val", val.String())
}
loc.SetBytes(val.Bytes())
return nil, nil
}
Expand Down
5 changes: 0 additions & 5 deletions core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,6 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
in.evm.Config.Tracer.CaptureState(pc, op, gasCopy, cost, callContext, in.returnData, in.evm.depth, err)
logged = true
}

if in.evm.Context.BlockNumber.Uint64() == 699904 && in.evm.StateDB.TxIndex() == 3 {
log.Debug("operation execution", "op", op, "cost", cost)
}

// execute the operation
res, err = operation.execute(&pc, in, callContext)
if err != nil {
Expand Down

0 comments on commit 7cd1604

Please sign in to comment.