nimbus-eth1/nimbus/evm
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
..
interpreter Cache code and invalid jump destination tables (fixes #2268) (#2404) 2024-06-21 09:44:10 +02:00
tracer avoid initTable (#2328) 2024-06-10 11:05:30 +02:00
blake2b_f.nim Add check copyright year linter to CI 2023-11-01 10:41:20 +07:00
blscurve.nim Bump nim-blscurve for gcc-14 compatibility (#2365) 2024-06-15 17:34:07 +00:00
code_bytes.nim Cache code and invalid jump destination tables (fixes #2268) (#2404) 2024-06-21 09:44:10 +02:00
code_stream.nim Cache code and invalid jump destination tables (fixes #2268) (#2404) 2024-06-21 09:44:10 +02:00
computation.nim Cache code and invalid jump destination tables (fixes #2268) (#2404) 2024-06-21 09:44:10 +02:00
evm_errors.nim Remove exceptions from EVM (#2314) 2024-06-07 15:24:32 +07:00
evmc_api.nim Bump nim-eth, nim-web3, nimbus-eth2 (#2344) 2024-06-14 14:31:08 +07:00
evmc_helpers.nim Add check copyright year linter to CI 2023-11-01 10:41:20 +07:00
internals.nim Remove EVM indirect imports and unused EVM errors (#2370) 2024-06-17 09:56:39 +02:00
interpreter_dispatch.nim Vm2Ctx -> VmCtx, Vm2Op -> VmOp (#2369) 2024-06-15 23:18:53 +07:00
memory.nim Fix lowest-hanging fruit in VM (#2382) 2024-06-18 07:55:35 +07:00
message.nim EVM embrace more EVMC types 2023-08-28 21:36:23 +07:00
modexp.nim Add style check to config.nims and fix styles in source code (#2038) 2024-02-20 10:07:38 +07:00
nimdoc.cfg Add check copyright year linter to CI 2023-11-01 10:41:20 +07:00
precompiles.nim Bump nim-eth, nim-web3, nimbus-eth2 (#2344) 2024-06-14 14:31:08 +07:00
stack.nim Remove exceptions from EVM (#2314) 2024-06-07 15:24:32 +07:00
state.nim use Nim 2.0.6 (#2384) 2024-06-19 01:27:54 +00:00
state_transactions.nim Bump nim-eth, nim-web3, nimbus-eth2 (#2344) 2024-06-14 14:31:08 +07:00
types.nim Bump nim-eth, nim-web3, nimbus-eth2 (#2344) 2024-06-14 14:31:08 +07:00