2021-07-06 13:14:45 +00:00
|
|
|
# Nimbus
|
2024-01-22 09:11:37 +00:00
|
|
|
# Copyright (c) 2018-2024 Status Research & Development GmbH
|
2021-07-06 13:14:45 +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.
|
|
|
|
|
|
|
|
import
|
2022-12-02 04:35:41 +00:00
|
|
|
../../common/common,
|
2024-10-16 01:34:12 +00:00
|
|
|
../../utils/utils,
|
2021-07-06 13:14:45 +00:00
|
|
|
../../constants,
|
2023-12-12 19:12:56 +00:00
|
|
|
../../db/ledger,
|
2021-07-06 13:14:45 +00:00
|
|
|
../../transaction,
|
2024-06-17 07:56:39 +00:00
|
|
|
../../evm/state,
|
|
|
|
../../evm/types,
|
2021-07-06 13:14:45 +00:00
|
|
|
../dao,
|
2024-09-12 03:51:13 +00:00
|
|
|
../eip6110,
|
2021-07-06 13:14:45 +00:00
|
|
|
./calculate_reward,
|
|
|
|
./executor_helpers,
|
|
|
|
./process_transaction,
|
2024-10-04 14:34:31 +00:00
|
|
|
eth/common/transaction_utils,
|
2021-07-06 13:14:45 +00:00
|
|
|
chronicles,
|
2024-05-30 12:54:03 +00:00
|
|
|
results
|
2021-07-06 13:14:45 +00:00
|
|
|
|
2023-01-30 22:10:23 +00:00
|
|
|
{.push raises: [].}
|
2021-07-14 15:13:27 +00:00
|
|
|
|
2023-04-12 12:39:11 +00:00
|
|
|
# Factored this out of procBlkPreamble so that it can be used directly for
|
|
|
|
# stateless execution of specific transactions.
|
2024-05-22 21:01:19 +00:00
|
|
|
proc processTransactions*(
|
2024-06-15 09:22:37 +00:00
|
|
|
vmState: BaseVMState,
|
2024-10-16 01:34:12 +00:00
|
|
|
header: Header,
|
2024-06-15 09:22:37 +00:00
|
|
|
transactions: seq[Transaction],
|
|
|
|
skipReceipts = false,
|
2024-09-12 03:51:13 +00:00
|
|
|
collectLogs = false
|
2024-06-11 15:50:22 +00:00
|
|
|
): Result[void, string] =
|
2024-06-15 09:22:37 +00:00
|
|
|
vmState.receipts.setLen(if skipReceipts: 0 else: transactions.len)
|
2023-04-12 12:39:11 +00:00
|
|
|
vmState.cumulativeGasUsed = 0
|
2024-09-12 03:51:13 +00:00
|
|
|
vmState.allLogs = @[]
|
2023-08-30 16:29:48 +00:00
|
|
|
|
2023-04-12 12:39:11 +00:00
|
|
|
for txIndex, tx in transactions:
|
2024-10-04 14:34:31 +00:00
|
|
|
let sender = tx.recoverSender().valueOr:
|
2023-08-21 02:10:18 +00:00
|
|
|
return err("Could not get sender for tx with index " & $(txIndex))
|
2023-04-12 12:39:11 +00:00
|
|
|
let rc = vmState.processTransaction(tx, sender, header)
|
|
|
|
if rc.isErr:
|
2023-08-21 02:10:18 +00:00
|
|
|
return err("Error processing tx with index " & $(txIndex) & ":" & rc.error)
|
2024-06-15 09:22:37 +00:00
|
|
|
if skipReceipts:
|
|
|
|
# TODO don't generate logs at all if we're not going to put them in
|
|
|
|
# receipts
|
2024-09-12 03:51:13 +00:00
|
|
|
if collectLogs:
|
|
|
|
vmState.allLogs.add vmState.getAndClearLogEntries()
|
|
|
|
else:
|
|
|
|
discard vmState.getAndClearLogEntries()
|
2024-06-15 09:22:37 +00:00
|
|
|
else:
|
|
|
|
vmState.receipts[txIndex] = vmState.makeReceipt(tx.txType)
|
2024-09-12 03:51:13 +00:00
|
|
|
if collectLogs:
|
|
|
|
vmState.allLogs.add vmState.receipts[txIndex].logs
|
2023-04-12 12:39:11 +00:00
|
|
|
ok()
|
|
|
|
|
2024-06-15 09:22:37 +00:00
|
|
|
proc procBlkPreamble(
|
2024-10-16 01:34:12 +00:00
|
|
|
vmState: BaseVMState, blk: Block, skipValidation, skipReceipts, skipUncles: bool
|
2024-06-15 09:22:37 +00:00
|
|
|
): Result[void, string] =
|
2024-10-16 01:34:12 +00:00
|
|
|
template header(): Header =
|
2024-06-11 15:50:22 +00:00
|
|
|
blk.header
|
|
|
|
|
2024-07-04 13:48:36 +00:00
|
|
|
let com = vmState.com
|
|
|
|
if com.daoForkSupport and com.daoForkBlock.get == header.number:
|
2021-07-06 13:14:45 +00:00
|
|
|
vmState.mutateStateDB:
|
|
|
|
db.applyDAOHardFork()
|
|
|
|
|
2024-06-15 09:22:37 +00:00
|
|
|
if not skipValidation: # Expensive!
|
|
|
|
if blk.transactions.calcTxRoot != header.txRoot:
|
|
|
|
return err("Mismatched txRoot")
|
2021-07-06 13:14:45 +00:00
|
|
|
|
2024-09-10 09:52:03 +00:00
|
|
|
if com.isPragueOrLater(header.timestamp):
|
2024-10-18 09:38:18 +00:00
|
|
|
if header.requestsHash.isNone:
|
|
|
|
return err("Post-Prague block header must have requestsHash")
|
2024-09-12 03:51:13 +00:00
|
|
|
|
2024-09-10 09:52:03 +00:00
|
|
|
?vmState.processParentBlockHash(header.parentHash)
|
2024-09-12 03:51:13 +00:00
|
|
|
else:
|
2024-10-18 09:38:18 +00:00
|
|
|
if header.requestsHash.isSome:
|
|
|
|
return err("Pre-Prague block header must not have requestsHash")
|
2024-09-10 09:52:03 +00:00
|
|
|
|
2024-07-04 13:48:36 +00:00
|
|
|
if com.isCancunOrLater(header.timestamp):
|
2023-08-30 16:29:48 +00:00
|
|
|
if header.parentBeaconBlockRoot.isNone:
|
2024-06-11 15:50:22 +00:00
|
|
|
return err("Post-Cancun block header must have parentBeaconBlockRoot")
|
|
|
|
|
|
|
|
?vmState.processBeaconBlockRoot(header.parentBeaconBlockRoot.get)
|
2023-08-30 16:29:48 +00:00
|
|
|
else:
|
|
|
|
if header.parentBeaconBlockRoot.isSome:
|
2024-06-11 15:50:22 +00:00
|
|
|
return err("Pre-Cancun block header must not have parentBeaconBlockRoot")
|
2023-10-18 23:55:50 +00:00
|
|
|
|
2022-09-03 18:15:35 +00:00
|
|
|
if header.txRoot != EMPTY_ROOT_HASH:
|
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
|
|
|
if blk.transactions.len == 0:
|
2024-06-11 15:50:22 +00:00
|
|
|
return err("Transactions missing from body")
|
|
|
|
|
2024-10-16 06:51:38 +00:00
|
|
|
let collectLogs = header.requestsHash.isSome and not skipValidation
|
2024-09-12 03:51:13 +00:00
|
|
|
?processTransactions(vmState, header, blk.transactions, skipReceipts, collectLogs)
|
2024-06-11 15:50:22 +00:00
|
|
|
elif blk.transactions.len > 0:
|
|
|
|
return err("Transactions in block with empty txRoot")
|
2021-07-06 13:14:45 +00:00
|
|
|
|
2024-07-04 13:48:36 +00:00
|
|
|
if com.isShanghaiOrLater(header.timestamp):
|
2023-03-17 18:16:24 +00:00
|
|
|
if header.withdrawalsRoot.isNone:
|
2024-06-11 15:50:22 +00:00
|
|
|
return err("Post-Shanghai block header must have withdrawalsRoot")
|
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
|
|
|
if blk.withdrawals.isNone:
|
2024-06-11 15:50:22 +00:00
|
|
|
return err("Post-Shanghai block body must have withdrawals")
|
2023-03-09 23:40:55 +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 withdrawal in blk.withdrawals.get:
|
2023-10-04 03:47:18 +00:00
|
|
|
vmState.stateDB.addBalance(withdrawal.address, withdrawal.weiAmount)
|
2023-03-17 18:16:24 +00:00
|
|
|
else:
|
|
|
|
if header.withdrawalsRoot.isSome:
|
2024-06-11 15:50:22 +00:00
|
|
|
return err("Pre-Shanghai block header must not have withdrawalsRoot")
|
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
|
|
|
if blk.withdrawals.isSome:
|
2024-06-11 15:50:22 +00:00
|
|
|
return err("Pre-Shanghai block body must not have withdrawals")
|
2023-03-09 23:40:55 +00:00
|
|
|
|
2021-07-06 13:14:45 +00:00
|
|
|
if vmState.cumulativeGasUsed != header.gasUsed:
|
2024-06-11 15:50:22 +00:00
|
|
|
# TODO replace logging with better error
|
2021-07-06 13:14:45 +00:00
|
|
|
debug "gasUsed neq cumulativeGasUsed",
|
2024-06-11 15:50:22 +00:00
|
|
|
gasUsed = header.gasUsed, cumulativeGasUsed = vmState.cumulativeGasUsed
|
|
|
|
return err("gasUsed mismatch")
|
2021-07-06 13:14:45 +00:00
|
|
|
|
|
|
|
if header.ommersHash != EMPTY_UNCLE_HASH:
|
2024-06-15 09:22:37 +00:00
|
|
|
# TODO It's strange that we persist uncles before processing block but the
|
|
|
|
# rest after...
|
|
|
|
if not skipUncles:
|
|
|
|
let h = vmState.com.db.persistUncles(blk.uncles)
|
|
|
|
if h != header.ommersHash:
|
|
|
|
return err("ommersHash mismatch")
|
|
|
|
elif not skipValidation and rlpHash(blk.uncles) != header.ommersHash:
|
2024-06-11 15:50:22 +00:00
|
|
|
return err("ommersHash mismatch")
|
|
|
|
elif blk.uncles.len > 0:
|
|
|
|
return err("Uncles in block with empty uncle hash")
|
2021-07-06 13:14:45 +00:00
|
|
|
|
2024-06-11 15:50:22 +00:00
|
|
|
ok()
|
2021-07-06 13:14:45 +00:00
|
|
|
|
2024-06-15 09:22:37 +00:00
|
|
|
proc procBlkEpilogue(
|
2024-10-16 01:34:12 +00:00
|
|
|
vmState: BaseVMState, blk: Block, skipValidation: bool, skipReceipts: bool
|
2024-06-15 09:22:37 +00:00
|
|
|
): Result[void, string] =
|
2024-10-16 01:34:12 +00:00
|
|
|
template header(): Header =
|
2024-09-12 03:51:13 +00:00
|
|
|
blk.header
|
|
|
|
|
2021-07-06 13:14:45 +00:00
|
|
|
# Reward beneficiary
|
|
|
|
vmState.mutateStateDB:
|
2024-06-08 08:05:00 +00:00
|
|
|
if vmState.collectWitnessData:
|
2021-07-06 13:14:45 +00:00
|
|
|
db.collectWitnessData()
|
2024-06-02 19:21:29 +00:00
|
|
|
|
2024-06-25 05:30:32 +00:00
|
|
|
# Clearing the account cache here helps manage its size when replaying
|
|
|
|
# large ranges of blocks, implicitly limiting its size using the gas limit
|
|
|
|
db.persist(
|
2024-07-04 13:48:36 +00:00
|
|
|
clearEmptyAccount = vmState.com.isSpuriousOrLater(header.number),
|
2024-06-25 05:30:32 +00:00
|
|
|
clearCache = true)
|
2021-07-06 13:14:45 +00:00
|
|
|
|
2024-06-15 09:22:37 +00:00
|
|
|
if not skipValidation:
|
|
|
|
let stateDB = vmState.stateDB
|
|
|
|
if header.stateRoot != stateDB.rootHash:
|
|
|
|
# TODO replace logging with better error
|
|
|
|
debug "wrong state root in block",
|
|
|
|
blockNumber = header.number,
|
|
|
|
expected = header.stateRoot,
|
|
|
|
actual = stateDB.rootHash,
|
|
|
|
arrivedFrom = vmState.com.db.getCanonicalHead().stateRoot
|
|
|
|
return err("stateRoot mismatch")
|
|
|
|
|
2024-06-26 00:27:48 +00:00
|
|
|
if not skipReceipts:
|
|
|
|
let bloom = createBloom(vmState.receipts)
|
2024-09-10 09:52:03 +00:00
|
|
|
|
2024-06-26 00:27:48 +00:00
|
|
|
if header.logsBloom != bloom:
|
|
|
|
return err("bloom mismatch")
|
2024-09-10 09:52:03 +00:00
|
|
|
|
2024-06-26 00:27:48 +00:00
|
|
|
let receiptsRoot = calcReceiptsRoot(vmState.receipts)
|
|
|
|
if header.receiptsRoot != receiptsRoot:
|
|
|
|
# TODO replace logging with better error
|
|
|
|
debug "wrong receiptRoot in block",
|
|
|
|
blockNumber = header.number,
|
|
|
|
actual = receiptsRoot,
|
|
|
|
expected = header.receiptsRoot
|
|
|
|
return err("receiptRoot mismatch")
|
2021-07-06 13:14:45 +00:00
|
|
|
|
2024-10-16 06:51:38 +00:00
|
|
|
if header.requestsHash.isSome:
|
2024-10-18 09:38:18 +00:00
|
|
|
let
|
|
|
|
depositReqs = ?parseDepositLogs(vmState.allLogs)
|
|
|
|
withdrawalReqs = processDequeueWithdrawalRequests(vmState)
|
|
|
|
consolidationReqs = processDequeueConsolidationRequests(vmState)
|
|
|
|
requestsHash = calcRequestsHashInsertType(depositReqs, withdrawalReqs, consolidationReqs)
|
|
|
|
|
|
|
|
if header.requestsHash.get != requestsHash:
|
|
|
|
debug "wrong requestsHash in block",
|
2024-09-12 03:51:13 +00:00
|
|
|
blockNumber = header.number,
|
2024-10-18 09:38:18 +00:00
|
|
|
actual = requestsHash,
|
2024-10-16 06:51:38 +00:00
|
|
|
expected = header.requestsHash.get
|
2024-10-18 09:38:18 +00:00
|
|
|
return err("requestsHash mismatch")
|
2024-09-12 06:56:13 +00:00
|
|
|
|
2024-06-11 15:50:22 +00:00
|
|
|
ok()
|
2021-07-06 13:14:45 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public functions
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2022-01-10 09:04:06 +00:00
|
|
|
proc processBlock*(
|
2024-06-11 15:50:22 +00:00
|
|
|
vmState: BaseVMState, ## Parent environment of header/body block
|
2024-10-16 01:34:12 +00:00
|
|
|
blk: Block, ## Header/body block to add to the blockchain
|
2024-06-15 09:22:37 +00:00
|
|
|
skipValidation: bool = false,
|
|
|
|
skipReceipts: bool = false,
|
|
|
|
skipUncles: bool = false,
|
2024-06-11 15:50:22 +00:00
|
|
|
): Result[void, string] =
|
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
|
|
|
## Generalised function to processes `blk` for any network.
|
2024-06-15 09:22:37 +00:00
|
|
|
?vmState.procBlkPreamble(blk, skipValidation, skipReceipts, skipUncles)
|
2021-07-06 13:14:45 +00:00
|
|
|
|
2022-12-02 04:35:41 +00:00
|
|
|
# EIP-3675: no reward for miner in POA/POS
|
2024-10-08 02:37:36 +00:00
|
|
|
if not vmState.com.proofOfStake(blk.header):
|
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
|
|
|
vmState.calculateReward(blk.header, blk.uncles)
|
2021-07-06 13:14:45 +00:00
|
|
|
|
2024-09-12 03:51:13 +00:00
|
|
|
?vmState.procBlkEpilogue(blk, skipValidation, skipReceipts)
|
2021-07-06 13:14:45 +00:00
|
|
|
|
2024-06-11 15:50:22 +00:00
|
|
|
ok()
|
2022-01-10 09:04:06 +00:00
|
|
|
|
2021-07-06 13:14:45 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# End
|
|
|
|
# ------------------------------------------------------------------------------
|