diff --git a/core/runtime/runtime_api/impl/tagged_transaction_queue.cpp b/core/runtime/runtime_api/impl/tagged_transaction_queue.cpp index 98f0e909cc..e6620a7308 100644 --- a/core/runtime/runtime_api/impl/tagged_transaction_queue.cpp +++ b/core/runtime/runtime_api/impl/tagged_transaction_queue.cpp @@ -22,18 +22,20 @@ namespace kagome::runtime { block_tree_ = std::move(block_tree); } - outcome::result + outcome::result TaggedTransactionQueueImpl::validate_transaction( primitives::TransactionSource source, const primitives::Extrinsic &ext) { BOOST_ASSERT(block_tree_); auto block = block_tree_->bestLeaf(); SL_TRACE(logger_, "Validate transaction called at block {}", block); - return executor_->callAt( - block.hash, - "TaggedTransactionQueue_validate_transaction", - source, - ext, - block.hash); + OUTCOME_TRY(result, + executor_->callAt( + block.hash, + "TaggedTransactionQueue_validate_transaction", + source, + ext, + block.hash)); + return TransactionValidityAt{block, std::move(result)}; } } // namespace kagome::runtime diff --git a/core/runtime/runtime_api/impl/tagged_transaction_queue.hpp b/core/runtime/runtime_api/impl/tagged_transaction_queue.hpp index 9818b2f607..ea7de3b842 100644 --- a/core/runtime/runtime_api/impl/tagged_transaction_queue.hpp +++ b/core/runtime/runtime_api/impl/tagged_transaction_queue.hpp @@ -24,7 +24,7 @@ namespace kagome::runtime { void setBlockTree(std::shared_ptr block_tree); - outcome::result validate_transaction( + outcome::result validate_transaction( primitives::TransactionSource source, const primitives::Extrinsic &ext) override; diff --git a/core/runtime/runtime_api/tagged_transaction_queue.hpp b/core/runtime/runtime_api/tagged_transaction_queue.hpp index f3981b7a5e..2da03291bc 100644 --- a/core/runtime/runtime_api/tagged_transaction_queue.hpp +++ b/core/runtime/runtime_api/tagged_transaction_queue.hpp @@ -19,15 +19,18 @@ namespace kagome::runtime { public: virtual ~TaggedTransactionQueue() = default; + using TransactionValidityAt = + std::pair; + /** * Calls the TaggedTransactionQueue_validate_transaction function from wasm * code * @param ext extrinsic containing transaction to be validated * @return structure with information about transaction validity */ - virtual outcome::result - validate_transaction(primitives::TransactionSource source, - const primitives::Extrinsic &ext) = 0; + virtual outcome::result validate_transaction( + primitives::TransactionSource source, + const primitives::Extrinsic &ext) = 0; }; } // namespace kagome::runtime diff --git a/core/transaction_pool/impl/transaction_pool_impl.cpp b/core/transaction_pool/impl/transaction_pool_impl.cpp index e17f504590..946e8a2e79 100644 --- a/core/transaction_pool/impl/transaction_pool_impl.cpp +++ b/core/transaction_pool/impl/transaction_pool_impl.cpp @@ -67,7 +67,7 @@ namespace kagome::transaction_pool { OUTCOME_TRY(res, ttq_->validate_transaction(source, extrinsic)); return visit_in_place( - res, + std::move(res.second), [&](const primitives::TransactionValidityError &e) { return visit_in_place( e, @@ -77,7 +77,7 @@ namespace kagome::transaction_pool { return validity_error; }); }, - [&](const primitives::ValidTransaction &v) + [&](primitives::ValidTransaction &&v) -> outcome::result { common::Hash256 hash = hasher_->blake2b_256(extrinsic.data); size_t length = extrinsic.data.size(); @@ -86,9 +86,9 @@ namespace kagome::transaction_pool { length, hash, v.priority, - v.longevity, - v.requires, - v.provides, + res.first.number + v.longevity, + std::move(v.requires), + std::move(v.provides), v.propagate}; }); } diff --git a/test/mock/core/runtime/tagged_transaction_queue_mock.hpp b/test/mock/core/runtime/tagged_transaction_queue_mock.hpp index 9f94722f7b..21559938bd 100644 --- a/test/mock/core/runtime/tagged_transaction_queue_mock.hpp +++ b/test/mock/core/runtime/tagged_transaction_queue_mock.hpp @@ -12,7 +12,7 @@ namespace kagome::runtime { struct TaggedTransactionQueueMock : public TaggedTransactionQueue { - MOCK_METHOD(outcome::result, + MOCK_METHOD(outcome::result, validate_transaction, (primitives::TransactionSource, const primitives::Extrinsic &), (override));