240 Commits

Author SHA1 Message Date
tersec
daebbfa18d
rm more Snap sync code (#3047)
* rm more Snap sync code

* clean up snap1
2025-02-07 08:45:03 +07: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
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
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
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
7d3616e3d9
Refactor TxPool: leaner and simpler (#2973)
* Refactor TxPool: leaner and simpler
* Rewrite test_txpool

Reduce number of tables used, from 5 to 2. Reduce number of files.
If need to modify the price rule or other filters, now is far more easier because only one table to work with(sender/nonce).
And the other table is just a map from txHash to TxItemRef.

Removing transactions from txPool either because of producing new block or syncing became much easier.
Removing expired transactions also simple.
Explicit Tx Pending, Staged, or Packed status is removed. The status of the transactions can be inferred implicitly.
Developer new to TxPool can easily follow the logic.

But the most important is we can revive the test_txpool without dirty trick and remove usage of getCanonicalHead furthermore to prepare for better integration with ForkedChain.
2024-12-26 17:07:25 +07:00
andri lim
aba9b582db
Rename stateDB to ledger (#2966)
* Rename stateDB to ledger

* Fix readOnlyLedger
2024-12-21 20:46:13 +07:00
andri lim
473da69043
Remove unused stuff from txpool (#2967) 2024-12-21 20:13:33 +07:00
andri lim
86fc24a1d7
devnet-5: Update EIP-7685: exclude empty requests data in commitment (#2963)
* devnet-5: Update EIP-7685: exclude empty requests data in commitment

* Fix test vector

* Add more tests

* Fix executionRequests order validation

* Simplify test vector

* Fix t8n executionRequests output
2024-12-21 05:59:30 +00:00
Jacek Sieka
036dd23e9b
cleanups, import fixes (#2964)
* more generic-path removal
* tighter imports
2024-12-20 12:57:15 +01:00
andri lim
80f8b3c2b1
devnet-5: Implement EIP-7691: Blob throughput increase (#2957) 2024-12-20 09:12:16 +00:00
Jacek Sieka
d45d03ce0c
reduce tx naming overload (#2952)
* if it's a db function, use `txFrame...`
* if it's not a db function, don't use `txFrame...`
2024-12-18 23:03:51 +07:00
Jacek Sieka
7bbb0f4421
Stream blocks during import (#2937)
When running the import, currently blocks are loaded in batches into a
`seq` then passed to the importer as such.

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

This PR introduces a persister that accepts these potentially large
blocks one by one and at the same time removes a number of redundant /
unnecessary copies, assignments and resets that were slowing down the
import process in general.
2024-12-18 13:21:20 +01:00
andri lim
45bc6422a0
Reduce getCanonicalHead usage, and delegate to ForkedChain (#2948)
The current getCanonicalHead of core db should not be confused with ForkedChain.latestHeader.
Therefore we need to use getCanonicalHead to restricted case only, e.g. initializing ForkedChain.
2024-12-18 11:04:23 +07:00
andri lim
806d9dd04a
Reuse taskpool in simulator to prevent OOM (#2945) 2024-12-17 18:57:16 +07:00
andri lim
b8932d9519
Remove MergeForkBlock alias and use MergeNetSplitBlock only (#2947) 2024-12-17 11:42:13 +00:00
andri lim
a57958f71e
Remove totalTerminalDifficultyPassed (#2934) 2024-12-13 13:29:00 +07:00
andri lim
2e5ef4fb5a
Wire ForkedChainRef properly to TxPool (#2933) 2024-12-13 13:21:20 +07:00
andri lim
847cc311eb
Remove verifyFrom, vmState, and checkSeal from ChainRef (#2932) 2024-12-13 12:12:57 +07:00
Jacek Sieka
3d58393b4c
Offload signature checking to taskpools (#2927)
In block processing, depending on the complexity of a transaction and
hotness of caches etc, signature checking can actually make up the
majority of time needed to process a transaction (60% observed in some
randomly sampled block ranges).

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

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

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

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

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

Co-authored-by: andri lim <jangko128@gmail.com>
2024-12-13 11:53:41 +07:00
andri lim
dc81863c3a
Fixes for Mekong testnet: EIP-7702 gas related (#2912) 2024-12-05 13:00:47 +07:00
Jacek Sieka
8cb3619141
stint: bump for endians (#2903)
* stint: bump for endians

* stint fix
2024-12-04 12:03:31 +01:00
andri lim
5a3bfe486f
Add blockByNumber to engine_client of simulator (#2902) 2024-12-04 10:57:21 +07:00
andri lim
5e90522e70
Bump nim-web3 to c8f36f59cb354196cfe117b6866e81d450c8cfd7 (#2878)
* Bump nim-web3 to c8f36f59cb354196cfe117b6866e81d450c8cfd7

* Fix portal bridge

* Comply to nph format style
2024-11-27 20:16:31 +07:00
andri lim
c525590a51
Fix simulator RPC object: add fields from latest spec (#2859) 2024-11-21 21:58:12 +07: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
89fac051cd
Reduce declared but not used warnings (#2822) 2024-11-03 00:11:24 +00:00
andri lim
4ffe056a25
Engine API simulator: simplify versioned method call (#2821)
* Engine API simulator: simplify versioned method call

* More cleanup
2024-11-02 16:58:18 +07:00
Advaita Saha
a45ac7e327
Port p2p to server API (#2769)
* eth_gasPrice

* signing endpoints

* transaction by hash + temp fixes

* fix CI

* fix: state not persisted

* decouple state access changes from this PR

* rpc complete set

* tests modified

* tests temp modifications

* add tests to CI + minor fixes

* remove p2p

* remove old dependency

* fix suggestions

* rework tests

* rework kurtosis issue + comments

* fix post bump issues

* suggestions + logs

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

* fix LruCache capitalization for styleCheck

* KzgProof/KzgCommitment for styleCheck

* TxEip4844 for styleCheck

* styleCheck issues in nimbus/beacon/payload_conv.nim

* ENode for styleCheck

* isOk for styleCheck

* some more styleCheck fixes

* more styleCheck fixes

---------

Co-authored-by: jangko <jangko128@gmail.com>
2024-11-01 19:06:26 +00:00
andri lim
94198bcf95
Fix engine api simulator related to eth types refactoring (#2801) 2024-10-29 22:06:52 +07:00
Jacek Sieka
d828dead2d
Use stateRoot/storageRoot more consistently (#2791)
* prefer the spec-derived name where possible
* don't pass stateRoot to LedgerRef and friends (it doesn't do anything)
* add deprecation warning in graphql - it needs updating to use
forkedchain instead
2024-10-27 19:56:28 +01:00
andri lim
738cb277cf
Fixes related to executionRequests of Pectra (#2787) 2024-10-26 11:10:54 +00:00
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
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
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
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
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
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
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
tersec
216604d0d6
add eth_sendRawTransaction to server API (#2678) 2024-10-02 03:56:39 +00:00
tersec
036a15c8f1
use non-deprecated engine API method for Hive JWT tests (#2668)
* use non-deprecated engine API method for Hive JWT tests

* also remove reference in nrpc
2024-10-01 03:28:14 +00: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
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
andri lim
a70bb78d27
Fix engine_sim compilation issue (#2594) 2024-09-06 11:06:31 +07:00