From 0f6abd5fad871c1ea504f7f548132162740942f5 Mon Sep 17 00:00:00 2001 From: Matus Kysel Date: Thu, 27 Apr 2023 10:37:42 +0200 Subject: [PATCH 1/5] feat: implement trace_replayTransaction --- libraries/core_libs/network/rpc/Debug.cpp | 52 +++++++++++++------ libraries/core_libs/network/rpc/Debug.h | 5 +- .../core_libs/network/rpc/Debug.jsonrpc.json | 9 ++++ libraries/core_libs/network/rpc/DebugClient.h | 11 ++++ libraries/core_libs/network/rpc/DebugFace.h | 8 +++ submodules/taraxa-evm | 2 +- 6 files changed, 70 insertions(+), 17 deletions(-) diff --git a/libraries/core_libs/network/rpc/Debug.cpp b/libraries/core_libs/network/rpc/Debug.cpp index 1a79ed1de9..4a94f48a10 100644 --- a/libraries/core_libs/network/rpc/Debug.cpp +++ b/libraries/core_libs/network/rpc/Debug.cpp @@ -15,19 +15,13 @@ namespace taraxa::net { Json::Value Debug::debug_traceTransaction(const std::string& transaction_hash) { Json::Value res; try { + auto [trx, loc] = get_transaction_with_location(transaction_hash); + if (!trx || !loc) { + res["status"] = "Transaction not found"; + return res; + } if (auto node = full_node_.lock()) { - const auto hash = jsToFixed<32>(transaction_hash); - const auto trx = node->getDB()->getTransaction(hash); - if (!trx) { - res["status"] = "Transaction not found"; - return res; - } - const auto loc = node->getFinalChain()->transaction_location(hash); - if (!loc) { - res["status"] = "Transaction not found"; - return res; - } - return util::readJsonFromString(node->getFinalChain()->trace_trx(to_eth_trx(trx), loc->blk_n)); + return util::readJsonFromString(node->getFinalChain()->trace_trx(to_eth_trx(std::move(trx)), loc->blk_n - 1)); } } catch (std::exception& e) { res["status"] = e.what(); @@ -65,6 +59,25 @@ Json::Value Debug::trace_call(const Json::Value& call_params, const Json::Value& return res; } +Json::Value Debug::trace_replayTransaction(const std::string& transaction_hash, const Json::Value& trace_params) { + Json::Value res; + try { + auto params = parse_tracking_parms(trace_params); + auto [trx, loc] = get_transaction_with_location(transaction_hash); + if (!trx || !loc) { + res["status"] = "Transaction not found"; + return res; + } + if (auto node = full_node_.lock()) { + return util::readJsonFromString( + node->getFinalChain()->trace_trx(to_eth_trx(std::move(trx)), loc->blk_n - 1, std::move(params))); + } + } catch (std::exception& e) { + res["status"] = e.what(); + } + return res; +} + state_api::Tracing Debug::parse_tracking_parms(const Json::Value& json) const { state_api::Tracing ret; if (!json.isArray() || json.empty()) { @@ -91,13 +104,13 @@ state_api::EVMTransaction Debug::to_eth_trx(const Json::Value& json, EthBlockNum } if (!json["from"].empty()) { - trx.from = toAddress(json["from"].asString()); + trx.from = to_address(json["from"].asString()); } else { trx.from = ZeroAddress; } if (!json["to"].empty() && json["to"].asString() != "0x" && !json["to"].asString().empty()) { - trx.to = toAddress(json["to"].asString()); + trx.to = to_address(json["to"].asString()); } if (!json["value"].empty()) { @@ -144,7 +157,7 @@ EthBlockNumber Debug::parse_blk_num(const string& blk_num_str) { return jsToInt(blk_num_str); } -Address Debug::toAddress(const string& s) const { +Address Debug::to_address(const string& s) const { try { if (auto b = fromHex(s.substr(0, 2) == "0x" ? s.substr(2) : s, WhenError::Throw); b.size() == Address::size) { return Address(b); @@ -154,4 +167,13 @@ Address Debug::toAddress(const string& s) const { throw InvalidAddress(); } +std::pair, std::optional> +Debug::get_transaction_with_location(const std::string& transaction_hash) const { + if (auto node = full_node_.lock()) { + const auto hash = jsToFixed<32>(transaction_hash); + return {node->getDB()->getTransaction(hash), node->getFinalChain()->transaction_location(hash)}; + } + return {}; +} + } // namespace taraxa::net \ No newline at end of file diff --git a/libraries/core_libs/network/rpc/Debug.h b/libraries/core_libs/network/rpc/Debug.h index 936e193177..19923be9d6 100644 --- a/libraries/core_libs/network/rpc/Debug.h +++ b/libraries/core_libs/network/rpc/Debug.h @@ -36,13 +36,16 @@ class Debug : public DebugFace { virtual Json::Value debug_traceCall(const Json::Value& param1, const std::string& param2) override; virtual Json::Value trace_call(const Json::Value& param1, const Json::Value& param2, const std::string& param3) override; + virtual Json::Value trace_replayTransaction(const std::string& param1, const Json::Value& param2) override; private: state_api::EVMTransaction to_eth_trx(std::shared_ptr t) const; state_api::EVMTransaction to_eth_trx(const Json::Value& json, EthBlockNumber blk_num); EthBlockNumber parse_blk_num(const string& blk_num_str); state_api::Tracing parse_tracking_parms(const Json::Value& json) const; - Address toAddress(const string& s) const; + Address to_address(const string& s) const; + std::pair, std::optional> + get_transaction_with_location(const std::string& transaction_hash) const; std::weak_ptr full_node_; const uint64_t kGasLimit = ((uint64_t)1 << 53) - 1; diff --git a/libraries/core_libs/network/rpc/Debug.jsonrpc.json b/libraries/core_libs/network/rpc/Debug.jsonrpc.json index 8a54721da9..ba0b72454c 100644 --- a/libraries/core_libs/network/rpc/Debug.jsonrpc.json +++ b/libraries/core_libs/network/rpc/Debug.jsonrpc.json @@ -25,5 +25,14 @@ ], "order": [], "returns": {} + }, + { + "name": "trace_replayTransaction", + "params": [ + "", + [] + ], + "order": [], + "returns": {} } ] \ No newline at end of file diff --git a/libraries/core_libs/network/rpc/DebugClient.h b/libraries/core_libs/network/rpc/DebugClient.h index 05d3904bd9..7aa5afc3b5 100644 --- a/libraries/core_libs/network/rpc/DebugClient.h +++ b/libraries/core_libs/network/rpc/DebugClient.h @@ -45,6 +45,17 @@ class DebugClient : public jsonrpc::Client { else throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); } + Json::Value trace_replayTransaction(const std::string& param1, + const Json::Value& param2) throw(jsonrpc::JsonRpcException) { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("trace_replayTransaction", p); + if (result.isObject()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } }; } // namespace net diff --git a/libraries/core_libs/network/rpc/DebugFace.h b/libraries/core_libs/network/rpc/DebugFace.h index 3411cecb00..086bf90673 100644 --- a/libraries/core_libs/network/rpc/DebugFace.h +++ b/libraries/core_libs/network/rpc/DebugFace.h @@ -22,6 +22,10 @@ class DebugFace : public ServerInterface { jsonrpc::Procedure("trace_call", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1", jsonrpc::JSON_OBJECT, "param2", jsonrpc::JSON_ARRAY, "param3", jsonrpc::JSON_STRING, NULL), &taraxa::net::DebugFace::trace_callI); + this->bindAndAddMethod( + jsonrpc::Procedure("trace_replayTransaction", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1", + jsonrpc::JSON_STRING, "param2", jsonrpc::JSON_ARRAY, NULL), + &taraxa::net::DebugFace::trace_replayTransactionI); } inline virtual void debug_traceTransactionI(const Json::Value& request, Json::Value& response) { @@ -33,9 +37,13 @@ class DebugFace : public ServerInterface { inline virtual void trace_callI(const Json::Value& request, Json::Value& response) { response = this->trace_call(request[0u], request[1u], request[2u].asString()); } + inline virtual void trace_replayTransactionI(const Json::Value& request, Json::Value& response) { + response = this->trace_replayTransaction(request[0u].asString(), request[1u]); + } virtual Json::Value debug_traceTransaction(const std::string& param1) = 0; virtual Json::Value debug_traceCall(const Json::Value& param1, const std::string& param2) = 0; virtual Json::Value trace_call(const Json::Value& param1, const Json::Value& param2, const std::string& param3) = 0; + virtual Json::Value trace_replayTransaction(const std::string& param1, const Json::Value& param2) = 0; }; } // namespace net diff --git a/submodules/taraxa-evm b/submodules/taraxa-evm index 9eaa5f51ce..983c116615 160000 --- a/submodules/taraxa-evm +++ b/submodules/taraxa-evm @@ -1 +1 @@ -Subproject commit 9eaa5f51ce4dba40ad2c123bca058b2eab0cc948 +Subproject commit 983c11661549954ad1d839347247511ff7759abe From c7ecdb98892409388e6bba2b138c9972defaaa70 Mon Sep 17 00:00:00 2001 From: Matus Kysel Date: Fri, 28 Apr 2023 08:16:25 +0200 Subject: [PATCH 2/5] feat: add support for tracking blocks --- .../include/final_chain/final_chain.hpp | 8 ++--- .../include/final_chain/state_api.hpp | 4 +-- .../consensus/src/final_chain/final_chain.cpp | 20 +++++------ .../consensus/src/final_chain/state_api.cpp | 10 +++--- libraries/core_libs/network/rpc/Debug.cpp | 33 ++++++++++++++++--- libraries/core_libs/network/rpc/Debug.h | 1 + .../core_libs/network/rpc/Debug.jsonrpc.json | 9 +++++ libraries/core_libs/network/rpc/DebugClient.h | 11 +++++++ libraries/core_libs/network/rpc/DebugFace.h | 8 +++++ submodules/taraxa-evm | 2 +- 10 files changed, 79 insertions(+), 27 deletions(-) diff --git a/libraries/core_libs/consensus/include/final_chain/final_chain.hpp b/libraries/core_libs/consensus/include/final_chain/final_chain.hpp index 30e97a429d..f2d7948c1f 100644 --- a/libraries/core_libs/consensus/include/final_chain/final_chain.hpp +++ b/libraries/core_libs/consensus/include/final_chain/final_chain.hpp @@ -177,14 +177,14 @@ class FinalChain { std::optional blk_n = {}) const = 0; /** - * @brief Trace execution of a new message call immediately without creating a transaction on the block chain. That + * @brief Trace execution of a new message call immediately without creating a transactions on the block chain. That * means that state would be reverted and not saved anywhere - * @param trx state_api::EVMTransaction + * @param trxs std::vector vector of transaction to trace * @param blk_n EthBlockNumber number of block we are getting state from * @return std::string */ - virtual std::string trace_trx(const state_api::EVMTransaction& trx, EthBlockNumber blk_n, - std::optional params = {}) const = 0; + virtual std::string trace(std::vector trx, EthBlockNumber blk_n, + std::optional params = {}) const = 0; /** * @brief total count of eligible votes are in DPOS precompiled contract diff --git a/libraries/core_libs/consensus/include/final_chain/state_api.hpp b/libraries/core_libs/consensus/include/final_chain/state_api.hpp index 5096eec020..c5349be356 100644 --- a/libraries/core_libs/consensus/include/final_chain/state_api.hpp +++ b/libraries/core_libs/consensus/include/final_chain/state_api.hpp @@ -38,8 +38,8 @@ class StateAPI { u256 get_account_storage(EthBlockNumber blk_num, const addr_t& addr, const u256& key) const; bytes get_code_by_address(EthBlockNumber blk_num, const addr_t& addr) const; ExecutionResult dry_run_transaction(EthBlockNumber blk_num, const EVMBlock& blk, const EVMTransaction& trx) const; - bytes trace_transaction(EthBlockNumber blk_num, const EVMBlock& blk, const EVMTransaction& trx, - std::optional params = {}) const; + bytes trace(EthBlockNumber blk_num, const EVMBlock& blk, const std::vector trx, + std::optional params = {}) const; StateDescriptor get_last_committed_state_descriptor() const; const StateTransitionResult& transition_state(const EVMBlock& block, const util::RangeView& transactions, diff --git a/libraries/core_libs/consensus/src/final_chain/final_chain.cpp b/libraries/core_libs/consensus/src/final_chain/final_chain.cpp index 212a2a2127..cd7d42cd97 100644 --- a/libraries/core_libs/consensus/src/final_chain/final_chain.cpp +++ b/libraries/core_libs/consensus/src/final_chain/final_chain.cpp @@ -407,17 +407,17 @@ class FinalChainImpl final : public FinalChain { trx); } - std::string trace_trx(const state_api::EVMTransaction& trx, EthBlockNumber blk_n, - std::optional params = {}) const override { + std::string trace(std::vector trxs, EthBlockNumber blk_n, + std::optional params = {}) const override { const auto blk_header = block_header(last_if_absent(blk_n)); - return dev::asString(state_api_.trace_transaction(blk_header->number, - { - blk_header->author, - blk_header->gas_limit, - blk_header->timestamp, - BlockHeader::difficulty(), - }, - trx, params)); + return dev::asString(state_api_.trace(blk_header->number, + { + blk_header->author, + blk_header->gas_limit, + blk_header->timestamp, + BlockHeader::difficulty(), + }, + trxs, params)); } uint64_t dpos_eligible_total_vote_count(EthBlockNumber blk_num) const override { diff --git a/libraries/core_libs/consensus/src/final_chain/state_api.cpp b/libraries/core_libs/consensus/src/final_chain/state_api.cpp index 7e18f6c408..6f0fa3a6a4 100644 --- a/libraries/core_libs/consensus/src/final_chain/state_api.cpp +++ b/libraries/core_libs/consensus/src/final_chain/state_api.cpp @@ -160,13 +160,13 @@ ExecutionResult StateAPI::dry_run_transaction(EthBlockNumber blk_num, const EVMB trx); } -bytes StateAPI::trace_transaction(EthBlockNumber blk_num, const EVMBlock& blk, const EVMTransaction& trx, - std::optional params) const { +bytes StateAPI::trace(EthBlockNumber blk_num, const EVMBlock& blk, const std::vector trxs, + std::optional params) const { if (params) { - return c_method_args_rlp(this_c_, blk_num, blk, trx, - *params); + return c_method_args_rlp(this_c_, blk_num, blk, trxs, + *params); } else { - return c_method_args_rlp(this_c_, blk_num, blk, trx); + return c_method_args_rlp(this_c_, blk_num, blk, trxs); } } diff --git a/libraries/core_libs/network/rpc/Debug.cpp b/libraries/core_libs/network/rpc/Debug.cpp index 4a94f48a10..3b506ebd69 100644 --- a/libraries/core_libs/network/rpc/Debug.cpp +++ b/libraries/core_libs/network/rpc/Debug.cpp @@ -21,7 +21,7 @@ Json::Value Debug::debug_traceTransaction(const std::string& transaction_hash) { return res; } if (auto node = full_node_.lock()) { - return util::readJsonFromString(node->getFinalChain()->trace_trx(to_eth_trx(std::move(trx)), loc->blk_n - 1)); + return util::readJsonFromString(node->getFinalChain()->trace({to_eth_trx(std::move(trx))}, loc->blk_n - 1)); } } catch (std::exception& e) { res["status"] = e.what(); @@ -35,7 +35,7 @@ Json::Value Debug::debug_traceCall(const Json::Value& call_params, const std::st const auto block = parse_blk_num(blk_num); auto trx = to_eth_trx(call_params, block); if (auto node = full_node_.lock()) { - return util::readJsonFromString(node->getFinalChain()->trace_trx(std::move(trx), block)); + return util::readJsonFromString(node->getFinalChain()->trace({std::move(trx)}, block)); } } catch (std::exception& e) { res["status"] = e.what(); @@ -48,10 +48,10 @@ Json::Value Debug::trace_call(const Json::Value& call_params, const Json::Value& Json::Value res; try { const auto block = parse_blk_num(blk_num); - auto trx = to_eth_trx(call_params, block); auto params = parse_tracking_parms(trace_params); if (auto node = full_node_.lock()) { - return util::readJsonFromString(node->getFinalChain()->trace_trx(std::move(trx), block, std::move(params))); + return util::readJsonFromString( + node->getFinalChain()->trace({to_eth_trx(call_params, block)}, block, std::move(params))); } } catch (std::exception& e) { res["status"] = e.what(); @@ -70,7 +70,30 @@ Json::Value Debug::trace_replayTransaction(const std::string& transaction_hash, } if (auto node = full_node_.lock()) { return util::readJsonFromString( - node->getFinalChain()->trace_trx(to_eth_trx(std::move(trx)), loc->blk_n - 1, std::move(params))); + node->getFinalChain()->trace({to_eth_trx(std::move(trx))}, loc->blk_n - 1, std::move(params))); + } + } catch (std::exception& e) { + res["status"] = e.what(); + } + return res; +} + +Json::Value Debug::trace_replayBlockTransactions(const std::string& block_num, const Json::Value& trace_params) { + Json::Value res; + try { + const auto block = parse_blk_num(block_num); + auto params = parse_tracking_parms(trace_params); + if (auto node = full_node_.lock()) { + auto transactions = node->getDB()->getPeriodTransactions(block); + if (!transactions.has_value() || transactions->empty()) { + res["status"] = "Block has no transactions"; + return res; + } + std::vector trxs; + trxs.reserve(transactions->size()); + std::transform(transactions->begin(), transactions->end(), std::back_inserter(trxs), + [this](auto t) { return to_eth_trx(std::move(t)); }); + return util::readJsonFromString(node->getFinalChain()->trace(std::move(trxs), block - 1, std::move(params))); } } catch (std::exception& e) { res["status"] = e.what(); diff --git a/libraries/core_libs/network/rpc/Debug.h b/libraries/core_libs/network/rpc/Debug.h index 19923be9d6..d318f9deee 100644 --- a/libraries/core_libs/network/rpc/Debug.h +++ b/libraries/core_libs/network/rpc/Debug.h @@ -37,6 +37,7 @@ class Debug : public DebugFace { virtual Json::Value trace_call(const Json::Value& param1, const Json::Value& param2, const std::string& param3) override; virtual Json::Value trace_replayTransaction(const std::string& param1, const Json::Value& param2) override; + virtual Json::Value trace_replayBlockTransactions(const std::string& param1, const Json::Value& param2) override; private: state_api::EVMTransaction to_eth_trx(std::shared_ptr t) const; diff --git a/libraries/core_libs/network/rpc/Debug.jsonrpc.json b/libraries/core_libs/network/rpc/Debug.jsonrpc.json index ba0b72454c..88c5411af1 100644 --- a/libraries/core_libs/network/rpc/Debug.jsonrpc.json +++ b/libraries/core_libs/network/rpc/Debug.jsonrpc.json @@ -34,5 +34,14 @@ ], "order": [], "returns": {} + }, + { + "name": "trace_replayBlockTransactions", + "params": [ + "", + [] + ], + "order": [], + "returns": {} } ] \ No newline at end of file diff --git a/libraries/core_libs/network/rpc/DebugClient.h b/libraries/core_libs/network/rpc/DebugClient.h index 7aa5afc3b5..f0faaf58ec 100644 --- a/libraries/core_libs/network/rpc/DebugClient.h +++ b/libraries/core_libs/network/rpc/DebugClient.h @@ -56,6 +56,17 @@ class DebugClient : public jsonrpc::Client { else throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); } + Json::Value trace_replayBlockTransactions(const std::string& param1, + const Json::Value& param2) throw(jsonrpc::JsonRpcException) { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("trace_replayBlockTransactions", p); + if (result.isObject()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } }; } // namespace net diff --git a/libraries/core_libs/network/rpc/DebugFace.h b/libraries/core_libs/network/rpc/DebugFace.h index 086bf90673..fbfd16f363 100644 --- a/libraries/core_libs/network/rpc/DebugFace.h +++ b/libraries/core_libs/network/rpc/DebugFace.h @@ -26,6 +26,10 @@ class DebugFace : public ServerInterface { jsonrpc::Procedure("trace_replayTransaction", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1", jsonrpc::JSON_STRING, "param2", jsonrpc::JSON_ARRAY, NULL), &taraxa::net::DebugFace::trace_replayTransactionI); + this->bindAndAddMethod( + jsonrpc::Procedure("trace_replayBlockTransactions", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1", + jsonrpc::JSON_STRING, "param2", jsonrpc::JSON_ARRAY, NULL), + &taraxa::net::DebugFace::trace_replayBlockTransactionsI); } inline virtual void debug_traceTransactionI(const Json::Value& request, Json::Value& response) { @@ -40,10 +44,14 @@ class DebugFace : public ServerInterface { inline virtual void trace_replayTransactionI(const Json::Value& request, Json::Value& response) { response = this->trace_replayTransaction(request[0u].asString(), request[1u]); } + inline virtual void trace_replayBlockTransactionsI(const Json::Value& request, Json::Value& response) { + response = this->trace_replayBlockTransactions(request[0u].asString(), request[1u]); + } virtual Json::Value debug_traceTransaction(const std::string& param1) = 0; virtual Json::Value debug_traceCall(const Json::Value& param1, const std::string& param2) = 0; virtual Json::Value trace_call(const Json::Value& param1, const Json::Value& param2, const std::string& param3) = 0; virtual Json::Value trace_replayTransaction(const std::string& param1, const Json::Value& param2) = 0; + virtual Json::Value trace_replayBlockTransactions(const std::string& param1, const Json::Value& param2) = 0; }; } // namespace net diff --git a/submodules/taraxa-evm b/submodules/taraxa-evm index 983c116615..67b732df89 160000 --- a/submodules/taraxa-evm +++ b/submodules/taraxa-evm @@ -1 +1 @@ -Subproject commit 983c11661549954ad1d839347247511ff7759abe +Subproject commit 67b732df89bdded116837c03589d2da3a6b0f64c From 72e47567ade29e17cfbe5abb2606c61ce2375daf Mon Sep 17 00:00:00 2001 From: Matus Kysel Date: Tue, 2 May 2023 11:59:35 +0200 Subject: [PATCH 3/5] chore: add check for block 0 --- libraries/core_libs/network/rpc/Debug.cpp | 16 ++++++++++++---- submodules/taraxa-evm | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libraries/core_libs/network/rpc/Debug.cpp b/libraries/core_libs/network/rpc/Debug.cpp index 3b506ebd69..4e5e93b315 100644 --- a/libraries/core_libs/network/rpc/Debug.cpp +++ b/libraries/core_libs/network/rpc/Debug.cpp @@ -12,6 +12,11 @@ using namespace jsonrpc; using namespace taraxa; namespace taraxa::net { + +inline EthBlockNumber get_ctx_block_num(EthBlockNumber block_number) { + return (block_number >= 1) ? block_number - 1 : 0; +} + Json::Value Debug::debug_traceTransaction(const std::string& transaction_hash) { Json::Value res; try { @@ -21,7 +26,8 @@ Json::Value Debug::debug_traceTransaction(const std::string& transaction_hash) { return res; } if (auto node = full_node_.lock()) { - return util::readJsonFromString(node->getFinalChain()->trace({to_eth_trx(std::move(trx))}, loc->blk_n - 1)); + return util::readJsonFromString( + node->getFinalChain()->trace({to_eth_trx(std::move(trx))}, get_ctx_block_num(loc->blk_n))); } } catch (std::exception& e) { res["status"] = e.what(); @@ -70,7 +76,7 @@ Json::Value Debug::trace_replayTransaction(const std::string& transaction_hash, } if (auto node = full_node_.lock()) { return util::readJsonFromString( - node->getFinalChain()->trace({to_eth_trx(std::move(trx))}, loc->blk_n - 1, std::move(params))); + node->getFinalChain()->trace({to_eth_trx(std::move(trx))}, get_ctx_block_num(loc->blk_n), std::move(params))); } } catch (std::exception& e) { res["status"] = e.what(); @@ -93,7 +99,8 @@ Json::Value Debug::trace_replayBlockTransactions(const std::string& block_num, c trxs.reserve(transactions->size()); std::transform(transactions->begin(), transactions->end(), std::back_inserter(trxs), [this](auto t) { return to_eth_trx(std::move(t)); }); - return util::readJsonFromString(node->getFinalChain()->trace(std::move(trxs), block - 1, std::move(params))); + return util::readJsonFromString( + node->getFinalChain()->trace(std::move(trxs), get_ctx_block_num(block), std::move(params))); } } catch (std::exception& e) { res["status"] = e.what(); @@ -108,7 +115,8 @@ state_api::Tracing Debug::parse_tracking_parms(const Json::Value& json) const { } for (const auto& obj : json) { if (obj.asString() == "trace") ret.trace = true; - if (obj.asString() == "stateDiff") ret.stateDiff = true; + // Disabled for now + // if (obj.asString() == "stateDiff") ret.stateDiff = true; if (obj.asString() == "vmTrace") ret.vmTrace = true; } return ret; diff --git a/submodules/taraxa-evm b/submodules/taraxa-evm index 67b732df89..6dafb2e792 160000 --- a/submodules/taraxa-evm +++ b/submodules/taraxa-evm @@ -1 +1 @@ -Subproject commit 67b732df89bdded116837c03589d2da3a6b0f64c +Subproject commit 6dafb2e79278cff343293b82ba25198924b8aed2 From d92796a0e89b9e450fde9eda8380eabb57c45f2b Mon Sep 17 00:00:00 2001 From: Matus Kysel Date: Tue, 2 May 2023 13:09:53 +0200 Subject: [PATCH 4/5] chore: simplify code --- .../core_libs/consensus/src/final_chain/state_api.cpp | 8 ++------ submodules/taraxa-evm | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/libraries/core_libs/consensus/src/final_chain/state_api.cpp b/libraries/core_libs/consensus/src/final_chain/state_api.cpp index 6f0fa3a6a4..7cf3e17657 100644 --- a/libraries/core_libs/consensus/src/final_chain/state_api.cpp +++ b/libraries/core_libs/consensus/src/final_chain/state_api.cpp @@ -162,12 +162,8 @@ ExecutionResult StateAPI::dry_run_transaction(EthBlockNumber blk_num, const EVMB bytes StateAPI::trace(EthBlockNumber blk_num, const EVMBlock& blk, const std::vector trxs, std::optional params) const { - if (params) { - return c_method_args_rlp(this_c_, blk_num, blk, trxs, - *params); - } else { - return c_method_args_rlp(this_c_, blk_num, blk, trxs); - } + return c_method_args_rlp(this_c_, blk_num, blk, trxs, + params); } StateDescriptor StateAPI::get_last_committed_state_descriptor() const { diff --git a/submodules/taraxa-evm b/submodules/taraxa-evm index 6dafb2e792..f12d621f69 160000 --- a/submodules/taraxa-evm +++ b/submodules/taraxa-evm @@ -1 +1 @@ -Subproject commit 6dafb2e79278cff343293b82ba25198924b8aed2 +Subproject commit f12d621f69f58a9fe17abf8f5064233a4b64e255 From 1ec921d75129bf6711e40227635e2d64400336f1 Mon Sep 17 00:00:00 2001 From: Matus Kysel Date: Wed, 3 May 2023 07:52:24 +0200 Subject: [PATCH 5/5] chore: update evm --- submodules/taraxa-evm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/taraxa-evm b/submodules/taraxa-evm index f12d621f69..88ab801e01 160000 --- a/submodules/taraxa-evm +++ b/submodules/taraxa-evm @@ -1 +1 @@ -Subproject commit f12d621f69f58a9fe17abf8f5064233a4b64e255 +Subproject commit 88ab801e01aa6ceb15a5dc21a289a23111594195