mirror of https://github.com/status-im/evmc.git
Remove deprecated tracing API
This commit is contained in:
parent
b045aad3de
commit
89e6fb2342
|
@ -296,7 +296,6 @@ fn build_create_fn(names: &VMNameSet) -> proc_macro2::TokenStream {
|
||||||
execute: Some(__evmc_execute),
|
execute: Some(__evmc_execute),
|
||||||
get_capabilities: Some(__evmc_get_capabilities),
|
get_capabilities: Some(__evmc_get_capabilities),
|
||||||
set_option: None,
|
set_option: None,
|
||||||
set_tracer: None,
|
|
||||||
name: unsafe { ::std::ffi::CStr::from_bytes_with_nul_unchecked(#static_name_ident.as_bytes()).as_ptr() as *const i8 },
|
name: unsafe { ::std::ffi::CStr::from_bytes_with_nul_unchecked(#static_name_ident.as_bytes()).as_ptr() as *const i8 },
|
||||||
version: unsafe { ::std::ffi::CStr::from_bytes_with_nul_unchecked(#static_version_ident.as_bytes()).as_ptr() as *const i8 },
|
version: unsafe { ::std::ffi::CStr::from_bytes_with_nul_unchecked(#static_version_ident.as_bytes()).as_ptr() as *const i8 },
|
||||||
};
|
};
|
||||||
|
|
|
@ -98,7 +98,6 @@ mod tests {
|
||||||
destroy: None,
|
destroy: None,
|
||||||
execute: None,
|
execute: None,
|
||||||
get_capabilities: None,
|
get_capabilities: None,
|
||||||
set_tracer: None,
|
|
||||||
set_option: None,
|
set_option: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,6 @@ extern "C" EVMC_EXPORT evmc_instance* evmc_create_example_precompiles_vm()
|
||||||
execute,
|
execute,
|
||||||
[](evmc_instance*) { return evmc_capabilities_flagset{EVMC_CAPABILITY_PRECOMPILES}; },
|
[](evmc_instance*) { return evmc_capabilities_flagset{EVMC_CAPABILITY_PRECOMPILES}; },
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
|
||||||
};
|
};
|
||||||
return &instance;
|
return &instance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -854,84 +854,6 @@ typedef uint32_t evmc_capabilities_flagset;
|
||||||
*/
|
*/
|
||||||
typedef evmc_capabilities_flagset (*evmc_get_capabilities_fn)(struct evmc_instance* instance);
|
typedef evmc_capabilities_flagset (*evmc_get_capabilities_fn)(struct evmc_instance* instance);
|
||||||
|
|
||||||
/**
|
|
||||||
* The opaque type representing a Client-side tracer object.
|
|
||||||
*
|
|
||||||
* @deprecated Deprecated since EVMC 6.3, see evmc_instance::set_tracer().
|
|
||||||
*/
|
|
||||||
struct evmc_tracer_context;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The callback to trace instructions execution in an EVM.
|
|
||||||
*
|
|
||||||
* This function informs the Client what instruction has been executed in the EVM implementation
|
|
||||||
* and what are the results of executing this particular instruction.
|
|
||||||
* The message level information (like call depth, destination address, etc.) are not provided here.
|
|
||||||
* This piece of information can be acquired by inspecting messages being sent to the EVM in
|
|
||||||
* ::evmc_execute_fn and the results of the messages execution.
|
|
||||||
*
|
|
||||||
* @deprecated Deprecated since EVMC 6.3, see evmc_instance::set_tracer().
|
|
||||||
*
|
|
||||||
* @param context The pointer to the Client-side tracing context. This allows to
|
|
||||||
* implement the tracer in OOP manner.
|
|
||||||
* @param code_offset The current instruction position in the code.
|
|
||||||
* @param status_code The status code of the instruction execution.
|
|
||||||
* @param gas_left The amount of the gas left after the instruction execution.
|
|
||||||
* @param stack_num_items The current EVM stack height after the instruction execution.
|
|
||||||
* @param pushed_stack_item The top EVM stack item pushed as the result of the instruction
|
|
||||||
* execution. This value is null when the instruction does not push
|
|
||||||
* anything to the stack.
|
|
||||||
* @param memory_size The size of the EVM memory after the instruction execution.
|
|
||||||
* @param changed_memory_offset The offset in number of bytes of the beginning of the memory area
|
|
||||||
* modified as the result of the instruction execution.
|
|
||||||
* The Client MAY use this information together with
|
|
||||||
* @p changed_memory_size and @p changed_memory to incrementally
|
|
||||||
* update the copy of the full VM's memory.
|
|
||||||
* @param changed_memory_size The size of the memory area modified as the result of
|
|
||||||
* the instruction execution.
|
|
||||||
* @param changed_memory The pointer to the memory area modified as the result of
|
|
||||||
* the instruction execution.
|
|
||||||
* The Client MAY access the pointed memory area
|
|
||||||
* (limited by the @p changed_memory_size) only during the current
|
|
||||||
* execution of the evmc_trace_callback().
|
|
||||||
* The pointer MUST NOT be stored by the Client.
|
|
||||||
* The Client MUST NOT assume that
|
|
||||||
* `changed_memory - changed_memory_offset` is a valid base pointer
|
|
||||||
* of the VM memory.
|
|
||||||
*/
|
|
||||||
typedef void (*evmc_trace_callback)(struct evmc_tracer_context* context,
|
|
||||||
size_t code_offset,
|
|
||||||
enum evmc_status_code status_code,
|
|
||||||
int64_t gas_left,
|
|
||||||
size_t stack_num_items,
|
|
||||||
const evmc_uint256be* pushed_stack_item,
|
|
||||||
size_t memory_size,
|
|
||||||
size_t changed_memory_offset,
|
|
||||||
size_t changed_memory_size,
|
|
||||||
const uint8_t* changed_memory);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the EVM instruction tracer.
|
|
||||||
*
|
|
||||||
* When the tracer is set in the EVM instance, the EVM SHOULD call back the tracer with information
|
|
||||||
* about instructions execution in the EVM.
|
|
||||||
* @see ::evmc_trace_callback.
|
|
||||||
*
|
|
||||||
* This will overwrite the previous settings (the callback and the context).
|
|
||||||
*
|
|
||||||
* @deprecated Deprecated since EVMC 6.3, see evmc_instance::set_tracer().
|
|
||||||
*
|
|
||||||
* @param instance The EVM instance.
|
|
||||||
* @param callback The tracer callback function. This argument MAY be NULL to disable previously
|
|
||||||
* set tracer.
|
|
||||||
* @param context The Client-side tracer context. This argument MAY be NULL in case the tracer
|
|
||||||
* does not require any context. This argument MUST be NULL if the callback
|
|
||||||
* argument is NULL.
|
|
||||||
*/
|
|
||||||
typedef void (*evmc_set_tracer_fn)(struct evmc_instance* instance,
|
|
||||||
evmc_trace_callback callback,
|
|
||||||
struct evmc_tracer_context* context);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The EVM instance.
|
* The EVM instance.
|
||||||
|
@ -990,17 +912,6 @@ struct evmc_instance
|
||||||
*/
|
*/
|
||||||
evmc_get_capabilities_fn get_capabilities;
|
evmc_get_capabilities_fn get_capabilities;
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional pointer to function setting the EVM instruction tracer.
|
|
||||||
*
|
|
||||||
* If the EVM does not support this feature the pointer can be NULL.
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
* Since EVMC 6.3, the tracing API has been deprecated as there have been some
|
|
||||||
* design flaws discovered. New API is expected to be introduced in future.
|
|
||||||
*/
|
|
||||||
evmc_set_tracer_fn set_tracer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional pointer to function modifying VM's options.
|
* Optional pointer to function modifying VM's options.
|
||||||
*
|
*
|
||||||
|
|
|
@ -80,20 +80,6 @@ static inline enum evmc_set_option_result evmc_set_option(struct evmc_instance*
|
||||||
return EVMC_SET_OPTION_INVALID_NAME;
|
return EVMC_SET_OPTION_INVALID_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the tracer callback for the VM instance, if the feature is supported by the VM.
|
|
||||||
*
|
|
||||||
* @see evmc_set_tracer_fn
|
|
||||||
*/
|
|
||||||
EVMC_DEPRECATED
|
|
||||||
static inline void evmc_set_tracer(struct evmc_instance* instance,
|
|
||||||
evmc_trace_callback callback,
|
|
||||||
struct evmc_tracer_context* context)
|
|
||||||
{
|
|
||||||
if (instance->set_tracer)
|
|
||||||
instance->set_tracer(instance, callback, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes code in the VM instance.
|
* Executes code in the VM instance.
|
||||||
*
|
*
|
||||||
|
|
|
@ -275,8 +275,7 @@ TEST(cpp, vm)
|
||||||
|
|
||||||
TEST(cpp, vm_set_option)
|
TEST(cpp, vm_set_option)
|
||||||
{
|
{
|
||||||
evmc_instance raw_instance = {EVMC_ABI_VERSION, "", "", nullptr,
|
evmc_instance raw_instance = {EVMC_ABI_VERSION, "", "", nullptr, nullptr, nullptr, nullptr};
|
||||||
nullptr, nullptr, nullptr, nullptr};
|
|
||||||
raw_instance.destroy = [](evmc_instance*) {};
|
raw_instance.destroy = [](evmc_instance*) {};
|
||||||
|
|
||||||
auto vm = evmc::VM{&raw_instance};
|
auto vm = evmc::VM{&raw_instance};
|
||||||
|
@ -295,7 +294,7 @@ TEST(cpp, vm_move)
|
||||||
static int destroy_counter = 0;
|
static int destroy_counter = 0;
|
||||||
const auto template_instance =
|
const auto template_instance =
|
||||||
evmc_instance{EVMC_ABI_VERSION, "", "", [](evmc_instance*) { ++destroy_counter; },
|
evmc_instance{EVMC_ABI_VERSION, "", "", [](evmc_instance*) { ++destroy_counter; },
|
||||||
nullptr, nullptr, nullptr, nullptr};
|
nullptr, nullptr, nullptr};
|
||||||
|
|
||||||
EXPECT_EQ(destroy_counter, 0);
|
EXPECT_EQ(destroy_counter, 0);
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,8 +73,8 @@ protected:
|
||||||
/// Creates a VM mock with only destroy() method.
|
/// Creates a VM mock with only destroy() method.
|
||||||
static evmc_instance* create_vm_barebone()
|
static evmc_instance* create_vm_barebone()
|
||||||
{
|
{
|
||||||
static auto instance = evmc_instance{EVMC_ABI_VERSION, "vm_barebone", "", destroy,
|
static auto instance =
|
||||||
nullptr, nullptr, nullptr, nullptr};
|
evmc_instance{EVMC_ABI_VERSION, "vm_barebone", "", destroy, nullptr, nullptr, nullptr};
|
||||||
++create_count;
|
++create_count;
|
||||||
return &instance;
|
return &instance;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ protected:
|
||||||
constexpr auto wrong_abi_version = 1985;
|
constexpr auto wrong_abi_version = 1985;
|
||||||
static_assert(wrong_abi_version != EVMC_ABI_VERSION, "");
|
static_assert(wrong_abi_version != EVMC_ABI_VERSION, "");
|
||||||
static auto instance =
|
static auto instance =
|
||||||
evmc_instance{wrong_abi_version, "", "", destroy, nullptr, nullptr, nullptr, nullptr};
|
evmc_instance{wrong_abi_version, "", "", destroy, nullptr, nullptr, nullptr};
|
||||||
++create_count;
|
++create_count;
|
||||||
return &instance;
|
return &instance;
|
||||||
}
|
}
|
||||||
|
@ -94,8 +94,7 @@ protected:
|
||||||
static evmc_instance* create_vm_with_set_option() noexcept
|
static evmc_instance* create_vm_with_set_option() noexcept
|
||||||
{
|
{
|
||||||
static auto instance = evmc_instance{
|
static auto instance = evmc_instance{
|
||||||
EVMC_ABI_VERSION, "vm_with_set_option", "", destroy, nullptr, nullptr, nullptr,
|
EVMC_ABI_VERSION, "vm_with_set_option", "", destroy, nullptr, nullptr, set_option};
|
||||||
set_option};
|
|
||||||
++create_count;
|
++create_count;
|
||||||
return &instance;
|
return &instance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,15 +163,6 @@ TEST_F(evmc_vm_test, set_option_unknown_value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(evmc_vm_test, set_tracer)
|
|
||||||
{
|
|
||||||
static const auto tracer_callback =
|
|
||||||
[](evmc_tracer_context*, size_t, evmc_status_code, int64_t, size_t, const evmc_uint256be*,
|
|
||||||
size_t, size_t, size_t, const uint8_t*) noexcept {};
|
|
||||||
if (vm->set_tracer)
|
|
||||||
vm->set_tracer(vm, tracer_callback, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(evmc_vm_test, precompile_test)
|
TEST_F(evmc_vm_test, precompile_test)
|
||||||
{
|
{
|
||||||
// This logic is based on and should match the description in EIP-2003.
|
// This logic is based on and should match the description in EIP-2003.
|
||||||
|
|
Loading…
Reference in New Issue