mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 08:49:29 +00:00
sanity check
This commit is contained in:
parent
f044367288
commit
232bafe6fb
1 changed files with 24 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
@ -157,6 +158,29 @@ func (t *perfTracer) OnBlockEnd(err error) {
|
||||||
blockEndIO.SnapshotCommits + blockEndIO.TrieDBCommits
|
blockEndIO.SnapshotCommits + blockEndIO.TrieDBCommits
|
||||||
evmTime := totalTime - ioTime
|
evmTime := totalTime - ioTime
|
||||||
|
|
||||||
|
// Sanity check: IO time should not exceed total time
|
||||||
|
if ioTime > totalTime {
|
||||||
|
log.Error("PerfTracer: Block IO time exceeds total time",
|
||||||
|
"blockNumber", t.currentBlock.Number(),
|
||||||
|
"ioTime", ioTime,
|
||||||
|
"totalTime", totalTime)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate sum of transaction times and gas
|
||||||
|
var totalTxTime time.Duration
|
||||||
|
for _, tx := range t.txData {
|
||||||
|
txTime, _ := strconv.ParseUint(tx["totalTime"].(string)[2:], 16, 64)
|
||||||
|
totalTxTime += time.Duration(txTime)
|
||||||
|
}
|
||||||
|
if totalTxTime > totalTime {
|
||||||
|
log.Error("PerfTracer: Sum of transaction times exceeds block total time",
|
||||||
|
"blockNumber", t.currentBlock.Number(),
|
||||||
|
"totalTxTime", totalTxTime,
|
||||||
|
"blockTotalTime", totalTime)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
blockRecord := map[string]interface{}{
|
blockRecord := map[string]interface{}{
|
||||||
"blockNumber": fmt.Sprintf("0x%x", t.currentBlock.Number()),
|
"blockNumber": fmt.Sprintf("0x%x", t.currentBlock.Number()),
|
||||||
"blockHash": t.currentBlockHash.Hex(),
|
"blockHash": t.currentBlockHash.Hex(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue