paradigmxyz / reth

Modular, contributor-friendly and blazing-fast implementation of the Ethereum protocol, in Rust
https://reth.rs/
Apache License 2.0
3.97k stars 1.2k forks source link

RPC Executor improvements #10974

Closed Rjected closed 1 month ago

Rjected commented 2 months ago

debug_executionWitness currently needs to output all state required to execute the given block. The endpoint currently does not work for optimism because it needs to use the optimism executor, and the eth mainnet system calls may be different from optimism. It also needs to retain more execution-related information than is desired for the vanilla executor.

The debug_executionWitness endpoint

The endpoint needs to return the following information:

We need to leave the current executor as-is, so we don't do more than needed during regular block processing.

A new executor

So, we now have the BlockAccessListExecutor, which implements the Executor trait: https://github.com/paradigmxyz/reth/blob/9760319f3427dba39f431871011d3fb9ad9b3b41/crates/ethereum/evm/src/execute.rs#L392

This is a new executor that retains the accessed state in the BundleState of the BlockExecutionOutput. There is also one for optimism. This separate executor meets all requirements for the endpoint, but we still need to make this executor accessible to the RPC endpoint.

Executors in RPC

We currently have the BlockExecutorProvider, which provides multiple types of executors for RPC to use: https://github.com/paradigmxyz/reth/blob/9760319f3427dba39f431871011d3fb9ad9b3b41/crates/evm/src/execute.rs#L110-L123

This PR includes a third type of executor to include in the BlockExecutorProvider trait: https://github.com/paradigmxyz/reth/pull/10868

We can either:

cc @mattsse

malik672 commented 1 month ago

debug_executionWitness currently needs to output all state required to execute the given block. The endpoint currently does not work for optimism because it needs to use the optimism executor, and the eth mainnet system calls may be different from optimism. It also needs to retain more execution-related information than is desired for the vanilla executor.

The debug_executionWitness endpoint

The endpoint needs to return the following information:

  • all state that was accessed or changed during block execution

    • including system calls and transactions
  • all code loaded during execution
  • merkle proofs for the state accessed / changed during block execution

We need to leave the current executor as-is, so we don't do more than needed during regular block processing.

A new executor

So, we now have the BlockAccessListExecutor, which implements the Executor trait:

https://github.com/paradigmxyz/reth/blob/9760319f3427dba39f431871011d3fb9ad9b3b41/crates/ethereum/evm/src/execute.rs#L392

This is a new executor that retains the accessed state in the BundleState of the BlockExecutionOutput. There is also one for optimism. This separate executor meets all requirements for the endpoint, but we still need to make this executor accessible to the RPC endpoint.

Executors in RPC

We currently have the BlockExecutorProvider, which provides multiple types of executors for RPC to use:

https://github.com/paradigmxyz/reth/blob/9760319f3427dba39f431871011d3fb9ad9b3b41/crates/evm/src/execute.rs#L110-L123

This PR includes a third type of executor to include in the BlockExecutorProvider trait: #10868

We can either:

  • pursue this direction further, or
  • change how we get executors for rpc somehow

cc @mattsse

I'm not sure but I think it should be made custom, would solve the compatibility issue easily

mattsse commented 1 month ago

closing this because this is now integrated, rpc improvements tracked #11122