nimbus-eth1/nimbus
Jacek Sieka 768307d91d
Cache code and invalid jump destination tables (fixes #2268) (#2404)
It is common for many accounts to share the same code - at the database
level, code is stored by hash meaning only one copy exists per unique
program but when loaded in memory, a copy is made for each account.

Further, every time we execute the code, it must be scanned for invalid
jump destinations which slows down EVM exeuction.

Finally, the extcodesize call causes code to be loaded even if only the
size is needed.

This PR improves on all these points by introducing a shared
CodeBytesRef type whose code section is immutable and that can be shared
between accounts. Further, a dedicated `len` API call is added so that
the EXTCODESIZE opcode can operate without polluting the GC and code
cache, for cases where only the size is requested - rocksdb will in this
case cache the code itself in the row cache meaning that lookup of the
code itself remains fast when length is asked for first.

With 16k code entries, there's a 90% hit rate which goes up to 99%
during the 2.3M attack - the cache significantly lowers memory
consumption and execution time not only during this event but across the
board.
2024-06-21 09:44:10 +02:00
..
beacon Bump nim-eth/web3/kzg4844/nimbus-eth2 and related fixes (#2392) 2024-06-19 08:57:45 +07:00
common Coredb maintenance (#2398) 2024-06-19 14:13:12 +00:00
core Cache code and invalid jump destination tables (fixes #2268) (#2404) 2024-06-21 09:44:10 +02:00
db Cache code and invalid jump destination tables (fixes #2268) (#2404) 2024-06-21 09:44:10 +02:00
evm Cache code and invalid jump destination tables (fixes #2268) (#2404) 2024-06-21 09:44:10 +02:00
graphql Cache code and invalid jump destination tables (fixes #2268) (#2404) 2024-06-21 09:44:10 +02:00
rpc Cache code and invalid jump destination tables (fixes #2268) (#2404) 2024-06-21 09:44:10 +02:00
stateless Cleanup stateless and block witness code. (#2295) 2024-06-08 15:05:00 +07:00
sync use Nim 2.0.6 (#2384) 2024-06-19 01:27:54 +00:00
transaction Cache code and invalid jump destination tables (fixes #2268) (#2404) 2024-06-21 09:44:10 +02:00
utils Cache code and invalid jump destination tables (fixes #2268) (#2404) 2024-06-21 09:44:10 +02:00
TODO-TRACER.md Aristo uses pre classified tree types (#2385) 2024-06-18 11:14:02 +00:00
common.nim implement better hardfork management 2022-12-02 13:51:42 +07:00
compile_info.nim Remove EVM indirect imports and unused EVM errors (#2370) 2024-06-17 09:56:39 +02:00
config.nim metrics: enable during import (#2401) 2024-06-20 19:06:58 +02:00
constants.nim Bump nim-eth, nim-web3, nimbus-eth2 (#2344) 2024-06-14 14:31:08 +07:00
errors.nim Remove EVM indirect imports and unused EVM errors (#2370) 2024-06-17 09:56:39 +02:00
launcher.nim Add check copyright year linter to CI 2023-11-01 10:41:20 +07:00
makefile Snap sync fix trie interpolation fringe condition (#1457) 2023-02-01 18:56:06 +00:00
nim.cfg import: read from era files (#2254) 2024-05-31 09:13:56 +02:00
nimbus.nim metrics: enable during import (#2401) 2024-06-20 19:06:58 +02:00
nimbus_desc.nim rm full sync (#2324) 2024-06-08 07:41:44 +07:00
nimbus_import.nim metrics: enable during import (#2401) 2024-06-20 19:06:58 +02:00
no-tracer.nim Coredb maintenance (#2398) 2024-06-19 14:13:12 +00:00
rpc.nim Aristo uses pre classified tree types (#2385) 2024-06-18 11:14:02 +00:00
transaction.nim Remove EVM indirect imports and unused EVM errors (#2370) 2024-06-17 09:56:39 +02:00
version.nim Add startup banner (#2354) 2024-06-14 10:08:44 +02:00