Merge pull request #68 from ethereum/abi-version-helper

Add evmc_is_abi_compatible helper
This commit is contained in:
Paweł Bylica 2018-08-20 16:23:29 +02:00 committed by GitHub
commit 36b7976121
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View File

@ -167,8 +167,8 @@ static const struct evmc_context_fn_table ctx_fn_table = {
int main()
{
struct evmc_instance* vm = evmc_create_examplevm();
if (vm->abi_version != EVMC_ABI_VERSION)
return 1; // Incompatible ABI version.
if (!evmc_is_abi_compatible(vm))
return 1;
const uint8_t code[] = "Place some EVM bytecode here";
const size_t code_size = sizeof(code);

View File

@ -17,6 +17,14 @@
#include <evmc/evmc.h>
/**
* Returns true if the instance has a compatible ABI version.
*/
static inline int evmc_is_abi_compatible(struct evmc_instance *instance)
{
return instance->abi_version == EVMC_ABI_VERSION;
}
/**
* Destroys the VM instance.
*

View File

@ -5,6 +5,7 @@
#include <evmc/loader.h>
#include <evmc/evmc.h>
#include <evmc/helpers.h>
#include <stdint.h>
#include <string.h>
@ -137,7 +138,7 @@ struct evmc_instance* evmc_load_and_create(const char* filename, enum evmc_loade
return NULL;
}
if (instance->abi_version != EVMC_ABI_VERSION)
if (!evmc_is_abi_compatible(instance))
{
*error_code = EVMC_LOADER_ABI_VERSION_MISMATCH;
return NULL;