Extend set_storage() by reporting the storage status

This commit is contained in:
Paweł Bylica 2018-08-08 15:34:15 +02:00
parent 28d2fd54ba
commit 8cf24c7dd9
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
2 changed files with 31 additions and 16 deletions

View File

@ -45,10 +45,10 @@ static void get_storage(struct evmc_uint256be* result,
printf("\n");
}
static void set_storage(struct evmc_context* context,
const struct evmc_address* address,
const struct evmc_uint256be* key,
const struct evmc_uint256be* value)
static enum evmc_storage_status set_storage(struct evmc_context* context,
const struct evmc_address* address,
const struct evmc_uint256be* key,
const struct evmc_uint256be* value)
{
(void)context;
(void)key;
@ -56,6 +56,7 @@ static void set_storage(struct evmc_context* context,
printf("EVM-C: SSTORE @");
print_address(address);
printf("\n");
return EVMC_STORAGE_UNCHANGED;
}
static void get_balance(struct evmc_uint256be* result,

View File

@ -40,7 +40,7 @@ extern "C" {
enum
{
/** The EVMC ABI version number of the interface declared in this file. */
EVMC_ABI_VERSION = 4
EVMC_ABI_VERSION = 5
};
/**
@ -451,21 +451,35 @@ typedef void (*evmc_get_storage_fn)(struct evmc_uint256be* result,
const struct evmc_address* address,
const struct evmc_uint256be* key);
/**
* The effect of an attempt to modify a contract storage item.
*/
enum evmc_storage_status
{
EVMC_STORAGE_UNCHANGED = 0, /**< The storage item value unchanged. */
EVMC_STORAGE_MODIFIED = 1, /**< The storage item value modified. */
EVMC_STORAGE_ADDED = 2, /**< The storage item added. */
EVMC_STORAGE_DELETED = 3, /**< The storage item deleted. */
};
/**
* Set storage callback function.
*
* This callback function is used by an EVM to update the given contract
* storage entry.
* @param context The pointer to the Host execution context.
* @see ::evmc_context.
* @param address The address of the contract.
* @param key The index of the storage entry.
* @param value The value to be stored.
* This callback function is used by an EVM to update the given contract
* storage entry.
* @param context The pointer to the Host execution context.
* @see ::evmc_context.
* @param address The address of the contract.
* @param key The index of the storage entry.
* @param value The value to be stored.
* @return The effect on the storage item.
*/
typedef void (*evmc_set_storage_fn)(struct evmc_context* context,
const struct evmc_address* address,
const struct evmc_uint256be* key,
const struct evmc_uint256be* value);
typedef enum evmc_storage_status (*evmc_set_storage_fn)(struct evmc_context* context,
const struct evmc_address* address,
const struct evmc_uint256be* key,
const struct evmc_uint256be* value);
/**
* Get balance callback function.