Commit Graph

227 Commits

Author SHA1 Message Date
Advaita Saha 48aa410f8a
reduce blockHash call (#2954) 2024-12-19 01:13:12 +05:30
Jacek Sieka d45d03ce0c
reduce tx naming overload (#2952)
* if it's a db function, use `txFrame...`
* if it's not a db function, don't use `txFrame...`
2024-12-18 23:03:51 +07:00
Jacek Sieka 7bbb0f4421
Stream blocks during import (#2937)
When running the import, currently blocks are loaded in batches into a
`seq` then passed to the importer as such.

In reality, blocks are still processed one by one, so the batching does
not offer any performance advantage. It does however require that the
client wastes memory, up to several GB, on the block sequence while
they're waiting to be processed.

This PR introduces a persister that accepts these potentially large
blocks one by one and at the same time removes a number of redundant /
unnecessary copies, assignments and resets that were slowing down the
import process in general.
2024-12-18 13:21:20 +01:00
andri lim 45bc6422a0
Reduce getCanonicalHead usage, and delegate to ForkedChain (#2948)
The current getCanonicalHead of core db should not be confused with ForkedChain.latestHeader.
Therefore we need to use getCanonicalHead to restricted case only, e.g. initializing ForkedChain.
2024-12-18 11:04:23 +07:00
andri lim f74813520a
Connect gasLimit from Config to CommonRef (#2946) 2024-12-17 10:48:31 +00:00
tersec 0b704040e3
increase default gas limit from 30M to 36M (#2941) 2024-12-16 23:32:29 +00:00
andri lim 2e5ef4fb5a
Wire ForkedChainRef properly to TxPool (#2933) 2024-12-13 13:21:20 +07:00
andri lim 847cc311eb
Remove verifyFrom, vmState, and checkSeal from ChainRef (#2932) 2024-12-13 12:12:57 +07:00
Jacek Sieka 3d58393b4c
Offload signature checking to taskpools (#2927)
In block processing, depending on the complexity of a transaction and
hotness of caches etc, signature checking can actually make up the
majority of time needed to process a transaction (60% observed in some
randomly sampled block ranges).

Fortunately, this is a task that trivially can be offloaded to a task
pool similar to how nimbus-eth2 does it.

This PR introduces taskpools in the most simple way possible, by
performing signature checking concurrently with other TX processing,
assigning a taskpool task per TX effectively.

With this little trick, we're in gigagas land 🎉 on my laptop!

```
INF 2024-12-10 21:05:35.170+01:00 Imported blocks
blockNumber=3874817 b... mgps=1222.707 ...
```

Tests don't use the taskpool for now because it needs manual cleanup and
we don't have a good mechanism in place. Future PR:s should address this
by creating a common shutdown sequence that also closes and cleans up
other resources like the DB.

Co-authored-by: andri lim <jangko128@gmail.com>
2024-12-13 11:53:41 +07:00
andri lim 1d5a48e153
Feature: configurable gas limit when building execution payload (#2931)
* Feature: configurable gas limit when building execution payload

* Raise default gas limit to 30M
2024-12-13 10:47:35 +07:00
Jacek Sieka 667897557a
Interpreter dispatch cleanups (#2913)
* `shouldPrepareTracer` always true
* simple `pop` should not copy value (reading the memory shows up in a
profiler)
* continuation code simplified
* remove some unnecessary EH
2024-12-06 13:01:15 +01:00
Jordan Hrycaj 90dd86be9a
Fc module can update base also when on parent arc (#2911)
* Re-org internal descriptor `CanonicalDesc` as `PivotArc`

why:
  Despite its name, `CanonicalDesc` contained a cursor arc (or leg) from
  the base tree with a designated block (or Header) on its arc members
  (aka blocks.) The type is used more generally than only for s block on
  the canonical cursor.

  Also, the `PivotArc` provides some more fields for caching intermediate
  data. This simplifies managing extra arguments for some functions.

* Remove cruft

details:
  No need to find cursor arc if it is given as function argument.

* Rename prototype variables `head: PivotArc` to `pvarc`

why:
  Better reading

* Function and code massage, adjust names

details:
  Avoid the syllable `canonical` in function names that do not strictly
  apply to the canonical chain. So renaming
  * findCanonicalHead() => findCursorArc()
  * canonicalChain() => findHeader()
  * trimCanonicalChain() => trimCursorArc()

* Combine `updateBase()` function-args into single `PivotArgs` object

why:
  Will generalise action for more complex scenarios in future.

* update `calculateNewBase()` return code type => `PivotArc`

why:
  So it can directly be used as argument into `updateBase()`

* Update `calculateNewBase()` for target on parent arc

* Update unit tests
2024-12-05 13:01:57 +07:00
andri lim 1101895f92
Move rlp block import into it's own subcommand (#2904)
* Move rlp block import into it's own subcommand

* Fix test_configuration
2024-12-04 20:36:07 +07:00
Jordan Hrycaj 9da3f29dff
Add desc validator to fc unit tests (#2899)
* Kludge: fix `eip4844` import in `validate`

why:
  Importing `validate` needs `blscurve` here or with the importing module.

* Separate out `FC` descriptor iinto separate file

why:
  Needed for external descriptor access (e.g. for debugging)

* Debugging toolkit for `FC`

* Verify chain descriptor after changing state
2024-12-02 17:49:53 +00:00
Jordan Hrycaj dd888deadb
Fc module various base tree admin updates (#2895)
* Cosmetics, update log and exception messages

* Update `FC` base tree updater `updateBase()`

why:
  Correct `forkJunction` of canonical cursor head record. When moving
  the `base`, this field would be below `base` unless updated.

* Fix `FC` chain selector `findCanonicalHead()`

why:
  Given a sample ref `hash` the function searched for the unique chain
  containing the block header referenced by `hash`.

  Unfortunately, when searching down the ancestry lineage, the function
  did not necessarily stop an the end of the sub-chain. Rather it
  continued with the parent chain without noticing. So returning the
  wrong result.

* When calculating new a base it must reside on cursor arc (or leg.)

why:
  The finalised block argument (that will eventually be the new base)
  might be moved further down the cursor arc if it is too close to the
  cursor head (typically smaller than 128 blocks.)

  So the finalised block selection is shifted down he cursor arc. And
  it might happen that the cursor arc itself is too small and one would
  end up at a parent cursor arc. This is rejected.

* Not starting a new cursor arc with a block already on another arc

why:
  This leads to an inconsistent set of cursor arcs which are supposed to
  be mutually disjunct.

* Tighten condition: A block that is not on the base tree must be on the DB

* One less TODO item
2024-12-02 08:25:58 +00:00
andri lim fbbc500445
Bump nim-evmc to 730d35d8572e1b3957b0c6c986ecd86413976da0 (#2879) 2024-11-27 16:08:14 +07:00
andri lim b87b255398
Add missing pieces of EIP-7702 (#2877) 2024-11-27 08:59:42 +01:00
Jordan Hrycaj 0e793aedf8
For the `FC` module, never add the `base` block to base tree (#2876)
why:
  The `base` block is ancestor to all blocks of the base tree bust stays
  outside the tree.

  Some fringe condition uses an opportunistic fix when the `cursor` is not in
  the base tree, which is legit if `cursor != base`.
2024-11-26 14:00:54 +00:00
Advaita Saha 5e152f9436
Fix logging in block processing (#2870)
* log blockhash and parentHash in stateRoot mismatch

* logs for case when parent not found

* some more logs in epilogue

* add parentHash
2024-11-25 21:10:03 +01:00
andri lim fbfc1611d7
Implement EIP-7702: Set EOA account code (#2631)
* Implement EIP-7702 part 1: Behavior

* Implement EIP-7702 part 2: Tx validation

* Implement EIP-7702 part 3: Delegation Designation and Gas Costs
2024-11-25 11:28:03 +01:00
andri lim 666f8d2cf1
Fixes related to Prague execution requests (#2847)
* Fixes related to Prague execution requests

Turn out the specs are changed:
- WITHDRAWAL_REQUEST_ADDRESS -> WITHDRAWAL_QUEUE_ADDRESS
- CONSOLIDATION_REQUEST_ADDRESS -> CONSOLIDATION_QUEUE_ADDRESS
- DEPOSIT_CONTRACT_ADDRESS -> only mainnet
- depositContractAddress can be configurable

Also fix bugs related to t8n tool

* Fix for evmc
2024-11-08 10:47:07 +07:00
andri lim 70a1f768f7
Engine API: Route more wiring from CoreDb to ForkedChain (#2844) 2024-11-07 03:43:25 +00:00
andri lim 6b86acfb8d
Cleanup db/core_apps error handling (#2838)
* Cleanup db/core_apps error handling

* Fix persistHeader

* Fix getUncles
2024-11-07 08:24:21 +07:00
andri lim fcb668d23f
FC fix: Genesis hash should canonical too (#2839)
* FC fix: Genesis hash should canonical too

* Remove debugEcho from production code
2024-11-06 12:38:35 +00:00
andri lim f201eb611e
Simplify LedgerRef: remove unnecessary abstraction (#2826) 2024-11-06 09:01:56 +07:00
andri lim f0f607b23b
Feature: User configurable extraData when assemble a block (#2823)
* Feature: User configurable extraData when assemble a block

As evident from https://holesky.beaconcha.in/block/2657016
when nimbus-eth1 assemble a block, the extraData field is empty.
This commit will give user a chance to put his extraData or
use default value.

* Warning if extraData exceeds 32 bytes limit

* Add missing comma
2024-11-06 09:01:25 +07:00
Advaita Saha a45ac7e327
Port p2p to server API (#2769)
* eth_gasPrice

* signing endpoints

* transaction by hash + temp fixes

* fix CI

* fix: state not persisted

* decouple state access changes from this PR

* rpc complete set

* tests modified

* tests temp modifications

* add tests to CI + minor fixes

* remove p2p

* remove old dependency

* fix suggestions

* rework tests

* rework kurtosis issue + comments

* fix post bump issues

* suggestions + logs

* remove unused imports
2024-11-02 10:30:45 +01:00
tersec 73661fd8a4
switch to Nim v2.0.12 (#2817)
* switch to Nim v2.0.12

* fix LruCache capitalization for styleCheck

* KzgProof/KzgCommitment for styleCheck

* TxEip4844 for styleCheck

* styleCheck issues in nimbus/beacon/payload_conv.nim

* ENode for styleCheck

* isOk for styleCheck

* some more styleCheck fixes

* more styleCheck fixes

---------

Co-authored-by: jangko <jangko128@gmail.com>
2024-11-01 19:06:26 +00:00
andri lim fa95633b57
Fix calcRequestsHash implementation (#2797)
Turn out it is a double layer hash
2024-10-29 05:01:59 +00:00
Advaita Saha ba1cbed14f
better logging for running client (#2781)
* better logging for running client

* logs for persistance + more data

* persistance logs fixed

* blobgas

* blobGas is Opt

* suggestions added

* fcU fixed
2024-10-27 22:20:04 +00:00
Jacek Sieka d828dead2d
Use stateRoot/storageRoot more consistently (#2791)
* prefer the spec-derived name where possible
* don't pass stateRoot to LedgerRef and friends (it doesn't do anything)
* add deprecation warning in graphql - it needs updating to use
forkedchain instead
2024-10-27 19:56:28 +01:00
andri lim 738cb277cf
Fixes related to executionRequests of Pectra (#2787) 2024-10-26 11:10:54 +00:00
andri lim cee4368075
Unify tx validation (#2777) 2024-10-26 09:19:48 +02:00
andri lim 67088540cf
Fix leftover eth types changes warnings (#2766) 2024-10-22 13:42:16 +07:00
Advaita Saha c9f97e6cd6
Fix blobs (#2762)
* add blobGasUsed calculation

* enable old tests

* add blob tests in kurtosis

* add blobGasUsed validation

* revert

* introduce blobs in test

* fix: kzg setup

* prevent regression
2024-10-22 09:07:43 +07:00
Advaita Saha c5573fb0aa
fix rpc for old blocks in db (#2756) 2024-10-19 06:57:37 +07:00
Jacek Sieka d4bb2088ea
txpool: use common txroot computation (#2755)
Avoids CoreDb overhead for this simple operation
2024-10-19 06:39:33 +07:00
andri lim 133387e6a7
Rework EIP-6110, EIP-7002, and EIP-7251: Pectra execution requests (#2734)
* Rework EIP-6110, EIP-7002, and EIP-7251

* Bump nimbus-eth2
2024-10-18 16:38:18 +07:00
Jordan Hrycaj 7d41a992e6
Update fork choice import for resuming after stop (#2746)
* Update `ForkedChainRef` constructor

why:
  Initialisation is based on the canonical head which is always zero
  after resuming a stopped `ForkedChainRef` based import.

* Update new-base calculator

why:
  There is some ambiguous code which might not do what the comment
  implies. In short, an unsigned condition like `2u - 3u < 1u => false`
  is coded where the comment suggests that `2 - 3 < 1 => true` is meant.

  This patch fixes notorious crashes when resuming import after a stop.
2024-10-17 12:14:09 +00:00
andri lim 1126c7700d
Bump nim-eth and nimbus-eth2 (#2741)
* Bump nim-eth and nimbus-eth2

* Fix ambiguous identifier
2024-10-16 13:51:38 +07:00
Chirag Parmar 2838191c4f
replace deprecated types (#2704)
* partial commit

* fixes

* remove converters too

* revert changes on nimbus_verified_proxy

* revert changes in converter

* revert changes(re-xport) in rpc_types

* update copyright year

* replace types in other binaries

* chain config bug

* fix rebase conflict imcomplete buffer

* fix more rebase buffers

* remove ditto types and converters

* fix the tests

* update copyright year
2024-10-16 08:34:12 +07:00
andri lim 76c2a75a53
Proof-of-stakiness based on block header (#2682)
* Proof-of-stakiness based on block header

* Remove unnecessary PoS check from test_txpool2

* Fix engine api simulator

* Fix indentation

* Fix vmstate debug util

* Fix MainNet ForkId calculation issue
2024-10-08 09:37:36 +07:00
tersec 845f3276e3
bump nimbus-build-system to use Nim v2.0.10 (#2684)
* bump nimbus-build-system to use Nim v2.0.10

* 2.0.10 fixes

* fluffy linting

* make trivial change which should trigger whole-nimbus+fluffy rebuild/ci

* Nim v2.0.10 chronicles.error/macros.error ambiguity workaround

* another contentType enum specifier

* fluffy linting
2024-10-06 12:15:54 +00:00
Jordan Hrycaj 3822c57ddc
Remove `hunter` (#2697)
* Remove `hunter`

why:
  Neither functional anymore, nor used

* Remove obsolete premix

* Remove obsolete launcher

---------

Co-authored-by: jangko <jangko128@gmail.com>
2024-10-06 10:11:44 +00:00
Kim De Mey dbe3393f5c
Fix eth/common & web3 related deprecation warnings for fluffy (#2698)
* Fix eth/common & web3 related deprecation warnings for fluffy

This commit uses the new types in the new eth/common/ structure
to remove deprecation warnings.

It is however more than just a mass replace as also all places
where eth/common or eth/common/eth_types or eth/common/eth_types_rlp
got imported have been revised and adjusted to a better per submodule
based import.

There are still a bunch of toMDigest deprecation warnings but that
convertor is not needed for fluffy code anymore so in theory it
should not be used (bug?). It seems to still get imported via export
leaks ffrom imported nimbus code I think.

* Address review comments

* Remove two more unused eth/common imports
2024-10-04 23:21:26 +02:00
Jacek Sieka 08ffb3161c
Use eth/common transaction signature utilities (#2696)
* Use eth/common transaction signature utilities

* bump

* bump

* bump

* bump

* bump

* bump
2024-10-04 16:34:31 +02:00
Advaita Saha e7782fd669
rpc fixes and enable kurtosis (#2681)
* fix: rpc can't serve blocks in db

* shift db access to forkedchainref

* cleanup

* kurtosis test fix, should fail + eth_getTransactionReceipt

* remove kurtosis not + cleanup

* alter CI check to pass

* optimize impl

* cleanup

* fix loop case
2024-10-04 07:59:38 +00:00
Jacek Sieka a03bb56bec
update web3 types to common eth (#2674) 2024-10-02 18:22:35 +02:00
tersec 216604d0d6
add eth_sendRawTransaction to server API (#2678) 2024-10-02 03:56:39 +00:00
Jacek Sieka 219b22b1f5
Versioned hash32 (#2672) 2024-10-01 19:40:37 +02:00