Commit Graph

4166 Commits

Author SHA1 Message Date
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
Kim De Mey 6307ea30aa
Update portal-spec-tests to latest revision (#2790) 2024-10-27 19:03:05 +01:00
Advaita Saha 814c2e1536
`external_sync` rename to `sync` (#2789)
* rename to sync

* improve logging and epoch only fcu call

* suggestions added

* static check
2024-10-27 13:23:32 +00: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
Kim De Mey 85d8ed7be1
Adjust ForkDigest dynamically in Portal beacon content tests (#2778)
Also iterates over multiple dirs now to run tests for each fork.
2024-10-27 08:34:50 +01: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 34e7e39cd4
migrate rest of GitHub macOS builder images to macos-13 (#2785) 2024-10-26 06:37:29 +00:00
tersec d53989cc2c
fix some XDeclaredButNotUsed hints (#2784) 2024-10-26 05:10:06 +00:00
bhartnett ca24dd915f
Fluffy: Make content request retries configurable (#2770)
* Make content request retries configurable and add to state network and history network.

* Set retries to 1. Use uint to prevent negative values. Make contentRequestRetries a debug parameter.
2024-10-25 15:15:01 +08:00
Kim De Mey 3d31911f1d
Portal beacon: Remove unneeded and confusing (fork specific) imports (#2776) 2024-10-24 20:31:17 +02: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 482de8e0a5
Bump nim-eth to 66297c5c0a8c22ec3f16c899e902d79aa00df575 (#2768) 2024-10-22 21:26:55 +07:00
andri lim 67088540cf
Fix leftover eth types changes warnings (#2766) 2024-10-22 13:42:16 +07:00
andri lim 993cbe64db
t8n parser: migrate from std/json to json-serialization (#2764) 2024-10-22 09:07:58 +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
Jacek Sieka 2decb618c8
fix Nim build on upgrade (#2760) 2024-10-20 17:24:49 +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
bhartnett 47337593c9
Fluffy: Enable content cache for history network (#2745)
* Cache content after lookups in history network.

* Cleanup config in PortalProtocol.

* Use local content lookup in history network to enable using cache.
2024-10-17 16:25:53 +08:00
bhartnett 54528fb24b
Fluffy: Enable content cache for state network (#2739)
* Enable content cache for state network.

* Update state json-rpc endpoints to return local content which uses cache if enabled.

* Add content cache metrics.

* Make content cache configurable.

* Add content cache tests.
2024-10-16 21:05:39 +08:00
Kim De Mey 4191f95527
Add Docker quickstart page for Fluffy + minor docs fixes (#2744) 2024-10-16 14:56:52 +02:00
Kim De Mey b885f822d0
More clean-up since eth types refactor (#2742) 2024-10-16 14:18:02 +02:00
Kim De Mey f797d55c35
Fix, improve and update some of the fluffy docs (#2743) 2024-10-16 13:48:34 +02: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
Kim De Mey 9c9a41a16d
More verbose error handling for Portal stream content reading (#2737) 2024-10-14 11:53:28 +02:00
bhartnett bdbea9853e
Rename Fluffy rpc methods to match updated spec (#2735) 2024-10-14 16:46:35 +08:00
Kim De Mey 3e36f52fd7
Rename the debug docker files + add a simpler/faster one for Linux (#2731)
Also update related documentation
2024-10-13 18:07:17 +02:00
tersec eec41bc0e8
test with aarch64 macOS (#2729) 2024-10-13 08:20:05 +07:00
Advaita Saha 1858d55748
shift kurtosis + assertor to stable release (#2733) 2024-10-13 08:19:33 +07:00
bhartnett 9db31ac17b
Fluffy: Fix state validation issue causing portal hive test failure (#2732) 2024-10-13 00:51:50 +08:00
Kim De Mey 6e114dc950
Fix JSON encoding for NodeId, no leading zeroes dropped (#2730)
Portal JSON-RPC API specifications dictate that the NodeId must be
the 32 byte identifier. We had leading zeroes being dropped in
our implementation.
2024-10-11 16:43:06 +02:00