From 89e6fb234289c5d4f80a7a22feaaeef48eef7e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Tue, 24 Sep 2019 23:43:58 +0200 Subject: [PATCH] Remove deprecated tracing API --- bindings/rust/evmc-declare/src/lib.rs | 1 - bindings/rust/evmc-vm/src/container.rs | 1 - .../example_precompiles_vm.cpp | 1 - include/evmc/evmc.h | 89 ------------------- include/evmc/helpers.h | 14 --- test/unittests/test_cpp.cpp | 7 +- test/unittests/test_loader.cpp | 9 +- test/vmtester/tests.cpp | 9 -- 8 files changed, 7 insertions(+), 124 deletions(-) diff --git a/bindings/rust/evmc-declare/src/lib.rs b/bindings/rust/evmc-declare/src/lib.rs index 6a4a422..f158e11 100644 --- a/bindings/rust/evmc-declare/src/lib.rs +++ b/bindings/rust/evmc-declare/src/lib.rs @@ -296,7 +296,6 @@ fn build_create_fn(names: &VMNameSet) -> proc_macro2::TokenStream { execute: Some(__evmc_execute), get_capabilities: Some(__evmc_get_capabilities), 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 }, version: unsafe { ::std::ffi::CStr::from_bytes_with_nul_unchecked(#static_version_ident.as_bytes()).as_ptr() as *const i8 }, }; diff --git a/bindings/rust/evmc-vm/src/container.rs b/bindings/rust/evmc-vm/src/container.rs index 0c618f8..1b7f888 100644 --- a/bindings/rust/evmc-vm/src/container.rs +++ b/bindings/rust/evmc-vm/src/container.rs @@ -98,7 +98,6 @@ mod tests { destroy: None, execute: None, get_capabilities: None, - set_tracer: None, set_option: None, }; diff --git a/examples/example_precompiles_vm/example_precompiles_vm.cpp b/examples/example_precompiles_vm/example_precompiles_vm.cpp index 2335e8c..18644f1 100644 --- a/examples/example_precompiles_vm/example_precompiles_vm.cpp +++ b/examples/example_precompiles_vm/example_precompiles_vm.cpp @@ -121,7 +121,6 @@ extern "C" EVMC_EXPORT evmc_instance* evmc_create_example_precompiles_vm() execute, [](evmc_instance*) { return evmc_capabilities_flagset{EVMC_CAPABILITY_PRECOMPILES}; }, nullptr, - nullptr, }; return &instance; } diff --git a/include/evmc/evmc.h b/include/evmc/evmc.h index 4e1e0d8..3ccf248 100644 --- a/include/evmc/evmc.h +++ b/include/evmc/evmc.h @@ -854,84 +854,6 @@ typedef uint32_t evmc_capabilities_flagset; */ 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. @@ -990,17 +912,6 @@ struct evmc_instance */ 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. * diff --git a/include/evmc/helpers.h b/include/evmc/helpers.h index 0cb32c2..d2ab322 100644 --- a/include/evmc/helpers.h +++ b/include/evmc/helpers.h @@ -80,20 +80,6 @@ static inline enum evmc_set_option_result evmc_set_option(struct evmc_instance* 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. * diff --git a/test/unittests/test_cpp.cpp b/test/unittests/test_cpp.cpp index 1b5e2f6..e7d44d1 100644 --- a/test/unittests/test_cpp.cpp +++ b/test/unittests/test_cpp.cpp @@ -275,8 +275,7 @@ TEST(cpp, vm) TEST(cpp, vm_set_option) { - evmc_instance raw_instance = {EVMC_ABI_VERSION, "", "", nullptr, - nullptr, nullptr, nullptr, nullptr}; + evmc_instance raw_instance = {EVMC_ABI_VERSION, "", "", nullptr, nullptr, nullptr, nullptr}; raw_instance.destroy = [](evmc_instance*) {}; auto vm = evmc::VM{&raw_instance}; @@ -294,8 +293,8 @@ TEST(cpp, vm_move) { static int destroy_counter = 0; const auto template_instance = - evmc_instance{EVMC_ABI_VERSION, "", "", [](evmc_instance*) { ++destroy_counter; }, - nullptr, nullptr, nullptr, nullptr}; + evmc_instance{EVMC_ABI_VERSION, "", "", [](evmc_instance*) { ++destroy_counter; }, + nullptr, nullptr, nullptr}; EXPECT_EQ(destroy_counter, 0); { diff --git a/test/unittests/test_loader.cpp b/test/unittests/test_loader.cpp index 97b2eaa..80fc0b2 100644 --- a/test/unittests/test_loader.cpp +++ b/test/unittests/test_loader.cpp @@ -73,8 +73,8 @@ protected: /// Creates a VM mock with only destroy() method. static evmc_instance* create_vm_barebone() { - static auto instance = evmc_instance{EVMC_ABI_VERSION, "vm_barebone", "", destroy, - nullptr, nullptr, nullptr, nullptr}; + static auto instance = + evmc_instance{EVMC_ABI_VERSION, "vm_barebone", "", destroy, nullptr, nullptr, nullptr}; ++create_count; return &instance; } @@ -85,7 +85,7 @@ protected: constexpr auto wrong_abi_version = 1985; static_assert(wrong_abi_version != EVMC_ABI_VERSION, ""); static auto instance = - evmc_instance{wrong_abi_version, "", "", destroy, nullptr, nullptr, nullptr, nullptr}; + evmc_instance{wrong_abi_version, "", "", destroy, nullptr, nullptr, nullptr}; ++create_count; return &instance; } @@ -94,8 +94,7 @@ protected: static evmc_instance* create_vm_with_set_option() noexcept { static auto instance = evmc_instance{ - EVMC_ABI_VERSION, "vm_with_set_option", "", destroy, nullptr, nullptr, nullptr, - set_option}; + EVMC_ABI_VERSION, "vm_with_set_option", "", destroy, nullptr, nullptr, set_option}; ++create_count; return &instance; } diff --git a/test/vmtester/tests.cpp b/test/vmtester/tests.cpp index 916c349..32ebac9 100644 --- a/test/vmtester/tests.cpp +++ b/test/vmtester/tests.cpp @@ -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) { // This logic is based on and should match the description in EIP-2003.