From 7026b5c25f5166aaf503a2f0b9f2ea4395e137ed Mon Sep 17 00:00:00 2001 From: turuslan Date: Tue, 14 Mar 2023 10:05:18 +0300 Subject: [PATCH 1/2] fix Signed-off-by: turuslan --- .../impl/tagged_transaction_queue.cpp | 16 +++++++++------- .../impl/tagged_transaction_queue.hpp | 2 +- .../runtime_api/tagged_transaction_queue.hpp | 9 ++++++--- .../impl/transaction_pool_impl.cpp | 4 ++-- .../runtime/tagged_transaction_queue_mock.hpp | 2 +- 5 files changed, 19 insertions(+), 14 deletions(-) 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..4d41e79ec6 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, + res.second, [&](const primitives::TransactionValidityError &e) { return visit_in_place( e, @@ -86,7 +86,7 @@ namespace kagome::transaction_pool { length, hash, v.priority, - v.longevity, + res.first.number + v.longevity, v.requires, 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)); From 3d759bce5ee6ab0bdae87c4a30c760b50ae43e79 Mon Sep 17 00:00:00 2001 From: turuslan Date: Tue, 14 Mar 2023 10:48:09 +0300 Subject: [PATCH 2/2] move Signed-off-by: turuslan --- core/transaction_pool/impl/transaction_pool_impl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/transaction_pool/impl/transaction_pool_impl.cpp b/core/transaction_pool/impl/transaction_pool_impl.cpp index 4d41e79ec6..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.second, + 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(); @@ -87,8 +87,8 @@ namespace kagome::transaction_pool { hash, v.priority, res.first.number + v.longevity, - v.requires, - v.provides, + std::move(v.requires), + std::move(v.provides), v.propagate}; }); }