PrecompileHandle trait (subcall support) + precompile testing utils#1487
PrecompileHandle trait (subcall support) + precompile testing utils#1487
Conversation
tgmichel
left a comment
There was a problem hiding this comment.
Looks awesome, after reading it a couple of times cannot really find anything fundamentally wrong with it.
To help me (and others) understand the changes, a quick summary:
-
PrecompileHandletrait is introduced torust-blockchain/evm. -
This trait is implemented for
StackExecutorHandle, which is a defensive private struct which sole purpose is to wrap a mutable reference to theStackExecutor. -
The purpose of the new handle is to:
- enables the WIP subcall functionality. That is, entering in a new nested EVM call on behalf of a precompile-provided, higher-level context caller without the need of delegate call op.
- allows to record gasometer cost and logs in-place a.k.a. without the need of returning them as part of the precompile result and perform the gasometer+logs later on. Thus logs can be recorded in the right order. This also removes the need of passing around the gasometer which is great.
-
A new functional precompile testing api that simplifies assertions and mocking.
| @@ -11,6 +11,5 @@ git clone --depth 1 -b master-without-wasm https://github.com/PureStake/moonbeam | |||
|
|
|||
| cd build/moonbeam-runtime-overrides | |||
| ./scripts/import-tracing-runtime.sh local ${1:-"$LOCAL_GIT_BRANCH"} | |||
| cd tracing/local && cargo update -p evm && cd ../.. | |||
There was a problem hiding this comment.
It seemed to be necessary at some point but no longer is, and instead doesn't seem to like the git dependency.
notlesh
left a comment
There was a problem hiding this comment.
I read through +6,228 −10,648 lines changed and only had a problem with the very last one 😆
|
Are we gonna include this PR with the modified branch in frontier? |
We should merge the PRed branch into our usual versionned branch. |
|
Blocked until #1528 is merged (0.9.20 upgrade with frontier bump) |
What does it do?
Update to changes suggested in this PR: rust-ethereum/evm#122
Adds support for precompiles to do subcalls throught an handle. This handle also allow to record gas and logs which are no longer part of
PrecompileOutput.Since it changed the signature of
PrecompileSet::executeall the tests broke. While fixing them I wrote a util to help write precompile tests and hide the implementation details, which will hopefully allow them to not break when new changes to the EVM are introduced.What important points reviewers should know?
Currently use custom branches until PRs are merged in their respective repos such as our frontier repo:
moonbeam-foundation/frontier#63
Is there something left for follow-up PRs?
Implementation of batch precompile: #1498
Some precompile performing subcall are needed to properly test tracing. A new tracing event has already been added to properly handle precompile subcalls.
The new design of precompiles moves all parameters inside the
handle. A newPrecompiletrait following this design is added in the utils, and all precompiles implementingpallet_evm::Precompileautomatically implement this new trait at the cost of cloning the input. Thus, a following PR could migrate our precompiles to directly implement this new trait to avoid input cloning and use new features.What alternative implementations were considered?
Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?
What value does it bring to the blockchain users?