From b62d9a66079f453959433637711f7ff4759fbcad Mon Sep 17 00:00:00 2001 From: Boris Erakhtin Date: Wed, 30 Oct 2024 13:34:04 +0700 Subject: [PATCH] candidates_pending_availability added --- core/runtime/runtime_api/impl/parachain_host.cpp | 13 +++++++++++++ core/runtime/runtime_api/impl/parachain_host.hpp | 7 +++++++ core/runtime/runtime_api/parachain_host.hpp | 10 ++++++++++ test/core/runtime/binaryen/parachain_test.cpp | 10 ++++++++++ test/mock/core/runtime/parachain_host_mock.hpp | 5 +++++ 5 files changed, 45 insertions(+) diff --git a/core/runtime/runtime_api/impl/parachain_host.cpp b/core/runtime/runtime_api/impl/parachain_host.cpp index 79e07c90dc..09fe025633 100644 --- a/core/runtime/runtime_api/impl/parachain_host.cpp +++ b/core/runtime/runtime_api/impl/parachain_host.cpp @@ -149,6 +149,18 @@ namespace kagome::runtime { return *ref; } + outcome::result>> + ParachainHostImpl::candidates_pending_availability( + const primitives::BlockHash &block, ParachainId id) { + OUTCOME_TRY(ref, + candidates_pending_availability_.call( + *executor_, + block, + "ParachainHost_candidates_pending_availability", + id)); + return *ref; + } + outcome::result> ParachainHostImpl::candidate_events(const primitives::BlockHash &block) { OUTCOME_TRY(ref, @@ -213,6 +225,7 @@ namespace kagome::runtime { availability_cores_.erase(blocks); session_index_for_child_.erase(blocks); candidate_pending_availability_.erase(blocks); + candidates_pending_availability_.erase(blocks); candidate_events_.erase(blocks); session_info_.erase(blocks); dmq_contents_.erase(blocks); diff --git a/core/runtime/runtime_api/impl/parachain_host.hpp b/core/runtime/runtime_api/impl/parachain_host.hpp index 3c00fcf9a6..7c39884ccb 100644 --- a/core/runtime/runtime_api/impl/parachain_host.hpp +++ b/core/runtime/runtime_api/impl/parachain_host.hpp @@ -68,6 +68,10 @@ namespace kagome::runtime { candidate_pending_availability(const primitives::BlockHash &block, ParachainId id) override; + outcome::result>> + candidates_pending_availability(const primitives::BlockHash &block, + ParachainId id) override; + outcome::result> candidate_events( const primitives::BlockHash &block) override; @@ -148,6 +152,9 @@ namespace kagome::runtime { }; RuntimeApiLruBlockArg> candidate_pending_availability_{10}; + RuntimeApiLruBlockArg>> + candidates_pending_availability_{10}; RuntimeApiLruBlock> candidate_events_{10}; RuntimeApiLruBlockArg> session_info_{10}; diff --git a/core/runtime/runtime_api/parachain_host.hpp b/core/runtime/runtime_api/parachain_host.hpp index 34f51a54ed..89d1114aa3 100644 --- a/core/runtime/runtime_api/parachain_host.hpp +++ b/core/runtime/runtime_api/parachain_host.hpp @@ -168,6 +168,16 @@ namespace kagome::runtime { candidate_pending_availability(const primitives::BlockHash &block, ParachainId id) = 0; + /** + * @brief Get the receipts of all candidates pending availability. + * @param id parachain id + * @return vector of CommittedCandidateReceipt + */ + virtual outcome::result< + std::vector>> + candidates_pending_availability(const primitives::BlockHash &block, + ParachainId id) = 0; + /// /** * @brief Get a vector of events concerning candidates that occurred within diff --git a/test/core/runtime/binaryen/parachain_test.cpp b/test/core/runtime/binaryen/parachain_test.cpp index 7bf5b8af81..4175197e66 100644 --- a/test/core/runtime/binaryen/parachain_test.cpp +++ b/test/core/runtime/binaryen/parachain_test.cpp @@ -167,6 +167,16 @@ TEST_F(ParachainHostTest, DISABLED_CandidatePendingAvailabilityTest) { ASSERT_TRUE(api_->candidate_pending_availability("block_hash"_hash256, id)); } +/** + * @given initialized parachain host api + * @when candidates_pending_availability() is invoked + * @then successful result is returned + */ +TEST_F(ParachainHostTest, DISABLED_CandidatesPendingAvailabilityTest) { + auto id = createParachainId(); + ASSERT_TRUE(api_->candidates_pending_availability("block_hash"_hash256, id)); +} + /** * @given initialized parachain host api * @when candidate_events() is invoked diff --git a/test/mock/core/runtime/parachain_host_mock.hpp b/test/mock/core/runtime/parachain_host_mock.hpp index b785a7f0fb..34635bf49a 100644 --- a/test/mock/core/runtime/parachain_host_mock.hpp +++ b/test/mock/core/runtime/parachain_host_mock.hpp @@ -80,6 +80,11 @@ namespace kagome::runtime { (const primitives::BlockHash &, ParachainId), (override)); + MOCK_METHOD(outcome::result>>, + candidates_pending_availability, + (const primitives::BlockHash &, ParachainId), + (override)); + MOCK_METHOD(outcome::result>, candidate_events, (const primitives::BlockHash &),