Commit Graph

2045 Commits

Author SHA1 Message Date
Jacek Sieka 652539e628
Simplify state root api (#2864)
`updateOk` is obsolete and always set to true - callers should not have
to care about this detail

also take the opportunity to clean up storage root naming
2024-11-22 14:15:35 +01:00
Advaita Saha ac2f3a4358
serve state in rpc (#2824)
* simpler state replay logic

* add tests
2024-11-22 16:45:52 +05:30
andri lim 7b2b59a976
Add missing fields to RPC object conversion (#2863)
* Add missing fields to RPC object conversion

* Fix populateBlockObject call

* Remove server_api_helpers.nim

* Add metric defined conditional compilation

* link with rocksdb
2024-11-22 17:07:53 +07:00
Jordan Hrycaj a241050c94
Beacon sync update multi exe heads aware (#2861)
* Log/trace cancellation events in scheduler

* Provide `clear()` functions for explicitly flushing data objects

* Renaming header cache functions

why:
  More systematic, all functions start with prefix `dbHeader`

* Remove `danglingParent` from layout

why:
  Already provided by header cache

* Remove `couplerHash` and `headHash` from layout

why:
  No need to cache, `headHash` is unused and `couplerHash` used typically
  once, only.

* Remove `lastLayout` from sync descriptor

why:
  No need to compare changes, saving is always triggered after actively
  changing the sync layout state

* Early reject unsuitable head + finalised header from CL

why:
  The finalised header is only passed by its hash so the header must be
  fetched somewhere, e.g. from a peer via eth/xx.

  Also, finalised headers earlier than the `base` from `FC` cannot be
  handled due to the `Aristo` single state database architecture.

  Luckily, on a full node, the complete block history is available so
  unsuitable finalised headers are stored there already which is exploited
  here to avoid unnecessary network traffic.

* Code cosmetics, remove cruft, prettify logging, remove `final` metrics

detail:
  The `final` layout parameter will be deprecated and later removed

* Update/re-calibrate syncer logic documentation

why:
  The current implementation sucks if the `FC` module changes the
  canonical branch in the middle of completing a header chain (due
  to concurrent updates by the `newPayload()` logic.)

* Implement according to re-calibrated syncer docu

details:
  The implementation employs the notion of named layout states (see
  `SyncLayoutState` in `worker_desc.nim`) which are derived from the
  state parameter triple `(C,D,H)` as described in `README.md`.
2024-11-21 16:32:47 +00:00
andri lim c525590a51
Fix simulator RPC object: add fields from latest spec (#2859) 2024-11-21 21:58:12 +07:00
andri lim a57a887269
Fix t8n regression: Legacy Tx should not validate chainId (#2858) 2024-11-21 21:57:22 +07:00
Jacek Sieka 6086c2903c
Small deserialization speedup (#2852)
When walking AriVtx, parsing integers and nibbles actually becomes a
hotspot - these trivial changes reduces CPU usage during initial key
cache computation by ~15%.
2024-11-20 16:04:32 +01:00
Jacek Sieka 01ca415721
Store keys together with node data (#2849)
Currently, computed hash keys are stored in a separate column family
with respect to the MPT data they're generated from - this has several
disadvantages:

* A lot of space is wasted because the lookup key (`RootedVertexID`) is
repeated in both tables - this is 30% of the `AriKey` content!
* rocksdb must maintain in-memory bloom filters and LRU caches for said
keys, doubling its "minimal efficient cache size"
* An extra disk traversal must be made to check for existence of cached
hash key
* Doubles the amount of files on disk due to each column family being
its own set of files

Here, the two CFs are joined such that both key and data is stored in
`AriVtx`. This means:

* we save ~30% disk space on repeated lookup keys
* we save ~2gb of memory overhead that can be used to cache data instead
of indices
* we can skip storing hash keys for MPT leaf nodes - these are trivial
to compute and waste a lot of space - previously they had to present in
the `AriKey` CF to avoid having to look in two tables on the happy path.
* There is a small increase in write amplification because when a hash
value is updated for a branch node, we must write both key and branch
data - previously we would write only the key
* There's a small shift in CPU usage - instead of performing lookups in
the database, hashes for leaf nodes are (re)-computed on the fly
* We can return to slightly smaller on-disk SST files since there's
fewer of them, which should reduce disk traffic a bit

Internally, there are also other advantages:

* when clearing keys, we no longer have to store a zero hash in memory -
instead, we deduce staleness of the cached key from the presence of an
updated VertexRef - this saves ~1gb of mem overhead during import
* hash key cache becomes dedicated to branch keys since leaf keys are no
longer stored in memory, reducing churn
* key computation is a lot faster thanks to the skipped second disk
traversal - a key computation for mainnet can be completed in 11 hours
instead of ~2 days (!) thanks to better cache usage and less read
amplification - with additional improvements to the on-disk format, we
can probably get rid of the initial full traversal method of seeding the
key cache on first start after import

All in all, this PR reduces the size of a mainnet database from 160gb to
110gb and the peak memory footprint during import by ~1-2gb.
2024-11-20 09:56:27 +01:00
Jacek Sieka 9e98c934b7
eth: bump to devp2p v5 (#2837) 2024-11-08 10:24:35 +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 c15647075d
Use CompileDate's year part for copyright banner (#2848)
* Use CompileDate's year part for copyright banner

* Fix copyright year

* Fix missing import
2024-11-08 10:46:37 +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 6c3bbbf22c
Feature: Prevent loading an existing data directory for the wrong network (#2825)
* Prevent loading an existing data directory for the wrong network

* Fix and add more info
2024-11-06 09:01:42 +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
Jordan Hrycaj 7fe4023d1f
Beacon sync docu todo and async prototype update v2 (#2832)
* Annotate `async` functions for non-exception tracking at compile time

details:
  This also requires some additional try/except catching in the function
  bodies.

* Update sync logic docu to what is to be updated

why:
  The understanding of details of how to accommodate for merging
  sub-chains of blocks or headers have changed. Some previous set-ups
  are outright wrong.
2024-11-05 11:39:45 +00:00
andri lim 89fac051cd
Reduce declared but not used warnings (#2822) 2024-11-03 00:11:24 +00: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
Jacek Sieka 58cde36656
Remove `RawData` from possible leaf payload types (#2794)
This kind of data is not used except in tests where it is used only to
create databases that don't match actual usage of aristo.

Removing simplifies future optimizations that can focus on processing
specific leaf types more efficiently.

A casualty of this removal is some test code as well as some proof
generation code that is unused - on the surface, it looks like it should
be possible to port both of these to the more specific data types -
doing so would ensure that a database written by one part of the
codebase can interact with the other - as it stands, there is confusion
on this point since using the proof generation code will result in a
database of a shape that is incompatible with the rest of eth1.
2024-11-02 10:29:16 +01:00
Jacek Sieka a5541a5a4f
holesky: fix timestamp (#2819)
* holesky: fix timestamp

* log a bit more about genesis
2024-11-02 08:18:26 +01:00
andri lim c88c1911c9
Simplify BeaconEngineRef (#2812) 2024-11-02 08:45:27 +07:00
Jordan Hrycaj 430611d3bc
Beacon sync updates tbc (#2818)
* Clear rejected sync target so that it would not be processed again

* Use in-memory table to stash headers after FCU import has started

why:
  After block imported has started, there is no way to save/stash block
  headers persistently. The FCU handlers always maintain a positive
  transaction level and in some instances the current transaction is
  flushed and re-opened.

  This patch fixes an exception thrown when a block header has gone
  missing.

* When resuming sync, delete stale headers and state

why:
  Deleting headers saves some persistent space that would get lost
  otherwise. Deleting the state after resuming prevents from race
  conditions.

* On clean start hibernate sync `deamon` entity before first update from CL

details:
  Only reduces services are running
  * accept FCU from CL
  * fetch finalised header after accepting FCY (provides hash only)

* Improve text/meaning of some log messages

* Revisit error handling for useless peers

why:
  A peer is abandoned from if the error score is too high. This was not
  properly handled for some fringe case when the error was detected at
  staging time but fetching via eth/xx was ok.

* Clarify `break` meaning by using labelled `break` statements

* Fix action how to commit when sync target has been reached

why:
  The sync target block number might precede than latest FCU block number.
  This happens when the engine API squeezes in some request to execute
  and import subsequent blocks.

  This patch fixes and assert thrown when after reaching target the latest
  FCU block number is higher than the expected target block number.

* Update TODO list
2024-11-01 19:18:41 +00: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
Jacek Sieka 20edc0dcf5
Use common format for clientid (#2810) 2024-11-01 21:29:38 +07:00
andri lim fa95633b57
Fix calcRequestsHash implementation (#2797)
Turn out it is a double layer hash
2024-10-29 05:01:59 +00:00
tersec 11c875c5c2
rm --protocol CLI flag (#2793) 2024-10-28 22:17:07 +00:00
Jacek Sieka 1406feab5f
fix computeKey account hash (#2795)
Oops. Discovered as part of making the code use the actual production
database types in the key computation test ;)
2024-10-28 19:14:28 +01:00
Jacek Sieka 43e08d08c7
drop support for generic data in coredb (#2792)
All actual access to CoreDB is typed (account or storage) - it's
unlikely ethereum will grow another trie structure in the near future.
2024-10-28 17:56:43 +01:00
Jordan Hrycaj ea268e81ff
Beacon sync activation control update (#2782)
* Clarifying/commenting FCU setup condition & small fixes, comments etc.

* Update some logging

* Reorg metrics updater and activation

* Better `async` responsiveness

why:
  Block import does not allow `async` task activation while
  executing. So allow potential switch after each imported
  block (rather than a group of 32 blocks.)

* Handle resuming after previous sync followed by import

why:
  In this case the ledger state is more recent than the saved
  sync state. So this is considered a pristine sync where any
  previous sync state is forgotten.

  This fixes some assert thrown because of inconsistent internal
  state at some point.

* Provide option for clearing saved beacon sync state before starting syncer

why:
  It would resume with the last state otherwise which might be undesired
  sometimes.

  Without RPC available, the syncer typically stops and terminates with
  the canonical head larger than the base/finalised head. The latter one
  will be saved as database/ledger state and the canonical head as syncer
  target. Resuming syncing here will repeat itself.

  So clearing the syncer state can prevent from starting the syncer
  unnecessarily avoiding useless actions.

* Allow workers to request syncer shutdown from within

why:
  In one-trick-pony mode (after resuming without RPC support) the
  syncer can be stopped from within soavoiding unnecessary polling.
  In that case, the syncer can (theoretically) be restarted externally
  with `startSync()`.

* Terminate beacon sync after a single run target is reached

why:
  Stops doing useless polling (typically when there is no RPC available)

* Remove crufty comments

* Tighten state reload condition when resuming

why:
  Some pathological case might apply if the syncer is stopped while the
  distance between finalised block and head is very large and the FCU
  base becomes larger than the locked finalised state.

* Verify that finalised number from CL is at least FCU base number

why:
  The FCU base number is determined by the database, non zero if
  manually imported. The finalised number is passed via RPC by the CL
  node and will increase over time. Unless fully synced, this number
  will be pretty low.

  On the other hand, the FCU call `forkChoice()` will eventually fail
  if the `finalizedHash` argument refers to something outside the
  internal chain starting at the FCU base block.

* Remove support for completing interrupted sync without RPC support

why:
  Simplifies start/stop logic

* Rmove unused import
2024-10-28 16:22:04 +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
Jacek Sieka 188d689d9d
Speed up initial MPT root computation after import (#2788)
When `nimbus import` runs, we end up with a database without MPT roots
leading to long startup times the first time one is needed.

Computing the state root is slow because the on-disk order based on
VertexID sorting does not match the trie traversal order and therefore
makes lookups inefficent.

Here we introduce a helper that speeds up this computation by traversing
the trie in on-disk order and computing the trie hashes bottom up
instead - even though this leads to some redundant reads of nodes that
we cannot yet compute, it's still a net win as leaves and "bottom"
branches make up the majority of the database.

This PR also addresses a few other sources of inefficiency largely due
to the separation of AriKey and AriVtx into their own column families.

Each column family is its own LSM tree that produces hundreds of SST
filtes - with a limit of 512 open files, rocksdb must keep closing and
opening files which leads to expensive metadata reads during random
access.

When rocksdb makes a lookup, it has to read several layers of files for
each lookup. Ribbon filters to skip over files that don't have the
requested data but when these filters are not in memory, reading them is
slow - this happens in two cases: when opening a file and when the
filter has been evicted from the LRU cache. Addressing the open file
limit solves one source of inefficiency, but we must also increase the
block cache size to deal with this problem.

* rocksdb.max_open_files increased to 2048
* per-file size limits increased so that fewer files are created
* WAL size increased to avoid partial flushes which lead to small files
* rocksdb block cache increased

All these increases of course lead to increased memory usage, but at
least performance is acceptable - in the future, we'll need to explore
options such as joining AriVtx and AriKey and/or reducing the row count
(by grouping branch layers under a single vertexid).

With this PR, the mainnet state root can be computed in ~8 hours (down
from 2-3 days) - not great, but still better.

Further, we write all keys to the database, also those that are less
than 32 bytes - because the mpt path is part of the input, it is very
rare that we actually hit a key like this (about 200k such entries on
mainnet), so the code complexity is not worth the benefit really, in the
current database layout / design.
2024-10-27 11:08:37 +00:00
andri lim 738cb277cf
Fixes related to executionRequests of Pectra (#2787) 2024-10-26 11:10:54 +00:00
Jacek Sieka 6b2d341ebb
simplify genesis generation code (#2786)
* remove redundant abstraction
* fix misleading raises - the implementation actually swallows errors or
panics (depending on how many other layers of abstraction we penetrate
before detecting it)
2024-10-26 16:26:38 +07:00
andri lim cee4368075
Unify tx validation (#2777) 2024-10-26 09:19:48 +02:00
Jacek Sieka a1c34efed7
Update networking defaults (#2783)
* prefer IPv6 dual stack address, if available
* use `8551` as default engine api port
2024-10-26 09:18:02 +02:00
tersec d53989cc2c
fix some XDeclaredButNotUsed hints (#2784) 2024-10-26 05:10:06 +00:00
andri lim 0d4de335df
Fix keystore loader bug (#2774) 2024-10-24 04:07:06 +00:00
Jacek Sieka fc5ea1c236
avoid loading full block for logs (#2772)
the block body is not needed until a match and parts of the block body
are not needed at all.
2024-10-23 22:02:20 +00:00
andri lim 2c612d4357
Bump nim-web3, nim-serialization: no more derefType (#2771) 2024-10-23 21:40:48 +07:00
Jacek Sieka 5fc4c13ab1
Increase JSON-RPC limits, bump json-rpc (#2759)
* blocks can be bigger than the default 1mb when json-rpc-encoded - this
happens on sepolia for example
* json-rpc bump improves debug logging and fixes a number of bugs
* json-serialization bump fixes a crash on invalid arrays in json data

At some point, it would probably be better to compute the maximum block
size from actual block constraints, though this is somewhat tricky and
depends on gas limits etc. Until then, 16mb should be plenty.

With this, sepolia can be synced :)
2024-10-23 10:26:56 +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
Jordan Hrycaj 070f117d3c
Suppress beacon sync unless potential actions (#2765)
* Update comments & logs

* Do not start beacon sync unless there is possibly something to do

why:
  It would continue polling without having any effect other than
  logging. Now it will not start unless there is RPC available
  or there was a previously interrupted sync to be resumed.
2024-10-21 18:01:45 +00:00
Jacek Sieka 693ad315b3
Simplify verified proxy (#2754)
Reuse helpers from nimbus/web3/eth to simplify verifying proxy
implementation.
2024-10-21 03:10:41 +00:00
Jacek Sieka 503dcd40c4
aristo: remove `replicate` (#2758)
Not used, not tested, mostly obsolete due to how key table has become a
cache
2024-10-20 17:25:12 +02:00
Chirag Parmar 2b705bb363
revert proc/func changes from 2704 (#2757) 2024-10-19 15:51:31 +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
andri lim 0d4a5e87d2
engine_newPayloadV4 accepts ExecutionPayloadV3 (#2749) 2024-10-18 16:35:56 +07:00
Jordan Hrycaj 0b93236d1b
Beacon sync block import via forked chain (#2747)
* Accept finalised hash from RPC with the canon header as well

* Reorg internal sync descriptor(s)

details:
  Update target from RPC to provide the `consensus header` as well as
  the `finalised` block number

why:
  Prepare for using `importBlock()` instead of `persistBlocks()`

* Cosmetic updates

details:
+ Collect all pretty printers in `helpers.nim`
+ Remove unused return codes from function prototype

* Use `importBlock()` + `forkChoice()` rather than `persistBlocks()`

* Update logging and metrics

* Update docu
2024-10-17 17:59:50 +00: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
Pedro Miranda bc0f1ba904
Rename nimbus binary to nimbus_execution_client (#2728)
* rename nimbus binary to nimbus_execution_client

* additional replacements

* makefile and dockerfile

* fix ci building errors

* github workflows

* improved Makefile target

---------

Co-authored-by: Pedro Miranda <pedro.miranda@nimbus.team>
2024-10-15 09:37:54 +00:00
tersec 266b72698d
rm obsolete MergeTracker (#2725) 2024-10-10 20:25:12 +07:00
Jordan Hrycaj f937f57838
Beacon sync targets cons head rather than finalised block (#2721)
* Fix fringe condition clarifying how to handle an empty range

why:
  The `interval_set` module would treat an undefined interval construct
  `[2,1]` as`[2,2]` (the right bound being `max(2,1)`.)

* Use the `consensus head` rather than the `finalised` block as sync target

why:
  The former is ahead of the `finalised` block.

* In ctx descriptor rename `final` field to `target`

* Update docu, rename `F` -> `T`
2024-10-09 18:00:00 +00:00
Jacek Sieka 11646ad3c4
Ordered trie (#2712)
Speed up trie computations and remove redundant ways of performing this
operation.

Co-authored-by: jangko <jangko128@gmail.com>
2024-10-09 09:44:15 +02: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
Advaita Saha 6565544d35
add rpc `eth_estimateGas` - dependency for blob spammer (#2701)
* add eth_estimateGas, dependency for blob spammer

* remove restriction

* fix indentation
2024-10-06 09:39:47 +07: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
Jordan Hrycaj 9b666860db
Beacon sync: Fix race condition with peer fifo overflow (#2699)
why:
  Must not call `runStop()` twice rather rely on the worker to honour
  to `zombie` flag (no harm if it does not.)
2024-10-04 20:23:30 +00: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
Advaita Saha 3519b4a38c
fix: show correct blockNumber and log in end of era files (#2691) 2024-10-04 01:37:50 +00:00
Jordan Hrycaj d6eb8c36f5
Beacon sync align internal names and docu update (#2690)
* Rename `base` -> `coupler`, `B` -> `C`

why:
  Glossary: The jargon `base` is used for the `base state` block number
  which can be smaller than what is now the `coupler`.

* Rename `global state` -> `base`, `T` -> `B`

why:
  See glossary

* Rename `final` -> `end`, `F` -> `E`

why:
  See glossary. Previously, `final` denoted some finalised block but not
  `the finalised` block from the glossary (which is maximal.)

* Properly name finalised block as such, rename `Z` -> `F`

why:
  See glossary

* Rename `least` -> `dangling`, `L` -> `D`

* Metrics update (variables not covered yet)

* Docu update and corrections

* Logger updates

* Remove obsolete `skeleton*Key` kvt columns from `storage_types` module
2024-10-03 20:19:11 +00:00
Jacek Sieka ce331b4de8
post-merge nrpc fix (#2685)
* post-merge nrpc fix

* bump

* bump

* bump

* bump

* bump

* bump

* bump

* bump

* bump

* bump

* bump
2024-10-03 11:42:24 +00:00
Jacek Sieka a03bb56bec
update web3 types to common eth (#2674) 2024-10-02 18:22:35 +02:00
Jordan Hrycaj 05483d89bd
Rename flare as beacon (#2680)
* Remove `--sync-mode` option from nimbus config

why:
  Currently there is only one sync mode available.

* Rename `flare` -> `beacon`, but not base module folder and nim source

why:
  The name `flare` was used do designate an alternative `beacon` mode that.

  Leaving the base folder and source as-is for a moment, makes it easier
  to read change diffs.

* Rename `flare` base module folder and nim source: `flare` -> `beacon`
2024-10-02 11:31:33 +00:00
tersec 216604d0d6
add eth_sendRawTransaction to server API (#2678) 2024-10-02 03:56:39 +00:00
Jordan Hrycaj 5b6ccddaa0
Db folder sources and related remove compiler warnings (#2673)
* Aristo: Rename `Hash256` -> `Hash32`

* CoreDb: Rename `Hash256` -> `Hash32`

* Ledger: Rename `Hash256` -> `Hash32`

* StorageTypes: Rename `Hash256` -> `Hash32`

* Aristo: Rename `Blob` -> `seq[byte]`, `keccakHash` -> `keccak256`

* Kvt: Rename `Blob` -> `seq[byte]`

* CoreDb: Rename `Blob` -> `seq[byte]`, `keccakHash` -> `keccak256`

* Ledger: Rename `Blob` -> `seq[byte]`, `keccakHash` -> `keccak256`

* CoreDb: Rename `BlockHeader` -> `Header`, `BlockNonce` -> `Bytes8`

* Misc: Rename `StorageKey` -> `Bytes32`

* Tracer: `Hash256` -> `Hash32`, `BlockHeader` -> `Header`, etc.

* Fix copyright header
2024-10-01 21:03:10 +00:00
Jacek Sieka 219b22b1f5
Versioned hash32 (#2672) 2024-10-01 19:40:37 +02:00
Jordan Hrycaj c022b29d14
Clean up modules in sync folder (#2670)
* Dissolve legacy `sync/types.nim` into `*/eth/eth_types.nim`

* Flare sync: Simplify scheduler and remove `runSingle()` method

why:
  `runSingle()` is not used anymore (main purpose was for negotiating
  best headers in legacy full sync.)

  Also, `runMulti()` was renamed `runPeer()`

* Flare sync: Move `chain` field from `sync_desc` -> `worker_desc`

* Flare sync: Remove handler descriptor lateral reference

why:
  Not used anymore. It enabled to turn on/off eth handler activity with
  regards to the sync state, i.e.from with in the sync worker.

* Flare sync: Update `Hash256` and other deprecated `std/eth` symbols

* Protocols: Update `Hash256` and other deprecated `std/eth` symbols

* Eth handler: Update `Hash256` and other deprecated `std/eth` symbols

* Update flare TODO

* Remove redundant `sync/type` import

why:
  The import module `type` has been removed

* Remove duplicate implementation
2024-10-01 09:19:29 +00:00
Advaita Saha e8542f951f
External syncer (#2574)
* inital external sync structure

* add to makefile

* feat: external syncer with healing process

* fix: suggestions

* network mapping

* minor changes

* forward sync

* jwt auth

* nrpc structure

* nrpc engine-api loader

* fix: suggestions

* fix: suggestions

* remove sync_db

* fix: edge cases and forks

* fix: rebase changes

* revert nimbus config changes
2024-09-29 18:48:11 +02:00
Jacek Sieka c210885b73
eth: bump to new types (#2660)
This is a minimal set of changes to make things work with the new types
in nim-eth - this is the minimal PR that merely resolves
incompatibilities while the full change set would include more cleanup
and migration.
2024-09-29 14:37:09 +02:00
andri lim 5f1b945ebe
Remove beacon sync (#2666) 2024-09-29 02:13:50 +00:00
Jordan Hrycaj debb68b3a7
Flare sync: Remove `debug` modules (#2665)
why:
  Not needed anymore but deletion kept in a separate PR to make it easy
  to refer back and find these modules.
2024-09-27 16:59:16 +00:00
Jordan Hrycaj 0d2a72d2a9
Flare sync (#2627)
* Cosmetics, small fixes, add stashed headers verifier

* Remove direct `Era1` support

why:
  Era1 is indirectly supported by using the import tool before syncing.

* Clarify database persistent save function.

why:
  Function relied on the last saved state block number which was wrong.
  It now relies on the tx-level. If it is 0, then data are saved directly.
  Otherwise the task that owns the tx will do it.

* Extracted configuration constants into separate file

* Enable single peer mode for debugging

* Fix peer losing issue in multi-mode

details:
  Running concurrent download peers was previously programmed as running
  a batch downloading and storing ~8k headers and then leaving the `async`
  function to be restarted by a scheduler.

  This was unfortunate because of occasionally occurring long waiting
  times for restart.

  While the time gap until restarting were typically observed a few
  millisecs, there were always a few outliers which well exceed several
  seconds. This seemed to let remote peers run into timeouts.

* Prefix function names `unprocXxx()` and `stagedYyy()` by `headers`

why:
  There will be other `unproc` and `staged` modules.

* Remove cruft, update logging

* Fix accounting issue

details:
  When staging after fetching headers from the network, there was an off
  by 1 error occurring when the result was by one smaller than requested.
  Also, a whole range was mis-accounted when a peer was terminating
  connection immediately after responding.

* Fix slow/error header accounting when fetching

why:
  Originally set for detecting slow headers in a row, the counter
  was wrongly extended to general errors.

* Ban peers for a while that respond with too few headers continuously

why:
  Some peers only returned one header at a time. If these peers sit on a
  farm, they might collectively slow down the download process.

* Update RPC beacon header updater

why:
  Old function hook has slightly changed its meaning since it was used
  for snap sync. Also, the old hook is used by other functions already.

* Limit number of peers or set to single peer mode

details:
  Merge several concepts, single peer mode being one of it.

* Some code clean up, fixings for removing of compiler warnings

* De-noise header fetch related sources

why:
  Header download looks relatively stable, so general debugging is not
  needed, anymore. This is the equivalent of removing the scaffold from
  the part of the building where work has completed.

* More clean up and code prettification for headers stuff

* Implement body fetch and block import

details:
  Available headers are used stage blocks by combining existing headers
  with newly fetched blocks. Then these blocks are imported/executed via
  `persistBlocks()`.

* Logger cosmetics and cleanup

* Remove staged block queue debugging

details:
  Feature still available, just not executed anymore

* Docu, logging update

* Update/simplify `runDaemon()`

* Re-calibrate block body requests and soft config for import blocks batch

why:
* For fetching, larger fetch requests are mostly truncated anyway on
  MainNet.
* For executing, smaller batch sizes reduce the memory needed for the
  price of longer execution times.

* Update metrics counters

* Docu update

* Some fixes, formatting updates, etc.

* Update `borrowed` type: uint -. uint64

also:
  Always convert to `uint64` rather than `uint` where appropriate
2024-09-27 15:07:42 +00:00
andri lim db8b68a28c
ForkedChainRef.forkchoice: Skip newBase calculation and skip chain finalization if finalizedHash is zero (#2654)
* ForkedChainRef.forkchoice: Skip newBase calculation and skip chain finalization if finalizedHash is zero

* Fix ForkedChainRef.forkChoice: do nothing if headHash is the same with cursorHash

* Fix stupid bug in engine API FCU when calling ForkedChainRef.forkChoice

* Wire RPC server API to nimbus RPC manager

* Add test case

* Use default(Hash256) in ForkedChainRef
2024-09-27 07:53:27 +07:00
Jacek Sieka f3e3c6bbe0
init style for Hash256 (#2661)
* init style for Hash256

https://github.com/status-im/nim-eth/pull/733 updates `Hash256` to
become an array instead of an object - unfortunately, nim does not allow
constructing arrays with `name()`, so this PR changes it to `default`
which works with both.

* lint
2024-09-26 13:24:36 +02:00
Jacek Sieka 513f11f911
bumps (#2652)
eth/stew/unittest2 in preparation for eth refactoring
2024-09-24 13:19:09 +02:00
andri lim 38d651c9c8
FCU should consider ForkedChainRef when calculating valid ancestor (#2651) 2024-09-24 10:53:18 +00:00
Advaita Saha 379592e711
Fix import stuck with era history behind (#2629)
* fix: nimbus state ahead of era history

* comments

* fix: suggestions

* fix: messages

* fix edge case resume

* check from last file

* formatting

* fix: typo

* fix: unwanted quit before rlp import
2024-09-21 08:38:38 +02:00
Jacek Sieka 7a15aa2a3a
clean up vertex delete (#2644)
avoid allocating and updating the trie twice when the branch is fully
removed
2024-09-20 10:31:29 +02:00
Jacek Sieka b4b4d16729
speed up key computation (#2642)
* batch database key writes during `computeKey` calls
* log progress when there are many keys to update
* avoid evicting the vertex cache when traversing the trie for key
computation purposes
* avoid storing trivial leaf hashes that directly can be loaded from the
vertex
2024-09-20 07:43:53 +02:00
Jacek Sieka 2fe8cc4551
leaf cache fixes (#2637)
* Add missing leaf cache update when a leaf turns to a branch with two
leaves (on merge) and vice versa (on delete) - this could lead to stale
leaves being returned from the cache causing validation failures - it
didn't happen because the leaf caches were not being used efficiently :)
* Replace `seq` with `ArrayBuf` in `Hike` allowing it to become
allocation-free - this PR also works around an inefficiency in nim in
returning large types via a `var` parameter
* Use the leaf cache instead of `getVtxRc` to fetch recent leaves - this
makes the vertex cache more efficient at caching branches because fewer
leaf requests pass through it.
2024-09-19 10:39:06 +02:00
tersec 3fb2e080ea
rm exp_ RPC API infrastructure; had no actual RPC endpoints (#2635)
* rm exp_ RPC API infrastructure; had no actual RPC endpoints

* update command-line flag descriptions
2024-09-18 08:53:26 +00:00
tersec 6bf4cd55b9
rm some commented-out/stub/obsolete RPC endpoints (#2630) 2024-09-16 19:33:20 +00:00
Jacek Sieka 5cd0297462
fix missed cache opportunity (#2628)
The storage leaf cache was being circumvented when actually fetching
leaves and was instead only being filled with items :/

Also avoids an expensive copy when fetching account data (broadly,
variant objects are comparatively expensive to copy and fetching
accounts is a hotspot)
2024-09-14 09:47:32 +02:00
Jacek Sieka adb8d64377
simplify VertexRef (#2626)
* move pfx out of variant which avoids pointless field type panic checks
and copies on access
* make `VertexRef` a non-inheritable object which reduces its memory
footprint and simplifies its use - it's also unclear from a semantic
point of view why inheritance makes sense for storing keys
2024-09-13 18:55:17 +02:00
andri lim 0be6291fba
Bump nim-eth and nim-web3 (#2625) 2024-09-13 15:48:27 +02:00
Jacek Sieka 5c1e2e7d3b
Migrate `keyed_queue` to `minilru` (#2608)
Compared to `keyed_queue`, `minilru` uses significantly less memory, in
particular for the 32-byte hash keys where `kq` stores several copies of
the key redundantly.
2024-09-13 15:47:50 +02:00
tersec aaefac0795
key eth_syncing off correct indication, not peer count (#2619) 2024-09-12 16:42:38 +00:00
andri lim 178d77ab31
Implement EIP-7002 and EIP-7251 (#2616) 2024-09-12 16:09:46 +07:00
andri lim 6503d51b44
Implement EIP-6110: Execution layer triggered deposits (#2612)
* Implement EIP-6110: Execution layer triggered deposits

* Implement EIP-6110 of t8n tool

* Avoid unnecessary DepositRequestType check

* Avoid using 'result' in t8n helpers

* Fix logs collection and deposits validation
2024-09-12 16:09:46 +07:00