Kagome
Polkadot Runtime Engine in C++17
parachain_host.cpp
Go to the documentation of this file.
1 
7 
8 #include "common/blob.hpp"
11 
12 namespace kagome::runtime {
13 
14  ParachainHostImpl::ParachainHostImpl(std::shared_ptr<Executor> executor)
15  : executor_{std::move(executor)} {
16  BOOST_ASSERT(executor_);
17  }
18 
19  outcome::result<DutyRoster> ParachainHostImpl::duty_roster(
20  const primitives::BlockHash &block) {
21  return executor_->callAt<DutyRoster>(block, "ParachainHost_duty_roster");
22  }
23 
24  outcome::result<std::vector<ParachainId>>
26  return executor_->callAt<std::vector<ParachainId>>(
27  block, "ParachainHost_active_parachains");
28  }
29 
30  outcome::result<std::optional<common::Buffer>>
32  ParachainId id) {
33  return executor_->callAt<std::optional<Buffer>>(
34  block, "ParachainHost_parachain_head", id);
35  }
36 
37  outcome::result<std::optional<common::Buffer>>
39  ParachainId id) {
40  return executor_->callAt<std::optional<common::Buffer>>(
41  block, "ParachainHost_parachain_code", id);
42  }
43 
44  outcome::result<std::vector<ValidatorId>> ParachainHostImpl::validators(
45  const primitives::BlockHash &block) {
46  return executor_->callAt<std::vector<ValidatorId>>(
47  block, "ParachainHost_validators");
48  }
49 
50  outcome::result<std::vector<ValidatorGroup>>
52  return executor_->callAt<std::vector<ValidatorGroup>>(
53  block, "ParachainHost_validator_groups");
54  }
55 
56  outcome::result<std::vector<CoreState>> ParachainHostImpl::availability_cores(
57  const primitives::BlockHash &block) {
58  return executor_->callAt<std::vector<CoreState>>(
59  block, "ParachainHost_availability_cores");
60  }
61 
62  outcome::result<std::optional<PersistedValidationData>>
64  const primitives::BlockHash &block,
65  ParachainId id,
66  OccupiedCoreAssumption assumption) {
67  return executor_->callAt<std::optional<PersistedValidationData>>(
68  block, "ParachainHost_persisted_validation_data", id, assumption);
69  }
70 
72  const primitives::BlockHash &block,
73  ParachainId id,
74  CandidateCommitments outputs) {
75  return executor_->callAt<bool>(
76  block, "ParachainHost_check_validation_outputs", id, outputs);
77  }
78 
79  outcome::result<SessionIndex> ParachainHostImpl::session_index_for_child(
80  const primitives::BlockHash &block) {
81  return executor_->callAt<SessionIndex>(
82  block, "ParachainHost_session_index_for_child");
83  }
84 
85  outcome::result<std::optional<ValidationCode>>
87  ParachainId id,
88  OccupiedCoreAssumption assumption) {
89  return executor_->callAt<std::optional<ValidationCode>>(
90  block, "ParachainHost_validation_code");
91  }
92 
93  outcome::result<std::optional<ValidationCode>>
95  ValidationCodeHash hash) {
96  return executor_->callAt<std::optional<ValidationCode>>(
97  block, "ParachainHost_validation_code_by_hash", hash);
98  }
99 
100  outcome::result<std::optional<CommittedCandidateReceipt>>
102  const primitives::BlockHash &block, ParachainId id) {
103  return executor_->callAt<std::optional<CommittedCandidateReceipt>>(
104  block, "ParachainHost_candidate_pending_availability", id);
105  }
106 
107  outcome::result<std::vector<CandidateEvent>>
109  return executor_->callAt<std::vector<CandidateEvent>>(
110  block, "ParachainHost_candidate_events");
111  }
112 
113  outcome::result<std::optional<SessionInfo>> ParachainHostImpl::session_info(
114  const primitives::BlockHash &block, SessionIndex index) {
115  return executor_->callAt<std::optional<SessionInfo>>(
116  block, "ParachainHost_session_info", index);
117  }
118 
119  outcome::result<std::vector<InboundDownwardMessage>>
121  ParachainId id) {
122  return executor_->callAt<std::vector<InboundDownwardMessage>>(
123  block, "ParachainHost_dmq_contents", id);
124  }
125 
126  outcome::result<std::map<ParachainId, std::vector<InboundHrmpMessage>>>
128  const primitives::BlockHash &block, ParachainId id) {
129  return executor_
130  ->callAt<std::map<ParachainId, std::vector<InboundHrmpMessage>>>(
131  block, "ParachainHost_inbound_hrmp_channels_contents", id);
132  }
133 
134 } // namespace kagome::runtime
outcome::result< std::vector< ValidatorGroup > > validator_groups(const primitives::BlockHash &block) override
Returns the validator groups and rotation info localized based on the hypothetical child of a block w...
outcome::result< std::optional< SessionInfo > > session_info(const primitives::BlockHash &block, SessionIndex index) override
Get the session info for the given session, if stored.
outcome::result< std::optional< ValidationCode > > validation_code_by_hash(const primitives::BlockHash &block, ValidationCodeHash hash) override
Get the validation code (runtime) from its hash.
outcome::result< std::vector< CandidateEvent > > candidate_events(const primitives::BlockHash &block) override
Get a vector of events concerning candidates that occurred within a block.
std::shared_ptr< Executor > executor_
outcome::result< std::optional< ValidationCode > > validation_code(const primitives::BlockHash &block, ParachainId id, OccupiedCoreAssumption assumption) override
Fetch the validation code used by a para, making the given OccupiedCoreAssumption.
outcome::result< std::optional< PersistedValidationData > > persisted_validation_data(const primitives::BlockHash &block, ParachainId id, OccupiedCoreAssumption assumption) override
Yields the persisted validation data for the given ParaId along with an assumption that should be use...
outcome::result< std::vector< CoreState > > availability_cores(const primitives::BlockHash &block) override
Yields information on all availability cores as relevant to the child block. Cores are either free or...
outcome::result< std::vector< ParachainId > > active_parachains(const primitives::BlockHash &block) override
Calls the ParachainHost_active_parachains function from wasm code.
outcome::result< DutyRoster > duty_roster(const primitives::BlockHash &block) override
Calls the ParachainHost_duty_roster function from wasm code.
ParachainHostImpl(std::shared_ptr< Executor > executor)
outcome::result< bool > check_validation_outputs(const primitives::BlockHash &block, ParachainId id, CandidateCommitments outputs) override
Checks if the given validation outputs pass the acceptance criteria.
outcome::result< std::optional< kagome::common::Buffer > > parachain_code(const primitives::BlockHash &block, ParachainId id) override
Calls the ParachainHost_parachain_code function from wasm code.
outcome::result< std::vector< InboundDownwardMessage > > dmq_contents(const primitives::BlockHash &block, ParachainId id) override
Get all the pending inbound messages in the downward message queue for a para.
outcome::result< std::vector< ValidatorId > > validators(const primitives::BlockHash &block) override
reports validators list for given block_id
outcome::result< std::optional< Buffer > > parachain_head(const primitives::BlockHash &block, ParachainId id) override
Calls the ParachainHost_parachain_head function from wasm code.
primitives::parachain::DutyRoster DutyRoster
outcome::result< SessionIndex > session_index_for_child(const primitives::BlockHash &block) override
Returns the session index expected at a child of the block. This can be used to instantiate a Signing...
outcome::result< std::optional< CommittedCandidateReceipt > > candidate_pending_availability(const primitives::BlockHash &block, ParachainId id) override
Get the receipt of a candidate pending availability.
primitives::parachain::ParaId ParachainId
outcome::result< std::map< ParachainId, std::vector< InboundHrmpMessage > > > inbound_hrmp_channels_contents(const primitives::BlockHash &block, ParachainId id) override
Get the contents of all channels addressed to the given recipient. Channels that have no messages in ...