From a066cf37299e560c4aac82c037e8f06d6aaf8115 Mon Sep 17 00:00:00 2001 From: Dmytro Kostenko Date: Fri, 3 Nov 2023 14:07:39 +0100 Subject: [PATCH] chore: remove logs and add address to getProof response --- .../core_libs/consensus/src/final_chain/final_chain.cpp | 3 +++ .../core_libs/consensus/src/final_chain/trie_common.cpp | 3 --- libraries/core_libs/network/rpc/eth/Eth.cpp | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) 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 dc1a98a910..bc2100facd 100644 --- a/libraries/core_libs/consensus/src/final_chain/final_chain.cpp +++ b/libraries/core_libs/consensus/src/final_chain/final_chain.cpp @@ -454,6 +454,9 @@ class FinalChainImpl final : public FinalChain { state_api::ProofResponse get_proof(EthBlockNumber blk_num, const addr_t& addr, const std::vector& keys) const override { auto h = get_block_header(blk_num); + if (!h) { + throw std::runtime_error("Future block"); + } return state_api_.get_proof(blk_num, addr, h->state_root, keys); } diff --git a/libraries/core_libs/consensus/src/final_chain/trie_common.cpp b/libraries/core_libs/consensus/src/final_chain/trie_common.cpp index 5673514553..3c3a33d519 100644 --- a/libraries/core_libs/consensus/src/final_chain/trie_common.cpp +++ b/libraries/core_libs/consensus/src/final_chain/trie_common.cpp @@ -111,9 +111,6 @@ h256 hash256(BytesMap const& _s) { HexMap hexMap; for (auto i = _s.rbegin(); i != _s.rend(); ++i) hexMap[asNibbles(bytesConstRef(&i->first))] = i->second; RLPStream s; - for (const auto& [k, v] : hexMap) { - std::cout << toHex(k) << ": " << toHex(v) << std::endl; - } hash256rlp(hexMap, hexMap.cbegin(), hexMap.cend(), 0, s); return sha3(s.out()); } diff --git a/libraries/core_libs/network/rpc/eth/Eth.cpp b/libraries/core_libs/network/rpc/eth/Eth.cpp index e1dac52faf..d227ce16df 100644 --- a/libraries/core_libs/network/rpc/eth/Eth.cpp +++ b/libraries/core_libs/network/rpc/eth/Eth.cpp @@ -333,10 +333,9 @@ class EthImpl : public Eth, EthParams { keys.reserve(_keys.size()); std::transform(_keys.begin(), _keys.end(), std::back_inserter(keys), [](const auto& k) { return jsToFixed<32>(k.asString()); }); - const auto proof = final_chain->get_proof(block_number, addr_t(_address), keys); - // std::cout << proof.storage_hash << std::endl; - // return to JS(final_chain->get_account_storage(toAddress(_address), jsToU256(_position), block_number)); - return toJson(proof); + auto proof = toJson(final_chain->get_proof(block_number, addr_t(_address), keys)); + proof["address"] = _address; + return proof; } void note_block_executed(const BlockHeader& blk_header, const SharedTransactions& trxs,