4374 Commits

Author SHA1 Message Date
Advaita Saha
d09458ec56
prelim single point integration 2025-02-08 21:50:03 +05:30
Advaita Saha
8f7c2c8fc3
initial structuring of portal integration 2025-02-08 21:50:03 +05:30
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
kdeme
4b893eb88e
Discard received data on uTP content stream timeout (#3014)
Discard the received data on uTP content stream read timeout.
Before the data was still added to the queue and being processed
and should normally fail in validation. However as we know not all
data got read it should not even move to the validation step.

Added however a FIN send after the timeout instead of the delayed
socket clean-up which does not make much sense in that scenario
either. Basically either be nice and still send a FIN or just
destroy the socket immediatly.
2025-01-21 17:44:02 +01:00
andri lim
c62024ea24
devnet-5: Add EIP-7623: Increase calldata cost (#3015)
* devnet5: Add EIP-7623: Increase calldata cost

* Fix copyright year
2025-01-21 11:26:23 +00:00
kdeme
234487a8cb
Portal JSON-RPC: add eth_blockNumber and fix eth_getBlockByNumber (#3013)
- add eth_blockNumber
- fix eth_getBlockByNumber: latest vs safe fix.
2025-01-21 09:44:13 +01:00
bhartnett
285b6de4bc
Fluffy: Cleanup unused code from PortalProtocol (#3006) 2025-01-20 20:57:18 +08:00
Jordan Hrycaj
3aae33d6cc
Beacon sync maintenance update (#3012)
* Force metrics update when peers vanish

why:
  After that there might be reduced activity so that the next metrics
  update is delayed.

* Update comments (code cosmetics)

* Tidy up nano-sleep wait directives to an `update.nim`-function

* Fix copyright year
2025-01-20 10:30:04 +00:00
bhartnett
5b74335977
Update nim-rocksdb to v9.8.4.0 (#2997) 2025-01-17 18:23:24 +01:00
Advaita Saha
bf57c8e0e4
fix copyright lint failure (#3008) 2025-01-17 16:29:26 +05:30
kdeme
fa147f90ed
Portal JSON-RPC: minor clean-up (#3000)
Minor cleanup/refactor + add a basic TraceObject when returning
locally found content.
2025-01-17 11:57:15 +01:00
andri lim
aa85d6a61c
Only hashing immutable part of network configuration for dataDir ID (#2955)
* Only hashing immutable part of network configuration for dataDir ID

* Add debug- prefix to rewrite-datadir-id
2025-01-17 15:33:15 +05:30
andri lim
ac053bf4c8
devnet-5: Add EIP-7840: Add blob schedule to EL config files (#3005)
* devnet-5: Add EIP-7840: Add blob schedule to EL config files

* Fix test_transaction_json

* Add missing blobSchedule to common/helpers
2025-01-16 05:10:52 +00:00
bhartnett
19ea82bf50
Fluffy: State bridge clean shutdown (#2996)
* Implement clean shutdown for state bridge.

* Handle shutdown in history and beacon bridges.
2025-01-16 08:48:10 +08:00
andri lim
232a9ad247
devnet-5: Update EIP-7702: Remove delegation behavior of EXTCODE* (#2871) 2025-01-15 14:30:26 +00:00
andri lim
5c02b88f82
devnet-5: Update EIP-2935: bring up to date with sys contract impl (#3003)
* devnet-5: Update EIP-2935: bring up to date with sys contract impl

* Fix copyright year
2025-01-15 02:42:20 +00:00
andri lim
265d794583
devnet-5: Move EIP-7702 Authorization validation to authority func (#2999)
* Move EIP-7702 Authorization validation to authority func

If the authorization is invalid the transaction itself is still valid,
the invalid authorization will be skipped.

* Fix copyright year
2025-01-15 02:18:25 +00:00
andri lim
288ee28077
Integrate PoS payload attributes into txPool (#2998)
* Integrate PoS payload attributes into txPool

* Fix test_txpool
2025-01-14 13:30:56 +00:00