Skip to content

Commit

Permalink
Support for EXTCODEHASH
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Jul 31, 2018
1 parent a4f7029 commit 1e52487
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion include/evmc/evmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

/**
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion lib/instructions/instruction_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit 1e52487

Please sign in to comment.