feat: precompile override via params.Extras
hooks
#2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why this should be merged
Adds support for overriding precompiles.
How this works
The
params.RegisterExtras
type parameters are no longerany
butChainConfigHooks
andRulesHooks
interfaces that allow for injection of hooks, the first of which isPrecompileOverride(common.Address)
. The hook returns avm.PrecompiledContract
(interface) and a boolean which, if true, indicates that the returned value MUST override the default.If
params.RegisterExtras()
is never called, a set ofNOOPHooks
is used by default. These can also be embedded into registered types that wish to propagate payloads but without modifying behaviour.Tip
The hook returns a bool to indicate overriding, not to indicate if the address must be treated as a precompile. The latter is inferred from whether or not the returned
PrecompiledContract
isnil
. An address that would otherwise be treated as a precompile by geth can therefore be disabled by returningnil, true
.How this was tested
Integrations tests override precompile addresses (including native ones) with a stub registered via
params.RegisterExtras()
, which is exercised viavm.EVM.Call()
. This demonstrates complete integration.