diff --git a/include/evmc/evmc.h b/include/evmc/evmc.h index 699d60c82..7945e839b 100644 --- a/include/evmc/evmc.h +++ b/include/evmc/evmc.h @@ -40,7 +40,7 @@ extern "C" { enum { /** The EVMC ABI version number of the interface declared in this file. */ - EVMC_ABI_VERSION = 3 + EVMC_ABI_VERSION = 4 }; /** @@ -491,6 +491,18 @@ typedef void (*evmc_get_balance_fn)(struct evmc_uint256be* result, typedef size_t (*evmc_get_code_size_fn)(struct evmc_context* context, const struct evmc_address* address); +/** + * Get code size callback function. + * + * This callback function is used by an EVM to get the keccak256 hash of the code stored + * in the account at the given address. For accounts not having a code, this + * function returns keccak256 hash of empty data. For accounts not existing in the state, + * this function returns 0. + */ +typedef void (*evmc_get_code_hash_fn)(struct evmc_uint256be* result, + struct evmc_context* context, + const struct evmc_address* address); + /** * Copy code callback function. * @@ -591,6 +603,9 @@ struct evmc_context_fn_table /** Get code size callback function. */ evmc_get_code_size_fn get_code_size; + /** Get code hash callback function. */ + evmc_get_code_hash_fn get_code_hash; + /** Copy code callback function. */ evmc_copy_code_fn copy_code; diff --git a/lib/instructions/instruction_metrics.c b/lib/instructions/instruction_metrics.c index b8fe69780..49c0fba85 100644 --- a/lib/instructions/instruction_metrics.c +++ b/lib/instructions/instruction_metrics.c @@ -85,7 +85,7 @@ static struct evmc_instruction_metrics constantinople_metrics[256] = { /* EXTCODECOPY = 0x3c */ {700, 4, 0}, /* RETURNDATASIZE = 0x3d */ {BASE, 0, 1}, /* RETURNDATACOPY = 0x3e */ {VERYLOW, 3, 0}, - /* = 0x3f */ {UNDEFINED, 0, 0}, + /* EXTCODEHASH = 0x3f */ {400, 1, 1}, /* BLOCKHASH = 0x40 */ {20, 1, 1}, /* COINBASE = 0x41 */ {BASE, 0, 1}, /* TIMESTAMP = 0x42 */ {BASE, 0, 1},