From b691670f9a62eccb09d4aba79db9a572a198a3e3 Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Fri, 24 May 2024 17:12:36 -0300 Subject: [PATCH] Slight changes to adapt to 5.0 updates, around http api macro, eosvmoc access sepcifically --- libraries/libfc/src/network/http/http_client.cpp | 4 ++-- plugins/subst_api_plugin/api.hpp | 16 ++++++++++------ plugins/subst_api_plugin/subst_api_plugin.cpp | 12 ++++++------ plugins/subst_plugin/substitution_context.cpp | 4 ++-- plugins/subst_plugin/substitution_context.hpp | 9 ++------- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/libraries/libfc/src/network/http/http_client.cpp b/libraries/libfc/src/network/http/http_client.cpp index ced202e570..6473312240 100644 --- a/libraries/libfc/src/network/http/http_client.cpp +++ b/libraries/libfc/src/network/http/http_client.cpp @@ -255,12 +255,12 @@ class http_client_impl { auto deadline = epoch + boost::posix_time::microseconds(_deadline.time_since_epoch().count()); FC_ASSERT(dest.host(), "No host set on URL"); - string path = dest.path() ? dest.path()->generic_string() : "/"; + std::string path = dest.path() ? dest.path()->generic_string() : "/"; if (dest.query()) { path = path + "?" + *dest.query(); } - string host_str = *dest.host(); + std::string host_str = *dest.host(); if (dest.port()) { auto port = *dest.port(); auto proto_iter = default_proto_ports.find(dest.proto()); diff --git a/plugins/subst_api_plugin/api.hpp b/plugins/subst_api_plugin/api.hpp index 54b4f56f4f..796167f1ed 100644 --- a/plugins/subst_api_plugin/api.hpp +++ b/plugins/subst_api_plugin/api.hpp @@ -3,22 +3,25 @@ #include "subst_plugin.hpp" -#define CALL_WITH_400(api_name, api_handle, api_namespace, call_name, http_response_code, params_type) \ +#define CALL_WITH_400(api_name, category, api_handle, api_namespace, call_name, http_response_code, params_type) \ {std::string("/v1/" #api_name "/" #call_name), \ + api_category::category,\ [api_handle](string&&, string&& body, url_response_callback&& cb) mutable { \ auto deadline = api_handle.start(); \ try { \ auto params = parse_params(body);\ - FC_CHECK_DEADLINE(deadline);\ fc::variant result( api_handle.call_name( std::move(params), deadline ) ); \ - cb(http_response_code, deadline, std::move(result)); \ + cb(http_response_code, std::move(result)); \ } catch (...) { \ http_plugin::handle_exception(#api_name, #call_name, body, cb); \ } \ }} -#define SUBST_CALL(call_name, http_response_code, params_type) \ - CALL_WITH_400(subst, subst_api, eosio::subst_apis, call_name, http_response_code, params_type) +#define SUBST_RO_CALL(call_name, http_response_code, params_type) \ + CALL_WITH_400(subst, chain_ro, subst_api, eosio::subst_apis, call_name, http_response_code, params_type) + +#define SUBST_RW_CALL(call_name, http_response_code, params_type) \ + CALL_WITH_400(subst, chain_rw, subst_api, eosio::subst_apis, call_name, http_response_code, params_type) namespace eosio { @@ -131,12 +134,13 @@ namespace eosio { #ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED // if oc mode is enabled fetch code descriptor - std::optional& eosvmoc = sctx.get_eosvmoc(); + auto& eosvmoc = sctx.get_eosvmoc(); if (eosvmoc && meta->og_hash() != digest_type()) { status_eosvmoc_cache ocvm_status; chain::eosvmoc::code_cache_base::get_cd_failure failure = chain::eosvmoc::code_cache_base::get_cd_failure::temporary; const code_descriptor* cd = eosvmoc->cc.get_descriptor_for_code( + true, code_obj->code_hash, code_obj->vm_version, false, diff --git a/plugins/subst_api_plugin/subst_api_plugin.cpp b/plugins/subst_api_plugin/subst_api_plugin.cpp index 70b9dd4ce6..b6becdfa75 100644 --- a/plugins/subst_api_plugin/subst_api_plugin.cpp +++ b/plugins/subst_api_plugin/subst_api_plugin.cpp @@ -25,7 +25,7 @@ namespace eosio { // read only _http_plugin->add_api({ - SUBST_CALL(status, 200, http_params_types::possible_no_params) + SUBST_RO_CALL(status, 200, http_params_types::possible_no_params) }, appbase::exec_queue::read_only); @@ -34,12 +34,12 @@ namespace eosio { wlog("subst-admin-apis enabled, don\'t expose these to "); _http_plugin->add_api({ - SUBST_CALL(upsert, 200, http_params_types::params_required), - SUBST_CALL(activate, 200, http_params_types::possible_no_params), - SUBST_CALL(deactivate, 200, http_params_types::possible_no_params), - SUBST_CALL(remove, 200, http_params_types::possible_no_params), + SUBST_RW_CALL(upsert, 200, http_params_types::params_required), + SUBST_RW_CALL(activate, 200, http_params_types::possible_no_params), + SUBST_RW_CALL(deactivate, 200, http_params_types::possible_no_params), + SUBST_RW_CALL(remove, 200, http_params_types::possible_no_params), - SUBST_CALL(fetch_manifest, 200, http_params_types::no_params) + SUBST_RW_CALL(fetch_manifest, 200, http_params_types::no_params) }, appbase::exec_queue::read_write, appbase::priority::highest); } diff --git a/plugins/subst_plugin/substitution_context.cpp b/plugins/subst_plugin/substitution_context.cpp index 324bc8cb93..bb1d0fdc62 100644 --- a/plugins/subst_plugin/substitution_context.cpp +++ b/plugins/subst_plugin/substitution_context.cpp @@ -186,7 +186,7 @@ namespace eosio { #ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED // remove eosvmoc code cache if present - std::optional& eosvmoc = get_eosvmoc(); + auto& eosvmoc = get_eosvmoc(); if (eosvmoc) { eosvmoc->cc.free_code(cobj->code_hash, cobj->vm_version); @@ -336,7 +336,7 @@ namespace eosio { auto it = manif_obj.find(chain_id); if (it != manif_obj.end()) { for (auto subst_entry : (*it).value().get_object()) { - bpath url_path = *(target_url.path()); + std::filesystem::path url_path = *(target_url.path()); auto wasm_url_path = url_path.remove_filename() / chain_id / subst_entry.value().get_string(); auto wasm_url = fc::url( diff --git a/plugins/subst_plugin/substitution_context.hpp b/plugins/subst_plugin/substitution_context.hpp index 06885db1be..9210224f14 100644 --- a/plugins/subst_plugin/substitution_context.hpp +++ b/plugins/subst_plugin/substitution_context.hpp @@ -22,9 +22,6 @@ #endif -typedef boost::filesystem::path bpath; - - namespace http = boost::beast::http; @@ -41,8 +38,6 @@ namespace eosio { #ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED using chain::eosvmoc::code_descriptor; using chain::eosvmoc::code_cache_async; - - typedef chain::wasm_interface_impl::eosvmoc_tier eosvmoc_tier; #endif struct by_account; @@ -127,8 +122,8 @@ namespace eosio { void reset_caches(const name& account); #ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED - // get a reference to wasm iface eosvmoc_tier optional field - std::optional& get_eosvmoc() { + // get ptr to wasm iface eosvmoc_tier + std::unique_ptr& get_eosvmoc() { return control->get_wasm_interface().my->eosvmoc; } #endif