nimbus-eth1/nimbus/rpc
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
..
TODO-P2P.md Core db disable legacy api n remove distinct tries (#2299) 2024-06-05 20:52:04 +00:00
common.nim Bump nim-web3 and others 2024-01-14 10:41:23 +07:00
cors.nim Implement combo http server for rpc, engine_api, and graphql services (#1992) 2024-01-29 20:20:04 +07:00
debug.nim Remove EVM indirect imports and unused EVM errors (#2370) 2024-06-17 09:56:39 +02:00
engine_api.nim Bump nim-eth, nim-web3, nimbus-eth2 (#2344) 2024-06-14 14:31:08 +07:00
experimental.nim Remove EVM indirect imports and unused EVM errors (#2370) 2024-06-17 09:56:39 +02:00
filters.nim Bump nim-eth, nim-web3, nimbus-eth2 (#2344) 2024-06-14 14:31:08 +07:00
jwt_auth.nim results: use canonical import (#2248) 2024-05-30 14:54:03 +02:00
jwt_auth_helper.nim Implement combo http server for rpc, engine_api, and graphql services (#1992) 2024-01-29 20:20:04 +07:00
oracle.nim Bump nim-eth, nim-web3, nimbus-eth2 (#2344) 2024-06-14 14:31:08 +07:00
p2p.nim Cache code and invalid jump destination tables (fixes #2268) (#2404) 2024-06-21 09:44:10 +02:00
params.nim Remove EVM indirect imports and unused EVM errors (#2370) 2024-06-17 09:56:39 +02:00
rpc_server.nim Implement combo http server for rpc, engine_api, and graphql services (#1992) 2024-01-29 20:20:04 +07:00
rpc_types.nim Get rid of HexQuantityStr and HexDataStr usage 2023-12-27 07:48:53 +07:00
rpc_utils.nim Remove EVM indirect imports and unused EVM errors (#2370) 2024-06-17 09:56:39 +02:00