EVMC specifies a generic API for Ethereum execution engines.
This EIP specifies a way of providing implementations of Ethereum precompiled contracts
using the EVMC VM API.
Specification
For the complete EVMC specification visit the EVMC documentation first.
This EIP is based on and is compatible with EVMC ABI version 6.
The EVMC module with implementations of precompiled contracts SHOULD:
There is no code provided (the code argument is NULL and code_size argument is 0).
If the requirements are not fulfilled, abort execution with the EVMC_REJECTED status code.
Check if the call destination address (evmc_message::destination)
targets existing precompiled contract.
Consider the EVM revision (evmc_revision) requested by
the rev parameter of execute().
Otherwise, emulate execution of empty code by returning
the EVMC_SUCCESS status code
and gas left equal the call gas limit (evmc_message::gas).
Precompiled contract implementations are allowed to return two more EVMC error codes:
EVMC_FAILURE if the failure was caused due to something other than out of gas (e.g. input validation error)
EVMC_REVERT if the precompile doesn’t want to forfeit all supplied gas (as of May 2019 no such precompile exists)
The Client is not required to provide the Host interface ([evmc_context] argument of execute() is set to NULL).
Therefore, the precompiled contracts implementation MUST NOT access the evmc_context.
Rationale
It is very unlikely that any precompile will need to access or modify a contract state.
Not requiring the Client to implement the EVMC Host interface removes the big portion of work
needed for full EVMC integration.
Test Cases
EVMC provides the evmc-vmtester tool for checking compatibility with the EVMC specification.