2023-11-01 03:32:09 +00:00
|
|
|
# Nimbus
|
2024-01-13 01:41:57 +00:00
|
|
|
# Copyright (c) 2019-2024 Status Research & Development GmbH
|
2023-11-01 03:32:09 +00:00
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
|
|
# http://opensource.org/licenses/MIT)
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
2024-06-18 11:14:02 +00:00
|
|
|
# TODO: CoreDb module needs to be updated
|
|
|
|
|
2018-12-03 10:54:19 +00:00
|
|
|
import
|
2022-12-02 04:39:12 +00:00
|
|
|
std/[strutils, json],
|
|
|
|
./common/common,
|
2023-12-12 19:12:56 +00:00
|
|
|
./db/[core_db, ledger],
|
2022-12-02 04:39:12 +00:00
|
|
|
./utils/utils,
|
2023-08-02 10:17:40 +00:00
|
|
|
./evm/tracer/legacy_tracer,
|
2024-06-17 07:56:39 +00:00
|
|
|
./constants,
|
|
|
|
./transaction,
|
|
|
|
./core/executor,
|
|
|
|
./evm/[state, types],
|
2022-12-02 04:39:12 +00:00
|
|
|
nimcrypto/utils as ncrutils,
|
2023-12-08 09:35:50 +00:00
|
|
|
web3/conversions, ./launcher,
|
|
|
|
results,
|
|
|
|
./beacon/web3_eth_conv
|
2018-12-03 16:22:08 +00:00
|
|
|
|
2024-05-16 15:00:20 +00:00
|
|
|
proc getParentHeader(self: CoreDbRef, header: BlockHeader): BlockHeader =
|
|
|
|
self.getBlockHeader(header.parentHash)
|
2018-12-03 16:22:08 +00:00
|
|
|
|
2024-03-22 17:31:56 +00:00
|
|
|
type
|
|
|
|
SaveCtxEnv = object
|
|
|
|
db: CoreDbRef
|
|
|
|
ctx: CoreDbCtxRef
|
|
|
|
|
|
|
|
proc newCtx(com: CommonRef; root: eth_types.Hash256): SaveCtxEnv =
|
|
|
|
let ctx = com.db.ctxFromTx(root).valueOr:
|
|
|
|
raiseAssert "setParentCtx: " & $$error
|
|
|
|
SaveCtxEnv(db: com.db, ctx: ctx)
|
2024-03-21 10:45:57 +00:00
|
|
|
|
2024-03-22 17:31:56 +00:00
|
|
|
proc setCtx(saveCtx: SaveCtxEnv): SaveCtxEnv =
|
|
|
|
SaveCtxEnv(db: saveCtx.db, ctx: saveCtx.db.swapCtx saveCtx.ctx)
|
2024-03-21 10:45:57 +00:00
|
|
|
|
|
|
|
|
2018-12-25 10:31:51 +00:00
|
|
|
proc `%`(x: openArray[byte]): JsonNode =
|
|
|
|
result = %toHex(x, false)
|
|
|
|
|
|
|
|
proc toJson(receipt: Receipt): JsonNode =
|
|
|
|
result = newJObject()
|
|
|
|
|
|
|
|
result["cumulativeGasUsed"] = %receipt.cumulativeGasUsed
|
2024-06-14 07:31:08 +00:00
|
|
|
result["bloom"] = %receipt.logsBloom
|
2018-12-25 10:31:51 +00:00
|
|
|
result["logs"] = %receipt.logs
|
|
|
|
|
|
|
|
if receipt.hasStateRoot:
|
|
|
|
result["root"] = %($receipt.stateRoot)
|
|
|
|
else:
|
|
|
|
result["status"] = %receipt.status
|
|
|
|
|
2023-08-04 11:10:09 +00:00
|
|
|
proc dumpReceipts*(chainDB: CoreDbRef, header: BlockHeader): JsonNode =
|
2018-12-25 10:31:51 +00:00
|
|
|
result = newJArray()
|
2024-06-14 07:31:08 +00:00
|
|
|
for receipt in chainDB.getReceipts(header.receiptsRoot):
|
2018-12-25 10:31:51 +00:00
|
|
|
result.add receipt.toJson
|
|
|
|
|
2018-12-31 03:27:02 +00:00
|
|
|
proc toJson*(receipts: seq[Receipt]): JsonNode =
|
2018-12-25 10:31:51 +00:00
|
|
|
result = newJArray()
|
|
|
|
for receipt in receipts:
|
|
|
|
result.add receipt.toJson
|
2018-12-03 10:54:19 +00:00
|
|
|
|
2023-12-12 19:12:56 +00:00
|
|
|
proc captureAccount(n: JsonNode, db: LedgerRef, address: EthAddress, name: string) =
|
2018-12-12 03:40:37 +00:00
|
|
|
var jaccount = newJObject()
|
|
|
|
jaccount["name"] = %name
|
2019-01-11 06:53:18 +00:00
|
|
|
jaccount["address"] = %("0x" & $address)
|
2020-06-01 06:45:32 +00:00
|
|
|
|
|
|
|
let nonce = db.getNonce(address)
|
|
|
|
let balance = db.getBalance(address)
|
|
|
|
let codeHash = db.getCodeHash(address)
|
|
|
|
let storageRoot = db.getStorageRoot(address)
|
|
|
|
|
2024-01-13 01:41:57 +00:00
|
|
|
jaccount["nonce"] = %(conversions.`$`(nonce.Web3Quantity))
|
2020-06-01 06:45:32 +00:00
|
|
|
jaccount["balance"] = %("0x" & balance.toHex)
|
2018-12-11 09:53:05 +00:00
|
|
|
|
|
|
|
let code = db.getCode(address)
|
2020-06-01 06:45:32 +00:00
|
|
|
jaccount["codeHash"] = %("0x" & ($codeHash).toLowerAscii)
|
2020-04-20 18:12:44 +00:00
|
|
|
jaccount["code"] = %("0x" & toHex(code, true))
|
2020-06-01 06:45:32 +00:00
|
|
|
jaccount["storageRoot"] = %("0x" & ($storageRoot).toLowerAscii)
|
2018-12-11 09:53:05 +00:00
|
|
|
|
|
|
|
var storage = newJObject()
|
|
|
|
for key, value in db.storage(address):
|
2019-01-11 06:53:18 +00:00
|
|
|
storage["0x" & key.dumpHex] = %("0x" & value.dumpHex)
|
2018-12-12 03:40:37 +00:00
|
|
|
jaccount["storage"] = storage
|
2018-12-11 09:53:05 +00:00
|
|
|
|
2018-12-12 03:40:37 +00:00
|
|
|
n.add jaccount
|
2018-12-11 09:53:05 +00:00
|
|
|
|
2023-08-04 11:10:09 +00:00
|
|
|
proc dumpMemoryDB*(node: JsonNode, db: CoreDbRef) =
|
2018-12-12 15:18:46 +00:00
|
|
|
var n = newJObject()
|
2024-07-10 12:19:35 +00:00
|
|
|
for k, v in db.ctx.getKvt():
|
2018-12-25 10:31:51 +00:00
|
|
|
n[k.toHex(false)] = %v
|
2018-12-12 15:18:46 +00:00
|
|
|
node["state"] = n
|
|
|
|
|
2024-03-21 01:05:22 +00:00
|
|
|
proc dumpMemoryDB*(node: JsonNode, kvt: TableRef[common.Blob, common.Blob]) =
|
2024-03-07 19:24:05 +00:00
|
|
|
var n = newJObject()
|
|
|
|
for k, v in kvt:
|
|
|
|
n[k.toHex(false)] = %v
|
|
|
|
node["state"] = n
|
|
|
|
|
2024-06-19 14:13:12 +00:00
|
|
|
proc dumpMemoryDB*(node: JsonNode, capture: CoreDbCaptRef) =
|
2023-10-11 19:09:11 +00:00
|
|
|
node.dumpMemoryDB capture.logDb
|
2023-08-04 11:10:09 +00:00
|
|
|
|
2018-12-12 03:40:37 +00:00
|
|
|
const
|
|
|
|
senderName = "sender"
|
|
|
|
recipientName = "recipient"
|
|
|
|
minerName = "miner"
|
|
|
|
uncleName = "uncle"
|
2018-12-25 07:31:12 +00:00
|
|
|
internalTxName = "internalTx"
|
2018-12-11 09:53:05 +00:00
|
|
|
|
2022-12-02 04:39:12 +00:00
|
|
|
proc traceTransaction*(com: CommonRef, header: BlockHeader,
|
2024-06-14 07:31:08 +00:00
|
|
|
transactions: openArray[Transaction], txIndex: uint64,
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
tracerFlags: set[TracerFlags] = {}): JsonNode =
|
2018-12-03 16:22:08 +00:00
|
|
|
let
|
2018-12-04 02:01:56 +00:00
|
|
|
# we add a memory layer between backend/lower layer db
|
2018-12-04 01:53:21 +00:00
|
|
|
# and capture state db snapshot during transaction execution
|
2024-03-21 10:45:57 +00:00
|
|
|
capture = com.db.newCapture.value
|
2023-08-02 10:17:40 +00:00
|
|
|
tracerInst = newLegacyTracer(tracerFlags)
|
2023-08-04 11:10:09 +00:00
|
|
|
captureCom = com.clone(capture.recorder)
|
2024-03-22 17:31:56 +00:00
|
|
|
|
|
|
|
saveCtx = setCtx com.newCtx(com.db.getParentHeader(header).stateRoot)
|
2024-06-07 08:24:32 +00:00
|
|
|
vmState = BaseVMState.new(header, captureCom).valueOr:
|
|
|
|
return newJNull()
|
2024-03-22 17:31:56 +00:00
|
|
|
stateDb = vmState.stateDB
|
2024-06-07 08:24:32 +00:00
|
|
|
|
2024-03-21 10:45:57 +00:00
|
|
|
defer:
|
2024-03-22 17:31:56 +00:00
|
|
|
saveCtx.setCtx().ctx.forget()
|
|
|
|
capture.forget()
|
2018-12-26 03:34:16 +00:00
|
|
|
|
2022-09-03 18:15:35 +00:00
|
|
|
if header.txRoot == EMPTY_ROOT_HASH: return newJNull()
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
doAssert(transactions.calcTxRoot == header.txRoot)
|
|
|
|
doAssert(transactions.len != 0)
|
2018-12-03 10:54:19 +00:00
|
|
|
|
2018-12-11 09:53:05 +00:00
|
|
|
var
|
|
|
|
gasUsed: GasInt
|
2018-12-12 09:41:18 +00:00
|
|
|
before = newJArray()
|
|
|
|
after = newJArray()
|
2018-12-11 09:53:05 +00:00
|
|
|
stateDiff = %{"before": before, "after": after}
|
2023-12-08 09:35:50 +00:00
|
|
|
beforeRoot: common.Hash256
|
2024-03-22 17:31:56 +00:00
|
|
|
beforeCtx: SaveCtxEnv
|
2018-12-11 09:53:05 +00:00
|
|
|
|
2020-06-22 00:48:23 +00:00
|
|
|
let
|
|
|
|
miner = vmState.coinbase()
|
2019-04-23 12:50:45 +00:00
|
|
|
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
for idx, tx in transactions:
|
2018-12-12 03:40:37 +00:00
|
|
|
let sender = tx.getSender
|
2021-05-04 06:27:18 +00:00
|
|
|
let recipient = tx.getRecipient(sender)
|
2018-12-11 09:53:05 +00:00
|
|
|
|
2024-06-14 07:31:08 +00:00
|
|
|
if idx.uint64 == txIndex:
|
2023-08-02 10:17:40 +00:00
|
|
|
vmState.tracer = tracerInst # only enable tracer on target tx
|
2018-12-12 03:40:37 +00:00
|
|
|
before.captureAccount(stateDb, sender, senderName)
|
|
|
|
before.captureAccount(stateDb, recipient, recipientName)
|
2020-06-22 00:48:23 +00:00
|
|
|
before.captureAccount(stateDb, miner, minerName)
|
2020-06-01 06:45:32 +00:00
|
|
|
stateDb.persist()
|
2018-12-25 10:31:51 +00:00
|
|
|
stateDiff["beforeRoot"] = %($stateDb.rootHash)
|
2018-12-26 03:34:16 +00:00
|
|
|
beforeRoot = stateDb.rootHash
|
2024-03-22 17:31:56 +00:00
|
|
|
beforeCtx = com.newCtx beforeRoot
|
2018-12-11 09:53:05 +00:00
|
|
|
|
2022-01-10 09:04:06 +00:00
|
|
|
let rc = vmState.processTransaction(tx, sender, header)
|
2022-04-08 04:54:11 +00:00
|
|
|
gasUsed = if rc.isOk: rc.value else: 0
|
2018-12-12 03:40:37 +00:00
|
|
|
|
2024-06-14 07:31:08 +00:00
|
|
|
if idx.uint64 == txIndex:
|
2018-12-12 03:40:37 +00:00
|
|
|
after.captureAccount(stateDb, sender, senderName)
|
|
|
|
after.captureAccount(stateDb, recipient, recipientName)
|
2020-06-22 00:48:23 +00:00
|
|
|
after.captureAccount(stateDb, miner, minerName)
|
2023-08-02 10:17:40 +00:00
|
|
|
tracerInst.removeTracedAccounts(sender, recipient, miner)
|
2020-06-01 06:45:32 +00:00
|
|
|
stateDb.persist()
|
2018-12-25 10:31:51 +00:00
|
|
|
stateDiff["afterRoot"] = %($stateDb.rootHash)
|
2018-12-12 03:40:37 +00:00
|
|
|
break
|
2018-12-03 10:54:19 +00:00
|
|
|
|
2018-12-25 07:31:12 +00:00
|
|
|
# internal transactions:
|
2024-03-22 17:31:56 +00:00
|
|
|
let
|
|
|
|
saveCtxBefore = setCtx beforeCtx
|
2024-05-29 11:06:49 +00:00
|
|
|
stateBefore = LedgerRef.init(capture.recorder, beforeRoot)
|
2024-03-22 17:31:56 +00:00
|
|
|
defer:
|
|
|
|
saveCtxBefore.setCtx().ctx.forget()
|
|
|
|
|
2023-08-02 10:17:40 +00:00
|
|
|
for idx, acc in tracedAccountsPairs(tracerInst):
|
2018-12-25 07:31:12 +00:00
|
|
|
before.captureAccount(stateBefore, acc, internalTxName & $idx)
|
|
|
|
|
2023-08-02 10:17:40 +00:00
|
|
|
for idx, acc in tracedAccountsPairs(tracerInst):
|
2018-12-25 07:31:12 +00:00
|
|
|
after.captureAccount(stateDb, acc, internalTxName & $idx)
|
|
|
|
|
2023-08-02 10:17:40 +00:00
|
|
|
result = tracerInst.getTracingResult()
|
2018-12-03 16:22:08 +00:00
|
|
|
result["gas"] = %gasUsed
|
2018-12-25 10:31:51 +00:00
|
|
|
|
|
|
|
if TracerFlags.DisableStateDiff notin tracerFlags:
|
|
|
|
result["stateDiff"] = stateDiff
|
2018-12-03 16:22:08 +00:00
|
|
|
|
2018-12-04 01:53:21 +00:00
|
|
|
# now we dump captured state db
|
2018-12-04 02:01:56 +00:00
|
|
|
if TracerFlags.DisableState notin tracerFlags:
|
2023-08-04 11:10:09 +00:00
|
|
|
result.dumpMemoryDB(capture)
|
2018-12-11 10:05:49 +00:00
|
|
|
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
proc dumpBlockState*(com: CommonRef, blk: EthBlock, dumpState = false): JsonNode =
|
|
|
|
template header: BlockHeader = blk.header
|
2018-12-12 03:40:37 +00:00
|
|
|
let
|
2022-12-02 04:39:12 +00:00
|
|
|
parent = com.db.getParentHeader(header)
|
2024-03-21 10:45:57 +00:00
|
|
|
capture = com.db.newCapture.value
|
2023-08-04 11:10:09 +00:00
|
|
|
captureCom = com.clone(capture.recorder)
|
2024-03-21 10:45:57 +00:00
|
|
|
# we only need a stack dump when scanning for internal transaction address
|
2023-08-02 10:17:40 +00:00
|
|
|
captureFlags = {DisableMemory, DisableStorage, EnableAccount}
|
|
|
|
tracerInst = newLegacyTracer(captureFlags)
|
2024-03-22 17:31:56 +00:00
|
|
|
|
|
|
|
saveCtx = setCtx com.newCtx(parent.stateRoot)
|
2024-06-07 08:24:32 +00:00
|
|
|
vmState = BaseVMState.new(header, captureCom, tracerInst).valueOr:
|
|
|
|
return newJNull()
|
2020-06-22 00:48:23 +00:00
|
|
|
miner = vmState.coinbase()
|
2024-03-21 10:45:57 +00:00
|
|
|
defer:
|
2024-03-22 17:31:56 +00:00
|
|
|
saveCtx.setCtx().ctx.forget()
|
|
|
|
capture.forget()
|
2018-12-12 03:40:37 +00:00
|
|
|
|
|
|
|
var
|
2018-12-12 09:41:18 +00:00
|
|
|
before = newJArray()
|
|
|
|
after = newJArray()
|
2024-05-29 11:06:49 +00:00
|
|
|
stateBefore = LedgerRef.init(capture.recorder, parent.stateRoot)
|
2018-12-12 03:40:37 +00:00
|
|
|
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
for idx, tx in blk.transactions:
|
2018-12-12 03:40:37 +00:00
|
|
|
let sender = tx.getSender
|
2021-05-04 06:27:18 +00:00
|
|
|
let recipient = tx.getRecipient(sender)
|
2018-12-12 09:41:18 +00:00
|
|
|
before.captureAccount(stateBefore, sender, senderName & $idx)
|
|
|
|
before.captureAccount(stateBefore, recipient, recipientName & $idx)
|
2018-12-12 03:40:37 +00:00
|
|
|
|
2020-06-22 00:48:23 +00:00
|
|
|
before.captureAccount(stateBefore, miner, minerName)
|
2018-12-12 03:40:37 +00:00
|
|
|
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
for idx, uncle in blk.uncles:
|
2018-12-12 03:40:37 +00:00
|
|
|
before.captureAccount(stateBefore, uncle.coinbase, uncleName & $idx)
|
|
|
|
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
discard vmState.processBlock(blk)
|
2018-12-12 03:40:37 +00:00
|
|
|
|
2021-10-28 09:42:39 +00:00
|
|
|
var stateAfter = vmState.stateDB
|
2019-02-02 09:20:45 +00:00
|
|
|
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
for idx, tx in blk.transactions:
|
2018-12-12 03:40:37 +00:00
|
|
|
let sender = tx.getSender
|
2021-05-04 06:27:18 +00:00
|
|
|
let recipient = tx.getRecipient(sender)
|
2018-12-12 09:41:18 +00:00
|
|
|
after.captureAccount(stateAfter, sender, senderName & $idx)
|
|
|
|
after.captureAccount(stateAfter, recipient, recipientName & $idx)
|
2023-08-02 10:17:40 +00:00
|
|
|
tracerInst.removeTracedAccounts(sender, recipient)
|
2018-12-12 03:40:37 +00:00
|
|
|
|
2020-06-22 00:48:23 +00:00
|
|
|
after.captureAccount(stateAfter, miner, minerName)
|
2023-08-02 10:17:40 +00:00
|
|
|
tracerInst.removeTracedAccounts(miner)
|
2018-12-12 03:40:37 +00:00
|
|
|
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
for idx, uncle in blk.uncles:
|
2018-12-12 03:40:37 +00:00
|
|
|
after.captureAccount(stateAfter, uncle.coinbase, uncleName & $idx)
|
2023-08-02 10:17:40 +00:00
|
|
|
tracerInst.removeTracedAccounts(uncle.coinbase)
|
2018-12-12 03:40:37 +00:00
|
|
|
|
2018-12-25 07:31:12 +00:00
|
|
|
# internal transactions:
|
2023-08-02 10:17:40 +00:00
|
|
|
for idx, acc in tracedAccountsPairs(tracerInst):
|
2018-12-25 07:31:12 +00:00
|
|
|
before.captureAccount(stateBefore, acc, internalTxName & $idx)
|
|
|
|
|
2023-08-02 10:17:40 +00:00
|
|
|
for idx, acc in tracedAccountsPairs(tracerInst):
|
2018-12-25 07:31:12 +00:00
|
|
|
after.captureAccount(stateAfter, acc, internalTxName & $idx)
|
|
|
|
|
2018-12-12 03:40:37 +00:00
|
|
|
result = %{"before": before, "after": after}
|
2018-12-12 04:16:40 +00:00
|
|
|
|
2018-12-12 15:18:46 +00:00
|
|
|
if dumpState:
|
2023-08-04 11:10:09 +00:00
|
|
|
result.dumpMemoryDB(capture)
|
2018-12-12 15:18:46 +00:00
|
|
|
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
proc traceBlock*(com: CommonRef, blk: EthBlock, tracerFlags: set[TracerFlags] = {}): JsonNode =
|
|
|
|
template header: BlockHeader = blk.header
|
2018-12-12 04:16:40 +00:00
|
|
|
let
|
2024-03-21 10:45:57 +00:00
|
|
|
capture = com.db.newCapture.value
|
2023-08-04 11:10:09 +00:00
|
|
|
captureCom = com.clone(capture.recorder)
|
2023-08-02 10:17:40 +00:00
|
|
|
tracerInst = newLegacyTracer(tracerFlags)
|
2024-03-22 17:31:56 +00:00
|
|
|
|
|
|
|
saveCtx = setCtx com.newCtx(com.db.getParentHeader(header).stateRoot)
|
2024-06-07 08:24:32 +00:00
|
|
|
vmState = BaseVMState.new(header, captureCom, tracerInst).valueOr:
|
|
|
|
return newJNull()
|
|
|
|
|
2024-03-21 10:45:57 +00:00
|
|
|
defer:
|
2024-03-22 17:31:56 +00:00
|
|
|
saveCtx.setCtx().ctx.forget()
|
|
|
|
capture.forget()
|
2018-12-12 04:16:40 +00:00
|
|
|
|
2022-09-03 18:15:35 +00:00
|
|
|
if header.txRoot == EMPTY_ROOT_HASH: return newJNull()
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
doAssert(blk.transactions.calcTxRoot == header.txRoot)
|
|
|
|
doAssert(blk.transactions.len != 0)
|
2018-12-12 04:16:40 +00:00
|
|
|
|
|
|
|
var gasUsed = GasInt(0)
|
|
|
|
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
for tx in blk.transactions:
|
2022-01-10 09:04:06 +00:00
|
|
|
let
|
|
|
|
sender = tx.getSender
|
|
|
|
rc = vmState.processTransaction(tx, sender, header)
|
2022-04-08 04:54:11 +00:00
|
|
|
if rc.isOk:
|
2022-01-10 09:04:06 +00:00
|
|
|
gasUsed = gasUsed + rc.value
|
2018-12-12 04:16:40 +00:00
|
|
|
|
2023-08-02 10:17:40 +00:00
|
|
|
result = tracerInst.getTracingResult()
|
2018-12-12 04:31:53 +00:00
|
|
|
result["gas"] = %gasUsed
|
|
|
|
|
2018-12-12 15:18:46 +00:00
|
|
|
if TracerFlags.DisableState notin tracerFlags:
|
2023-08-04 11:10:09 +00:00
|
|
|
result.dumpMemoryDB(capture)
|
2018-12-12 15:18:46 +00:00
|
|
|
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
proc traceTransactions*(com: CommonRef, header: BlockHeader, transactions: openArray[Transaction]): JsonNode =
|
2018-12-25 10:31:51 +00:00
|
|
|
result = newJArray()
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
for i in 0 ..< transactions.len:
|
2024-06-14 07:31:08 +00:00
|
|
|
result.add traceTransaction(com, header, transactions, i.uint64, {DisableState})
|
2018-12-25 10:31:51 +00:00
|
|
|
|
2024-03-21 10:45:57 +00:00
|
|
|
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
proc dumpDebuggingMetaData*(vmState: BaseVMState, blk: EthBlock, launchDebugger = true) =
|
|
|
|
template header: BlockHeader = blk.header
|
2018-12-25 10:31:51 +00:00
|
|
|
let
|
2024-03-21 10:45:57 +00:00
|
|
|
com = vmState.com
|
2024-06-14 07:31:08 +00:00
|
|
|
blockNumber = header.number
|
2024-03-21 10:45:57 +00:00
|
|
|
capture = com.db.newCapture.value
|
2023-08-04 11:10:09 +00:00
|
|
|
captureCom = com.clone(capture.recorder)
|
2019-02-03 09:08:13 +00:00
|
|
|
bloom = createBloom(vmState.receipts)
|
2024-03-21 10:45:57 +00:00
|
|
|
defer:
|
|
|
|
capture.forget()
|
2019-02-03 09:08:13 +00:00
|
|
|
|
|
|
|
let blockSummary = %{
|
2024-06-14 07:31:08 +00:00
|
|
|
"receiptsRoot": %("0x" & toHex(calcReceiptsRoot(vmState.receipts).data)),
|
2021-10-28 09:42:39 +00:00
|
|
|
"stateRoot": %("0x" & toHex(vmState.stateDB.rootHash.data)),
|
2019-02-03 09:08:13 +00:00
|
|
|
"logsBloom": %("0x" & toHex(bloom))
|
|
|
|
}
|
2018-12-25 10:31:51 +00:00
|
|
|
|
|
|
|
var metaData = %{
|
|
|
|
"blockNumber": %blockNumber.toHex,
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
"txTraces": traceTransactions(captureCom, header, blk.transactions),
|
|
|
|
"stateDump": dumpBlockState(captureCom, blk),
|
|
|
|
"blockTrace": traceBlock(captureCom, blk, {DisableState}),
|
2019-02-03 09:08:13 +00:00
|
|
|
"receipts": toJson(vmState.receipts),
|
|
|
|
"block": blockSummary
|
2018-12-25 10:31:51 +00:00
|
|
|
}
|
|
|
|
|
2023-08-04 11:10:09 +00:00
|
|
|
metaData.dumpMemoryDB(capture)
|
2019-01-12 12:48:28 +00:00
|
|
|
|
|
|
|
let jsonFileName = "debug" & $blockNumber & ".json"
|
|
|
|
if launchDebugger:
|
|
|
|
launchPremix(jsonFileName, metaData)
|
|
|
|
else:
|
|
|
|
writeFile(jsonFileName, metaData.pretty())
|