diff --git a/CMakeModules/cpp_graphql_gen.cmake b/CMakeModules/cpp_graphql_gen.cmake index 8cfbcfbafe..1ee15d1f86 100644 --- a/CMakeModules/cpp_graphql_gen.cmake +++ b/CMakeModules/cpp_graphql_gen.cmake @@ -1,4 +1,4 @@ -########### cppgraphqlgen ########### +# ########## cppgraphqlgen ########### include(FetchContent) set(Boost_NO_WARN_NEW_VERSIONS 1) @@ -6,36 +6,41 @@ set(Boost_NO_WARN_NEW_VERSIONS 1) FetchContent_Declare( cppgraphqlgen GIT_REPOSITORY https://github.com/microsoft/cppgraphqlgen.git - GIT_TAG 8c1623acc42392ef2a1bc0336482621386f98c77 # v4.5.0 + GIT_TAG 8c1623acc42392ef2a1bc0336482621386f98c77 # v4.5.0 ) set(GRAPHQL_BUILD_TESTS OFF) set(GRAPHQL_UPDATE_VERSION OFF) set(GRAPHQL_UPDATE_SAMPLES OFF) -#set(GRAPHQL_BUILD_SCHEMAGEN OFF) + +# set(GRAPHQL_BUILD_SCHEMAGEN OFF) set(GRAPHQL_BUILD_CLIENTGEN OFF) FetchContent_MakeAvailable(cppgraphqlgen) -###################################### + +# ##################################### set(GRAPHQL_GEN_DIR ${CMAKE_CURRENT_SOURCE_DIR}/network/graphql/gen) list(APPEND GRAPHQL_GENERATED_SOURCES - ${GRAPHQL_GEN_DIR}/AccountObject.cpp - ${GRAPHQL_GEN_DIR}/BlockObject.cpp - ${GRAPHQL_GEN_DIR}/CallResultObject.cpp - ${GRAPHQL_GEN_DIR}/CurrentStateObject.cpp - ${GRAPHQL_GEN_DIR}/DagBlockObject.cpp - ${GRAPHQL_GEN_DIR}/LogObject.cpp - ${GRAPHQL_GEN_DIR}/MutationObject.cpp - ${GRAPHQL_GEN_DIR}/PendingObject.cpp - ${GRAPHQL_GEN_DIR}/QueryObject.cpp - ${GRAPHQL_GEN_DIR}/SubscriptionObject.cpp - ${GRAPHQL_GEN_DIR}/SyncStateObject.cpp - ${GRAPHQL_GEN_DIR}/TaraxaSchema.cpp - ${GRAPHQL_GEN_DIR}/TransactionObject.cpp + ${GRAPHQL_GEN_DIR}/AccountObject.cpp + ${GRAPHQL_GEN_DIR}/BlockObject.cpp + ${GRAPHQL_GEN_DIR}/CallResultObject.cpp + ${GRAPHQL_GEN_DIR}/CurrentStateObject.cpp + ${GRAPHQL_GEN_DIR}/DagBlockObject.cpp + ${GRAPHQL_GEN_DIR}/LogObject.cpp + ${GRAPHQL_GEN_DIR}/MutationObject.cpp + ${GRAPHQL_GEN_DIR}/PendingObject.cpp + ${GRAPHQL_GEN_DIR}/QueryObject.cpp + ${GRAPHQL_GEN_DIR}/SubscriptionObject.cpp + ${GRAPHQL_GEN_DIR}/SyncStateObject.cpp + ${GRAPHQL_GEN_DIR}/TaraxaSchema.cpp + ${GRAPHQL_GEN_DIR}/TransactionObject.cpp ) -add_custom_command(OUTPUT ${GRAPHQL_GENERATED_SOURCES} - COMMAND ${CMAKE_COMMAND} -E remove -f ${GRAPHQL_GEN_DIR}/*.cpp - COMMAND ${CMAKE_COMMAND} -E remove -f ${GRAPHQL_GEN_DIR}/*.h - COMMAND cppgraphqlgen::schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/network/graphql/schema/schema.taraxa.graphql" --prefix="Taraxa" --namespace="taraxa" - WORKING_DIRECTORY ${GRAPHQL_GEN_DIR} - COMMENT "Regenerating TaraxaSchema files") +add_custom_command( + OUTPUT ${GRAPHQL_GENERATED_SOURCES} + COMMAND ${CMAKE_COMMAND} -E remove -f ${GRAPHQL_GEN_DIR}/*.cpp + COMMAND ${CMAKE_COMMAND} -E remove -f ${GRAPHQL_GEN_DIR}/*.h + COMMAND cppgraphqlgen::schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/network/graphql/schema/schema.taraxa.graphql" --prefix="Taraxa" --namespace="taraxa" + WORKING_DIRECTORY ${GRAPHQL_GEN_DIR} + COMMENT "Regenerating TaraxaSchema files" + DEPENDS ${GRAPHQL_GEN_DIR}/../schema/schema.taraxa.graphql +) diff --git a/libraries/core_libs/CMakeLists.txt b/libraries/core_libs/CMakeLists.txt index b7bb353dcd..5eae61bbb9 100644 --- a/libraries/core_libs/CMakeLists.txt +++ b/libraries/core_libs/CMakeLists.txt @@ -5,6 +5,7 @@ file(GLOB_RECURSE CONSENSUS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/consensus/*.cpp) file(GLOB_RECURSE NETWORK_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/network/*.hpp) file(GLOB_RECURSE NETWORK_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/network/*.cpp) + # GraphQL include(${PROJECT_SOURCE_DIR}/CMakeModules/cpp_graphql_gen.cmake) file(GLOB_RECURSE NETWORK_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/network/*.h) @@ -16,18 +17,20 @@ file(GLOB_RECURSE NODE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/node/*.hpp) file(GLOB_RECURSE NODE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/node/*.cpp) set(HEADERS - ${CONSENSUS_HEADERS} - ${NETWORK_HEADERS} - ${STORAGE_HEADERS} - ${NODE_HEADERS} + ${CONSENSUS_HEADERS} + ${NETWORK_HEADERS} + ${STORAGE_HEADERS} + ${NODE_HEADERS} + ${REWARDS_HEADERS} ) set(SOURCES - ${CONSENSUS_SOURCES} - ${NETWORK_SOURCES} - ${STORAGE_SOURCES} - ${NODE_SOURCES} - ${GRAPHQL_GENERATED_SOURCES} + ${CONSENSUS_SOURCES} + ${NETWORK_SOURCES} + ${STORAGE_SOURCES} + ${NODE_SOURCES} + ${GRAPHQL_GENERATED_SOURCES} + ${REWARDS_SOURCES} ) add_library(core_libs ${SOURCES} ${HEADERS}) @@ -37,25 +40,26 @@ target_include_directories(core_libs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/network/ target_include_directories(core_libs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/node/include) target_include_directories(core_libs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/storage/include) target_include_directories(core_libs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + # GraphQL target_include_directories(core_libs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/network/graphql/gen) target_include_directories(core_libs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/network/graphql/include) target_link_libraries(core_libs PUBLIC - cli - pbft_block - taraxa-evm - p2p - metrics - Jsonrpccpp - CONAN_PKG::rocksdb -# GraphQL - cppgraphqlgen::graphqlservice - cppgraphqlgen::graphqljson -) + cli + pbft_block + taraxa-evm + p2p + metrics + Jsonrpccpp + CONAN_PKG::rocksdb + # GraphQL + cppgraphqlgen::graphqlservice + cppgraphqlgen::graphqljson +) install(TARGETS core_libs - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) \ No newline at end of file diff --git a/libraries/core_libs/network/graphql/include/graphql/block.hpp b/libraries/core_libs/network/graphql/include/graphql/block.hpp index f253382002..cbee097866 100644 --- a/libraries/core_libs/network/graphql/include/graphql/block.hpp +++ b/libraries/core_libs/network/graphql/include/graphql/block.hpp @@ -8,15 +8,17 @@ #include "transaction/transaction_manager.hpp" namespace graphql::taraxa { - class Block { public: explicit Block(std::shared_ptr<::taraxa::final_chain::FinalChain> final_chain, std::shared_ptr<::taraxa::TransactionManager> trx_manager, + std::function(::taraxa::EthBlockNumber)> get_block_by_num, + const ::taraxa::blk_hash_t& pbft_block_hash, std::shared_ptr block_header) noexcept; response::Value getNumber() const noexcept; response::Value getHash() const noexcept; + response::Value getPbftHash() const noexcept; std::shared_ptr getParent() const noexcept; response::Value getNonce() const noexcept; response::Value getTransactionsRoot() const noexcept; @@ -46,6 +48,8 @@ class Block { private: std::shared_ptr<::taraxa::final_chain::FinalChain> final_chain_; std::shared_ptr<::taraxa::TransactionManager> trx_manager_; + std::function(::taraxa::EthBlockNumber)> get_block_by_num_; + const ::taraxa::blk_hash_t kPBftBlockHash; std::shared_ptr block_header_; mutable std::vector> transactions_; }; diff --git a/libraries/core_libs/network/graphql/include/graphql/query.hpp b/libraries/core_libs/network/graphql/include/graphql/query.hpp index 78dc542fab..237e673689 100644 --- a/libraries/core_libs/network/graphql/include/graphql/query.hpp +++ b/libraries/core_libs/network/graphql/include/graphql/query.hpp @@ -3,6 +3,7 @@ #include "QueryObject.h" #include "dag/dag_manager.hpp" #include "final_chain/final_chain.hpp" +#include "graphql/block.hpp" #include "network/network.hpp" #include "pbft/pbft_manager.hpp" #include "transaction/gas_pricer.hpp" @@ -46,6 +47,7 @@ class Query { std::shared_ptr<::taraxa::GasPricer> gas_pricer_; std::weak_ptr<::taraxa::Network> network_; const uint64_t kChainId; + std::function(::taraxa::EthBlockNumber)> get_block_by_num_; }; } // namespace graphql::taraxa \ No newline at end of file diff --git a/libraries/core_libs/network/graphql/include/graphql/transaction.hpp b/libraries/core_libs/network/graphql/include/graphql/transaction.hpp index 63e7fbd059..300d442e9e 100644 --- a/libraries/core_libs/network/graphql/include/graphql/transaction.hpp +++ b/libraries/core_libs/network/graphql/include/graphql/transaction.hpp @@ -14,6 +14,7 @@ class Transaction final : public std::enable_shared_from_this { public: explicit Transaction(std::shared_ptr<::taraxa::final_chain::FinalChain> final_chain, std::shared_ptr<::taraxa::TransactionManager> trx_manager, + std::function(::taraxa::EthBlockNumber)>, std::shared_ptr<::taraxa::Transaction> transaction) noexcept; response::Value getHash() const noexcept; @@ -38,6 +39,7 @@ class Transaction final : public std::enable_shared_from_this { private: std::shared_ptr<::taraxa::final_chain::FinalChain> final_chain_; std::shared_ptr<::taraxa::TransactionManager> trx_manager_; + std::function(::taraxa::EthBlockNumber)> get_block_by_num_; std::shared_ptr<::taraxa::Transaction> transaction_; // Caching for performance mutable std::optional<::taraxa::final_chain::TransactionReceipt> receipt_; diff --git a/libraries/core_libs/network/graphql/include/graphql/types/dag_block.hpp b/libraries/core_libs/network/graphql/include/graphql/types/dag_block.hpp index 8267135dbe..6ef037d513 100644 --- a/libraries/core_libs/network/graphql/include/graphql/types/dag_block.hpp +++ b/libraries/core_libs/network/graphql/include/graphql/types/dag_block.hpp @@ -12,7 +12,8 @@ class DagBlock { explicit DagBlock(std::shared_ptr<::taraxa::DagBlock> dag_block, std::shared_ptr<::taraxa::final_chain::FinalChain> final_chain, std::shared_ptr<::taraxa::PbftManager> pbft_manager, - std::shared_ptr<::taraxa::TransactionManager> transaction_manager) noexcept; + std::shared_ptr<::taraxa::TransactionManager> transaction_manager, + std::function(::taraxa::EthBlockNumber)> get_block_by_num) noexcept; response::Value getHash() const noexcept; response::Value getPivot() const noexcept; @@ -31,6 +32,7 @@ class DagBlock { std::shared_ptr<::taraxa::final_chain::FinalChain> final_chain_; std::shared_ptr<::taraxa::PbftManager> pbft_manager_; std::shared_ptr<::taraxa::TransactionManager> transaction_manager_; + std::function(::taraxa::EthBlockNumber)> get_block_by_num_; mutable std::optional period_; }; diff --git a/libraries/core_libs/network/graphql/schema/schema.taraxa.graphql b/libraries/core_libs/network/graphql/schema/schema.taraxa.graphql index 4bfad2bbb2..4c9c7267ee 100644 --- a/libraries/core_libs/network/graphql/schema/schema.taraxa.graphql +++ b/libraries/core_libs/network/graphql/schema/schema.taraxa.graphql @@ -159,6 +159,8 @@ type Block { number: Long! # Hash is the block hash of this block. hash: Bytes32! + # Pbft hash of this block. + pbftHash: Bytes32! # Parent is the parent block of this block. parent: Block # Nonce is the block nonce, an 8 byte sequence determined by the miner. diff --git a/libraries/core_libs/network/graphql/src/block.cpp b/libraries/core_libs/network/graphql/src/block.cpp index da39f2f36b..9158d37e1c 100644 --- a/libraries/core_libs/network/graphql/src/block.cpp +++ b/libraries/core_libs/network/graphql/src/block.cpp @@ -13,19 +13,23 @@ namespace graphql::taraxa { Block::Block(std::shared_ptr<::taraxa::final_chain::FinalChain> final_chain, std::shared_ptr<::taraxa::TransactionManager> trx_manager, + std::function(::taraxa::EthBlockNumber)> get_block_by_num, + const ::taraxa::blk_hash_t& pbft_block_hash, std::shared_ptr block_header) noexcept : final_chain_(std::move(final_chain)), trx_manager_(std::move(trx_manager)), + get_block_by_num_(std::move(get_block_by_num)), + kPBftBlockHash(pbft_block_hash), block_header_(std::move(block_header)) {} response::Value Block::getNumber() const noexcept { return response::Value(static_cast(block_header_->number)); } response::Value Block::getHash() const noexcept { return response::Value(block_header_->hash.toString()); } +response::Value Block::getPbftHash() const noexcept { return response::Value(kPBftBlockHash.toString()); } + std::shared_ptr Block::getParent() const noexcept { - return std::make_shared(std::make_shared( - final_chain_, trx_manager_, - final_chain_->block_header(final_chain_->block_number(dev::h256(block_header_->parent_hash))))); + return get_block_by_num_(block_header_->number - 1); } response::Value Block::getNonce() const noexcept { return response::Value(block_header_->nonce().toString()); } @@ -99,8 +103,8 @@ std::optional>> Block::getTrans } ret.reserve(transactions_.size()); for (auto& t : transactions_) { - ret.emplace_back( - std::make_shared(std::make_shared(final_chain_, trx_manager_, t))); + ret.emplace_back(std::make_shared( + std::make_shared(final_chain_, trx_manager_, get_block_by_num_, t))); } return ret; } @@ -114,7 +118,7 @@ std::shared_ptr Block::getTransactionAt(response::IntType&& return nullptr; } return std::make_shared( - std::make_shared(final_chain_, trx_manager_, transactions_[index])); + std::make_shared(final_chain_, trx_manager_, get_block_by_num_, transactions_[index])); } std::vector> Block::getLogs(BlockFilterCriteria&&) const noexcept { diff --git a/libraries/core_libs/network/graphql/src/query.cpp b/libraries/core_libs/network/graphql/src/query.cpp index 7606de867b..9afae748f1 100644 --- a/libraries/core_libs/network/graphql/src/query.cpp +++ b/libraries/core_libs/network/graphql/src/query.cpp @@ -26,40 +26,41 @@ Query::Query(std::shared_ptr<::taraxa::final_chain::FinalChain> final_chain, db_(std::move(db)), gas_pricer_(std::move(gas_pricer)), network_(std::move(network)), - kChainId(chain_id) {} + kChainId(chain_id) { + get_block_by_num_ = [&](::taraxa::EthBlockNumber num) { + return getBlock(response::Value(static_cast(num)), std::nullopt); + }; +} std::shared_ptr Query::getBlock(std::optional&& number, std::optional&& hash) const { + std::optional<::taraxa::EthBlockNumber> block_number; if (number) { - const uint64_t block_number = number->get(); + block_number = number->get(); if (const auto last_block_number = final_chain_->last_block_number(); last_block_number < block_number) { return nullptr; } - if (auto block_header = final_chain_->block_header(block_number)) { - return std::make_shared( - std::make_shared(final_chain_, transaction_manager_, std::move(block_header))); - } - return nullptr; } if (hash) { - if (auto block_number = final_chain_->block_number(dev::h256(hash->get()))) { - if (auto block_header = final_chain_->block_header(block_number)) { - return std::make_shared( - std::make_shared(final_chain_, transaction_manager_, std::move(block_header))); - } - } + block_number = final_chain_->block_number(dev::h256(hash->get())); + } + auto block_header = final_chain_->block_header(block_number); + + auto pbft_block = db_->getPbftBlock(block_header->number); + if (!pbft_block) { + // shouldn't be possible return nullptr; } - return std::make_shared( - std::make_shared(final_chain_, transaction_manager_, final_chain_->block_header())); + return std::make_shared(std::make_shared(final_chain_, transaction_manager_, get_block_by_num_, + pbft_block->getBlockHash(), block_header)); } std::vector> Query::getBlocks(response::Value&& fromArg, std::optional&& toArg) const { std::vector> blocks; - uint64_t start_block_num = fromArg.get(); - uint64_t end_block_num = toArg ? toArg->get() : (start_block_num + Query::kMaxPropagationLimit); + int start_block_num = fromArg.get(); + int end_block_num = toArg ? toArg->get() : (start_block_num + Query::kMaxPropagationLimit); // Incase of reverse order of blocks if (start_block_num > end_block_num) { @@ -68,11 +69,11 @@ std::vector> Query::getBlocks(response::Value&& f end_block_num = tmp; } - if (end_block_num - start_block_num > Query::kMaxPropagationLimit) { + if (end_block_num - start_block_num > static_cast(Query::kMaxPropagationLimit)) { end_block_num = start_block_num + Query::kMaxPropagationLimit; } - const auto last_block_number = final_chain_->last_block_number(); + const int last_block_number = final_chain_->last_block_number(); if (start_block_num > last_block_number) { return blocks; } else if (end_block_num > last_block_number) { @@ -81,9 +82,8 @@ std::vector> Query::getBlocks(response::Value&& f blocks.reserve(end_block_num - start_block_num); - for (uint64_t block_num = start_block_num; block_num <= end_block_num; block_num++) { - blocks.emplace_back(std::make_shared( - std::make_shared(final_chain_, transaction_manager_, final_chain_->block_header(block_num)))); + for (int block_num = start_block_num; block_num <= end_block_num; block_num++) { + blocks.emplace_back(getBlock(response::Value(block_num), std::nullopt)); } return blocks; @@ -92,7 +92,7 @@ std::vector> Query::getBlocks(response::Value&& f std::shared_ptr Query::getTransaction(response::Value&& hashArg) const { if (auto transaction = transaction_manager_->getTransaction(::taraxa::trx_hash_t(hashArg.get()))) { return std::make_shared( - std::make_shared(final_chain_, transaction_manager_, std::move(transaction))); + std::make_shared(final_chain_, transaction_manager_, get_block_by_num_, std::move(transaction))); } return nullptr; } @@ -130,10 +130,11 @@ std::shared_ptr Query::getDagBlock(std::optional(std::make_shared( - std::move(taraxa_dag_block), final_chain_, pbft_manager_, transaction_manager_)) - : nullptr; + if (taraxa_dag_block) { + return std::make_shared(std::make_shared( + std::move(taraxa_dag_block), final_chain_, pbft_manager_, transaction_manager_, get_block_by_num_)); + } + return nullptr; } std::vector> Query::getPeriodDagBlocks( @@ -149,8 +150,8 @@ std::vector> Query::getPeriodDagBlocks( if (dag_blocks.size()) { blocks.reserve(dag_blocks.size()); for (auto block : dag_blocks) { - blocks.emplace_back(std::make_shared( - std::make_shared(std::move(block), final_chain_, pbft_manager_, transaction_manager_))); + blocks.emplace_back(std::make_shared(std::make_shared( + std::move(block), final_chain_, pbft_manager_, transaction_manager_, get_block_by_num_))); } } return blocks; @@ -170,11 +171,11 @@ std::vector> Query::getDagBlocks(std::optional } auto addDagBlocks = [final_chain = final_chain_, pbft_manager = pbft_manager_, - transaction_manager = transaction_manager_](auto taraxa_dag_blocks, - auto& result_dag_blocks) -> size_t { + transaction_manager = transaction_manager_, get_block_by_num = get_block_by_num_]( + auto taraxa_dag_blocks, auto& result_dag_blocks) -> size_t { for (auto& dag_block : taraxa_dag_blocks) { - result_dag_blocks.emplace_back(std::make_shared( - std::make_shared(std::move(dag_block), final_chain, pbft_manager, transaction_manager))); + result_dag_blocks.emplace_back(std::make_shared(std::make_shared( + std::move(dag_block), final_chain, pbft_manager, transaction_manager, get_block_by_num))); } return taraxa_dag_blocks.size(); diff --git a/libraries/core_libs/network/graphql/src/transaction.cpp b/libraries/core_libs/network/graphql/src/transaction.cpp index afe45ce171..b6770ec7ac 100644 --- a/libraries/core_libs/network/graphql/src/transaction.cpp +++ b/libraries/core_libs/network/graphql/src/transaction.cpp @@ -13,9 +13,11 @@ namespace graphql::taraxa { Transaction::Transaction(std::shared_ptr<::taraxa::final_chain::FinalChain> final_chain, std::shared_ptr<::taraxa::TransactionManager> trx_manager, + std::function(::taraxa::EthBlockNumber)> get_block_by_num, std::shared_ptr<::taraxa::Transaction> transaction) noexcept : final_chain_(std::move(final_chain)), trx_manager_(std::move(trx_manager)), + get_block_by_num_(std::move(get_block_by_num)), transaction_(std::move(transaction)) {} response::Value Transaction::getHash() const noexcept { return response::Value(transaction_->getHash().toString()); } @@ -70,8 +72,7 @@ std::shared_ptr Transaction::getBlock() const { location_ = final_chain_->transaction_location(transaction_->getHash()); if (!location_) return nullptr; } - return std::make_shared( - std::make_shared(final_chain_, trx_manager_, final_chain_->block_header(location_->blk_n))); + return get_block_by_num_(location_->blk_n); } std::optional Transaction::getStatus() const noexcept { diff --git a/libraries/core_libs/network/graphql/src/types/dag_block.cpp b/libraries/core_libs/network/graphql/src/types/dag_block.cpp index 7124be5fd2..a9b1c78a81 100644 --- a/libraries/core_libs/network/graphql/src/types/dag_block.cpp +++ b/libraries/core_libs/network/graphql/src/types/dag_block.cpp @@ -10,11 +10,13 @@ namespace graphql::taraxa { DagBlock::DagBlock(std::shared_ptr<::taraxa::DagBlock> dag_block, std::shared_ptr<::taraxa::final_chain::FinalChain> final_chain, std::shared_ptr<::taraxa::PbftManager> pbft_manager, - std::shared_ptr<::taraxa::TransactionManager> transaction_manager) noexcept + std::shared_ptr<::taraxa::TransactionManager> transaction_manager, + std::function(::taraxa::EthBlockNumber)> get_block_by_num) noexcept : dag_block_(std::move(dag_block)), final_chain_(std::move(final_chain)), pbft_manager_(std::move(pbft_manager)), - transaction_manager_(std::move(transaction_manager)) {} + transaction_manager_(std::move(transaction_manager)), + get_block_by_num_(get_block_by_num) {} response::Value DagBlock::getHash() const noexcept { return response::Value(dag_block_->getHash().toString()); } @@ -72,7 +74,7 @@ std::optional>> DagBlock::getTr std::vector> transactions_result; for (const auto& trx_hash : dag_block_->getTrxs()) { transactions_result.push_back(std::make_shared(std::make_shared( - final_chain_, transaction_manager_, transaction_manager_->getTransaction(trx_hash)))); + final_chain_, transaction_manager_, get_block_by_num_, transaction_manager_->getTransaction(trx_hash)))); } return transactions_result;