nimbus-eth1/nimbus
Adam Spitz e040e2671a
Added basic async capabilities for vm2. (#1260)
* Added basic async capabilities for vm2.

This is a whole new Git branch, not the same one as last time
(https://github.com/status-im/nimbus-eth1/pull/1250) - there wasn't
much worth salvaging. Main differences:

I didn't do the "each opcode has to specify an async handler" junk
that I put in last time. Instead, in oph_memory.nim you can see
sloadOp calling asyncChainTo and passing in an async operation.
That async operation is then run by the execCallOrCreate (or
asyncExecCallOrCreate) code in interpreter_dispatch.nim.

In the test code, the (previously existing) macro called "assembler"
now allows you to add a section called "initialStorage", specifying
fake data to be used by the EVM computation run by that test. (In
the long run we'll obviously want to write tests that for-real use
the JSON-RPC API to asynchronously fetch data; for now, this was
just an expedient way to write a basic unit test that exercises the
async-EVM code pathway.)

There's also a new macro called "concurrentAssemblers" that allows
you to write a test that runs multiple assemblers concurrently (and
then waits for them all to finish). There's one example test using
this, in test_op_memory_lazy.nim, though you can't actually see it
doing so unless you uncomment some echo statements in
async_operations.nim (in which case you can see the two concurrently
running EVM computations each printing out what they're doing, and
you'll see that they interleave).

A question: is it possible to make EVMC work asynchronously? (For
now, this code compiles and "make test" passes even if ENABLE_EVMC
is turned on, but it doesn't actually work asynchronously, it just
falls back on doing the usual synchronous EVMC thing. See
FIXME-asyncAndEvmc.)

* Moved the AsyncOperationFactory to the BaseVMState object.

* Made the AsyncOperationFactory into a table of fn pointers.

Also ditched the plain-data Vm2AsyncOperation type; it wasn't
really serving much purpose. Instead, the pendingAsyncOperation
field directly contains the Future.

* Removed the hasStorage idea.

It's not the right solution to the "how do we know whether we
still need to fetch the storage value or not?" problem. I
haven't implemented the right solution yet, but at least
we're better off not putting in a wrong one.

* Added/modified/removed some comments.

(Based on feedback on the PR.)

* Removed the waitFor from execCallOrCreate.

There was some back-and-forth in the PR regarding whether nested
waitFor calls are acceptable:

https://github.com/status-im/nimbus-eth1/pull/1260#discussion_r998587449

The eventual decision was to just change the waitFor to a doAssert
(since we probably won't want this extra functionality when running
synchronously anyway) to make sure that the Future is already
finished.
2022-11-01 11:35:46 -04:00
..
accounts Initial implementation of the merge spec 2022-01-24 09:44:39 +02:00
db add additional constructor to BaseChainDB 2022-10-25 11:01:31 +07:00
docs.static Kludge for 'make docs' to produce pretty nim manuals 2022-01-22 08:26:57 +02:00
graphql add CORS support for HTTP local services(json-rpc, engine-api, graphql) 2022-07-19 16:12:36 +07:00
merge bump nim eth 2022-08-22 20:11:36 +07:00
p2p move isLondon to chain_config.nim 2022-10-25 11:01:31 +07:00
rpc initial wire protocol transformation 2022-10-15 19:48:21 +07:00
sync Prep for full sync after snap make 5 (#1286) 2022-11-01 15:07:44 +00:00
transaction Added basic async capabilities for vm2. (#1260) 2022-11-01 11:35:46 -04:00
utils move isLondon to chain_config.nim 2022-10-25 11:01:31 +07:00
vm2 Added basic async capabilities for vm2. (#1260) 2022-11-01 11:35:46 -04:00
block_types.nim reduce compiler warnings 2019-11-13 21:49:39 +07:00
chain_config.nim move isLondon to chain_config.nim 2022-10-25 11:01:31 +07:00
conf_utils.nim modify hive simulators to run in CI 2022-04-21 12:01:18 +07:00
config.nim Bump nim-eth and remove all now unneeded p2p related imports (#1273) 2022-10-20 10:34:59 +02:00
constants.nim eth: adapt to smaller eth_types (#1210) 2022-09-03 20:15:35 +02:00
context.nim enhance net-key command line option to accept random, hex, and path 2022-07-30 08:46:11 +07:00
debug.nim reduce imported but not used warning when evmc enabled 2022-10-03 16:41:33 +07:00
errors.nim Redesign of BaseVMState descriptor (#923) 2022-01-18 16:19:32 +00:00
forks.nim upgrade evmc to v10.0.0 2022-10-03 16:38:32 +07:00
genesis.nim Bump nim-eth and remove all now unneeded p2p related imports (#1273) 2022-10-20 10:34:59 +02:00
genesis_alloc.nim Added sepolia specs (#1148) 2022-07-01 21:16:26 +01:00
launcher.nim Premix-related changes 2019-01-28 12:38:23 +02:00
lightchain_shell.nim Some renames 2018-05-28 13:22:28 +03:00
makefile wire evmc to vm2 and drop legacy vm 2022-09-26 15:16:28 +07:00
nim.cfg NAT port mapping 2019-04-17 03:56:28 +02:00
nimbus.nim initial wire protocol transformation 2022-10-15 19:48:21 +07:00
peers.nim simple peer manager to handle static peers reconnection 2022-08-26 22:07:56 +07:00
sealer.nim move sealing engine gaslimit calculator to txpool 2022-08-29 16:54:59 +07:00
tracer.nim eth: adapt to smaller eth_types (#1210) 2022-09-03 20:15:35 +02:00
transaction.nim Cleanup some imports and fix some warnings in the process (#1096) 2022-05-22 22:44:15 +02:00
utils.nim initial beacon sync skeleton implementation 2022-09-17 09:08:55 +07:00
validation.nim first step into styleCheck fixes 2022-04-14 08:39:50 +07:00
version.nim dist: precompiled binaries and Docker images (#1015) 2022-03-27 13:21:15 +02:00
vm_compile_info.nim wire evmc to vm2 and drop legacy vm 2022-09-26 15:16:28 +07:00
vm_computation.nim wire evmc to vm2 and drop legacy vm 2022-09-26 15:16:28 +07:00
vm_gas_costs.nim upgrade evmc to v10.0.0 2022-10-03 16:38:32 +07:00
vm_internals.nim wire evmc to vm2 and drop legacy vm 2022-09-26 15:16:28 +07:00
vm_precompiles.nim wire evmc to vm2 and drop legacy vm 2022-09-26 15:16:28 +07:00
vm_state.nim add enabledTracing accessor to BaseVMState 2022-10-25 11:01:31 +07:00
vm_state_transactions.nim Added basic async capabilities for vm2. (#1260) 2022-11-01 11:35:46 -04:00
vm_types.nim wire evmc to vm2 and drop legacy vm 2022-09-26 15:16:28 +07:00