4389 Commits

Author SHA1 Message Date
kdeme
c0e329d768
Add log message on content query failure in lookup + refactor (#3079)
* Add log message on content query failure in lookup

* Refactor response handling Portal wire
2025-02-16 20:08:28 +01:00
andri lim
c300b41c07
Add engine_getBlobsV1 implementation (#3071)
* Add engine_getBlobsV1 implementation

* Addressing review
2025-02-15 12:18:07 +00:00
Jacek Sieka
45ec6e7050
Use unittest2 test runner (#3073)
* Use unittest2 test runner

Since upgrading to unittest2, the test runner prints the command line to
re-run a failed test - this however relies on actually using the
unittest2 command line runner.

Previously, test files were assigned numbers - with the unittest2
runner, tests are run using suite/category names instead, like so:

```
# run the Genesis suite
build/all_tests "Genesis::``
# run all tests with "blsMapG1" in the name
build/all_tests "blsMapG1*"
# run tests verbosely
build/all_tests -v
```

A reasonable follow-up here would be to review the suite names to make
them easier to run :)

* lint

* easier-to-compare test order

* bump unittest2 (also the repo)
2025-02-15 14:08:50 +07:00
kdeme
40722cdec9
Bump nim-eth submodule (#3075) 2025-02-14 21:37:59 +00:00
kdeme
fc4969d2ee
Bump nimbus-eth2 and required nim-kzg4884 (#3074) 2025-02-14 22:00:16 +01:00
Jacek Sieka
b6584153ff
add custom hash for RootedVertexID (#3070)
* add custom `hash` for `RootedVertexID`

There's no benefit hashing `root` since `vid` is already unique and the
"default" hash is not free - this trivially brings a small perf boost to
one of the key lookup tables in aristo_layers.

* lint
2025-02-14 14:50:46 +00:00
Jordan Hrycaj
e666eb52b0
Fix fringe case where the final checkpoint() must not be applied (#3072)
* Fix fringe case where the final `checkpoint()` must not be applied

why
  If there are no `era` or `era1` files that can be imported from,
  then the internal state will not be in sync with the DB state. This
  would lead to overwriting the saved state block number with something
  fancy. As a consequence the database becomes unusable for the next
  process which will eventually fail with a state root mismatch.

* Update comment
2025-02-14 12:51:56 +00:00
Jacek Sieka
42bb640443
Simplify shared rocksdb instance / write batch handling (#3063)
By introducing the "shared rocksdb instance" concept to the backend, we
can remove the "piggybacking" mode , thus reducing the complexity of
database initialisation and opening the possibility of extending how
write batching works across kvt/aristo.

The change makes explicit the hidden shared state that was previously
hiding in closures and provides the first step towards simplifying the
"commit/persist" interface of coredb, preparing it for optimizations to
reduce the "layering tax" that `forked-layers` introduced.
2025-02-14 09:40:22 +01:00
andri lim
bd65a019c7
Bump nim-web3 to e9640d65eca5618291438bf6e98f6ea21f4c1d03 (#3069) 2025-02-14 13:59:39 +07:00
andri lim
c08e83a9a5
Add Prague fork timestamp for Holesky and Sepolia (#3068) 2025-02-14 01:47:20 +00:00
tersec
b417dd1986
rm engine_exchangeTransitionConfigurationV1 support (#3067) 2025-02-14 08:10:47 +07:00
bhartnett
f513e1dc53
Update Nimbus EVM code to use the latest nim-evmc which supports EVMC v12.1.0 (#3065)
* Update Nimbus EVM code to use the latest nim-evmc which is now on EVMC v12.1.0

* Fix copyright.

* Fix tests.

* Update to use FkLatest.

* Fix copyright and update test helper.
2025-02-14 08:06:54 +07:00
andri lim
67dbe817a9
Add Sepolia depositContractAddress (#3059) 2025-02-12 12:53:01 +07:00
pmmiranda
411a3cadfa
Renamed 'nimbus' directory and its references to 'execution_chain' (#3052)
* renamed nimbus folder to execution_chain

* Renamed "nimbus" references to "execution_chain"

* fixed wrongly changed http reference

* delete snap types file given that it was deleted before this PR merge

* missing 'execution_chain' replacement

---------

Co-authored-by: pmmiranda <pedro.miranda@nimbus.team>
2025-02-11 22:28:42 +00:00
Advaita Saha
02014b382d
Speedup eth_getLogs (#3062)
* fetch txHash from txRecord + reduce blockHash call

* minor fixes
2025-02-11 13:34:24 +00:00
Bhaskar Metiya
577e355949
Fix getPayloadBodiesByRangeV1 fetching too many payloads (#3057) 2025-02-11 04:17:21 +00:00
bhartnett
f033a40482
Build nimbus evmc shared library and fix issue to enable loading (#3050) 2025-02-10 10:53:31 +08:00
Jordan Hrycaj
67b8dd7fdc
Beacon sync bookkeeping update and bug fix (#3051)
* Update unprocessed blocks bookkeeping avoiding race condition

details:
  Instead of keeping track in `borrowed` of the sum of a set of blocks
  fetched from the `unprocessed` list, the particular ranges details are
  stored. When committing a particular range, the range itself (rather
  then its length) is removed from the `borrowed` data.

why:
  The function `blocksUnprocAmend()`) may produce a race condition, so it
  was re-implemented as `blocksUnprocAppend()` considering range overlaps
  with borrowed.

* Clean up/re-org `blocks_unproc` module

why:
  The `borrowed` data structure can be fully maintained with the
  `blocksUnprocXxx()` functions.

* Update/simplify unprocessed headers bookkeeping (similar as for blocks)

* Removing stashed headers right after successfully assembled blocks

why:
  Was previously deleted after importing blocks although it is not needed
  anymore after blocks have been assembled using bodies fetched over
  the ethXX network.

* Always curb the blocks to the initialised length

why:
  Some error exit directives missed some clean up leaving the blocks
  list with empty/stale block bodies.

* Enter reorg-mode right away after block import error

why:
  There is not much one can do. Typically, this type of error is due
  to a switch to a different canonical chain. When this happens, the
  block batch is expected to be relatively short as the cause for a
  chain switch is an RPC instruction. This in turn is effective if some
  of the blocks on the `FC` database are maintained by the `CL`.
2025-02-07 10:43:00 +00:00
tersec
daebbfa18d
rm more Snap sync code (#3047)
* rm more Snap sync code

* clean up snap1
2025-02-07 08:45:03 +07:00
Advaita Saha
796c2f7cbf
wire in the syncstate callback to rpc (#3049) 2025-02-06 12:06:13 +00:00
Jacek Sieka
2961905a95
aristo: fork support via layers/txframes (#2960)
* aristo: fork support via layers/txframes

This change reorganises how the database is accessed: instead holding a
"current frame" in the database object, a dag of frames is created based
on the "base frame" held in `AristoDbRef` and all database access
happens through this frame, which can be thought of as a consistent
point-in-time snapshot of the database based on a particular fork of the
chain.

In the code, "frame", "transaction" and "layer" is used to denote more
or less the same thing: a dag of stacked changes backed by the on-disk
database.

Although this is not a requirement, in practice each frame holds the
change set of a single block - as such, the frame and its ancestors
leading up to the on-disk state represents the state of the database
after that block has been applied.

"committing" means merging the changes to its parent frame so that the
difference between them is lost and only the cumulative changes remain -
this facility enables frames to be combined arbitrarily wherever they
are in the dag.

In particular, it becomes possible to consolidate a set of changes near
the base of the dag and commit those to disk without having to re-do the
in-memory frames built on top of them - this is useful for "flattening"
a set of changes during a base update and sending those to storage
without having to perform a block replay on top.

Looking at abstractions, a side effect of this change is that the KVT
and Aristo are brought closer together by considering them to be part of
the "same" atomic transaction set - the way the code gets organised,
applying a block and saving it to the kvt happens in the same "logical"
frame - therefore, discarding the frame discards both the aristo and kvt
changes at the same time - likewise, they are persisted to disk together
- this makes reasoning about the database somewhat easier but has the
downside of increased memory usage, something that perhaps will need
addressing in the future.

Because the code reasons more strictly about frames and the state of the
persisted database, it also makes it more visible where ForkedChain
should be used and where it is still missing - in particular, frames
represent a single branch of history while forkedchain manages multiple
parallel forks - user-facing services such as the RPC should use the
latter, ie until it has been finalized, a getBlock request should
consider all forks and not just the blocks in the canonical head branch.

Another advantage of this approach is that `AristoDbRef` conceptually
becomes more simple - removing its tracking of the "current" transaction
stack simplifies reasoning about what can go wrong since this state now
has to be passed around in the form of `AristoTxRef` - as such, many of
the tests and facilities in the code that were dealing with "stack
inconsistency" are now structurally prevented from happening. The test
suite will need significant refactoring after this change.

Once this change has been merged, there are several follow-ups to do:

* there's no mechanism for keeping frames up to date as they get
committed or rolled back - TODO
* naming is confused - many names for the same thing for legacy reason
* forkedchain support is still missing in lots of code
* clean up redundant logic based on previous designs - in particular the
debug and introspection code no longer makes sense
* the way change sets are stored will probably need revisiting - because
it's a stack of changes where each frame must be interrogated to find an
on-disk value, with a base distance of 128 we'll at minimum have to
perform 128 frame lookups for *every* database interaction - regardless,
the "dag-like" nature will stay
* dispose and commit are poorly defined and perhaps redundant - in
theory, one could simply let the GC collect abandoned frames etc, though
it's likely an explicit mechanism will remain useful, so they stay for
now

More about the changes:

* `AristoDbRef` gains a `txRef` field (todo: rename) that "more or less"
corresponds to the old `balancer` field
* `AristoDbRef.stack` is gone - instead, there's a chain of
`AristoTxRef` objects that hold their respective "layer" which has the
actual changes
* No more reasoning about "top" and "stack" - instead, each
`AristoTxRef` can be a "head" that "more or less" corresponds to the old
single-history `top` notion and its stack
* `level` still represents "distance to base" - it's computed from the
parent chain instead of being stored
* one has to be careful not to use frames where forkedchain was intended
- layers are only for a single branch of history!

* fix layer vtop after rollback

* engine fix

* Fix test_txpool

* Fix test_rpc

* Fix copyright year

* fix simulator

* Fix copyright year

* Fix copyright year

* Fix tracer

* Fix infinite recursion bug

* Remove aristo and kvt empty files

* Fic copyright year

* Fix fc chain_kvt

* ForkedChain refactoring

* Fix merge master conflict

* Fix copyright year

* Reparent txFrame

* Fix test

* Fix txFrame reparent again

* Cleanup and fix test

* UpdateBase bugfix and fix test

* Fixe newPayload bug discovered by hive

* Fix engine api fcu

* Clean up call template, chain_kvt, andn txguid

* Fix copyright year

* work around base block loading issue

* Add test

* Fix updateHead bug

* Fix updateBase bug

* Change func commitBase to proc commitBase

* Touch up and fix debug mode crash

---------

Co-authored-by: jangko <jangko128@gmail.com>
2025-02-06 14:04:50 +07:00
Advaita Saha
7ebede9e1e
devnet-6 fix bls_12_381 (#3048)
* fix mathematical misconceptions

* fix lint

* change proc to func
2025-02-05 22:53:28 +00:00
andri lim
db0a971416
devnet-6: Update EIP-7702 outdated implementation (#3046)
f27ddf2b0a/EIPS/eip-7702.md (behavior)
2025-02-04 15:05:35 +00:00
andri lim
825cc4c242
Fix tools helper and allow GST to parse new eest devnet-6 test vectors (#3045)
* Fix tools helper

* Allow GST to parse new eest devnet-6 test vectors
2025-02-04 17:06:34 +07:00
andri lim
d4266dc186
devnet-6: Update EIP-2935, 7002, 7251: Final system contract address (#3044)
- https://github.com/ethereum/EIPs/pull/9287
- https://github.com/ethereum/EIPs/pull/9288
- https://github.com/ethereum/EIPs/pull/9289
2025-02-03 16:33:36 +07:00
Jacek Sieka
838f8649c3
Bump RPC server buffer size (#3042)
* Bump RPC server buffer size

When large blocks arrive via RPC, we need to be able to read them from
the socket in reasonable time - at 4kb, we might need thousands of reads
before the JSON can be parsed - 256kb ensures that most blocks can be
read in a few loop iterations - the size doesn't greatly matter since we
only have one of these (unlike p2p connections)

* copyright
2025-01-30 21:03:00 +00:00
Jacek Sieka
5c0310a7b2
Avoid re-compacting historical data (#3041)
* Avoid re-compacting historical data

Per rocksdb docs, it will by default re-compact any data not touched for
30 days - this is obviously wasteful since our historical data rarely
changes and _hopefully_ can stay untouched once written (with a bit of
key sorting luck).

* copyright
2025-01-30 20:49:03 +01:00
Jacek Sieka
8690a03af7
Fix poor eth_getLogs performance (fixes #3033) (#3040)
* Fix poor eth_getLogs performance (fixes #3033)

* don't recompute txhash in inner log loop (!)
* filter logs before computing hashes

* copyright
2025-01-30 19:38:24 +00:00
bhartnett
e03a9c3172
Update nim-rocksdb to v9.10.0.0 (#3035) 2025-01-30 19:34:27 +01:00
Jordan Hrycaj
bc0620f6ca
Provide global sync progress, supersedes activation indicator (#3039) 2025-01-29 16:20:25 +00:00
pmmiranda
3e1f5e0b5f
Improved logging (#3001)
* Improved logging using nimbus-eth2 options

- log file support removal
- auto detection of tty, colour support and related.

* Added EthTime serializer (implemented on eth_types_json_serialization)

* added json chronicles logging support
 for some eth, web3 and confutils types

---------

Co-authored-by: Pedro Miranda <pedro.miranda@nimbus.team>
2025-01-29 15:04:27 +00:00
Jordan Hrycaj
b9e1c94b99
Beacon sync provide activation status globally (#3038)
* Cosmetics, rename some functions, add/update comments

* Provide globally accessible syncer status query function
2025-01-29 12:31:06 +00:00
Jordan Hrycaj
8bc8094413
Beacon sync fix stalling while block processing (#3037)
* Correct docu

why:
  `T` is mentioned on the metrics table but not explained

* Update state sync ticker

why:
  Print last named state for debugging unexpected states.

* Rename `nec_consensus_head`=> `nec_sync_consensus_head`

why:
  This variable is syncer local, derived from what would be vaguely be
  the consensus head. In fact, at some point it is the consensus head
  but often will keep that value while the consensus head advances.

* Handle legit system state when block processing is cancelled

why:
  This state context was previously missing. It happens with problematic
  blocks (i.e. corrupt or missing.) Rather than trying to remedy the batch
  queue, all will be cancelled and the batch queue rebuilt from scratch.

* Update block queue with unexpectedly missing blocks

why:
  Concurrently serving `RPC` requests might cause a reset of the `FC`
  module data area. This in turn might produce a gap between expected `FC`
  module top and the beginning of the already downloaded blocks list.

  Currently this led to a deadlock situation because the missing blocks
  were never downloaded by the syncer, neither installed into `FC` module
  via `RFC`.

* Fix copyright year
2025-01-29 11:30:40 +00:00
kdeme
cdd71cac2e
Portal: Remove pruneDeprecatedAccumulatorRecords (#3031)
This was added to cleanup database from a content type that was
removed.

After ping extensions upgrade all active nodes must have been
updated to remain compatible and thus must have ran this pruning
code.
2025-01-29 10:20:29 +01:00
andri lim
13961fbae6
Bump nim-eth to 254be32672d0ffbddd110e21ecb55c32f9e90b02 (#3030)
* Bump nim-eth to 254be32672d0ffbddd110e21ecb55c32f9e90b02

* Bump nim-eth to e589cc0288b139509a19f3a27cd0cf0368ca0834
2025-01-29 13:53:47 +07:00
bhartnett
1b78aea40d
Bump nim-rocksdb (#3034) 2025-01-29 11:46:11 +08:00
andri lim
de80eb4214
Bump nim-stew to 687d1b4ab1a91e6cc9c92e4fd4d98bec7874c259 (#3032) 2025-01-29 08:48:03 +07:00
bhartnett
f78f82e8c9
Fluffy: Randomize gossip in neighborhoodGossip (#3029) 2025-01-29 08:49:37 +08:00
kdeme
28f9b792d9
Minimal implementation of Portal ping payload extensions spec (#3010)
* Minimal implementation of Portal ping payload extensions spec

* Remove serialization layer for CustomPayload (spec change)
2025-01-27 19:26:23 +01:00
andri lim
c4bc2a4eea
devnet-6: Update EIP-7840: Add BaseFeeUpdateFraction (#3022)
* devnet-6: Update EIP-7840: Add BaseFeeUpdateFraction

* Fix missing baseFeeUpdateFraction fallback

* Fix and add test
2025-01-27 16:20:39 +00:00
Advaita Saha
c16fc30358
Fix engine api misconceptions (#3025)
* fix shanghai misconception

* incorporate spec changes

* shanghai only check

* ForkchoiceUpdatedV2 after Cancun with beacon root field must return INVALID_PAYLOAD_ATTRIBUTES

* better exception positioning

* beter error msg
2025-01-27 19:07:03 +05:30
kdeme
c24335ce29
Bump nph formatter in CI to v0.6.1 (#3024) 2025-01-27 13:07:34 +01:00
kdeme
de80acdf79
Bump portal-spec-test (test-vectors) to latest (#3023) 2025-01-27 10:54:44 +00:00
andri lim
c11f20f8b0
devnet-6: Update EIP-7702: update EXTCODE* opcodes to act on full 'delegation designator' (#3021) 2025-01-25 14:32:39 +00:00
tersec
49523c5d8f
rm unused pre-1559 gas limit update calculation (#3011)
* rm unused pre-1559 gas limit update calculation

* wiki links 404
2025-01-25 17:36:43 +07:00
Advaita Saha
8372736600
custom genesis config fallback case for blobs (#3020)
* clear re-org misconception

* fcuV3 allow shanghai head

* add fallback blobcount for custom network

* fix tests
2025-01-24 22:49:11 +00:00
kdeme
b917be54ab
Fix wrong Result error usage in eth_data_exporter (#3018) 2025-01-24 08:36:28 +01:00
kdeme
9a5fd34dac
Portal history: Add ephemeral content type (#3017)
This does not yet enable the offer/accept and storage of the
ephemeral headers as it requires database changes.
Follow-up PR for that functionality.
2025-01-23 21:45:51 +01:00
Advaita Saha
f973b86dd8
nrpc re-org handling (#2994)
* reorg handling

* formatting fix

* fix validation condition

* eip-7685 compatible

* more exception handling

* remove strict checking
2025-01-23 01:51:44 +01:00
Jordan Hrycaj
184af027dc
Beacon sync metrics managemnt update (#3016)
* Sync scheduler provides an independent `ticker` loop process

why:
  Can be used to update `metrics` and for debug logging. While an event
  driven solution would stall if there are no events at the moment (e.g.
  when the syncer hibernates, the `ticker` will run regardless.

* Use `runTicker()` loop interface alike for updating ticker

why:
  Not event driven anymore so it will not stall when the syncer
  hibernates.

* Re-implement logging ticker by running it within the `runTicker()` driver

why:
  Simplifies implementation

* Re-name metrics variable to better fit into the current naming schemes

* Fix copyright header
2025-01-22 10:12:50 +00:00