Skip to content

Commit

Permalink
Feature/prospective parachain tests (#2270)
Browse files Browse the repository at this point in the history
* fixed `prospective_parachains` initialization for 11 ver.

Signed-off-by: iceseer <[email protected]>

* tests

Signed-off-by: iceseer <[email protected]>

---------

Signed-off-by: iceseer <[email protected]>
  • Loading branch information
iceseer authored Nov 13, 2024
1 parent 1d7f2ee commit b57dbc9
Show file tree
Hide file tree
Showing 8 changed files with 2,097 additions and 12 deletions.
15 changes: 14 additions & 1 deletion core/parachain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ target_link_libraries(grid_tracker
outcome
)

add_library(backing_implicit_view
validator/backing_implicit_view.cpp
)

target_link_libraries(backing_implicit_view
fmt::fmt
scale::scale
soralog::soralog
logger
Boost::boost
outcome
)

add_library(validator_parachain
availability/bitfield/signer.cpp
availability/bitfield/store_impl.cpp
Expand All @@ -40,7 +53,6 @@ add_library(validator_parachain
approval/approval.cpp
backing/store_impl.cpp
backing/cluster.cpp
validator/backing_implicit_view.cpp
validator/statement_distribution/statement_distribution.cpp
)

Expand All @@ -55,6 +67,7 @@ target_link_libraries(validator_parachain
kagome_pvf_worker
runtime_common
prospective_parachains
backing_implicit_view
)

add_library(kagome_pvf_worker
Expand Down
2 changes: 2 additions & 0 deletions core/parachain/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ namespace kagome::parachain {
/// Signature with which parachain validators sign blocks.
using ValidatorSignature = Signature;

constexpr uint32_t CLAIM_QUEUE_RUNTIME_REQUIREMENT = 11;

template <typename D>
struct Indexed {
using Type = std::decay_t<D>;
Expand Down
1 change: 0 additions & 1 deletion core/parachain/validator/impl/parachain_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,6 @@ namespace kagome::parachain {

outcome::result<std::optional<runtime::ClaimQueueSnapshot>>
ParachainProcessorImpl::fetch_claim_queue(const RelayHash &relay_parent) {
constexpr uint32_t CLAIM_QUEUE_RUNTIME_REQUIREMENT = 11;
OUTCOME_TRY(version, parachain_host_->runtime_api_version(relay_parent));
if (version < CLAIM_QUEUE_RUNTIME_REQUIREMENT) {
SL_TRACE(logger_, "Runtime doesn't support `request_claim_queue`");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ target_link_libraries(prospective_parachains
logger
Boost::boost
outcome
backing_implicit_view
)

Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,36 @@ namespace kagome::parachain {
return std::nullopt;
}

outcome::result<std::optional<runtime::ClaimQueueSnapshot>>
ProspectiveParachains::fetch_claim_queue(const RelayHash &relay_parent) {
OUTCOME_TRY(version, parachain_host_->runtime_api_version(relay_parent));
if (version < CLAIM_QUEUE_RUNTIME_REQUIREMENT) {
SL_TRACE(logger, "Runtime doesn't support `request_claim_queue`");
return std::nullopt;
}

OUTCOME_TRY(claims, parachain_host_->claim_queue(relay_parent));
return runtime::ClaimQueueSnapshot{
.claimes = std::move(claims),
};
}

outcome::result<std::unordered_set<ParachainId>>
ProspectiveParachains::fetchUpcomingParas(
const RelayHash &relay_parent,
std::unordered_set<CandidateHash> &pending_availability) {
OUTCOME_TRY(cores, parachain_host_->availability_cores(relay_parent));
OUTCOME_TRY(claim, fetch_claim_queue(relay_parent));
if (claim) {
std::unordered_set<ParachainId> result;
for (const auto &[_, paras] : claim->claimes) {
for (const auto &para : paras) {
result.emplace(para);
}
}
return result;
}

OUTCOME_TRY(cores, parachain_host_->availability_cores(relay_parent));
std::unordered_set<ParachainId> upcoming;
for (const auto &core : cores) {
visit_in_place(
Expand All @@ -305,6 +329,7 @@ namespace kagome::parachain {
},
[](const auto &) {});
}

return upcoming;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ namespace kagome::parachain {
const RelayHash &relay_parent,
std::unordered_set<CandidateHash> &pending_availability);

outcome::result<std::optional<runtime::ClaimQueueSnapshot>>
fetch_claim_queue(const RelayHash &relay_parent);

outcome::result<std::vector<fragment::BlockInfoProspectiveParachains>>
fetchAncestry(const RelayHash &relay_hash, size_t ancestors);

Expand Down
2 changes: 1 addition & 1 deletion test/core/parachain/parachain_test_harness.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class ProspectiveParachainsTestHarness : public testing::Test {
std::move(candidate));
}

Hash fromNumber(uint64_t n) const {
static Hash fromNumber(uint64_t n) {
assert(n <= 255);
Hash h{};
memset(&h[0], n, 32);
Expand Down
Loading

0 comments on commit b57dbc9

Please sign in to comment.