Skip to content

Commit

Permalink
candidates_pending_availability added
Browse files Browse the repository at this point in the history
  • Loading branch information
ErakhtinB committed Oct 30, 2024
1 parent 75b7a35 commit b62d9a6
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/runtime/runtime_api/impl/parachain_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ namespace kagome::runtime {
return *ref;
}

outcome::result<std::vector<std::optional<CommittedCandidateReceipt>>>
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<std::vector<CandidateEvent>>
ParachainHostImpl::candidate_events(const primitives::BlockHash &block) {
OUTCOME_TRY(ref,
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions core/runtime/runtime_api/impl/parachain_host.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ namespace kagome::runtime {
candidate_pending_availability(const primitives::BlockHash &block,
ParachainId id) override;

outcome::result<std::vector<std::optional<CommittedCandidateReceipt>>>
candidates_pending_availability(const primitives::BlockHash &block,
ParachainId id) override;

outcome::result<std::vector<CandidateEvent>> candidate_events(
const primitives::BlockHash &block) override;

Expand Down Expand Up @@ -148,6 +152,9 @@ namespace kagome::runtime {
};
RuntimeApiLruBlockArg<ParachainId, std::optional<CommittedCandidateReceipt>>
candidate_pending_availability_{10};
RuntimeApiLruBlockArg<ParachainId,
std::vector<std::optional<CommittedCandidateReceipt>>>
candidates_pending_availability_{10};
RuntimeApiLruBlock<std::vector<CandidateEvent>> candidate_events_{10};
RuntimeApiLruBlockArg<SessionIndex, std::optional<SessionInfo>>
session_info_{10};
Expand Down
10 changes: 10 additions & 0 deletions core/runtime/runtime_api/parachain_host.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::optional<CommittedCandidateReceipt>>>
candidates_pending_availability(const primitives::BlockHash &block,
ParachainId id) = 0;

///
/**
* @brief Get a vector of events concerning candidates that occurred within
Expand Down
10 changes: 10 additions & 0 deletions test/core/runtime/binaryen/parachain_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/mock/core/runtime/parachain_host_mock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ namespace kagome::runtime {
(const primitives::BlockHash &, ParachainId),
(override));

MOCK_METHOD(outcome::result<std::vector<std::optional<CommittedCandidateReceipt>>>,
candidates_pending_availability,
(const primitives::BlockHash &, ParachainId),
(override));

MOCK_METHOD(outcome::result<std::vector<CandidateEvent>>,
candidate_events,
(const primitives::BlockHash &),
Expand Down

0 comments on commit b62d9a6

Please sign in to comment.