mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 16:31:07 +00:00
Companion for removal of execution strategies (#7443)
* Companion for removal of execution strategies https://github.com/paritytech/substrate/pull/14387 * Fix some tests * 🤦 * Adapt to latest changes * Start supporting the offchain transaction pool * Fix tests * FMT * Remove patches * Update Substrate * update lockfile for {"substrate"} * Fix parachain upgrade smoke test * Fix test * Rewrite all tests to use `MockSubstemClient` --------- Co-authored-by: parity-processbot <>
This commit is contained in:
Generated
+200
-191
File diff suppressed because it is too large
Load Diff
@@ -18,9 +18,9 @@ polkadot-node-subsystem-types = { path = "../../subsystem-types" }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
async-trait = "0.1.57"
|
||||
futures = { version = "0.3.21", features = ["thread-pool"] }
|
||||
polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
|
||||
polkadot-node-primitives = { path = "../../primitives" }
|
||||
|
||||
@@ -16,233 +16,250 @@
|
||||
|
||||
use super::*;
|
||||
|
||||
use ::test_helpers::{dummy_committed_candidate_receipt, dummy_validation_code};
|
||||
use polkadot_node_primitives::{BabeAllowedSlots, BabeEpoch, BabeEpochConfiguration};
|
||||
use polkadot_node_subsystem::SpawnGlue;
|
||||
use polkadot_node_subsystem_test_helpers::make_subsystem_context;
|
||||
use polkadot_primitives::{
|
||||
runtime_api::ParachainHost, AuthorityDiscoveryId, Block, CandidateEvent,
|
||||
CommittedCandidateReceipt, CoreState, GroupRotationInfo, Id as ParaId, InboundDownwardMessage,
|
||||
InboundHrmpMessage, OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement,
|
||||
ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash,
|
||||
ValidatorId, ValidatorIndex, ValidatorSignature,
|
||||
vstaging, AuthorityDiscoveryId, BlockNumber, CandidateCommitments, CandidateEvent,
|
||||
CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams,
|
||||
GroupRotationInfo, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage,
|
||||
OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes,
|
||||
SessionIndex, SessionInfo, Slot, ValidationCode, ValidationCodeHash, ValidatorId,
|
||||
ValidatorIndex, ValidatorSignature,
|
||||
};
|
||||
use sp_api::ProvideRuntimeApi;
|
||||
use sp_authority_discovery::AuthorityDiscoveryApi;
|
||||
use sp_consensus_babe::BabeApi;
|
||||
use sp_api::ApiError;
|
||||
use sp_core::testing::TaskExecutor;
|
||||
use std::{
|
||||
collections::{BTreeMap, HashMap},
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
use test_helpers::{dummy_committed_candidate_receipt, dummy_validation_code};
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
struct MockRuntimeApi {
|
||||
#[derive(Default)]
|
||||
struct MockSubsystemClient {
|
||||
submitted_pvf_check_statement: Arc<Mutex<Vec<(PvfCheckStatement, ValidatorSignature)>>>,
|
||||
authorities: Vec<AuthorityDiscoveryId>,
|
||||
validators: Vec<ValidatorId>,
|
||||
validator_groups: Vec<Vec<ValidatorIndex>>,
|
||||
availability_cores: Vec<CoreState>,
|
||||
availability_cores_wait: Arc<Mutex<()>>,
|
||||
validation_data: HashMap<ParaId, PersistedValidationData>,
|
||||
session_index_for_child: SessionIndex,
|
||||
session_info: HashMap<SessionIndex, SessionInfo>,
|
||||
validation_code: HashMap<ParaId, ValidationCode>,
|
||||
validation_code_by_hash: HashMap<ValidationCodeHash, ValidationCode>,
|
||||
validation_outputs_results: HashMap<ParaId, bool>,
|
||||
session_index_for_child: SessionIndex,
|
||||
candidate_pending_availability: HashMap<ParaId, CommittedCandidateReceipt>,
|
||||
candidate_events: Vec<CandidateEvent>,
|
||||
dmq_contents: HashMap<ParaId, Vec<InboundDownwardMessage>>,
|
||||
hrmp_channels: HashMap<ParaId, BTreeMap<ParaId, Vec<InboundHrmpMessage>>>,
|
||||
validation_code_by_hash: HashMap<ValidationCodeHash, ValidationCode>,
|
||||
availability_cores_wait: Arc<Mutex<()>>,
|
||||
babe_epoch: Option<BabeEpoch>,
|
||||
on_chain_votes: Option<ScrapedOnChainVotes>,
|
||||
submitted_pvf_check_statement: Arc<Mutex<Vec<(PvfCheckStatement, ValidatorSignature)>>>,
|
||||
pvfs_require_precheck: Vec<ValidationCodeHash>,
|
||||
validation_code_hash: HashMap<ParaId, ValidationCodeHash>,
|
||||
session_info: HashMap<SessionIndex, SessionInfo>,
|
||||
candidate_events: Vec<CandidateEvent>,
|
||||
}
|
||||
|
||||
impl ProvideRuntimeApi<Block> for MockRuntimeApi {
|
||||
type Api = Self;
|
||||
|
||||
fn runtime_api<'a>(&'a self) -> sp_api::ApiRef<'a, Self::Api> {
|
||||
self.clone().into()
|
||||
}
|
||||
}
|
||||
|
||||
sp_api::mock_impl_runtime_apis! {
|
||||
impl ParachainHost<Block> for MockRuntimeApi {
|
||||
fn validators(&self) -> Vec<ValidatorId> {
|
||||
self.validators.clone()
|
||||
}
|
||||
|
||||
fn validator_groups(&self) -> (Vec<Vec<ValidatorIndex>>, GroupRotationInfo) {
|
||||
(
|
||||
self.validator_groups.clone(),
|
||||
GroupRotationInfo {
|
||||
session_start_block: 1,
|
||||
group_rotation_frequency: 100,
|
||||
now: 10,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn availability_cores(&self) -> Vec<CoreState> {
|
||||
let _lock = self.availability_cores_wait.lock().unwrap();
|
||||
self.availability_cores.clone()
|
||||
}
|
||||
|
||||
fn persisted_validation_data(
|
||||
&self,
|
||||
para: ParaId,
|
||||
_assumption: OccupiedCoreAssumption,
|
||||
) -> Option<PersistedValidationData> {
|
||||
self.validation_data.get(¶).cloned()
|
||||
}
|
||||
|
||||
fn assumed_validation_data(
|
||||
para_id: ParaId,
|
||||
expected_persisted_validation_data_hash: Hash,
|
||||
) -> Option<(PersistedValidationData, ValidationCodeHash)> {
|
||||
self.validation_data
|
||||
.get(¶_id)
|
||||
.cloned()
|
||||
.filter(|data| data.hash() == expected_persisted_validation_data_hash)
|
||||
.zip(self.validation_code.get(¶_id).map(|code| code.hash()))
|
||||
}
|
||||
|
||||
fn check_validation_outputs(
|
||||
&self,
|
||||
para_id: ParaId,
|
||||
_commitments: polkadot_primitives::CandidateCommitments,
|
||||
) -> bool {
|
||||
self.validation_outputs_results
|
||||
.get(¶_id)
|
||||
.cloned()
|
||||
.expect(
|
||||
"`check_validation_outputs` called but the expected result hasn't been supplied"
|
||||
)
|
||||
}
|
||||
|
||||
fn session_index_for_child(&self) -> SessionIndex {
|
||||
self.session_index_for_child.clone()
|
||||
}
|
||||
|
||||
fn session_info(&self, index: SessionIndex) -> Option<SessionInfo> {
|
||||
self.session_info.get(&index).cloned()
|
||||
}
|
||||
|
||||
fn validation_code(
|
||||
&self,
|
||||
para: ParaId,
|
||||
_assumption: OccupiedCoreAssumption,
|
||||
) -> Option<ValidationCode> {
|
||||
self.validation_code.get(¶).map(|c| c.clone())
|
||||
}
|
||||
|
||||
fn candidate_pending_availability(
|
||||
&self,
|
||||
para: ParaId,
|
||||
) -> Option<CommittedCandidateReceipt> {
|
||||
self.candidate_pending_availability.get(¶).map(|c| c.clone())
|
||||
}
|
||||
|
||||
fn candidate_events(&self) -> Vec<CandidateEvent> {
|
||||
self.candidate_events.clone()
|
||||
}
|
||||
|
||||
fn dmq_contents(
|
||||
&self,
|
||||
recipient: ParaId,
|
||||
) -> Vec<InboundDownwardMessage> {
|
||||
self.dmq_contents.get(&recipient).map(|q| q.clone()).unwrap_or_default()
|
||||
}
|
||||
|
||||
fn inbound_hrmp_channels_contents(
|
||||
&self,
|
||||
recipient: ParaId
|
||||
) -> BTreeMap<ParaId, Vec<InboundHrmpMessage>> {
|
||||
self.hrmp_channels.get(&recipient).map(|q| q.clone()).unwrap_or_default()
|
||||
}
|
||||
|
||||
fn validation_code_by_hash(
|
||||
&self,
|
||||
hash: ValidationCodeHash,
|
||||
) -> Option<ValidationCode> {
|
||||
self.validation_code_by_hash.get(&hash).map(|c| c.clone())
|
||||
}
|
||||
|
||||
fn on_chain_votes(&self) -> Option<ScrapedOnChainVotes> {
|
||||
self.on_chain_votes.clone()
|
||||
}
|
||||
|
||||
fn submit_pvf_check_statement(stmt: PvfCheckStatement, signature: ValidatorSignature) {
|
||||
self
|
||||
.submitted_pvf_check_statement
|
||||
.lock()
|
||||
.expect("poisoned mutext")
|
||||
.push((stmt, signature));
|
||||
}
|
||||
|
||||
fn pvfs_require_precheck() -> Vec<ValidationCodeHash> {
|
||||
self.pvfs_require_precheck.clone()
|
||||
}
|
||||
|
||||
fn validation_code_hash(
|
||||
&self,
|
||||
para: ParaId,
|
||||
_assumption: OccupiedCoreAssumption,
|
||||
) -> Option<ValidationCodeHash> {
|
||||
self.validation_code_hash.get(¶).map(|c| c.clone())
|
||||
}
|
||||
#[async_trait::async_trait]
|
||||
impl RuntimeApiSubsystemClient for MockSubsystemClient {
|
||||
async fn api_version_parachain_host(&self, _: Hash) -> Result<Option<u32>, ApiError> {
|
||||
Ok(Some(5))
|
||||
}
|
||||
|
||||
impl BabeApi<Block> for MockRuntimeApi {
|
||||
fn configuration(&self) -> sp_consensus_babe::BabeConfiguration {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn current_epoch_start(&self) -> sp_consensus_babe::Slot {
|
||||
self.babe_epoch.as_ref().unwrap().start_slot
|
||||
}
|
||||
|
||||
fn current_epoch(&self) -> BabeEpoch {
|
||||
self.babe_epoch.as_ref().unwrap().clone()
|
||||
}
|
||||
|
||||
fn next_epoch(&self) -> BabeEpoch {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn generate_key_ownership_proof(
|
||||
_slot: sp_consensus_babe::Slot,
|
||||
_authority_id: sp_consensus_babe::AuthorityId,
|
||||
) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> {
|
||||
None
|
||||
}
|
||||
|
||||
fn submit_report_equivocation_unsigned_extrinsic(
|
||||
_equivocation_proof: sp_consensus_babe::EquivocationProof<polkadot_primitives::Header>,
|
||||
_key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof,
|
||||
) -> Option<()> {
|
||||
None
|
||||
}
|
||||
async fn validators(&self, _: Hash) -> Result<Vec<ValidatorId>, ApiError> {
|
||||
Ok(self.validators.clone())
|
||||
}
|
||||
|
||||
impl AuthorityDiscoveryApi<Block> for MockRuntimeApi {
|
||||
fn authorities(&self) -> Vec<AuthorityDiscoveryId> {
|
||||
self.authorities.clone()
|
||||
}
|
||||
async fn validator_groups(
|
||||
&self,
|
||||
_: Hash,
|
||||
) -> Result<(Vec<Vec<ValidatorIndex>>, GroupRotationInfo<BlockNumber>), ApiError> {
|
||||
Ok((
|
||||
self.validator_groups.clone(),
|
||||
GroupRotationInfo { session_start_block: 1, group_rotation_frequency: 100, now: 10 },
|
||||
))
|
||||
}
|
||||
|
||||
async fn availability_cores(
|
||||
&self,
|
||||
_: Hash,
|
||||
) -> Result<Vec<CoreState<Hash, BlockNumber>>, ApiError> {
|
||||
let _lock = self.availability_cores_wait.lock().unwrap();
|
||||
Ok(self.availability_cores.clone())
|
||||
}
|
||||
|
||||
async fn persisted_validation_data(
|
||||
&self,
|
||||
_: Hash,
|
||||
para_id: ParaId,
|
||||
_: OccupiedCoreAssumption,
|
||||
) -> Result<Option<PersistedValidationData<Hash, BlockNumber>>, ApiError> {
|
||||
Ok(self.validation_data.get(¶_id).cloned())
|
||||
}
|
||||
|
||||
async fn assumed_validation_data(
|
||||
&self,
|
||||
_: Hash,
|
||||
para_id: ParaId,
|
||||
expected_persisted_validation_data_hash: Hash,
|
||||
) -> Result<Option<(PersistedValidationData<Hash, BlockNumber>, ValidationCodeHash)>, ApiError>
|
||||
{
|
||||
Ok(self
|
||||
.validation_data
|
||||
.get(¶_id)
|
||||
.cloned()
|
||||
.filter(|data| data.hash() == expected_persisted_validation_data_hash)
|
||||
.zip(self.validation_code.get(¶_id).map(|code| code.hash())))
|
||||
}
|
||||
|
||||
async fn check_validation_outputs(
|
||||
&self,
|
||||
_: Hash,
|
||||
para_id: ParaId,
|
||||
_: CandidateCommitments,
|
||||
) -> Result<bool, ApiError> {
|
||||
Ok(self.validation_outputs_results.get(¶_id).copied().unwrap())
|
||||
}
|
||||
|
||||
async fn session_index_for_child(&self, _: Hash) -> Result<SessionIndex, ApiError> {
|
||||
Ok(self.session_index_for_child)
|
||||
}
|
||||
|
||||
async fn validation_code(
|
||||
&self,
|
||||
_: Hash,
|
||||
para_id: ParaId,
|
||||
_: OccupiedCoreAssumption,
|
||||
) -> Result<Option<ValidationCode>, ApiError> {
|
||||
Ok(self.validation_code.get(¶_id).cloned())
|
||||
}
|
||||
|
||||
async fn candidate_pending_availability(
|
||||
&self,
|
||||
_: Hash,
|
||||
para_id: ParaId,
|
||||
) -> Result<Option<CommittedCandidateReceipt<Hash>>, ApiError> {
|
||||
Ok(self.candidate_pending_availability.get(¶_id).cloned())
|
||||
}
|
||||
|
||||
async fn candidate_events(&self, _: Hash) -> Result<Vec<CandidateEvent<Hash>>, ApiError> {
|
||||
Ok(self.candidate_events.clone())
|
||||
}
|
||||
|
||||
async fn dmq_contents(
|
||||
&self,
|
||||
_: Hash,
|
||||
para_id: ParaId,
|
||||
) -> Result<Vec<InboundDownwardMessage<BlockNumber>>, ApiError> {
|
||||
Ok(self.dmq_contents.get(¶_id).cloned().unwrap())
|
||||
}
|
||||
|
||||
async fn inbound_hrmp_channels_contents(
|
||||
&self,
|
||||
_: Hash,
|
||||
para_id: ParaId,
|
||||
) -> Result<BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>>, ApiError> {
|
||||
Ok(self.hrmp_channels.get(¶_id).cloned().unwrap())
|
||||
}
|
||||
|
||||
async fn validation_code_by_hash(
|
||||
&self,
|
||||
_: Hash,
|
||||
hash: ValidationCodeHash,
|
||||
) -> Result<Option<ValidationCode>, ApiError> {
|
||||
Ok(self.validation_code_by_hash.get(&hash).cloned())
|
||||
}
|
||||
|
||||
async fn on_chain_votes(&self, _: Hash) -> Result<Option<ScrapedOnChainVotes<Hash>>, ApiError> {
|
||||
todo!("Not required for tests")
|
||||
}
|
||||
|
||||
async fn session_info(
|
||||
&self,
|
||||
_: Hash,
|
||||
index: SessionIndex,
|
||||
) -> Result<Option<SessionInfo>, ApiError> {
|
||||
Ok(self.session_info.get(&index).cloned())
|
||||
}
|
||||
|
||||
async fn submit_pvf_check_statement(
|
||||
&self,
|
||||
_: Hash,
|
||||
stmt: PvfCheckStatement,
|
||||
sig: ValidatorSignature,
|
||||
) -> Result<(), ApiError> {
|
||||
self.submitted_pvf_check_statement.lock().unwrap().push((stmt, sig));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn pvfs_require_precheck(&self, _: Hash) -> Result<Vec<ValidationCodeHash>, ApiError> {
|
||||
Ok(self.pvfs_require_precheck.clone())
|
||||
}
|
||||
|
||||
async fn validation_code_hash(
|
||||
&self,
|
||||
_: Hash,
|
||||
para_id: ParaId,
|
||||
_: OccupiedCoreAssumption,
|
||||
) -> Result<Option<ValidationCodeHash>, ApiError> {
|
||||
Ok(self.validation_code_hash.get(¶_id).cloned())
|
||||
}
|
||||
|
||||
async fn disputes(
|
||||
&self,
|
||||
_: Hash,
|
||||
) -> Result<Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)>, ApiError> {
|
||||
todo!("Not required for tests")
|
||||
}
|
||||
|
||||
async fn unapplied_slashes(
|
||||
&self,
|
||||
_: Hash,
|
||||
) -> Result<Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)>, ApiError> {
|
||||
todo!("Not required for tests")
|
||||
}
|
||||
|
||||
async fn key_ownership_proof(
|
||||
&self,
|
||||
_: Hash,
|
||||
_: ValidatorId,
|
||||
) -> Result<Option<vstaging::slashing::OpaqueKeyOwnershipProof>, ApiError> {
|
||||
todo!("Not required for tests")
|
||||
}
|
||||
|
||||
async fn submit_report_dispute_lost(
|
||||
&self,
|
||||
_: Hash,
|
||||
_: vstaging::slashing::DisputeProof,
|
||||
_: vstaging::slashing::OpaqueKeyOwnershipProof,
|
||||
) -> Result<Option<()>, ApiError> {
|
||||
todo!("Not required for tests")
|
||||
}
|
||||
|
||||
async fn session_executor_params(
|
||||
&self,
|
||||
_: Hash,
|
||||
_: SessionIndex,
|
||||
) -> Result<Option<ExecutorParams>, ApiError> {
|
||||
todo!("Not required for tests")
|
||||
}
|
||||
|
||||
async fn current_epoch(&self, _: Hash) -> Result<sp_consensus_babe::Epoch, ApiError> {
|
||||
Ok(self.babe_epoch.as_ref().unwrap().clone())
|
||||
}
|
||||
|
||||
async fn authorities(&self, _: Hash) -> Result<Vec<AuthorityDiscoveryId>, ApiError> {
|
||||
Ok(self.authorities.clone())
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn requests_authorities() {
|
||||
let (ctx, mut ctx_handle) = make_subsystem_context(TaskExecutor::new());
|
||||
let runtime_api = Arc::new(MockRuntimeApi::default());
|
||||
let substem_client = Arc::new(MockSubsystemClient::default());
|
||||
let relay_parent = [1; 32].into();
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(substem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -253,7 +270,7 @@ fn requests_authorities() {
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), runtime_api.authorities);
|
||||
assert_eq!(rx.await.unwrap().unwrap(), substem_client.authorities);
|
||||
|
||||
ctx_handle.send(FromOrchestra::Signal(OverseerSignal::Conclude)).await;
|
||||
};
|
||||
@@ -264,12 +281,12 @@ fn requests_authorities() {
|
||||
#[test]
|
||||
fn requests_validators() {
|
||||
let (ctx, mut ctx_handle) = make_subsystem_context(TaskExecutor::new());
|
||||
let runtime_api = Arc::new(MockRuntimeApi::default());
|
||||
let subsystem_client = Arc::new(MockSubsystemClient::default());
|
||||
let relay_parent = [1; 32].into();
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -280,7 +297,7 @@ fn requests_validators() {
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), runtime_api.validators);
|
||||
assert_eq!(rx.await.unwrap().unwrap(), subsystem_client.validators);
|
||||
|
||||
ctx_handle.send(FromOrchestra::Signal(OverseerSignal::Conclude)).await;
|
||||
};
|
||||
@@ -291,12 +308,12 @@ fn requests_validators() {
|
||||
#[test]
|
||||
fn requests_validator_groups() {
|
||||
let (ctx, mut ctx_handle) = make_subsystem_context(TaskExecutor::new());
|
||||
let runtime_api = Arc::new(MockRuntimeApi::default());
|
||||
let subsystem_client = Arc::new(MockSubsystemClient::default());
|
||||
let relay_parent = [1; 32].into();
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -307,7 +324,7 @@ fn requests_validator_groups() {
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap().0, runtime_api.validator_groups);
|
||||
assert_eq!(rx.await.unwrap().unwrap().0, subsystem_client.validator_groups);
|
||||
|
||||
ctx_handle.send(FromOrchestra::Signal(OverseerSignal::Conclude)).await;
|
||||
};
|
||||
@@ -318,12 +335,12 @@ fn requests_validator_groups() {
|
||||
#[test]
|
||||
fn requests_availability_cores() {
|
||||
let (ctx, mut ctx_handle) = make_subsystem_context(TaskExecutor::new());
|
||||
let runtime_api = Arc::new(MockRuntimeApi::default());
|
||||
let subsystem_client = Arc::new(MockSubsystemClient::default());
|
||||
let relay_parent = [1; 32].into();
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -334,7 +351,7 @@ fn requests_availability_cores() {
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), runtime_api.availability_cores);
|
||||
assert_eq!(rx.await.unwrap().unwrap(), subsystem_client.availability_cores);
|
||||
|
||||
ctx_handle.send(FromOrchestra::Signal(OverseerSignal::Conclude)).await;
|
||||
};
|
||||
@@ -350,12 +367,12 @@ fn requests_persisted_validation_data() {
|
||||
let para_b = ParaId::from(6_u32);
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
|
||||
let mut runtime_api = MockRuntimeApi::default();
|
||||
runtime_api.validation_data.insert(para_a, Default::default());
|
||||
let runtime_api = Arc::new(runtime_api);
|
||||
let mut subsystem_client = MockSubsystemClient::default();
|
||||
subsystem_client.validation_data.insert(para_a, Default::default());
|
||||
let subsystem_client = Arc::new(subsystem_client);
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -401,14 +418,14 @@ fn requests_assumed_validation_data() {
|
||||
let expected_data_hash = <PersistedValidationData as Default>::default().hash();
|
||||
let expected_code_hash = validation_code.hash();
|
||||
|
||||
let mut runtime_api = MockRuntimeApi::default();
|
||||
runtime_api.validation_data.insert(para_a, Default::default());
|
||||
runtime_api.validation_code.insert(para_a, validation_code);
|
||||
runtime_api.validation_data.insert(para_b, Default::default());
|
||||
let runtime_api = Arc::new(runtime_api);
|
||||
let mut subsystem_client = MockSubsystemClient::default();
|
||||
subsystem_client.validation_data.insert(para_a, Default::default());
|
||||
subsystem_client.validation_code.insert(para_a, validation_code);
|
||||
subsystem_client.validation_data.insert(para_b, Default::default());
|
||||
let subsystem_client = Arc::new(subsystem_client);
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -445,20 +462,20 @@ fn requests_assumed_validation_data() {
|
||||
#[test]
|
||||
fn requests_check_validation_outputs() {
|
||||
let (ctx, mut ctx_handle) = make_subsystem_context(TaskExecutor::new());
|
||||
let mut runtime_api = MockRuntimeApi::default();
|
||||
let mut subsystem_client = MockSubsystemClient::default();
|
||||
let relay_parent = [1; 32].into();
|
||||
let para_a = ParaId::from(5_u32);
|
||||
let para_b = ParaId::from(6_u32);
|
||||
let commitments = polkadot_primitives::CandidateCommitments::default();
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
|
||||
runtime_api.validation_outputs_results.insert(para_a, false);
|
||||
runtime_api.validation_outputs_results.insert(para_b, true);
|
||||
subsystem_client.validation_outputs_results.insert(para_a, false);
|
||||
subsystem_client.validation_outputs_results.insert(para_b, true);
|
||||
|
||||
let runtime_api = Arc::new(runtime_api);
|
||||
let subsystem_client = Arc::new(subsystem_client);
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -471,7 +488,10 @@ fn requests_check_validation_outputs() {
|
||||
),
|
||||
})
|
||||
.await;
|
||||
assert_eq!(rx.await.unwrap().unwrap(), runtime_api.validation_outputs_results[¶_a]);
|
||||
assert_eq!(
|
||||
rx.await.unwrap().unwrap(),
|
||||
subsystem_client.validation_outputs_results[¶_a]
|
||||
);
|
||||
|
||||
let (tx, rx) = oneshot::channel();
|
||||
ctx_handle
|
||||
@@ -482,7 +502,10 @@ fn requests_check_validation_outputs() {
|
||||
),
|
||||
})
|
||||
.await;
|
||||
assert_eq!(rx.await.unwrap().unwrap(), runtime_api.validation_outputs_results[¶_b]);
|
||||
assert_eq!(
|
||||
rx.await.unwrap().unwrap(),
|
||||
subsystem_client.validation_outputs_results[¶_b]
|
||||
);
|
||||
|
||||
ctx_handle.send(FromOrchestra::Signal(OverseerSignal::Conclude)).await;
|
||||
};
|
||||
@@ -493,12 +516,12 @@ fn requests_check_validation_outputs() {
|
||||
#[test]
|
||||
fn requests_session_index_for_child() {
|
||||
let (ctx, mut ctx_handle) = make_subsystem_context(TaskExecutor::new());
|
||||
let runtime_api = Arc::new(MockRuntimeApi::default());
|
||||
let subsystem_client = Arc::new(MockSubsystemClient::default());
|
||||
let relay_parent = [1; 32].into();
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -509,7 +532,7 @@ fn requests_session_index_for_child() {
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), runtime_api.session_index_for_child);
|
||||
assert_eq!(rx.await.unwrap().unwrap(), subsystem_client.session_index_for_child);
|
||||
|
||||
ctx_handle.send(FromOrchestra::Signal(OverseerSignal::Conclude)).await;
|
||||
};
|
||||
@@ -537,16 +560,16 @@ fn dummy_session_info() -> SessionInfo {
|
||||
#[test]
|
||||
fn requests_session_info() {
|
||||
let (ctx, mut ctx_handle) = make_subsystem_context(TaskExecutor::new());
|
||||
let mut runtime_api = MockRuntimeApi::default();
|
||||
let mut subsystem_client = MockSubsystemClient::default();
|
||||
let session_index = 1;
|
||||
runtime_api.session_info.insert(session_index, dummy_session_info());
|
||||
let runtime_api = Arc::new(runtime_api);
|
||||
subsystem_client.session_info.insert(session_index, dummy_session_info());
|
||||
let subsystem_client = Arc::new(subsystem_client);
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
|
||||
let relay_parent = [1; 32].into();
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -578,12 +601,12 @@ fn requests_validation_code() {
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
let validation_code = dummy_validation_code();
|
||||
|
||||
let mut runtime_api = MockRuntimeApi::default();
|
||||
runtime_api.validation_code.insert(para_a, validation_code.clone());
|
||||
let runtime_api = Arc::new(runtime_api);
|
||||
let mut subsystem_client = MockSubsystemClient::default();
|
||||
subsystem_client.validation_code.insert(para_a, validation_code.clone());
|
||||
let subsystem_client = Arc::new(subsystem_client);
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -626,14 +649,14 @@ fn requests_candidate_pending_availability() {
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
let candidate_receipt = dummy_committed_candidate_receipt(relay_parent);
|
||||
|
||||
let mut runtime_api = MockRuntimeApi::default();
|
||||
runtime_api
|
||||
let mut subsystem_client = MockSubsystemClient::default();
|
||||
subsystem_client
|
||||
.candidate_pending_availability
|
||||
.insert(para_a, candidate_receipt.clone());
|
||||
let runtime_api = Arc::new(runtime_api);
|
||||
let subsystem_client = Arc::new(subsystem_client);
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -671,12 +694,12 @@ fn requests_candidate_pending_availability() {
|
||||
#[test]
|
||||
fn requests_candidate_events() {
|
||||
let (ctx, mut ctx_handle) = make_subsystem_context(TaskExecutor::new());
|
||||
let runtime_api = Arc::new(MockRuntimeApi::default());
|
||||
let subsystem_client = Arc::new(MockSubsystemClient::default());
|
||||
let relay_parent = [1; 32].into();
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -687,7 +710,7 @@ fn requests_candidate_events() {
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), runtime_api.candidate_events);
|
||||
assert_eq!(rx.await.unwrap().unwrap(), subsystem_client.candidate_events);
|
||||
|
||||
ctx_handle.send(FromOrchestra::Signal(OverseerSignal::Conclude)).await;
|
||||
};
|
||||
@@ -704,20 +727,20 @@ fn requests_dmq_contents() {
|
||||
let para_b = ParaId::from(6_u32);
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
|
||||
let runtime_api = Arc::new({
|
||||
let mut runtime_api = MockRuntimeApi::default();
|
||||
let subsystem_client = Arc::new({
|
||||
let mut subsystem_client = MockSubsystemClient::default();
|
||||
|
||||
runtime_api.dmq_contents.insert(para_a, vec![]);
|
||||
runtime_api.dmq_contents.insert(
|
||||
subsystem_client.dmq_contents.insert(para_a, vec![]);
|
||||
subsystem_client.dmq_contents.insert(
|
||||
para_b,
|
||||
vec![InboundDownwardMessage { sent_at: 228, msg: b"Novus Ordo Seclorum".to_vec() }],
|
||||
);
|
||||
|
||||
runtime_api
|
||||
subsystem_client
|
||||
});
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -758,21 +781,20 @@ fn requests_inbound_hrmp_channels_contents() {
|
||||
(para_a, vec![]),
|
||||
(para_c, vec![InboundHrmpMessage { sent_at: 1, data: "𝙀=𝙈𝘾²".as_bytes().to_owned() }]),
|
||||
]
|
||||
.iter()
|
||||
.cloned()
|
||||
.into_iter()
|
||||
.collect::<BTreeMap<_, _>>();
|
||||
|
||||
let runtime_api = Arc::new({
|
||||
let mut runtime_api = MockRuntimeApi::default();
|
||||
let subsystem_client = Arc::new({
|
||||
let mut subsystem_client = MockSubsystemClient::default();
|
||||
|
||||
runtime_api.hrmp_channels.insert(para_a, BTreeMap::new());
|
||||
runtime_api.hrmp_channels.insert(para_b, para_b_inbound_channels.clone());
|
||||
subsystem_client.hrmp_channels.insert(para_a, BTreeMap::new());
|
||||
subsystem_client.hrmp_channels.insert(para_b, para_b_inbound_channels.clone());
|
||||
|
||||
runtime_api
|
||||
subsystem_client
|
||||
});
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -807,21 +829,21 @@ fn requests_validation_code_by_hash() {
|
||||
let (ctx, mut ctx_handle) = make_subsystem_context(TaskExecutor::new());
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
|
||||
let (runtime_api, validation_code) = {
|
||||
let mut runtime_api = MockRuntimeApi::default();
|
||||
let (subsystem_client, validation_code) = {
|
||||
let mut subsystem_client = MockSubsystemClient::default();
|
||||
let mut validation_code = Vec::new();
|
||||
|
||||
for n in 0..5 {
|
||||
let code = ValidationCode::from(vec![n; 32]);
|
||||
runtime_api.validation_code_by_hash.insert(code.hash(), code.clone());
|
||||
subsystem_client.validation_code_by_hash.insert(code.hash(), code.clone());
|
||||
validation_code.push(code);
|
||||
}
|
||||
|
||||
(runtime_api, validation_code)
|
||||
(Arc::new(subsystem_client), validation_code)
|
||||
};
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(Arc::new(runtime_api), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
|
||||
let relay_parent = [1; 32].into();
|
||||
@@ -849,13 +871,13 @@ fn requests_validation_code_by_hash() {
|
||||
#[test]
|
||||
fn multiple_requests_in_parallel_are_working() {
|
||||
let (ctx, mut ctx_handle) = make_subsystem_context(TaskExecutor::new());
|
||||
let runtime_api = Arc::new(MockRuntimeApi::default());
|
||||
let subsystem_client = Arc::new(MockSubsystemClient::default());
|
||||
let relay_parent = [1; 32].into();
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
let mutex = runtime_api.availability_cores_wait.clone();
|
||||
let mutex = subsystem_client.availability_cores_wait.clone();
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
let test_task = async move {
|
||||
// Make all requests block until we release this mutex.
|
||||
@@ -891,7 +913,7 @@ fn multiple_requests_in_parallel_are_working() {
|
||||
|
||||
join.await
|
||||
.into_iter()
|
||||
.for_each(|r| assert_eq!(r.unwrap().unwrap(), runtime_api.availability_cores));
|
||||
.for_each(|r| assert_eq!(r.unwrap().unwrap(), subsystem_client.availability_cores));
|
||||
|
||||
ctx_handle.send(FromOrchestra::Signal(OverseerSignal::Conclude)).await;
|
||||
};
|
||||
@@ -902,22 +924,22 @@ fn multiple_requests_in_parallel_are_working() {
|
||||
#[test]
|
||||
fn requests_babe_epoch() {
|
||||
let (ctx, mut ctx_handle) = make_subsystem_context(TaskExecutor::new());
|
||||
let mut runtime_api = MockRuntimeApi::default();
|
||||
let mut subsystem_client = MockSubsystemClient::default();
|
||||
let epoch = BabeEpoch {
|
||||
epoch_index: 100,
|
||||
start_slot: sp_consensus_babe::Slot::from(1000),
|
||||
start_slot: Slot::from(1000),
|
||||
duration: 10,
|
||||
authorities: Vec::new(),
|
||||
randomness: [1u8; 32],
|
||||
config: BabeEpochConfiguration { c: (1, 4), allowed_slots: BabeAllowedSlots::PrimarySlots },
|
||||
};
|
||||
runtime_api.babe_epoch = Some(epoch.clone());
|
||||
let runtime_api = Arc::new(runtime_api);
|
||||
subsystem_client.babe_epoch = Some(epoch.clone());
|
||||
let subsystem_client = Arc::new(subsystem_client);
|
||||
let relay_parent = [1; 32].into();
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -939,10 +961,10 @@ fn requests_babe_epoch() {
|
||||
fn requests_submit_pvf_check_statement() {
|
||||
let (ctx, mut ctx_handle) = make_subsystem_context(TaskExecutor::new());
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
let subsystem_client = Arc::new(MockSubsystemClient::default());
|
||||
|
||||
let runtime_api = Arc::new(MockRuntimeApi::default());
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
|
||||
let relay_parent = [1; 32].into();
|
||||
@@ -974,7 +996,7 @@ fn requests_submit_pvf_check_statement() {
|
||||
assert_eq!(rx.await.unwrap().unwrap(), ());
|
||||
|
||||
assert_eq!(
|
||||
&*runtime_api.submitted_pvf_check_statement.lock().expect("poisened mutex"),
|
||||
&*subsystem_client.submitted_pvf_check_statement.lock().expect("poisened mutex"),
|
||||
&[(stmt.clone(), sig.clone()), (stmt.clone(), sig.clone())]
|
||||
);
|
||||
|
||||
@@ -1000,14 +1022,14 @@ fn requests_pvfs_require_precheck() {
|
||||
let (ctx, mut ctx_handle) = make_subsystem_context(TaskExecutor::new());
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
|
||||
let runtime_api = Arc::new({
|
||||
let mut runtime_api = MockRuntimeApi::default();
|
||||
runtime_api.pvfs_require_precheck = vec![[1; 32].into(), [2; 32].into()];
|
||||
runtime_api
|
||||
let subsystem_client = Arc::new({
|
||||
let mut subsystem_client = MockSubsystemClient::default();
|
||||
subsystem_client.pvfs_require_precheck = vec![[1; 32].into(), [2; 32].into()];
|
||||
subsystem_client
|
||||
});
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
|
||||
let relay_parent = [1; 32].into();
|
||||
@@ -1037,12 +1059,14 @@ fn requests_validation_code_hash() {
|
||||
let spawner = sp_core::testing::TaskExecutor::new();
|
||||
let validation_code_hash = dummy_validation_code().hash();
|
||||
|
||||
let mut runtime_api = MockRuntimeApi::default();
|
||||
runtime_api.validation_code_hash.insert(para_a, validation_code_hash.clone());
|
||||
let runtime_api = Arc::new(runtime_api);
|
||||
let mut subsystem_client = MockSubsystemClient::default();
|
||||
subsystem_client
|
||||
.validation_code_hash
|
||||
.insert(para_a, validation_code_hash.clone());
|
||||
let subsystem_client = Arc::new(subsystem_client);
|
||||
|
||||
let subsystem =
|
||||
RuntimeApiSubsystem::new(runtime_api.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
RuntimeApiSubsystem::new(subsystem_client.clone(), Metrics(None), SpawnGlue(spawner));
|
||||
let subsystem_task = run(ctx, subsystem).map(|x| x.unwrap());
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
@@ -28,6 +28,7 @@ use polkadot_cli::{
|
||||
Cli,
|
||||
};
|
||||
use polkadot_node_subsystem::SpawnGlue;
|
||||
use polkadot_node_subsystem_types::DefaultSubsystemClient;
|
||||
use sp_core::traits::SpawnNamed;
|
||||
|
||||
use crate::{
|
||||
@@ -62,7 +63,10 @@ impl OverseerGen for BackGarbageCandidates {
|
||||
&self,
|
||||
connector: OverseerConnector,
|
||||
args: OverseerGenArgs<'a, Spawner, RuntimeClient>,
|
||||
) -> Result<(Overseer<SpawnGlue<Spawner>, Arc<RuntimeClient>>, OverseerHandle), Error>
|
||||
) -> Result<
|
||||
(Overseer<SpawnGlue<Spawner>, Arc<DefaultSubsystemClient<RuntimeClient>>>, OverseerHandle),
|
||||
Error,
|
||||
>
|
||||
where
|
||||
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
|
||||
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
|
||||
|
||||
@@ -32,6 +32,7 @@ use polkadot_cli::{
|
||||
Cli,
|
||||
};
|
||||
use polkadot_node_subsystem::SpawnGlue;
|
||||
use polkadot_node_subsystem_types::DefaultSubsystemClient;
|
||||
use sp_core::traits::SpawnNamed;
|
||||
|
||||
// Filter wrapping related types.
|
||||
@@ -78,7 +79,10 @@ impl OverseerGen for DisputeValidCandidates {
|
||||
&self,
|
||||
connector: OverseerConnector,
|
||||
args: OverseerGenArgs<'a, Spawner, RuntimeClient>,
|
||||
) -> Result<(Overseer<SpawnGlue<Spawner>, Arc<RuntimeClient>>, OverseerHandle), Error>
|
||||
) -> Result<
|
||||
(Overseer<SpawnGlue<Spawner>, Arc<DefaultSubsystemClient<RuntimeClient>>>, OverseerHandle),
|
||||
Error,
|
||||
>
|
||||
where
|
||||
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
|
||||
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
|
||||
|
||||
@@ -33,6 +33,7 @@ use polkadot_cli::{
|
||||
};
|
||||
use polkadot_node_core_candidate_validation::find_validation_data;
|
||||
use polkadot_node_primitives::{AvailableData, BlockData, PoV};
|
||||
use polkadot_node_subsystem_types::DefaultSubsystemClient;
|
||||
use polkadot_primitives::{CandidateDescriptor, CandidateReceipt};
|
||||
|
||||
use polkadot_node_subsystem_util::request_validators;
|
||||
@@ -255,7 +256,10 @@ impl OverseerGen for SuggestGarbageCandidates {
|
||||
&self,
|
||||
connector: OverseerConnector,
|
||||
args: OverseerGenArgs<'a, Spawner, RuntimeClient>,
|
||||
) -> Result<(Overseer<SpawnGlue<Spawner>, Arc<RuntimeClient>>, OverseerHandle), Error>
|
||||
) -> Result<
|
||||
(Overseer<SpawnGlue<Spawner>, Arc<DefaultSubsystemClient<RuntimeClient>>>, OverseerHandle),
|
||||
Error,
|
||||
>
|
||||
where
|
||||
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
|
||||
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
|
||||
|
||||
@@ -32,7 +32,6 @@ polkadot-test-service = { path = "../test/service", features=["runtime-metrics"]
|
||||
substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
prometheus-parse = {version = "0.2.2"}
|
||||
|
||||
[features]
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
use hyper::{Client, Uri};
|
||||
use polkadot_test_service::{node_config, run_validator_node, test_prometheus_config};
|
||||
use primitives::metric_definitions::PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED;
|
||||
use sc_client_api::{execution_extensions::ExecutionStrategies, ExecutionStrategy};
|
||||
use sp_keyring::AccountKeyring::*;
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -41,15 +40,6 @@ async fn runtime_can_publish_metrics() {
|
||||
// Setup the runtime metrics provider.
|
||||
crate::logger_hook()(&mut builder, &alice_config);
|
||||
|
||||
// Override default native strategy, runtime metrics are available only in the wasm runtime.
|
||||
alice_config.execution_strategies = ExecutionStrategies {
|
||||
syncing: ExecutionStrategy::AlwaysWasm,
|
||||
importing: ExecutionStrategy::AlwaysWasm,
|
||||
block_construction: ExecutionStrategy::AlwaysWasm,
|
||||
offchain_worker: ExecutionStrategy::AlwaysWasm,
|
||||
other: ExecutionStrategy::AlwaysWasm,
|
||||
};
|
||||
|
||||
builder.init().expect("Failed to set up the logger");
|
||||
|
||||
// Start validator Alice.
|
||||
|
||||
@@ -24,6 +24,7 @@ sc-network = { git = "https://github.com/paritytech/substrate", branch = "master
|
||||
sc-network-common = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-network-sync = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-sync-state-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -52,6 +52,7 @@ use {
|
||||
peer_set::PeerSetProtocolNames, request_response::ReqProtocolNames,
|
||||
},
|
||||
sc_client_api::BlockBackend,
|
||||
sc_transaction_pool_api::OffchainTransactionPoolFactory,
|
||||
sp_core::traits::SpawnNamed,
|
||||
sp_trie::PrefixedMemoryDB,
|
||||
};
|
||||
@@ -87,7 +88,7 @@ pub use consensus_common::{Proposal, SelectChain};
|
||||
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
|
||||
use mmr_gadget::MmrGadget;
|
||||
pub use polkadot_primitives::{Block, BlockId, BlockNumber, CollatorPair, Hash, Id as ParaId};
|
||||
pub use sc_client_api::{Backend, CallExecutor, ExecutionStrategy};
|
||||
pub use sc_client_api::{Backend, CallExecutor};
|
||||
pub use sc_consensus::{BlockImport, LongestChain};
|
||||
pub use sc_executor::NativeExecutionDispatch;
|
||||
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
|
||||
@@ -513,13 +514,13 @@ where
|
||||
babe::block_import(babe_config.clone(), beefy_block_import, client.clone())?;
|
||||
|
||||
let slot_duration = babe_link.config().slot_duration();
|
||||
let (import_queue, babe_worker_handle) = babe::import_queue(
|
||||
babe_link.clone(),
|
||||
block_import.clone(),
|
||||
Some(Box::new(justification_import)),
|
||||
client.clone(),
|
||||
select_chain.clone(),
|
||||
move |_, ()| async move {
|
||||
let (import_queue, babe_worker_handle) = babe::import_queue(babe::ImportQueueParams {
|
||||
link: babe_link.clone(),
|
||||
block_import: block_import.clone(),
|
||||
justification_import: Some(Box::new(justification_import)),
|
||||
client: client.clone(),
|
||||
select_chain: select_chain.clone(),
|
||||
create_inherent_data_providers: move |_, ()| async move {
|
||||
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
|
||||
|
||||
let slot =
|
||||
@@ -530,10 +531,11 @@ where
|
||||
|
||||
Ok((slot, timestamp))
|
||||
},
|
||||
&task_manager.spawn_essential_handle(),
|
||||
config.prometheus_registry(),
|
||||
telemetry.as_ref().map(|x| x.handle()),
|
||||
)?;
|
||||
spawner: &task_manager.spawn_essential_handle(),
|
||||
registry: config.prometheus_registry(),
|
||||
telemetry: telemetry.as_ref().map(|x| x.handle()),
|
||||
offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool.clone()),
|
||||
})?;
|
||||
|
||||
let justification_stream = grandpa_link.justification_stream();
|
||||
let shared_authority_set = grandpa_link.shared_authority_set().clone();
|
||||
@@ -579,9 +581,10 @@ where
|
||||
beefy_best_block_stream: beefy_rpc_links.from_voter_best_beefy_stream.clone(),
|
||||
subscription_executor,
|
||||
},
|
||||
backend: backend.clone(),
|
||||
};
|
||||
|
||||
polkadot_rpc::create_full(deps, backend.clone()).map_err(Into::into)
|
||||
polkadot_rpc::create_full(deps).map_err(Into::into)
|
||||
}
|
||||
};
|
||||
|
||||
@@ -824,22 +827,25 @@ where
|
||||
})?;
|
||||
|
||||
if config.offchain_worker.enabled {
|
||||
let offchain_workers = Arc::new(sc_offchain::OffchainWorkers::new_with_options(
|
||||
client.clone(),
|
||||
sc_offchain::OffchainWorkerOptions { enable_http_requests: false },
|
||||
));
|
||||
use futures::FutureExt;
|
||||
|
||||
// Start the offchain workers to have
|
||||
task_manager.spawn_handle().spawn(
|
||||
"offchain-notifications",
|
||||
None,
|
||||
sc_offchain::notification_future(
|
||||
config.role.is_authority(),
|
||||
client.clone(),
|
||||
offchain_workers,
|
||||
task_manager.spawn_handle().clone(),
|
||||
network.clone(),
|
||||
),
|
||||
"offchain-workers-runner",
|
||||
"offchain-work",
|
||||
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
|
||||
runtime_api_provider: client.clone(),
|
||||
keystore: Some(keystore_container.keystore()),
|
||||
offchain_db: backend.offchain_storage(),
|
||||
transaction_pool: Some(OffchainTransactionPoolFactory::new(
|
||||
transaction_pool.clone(),
|
||||
)),
|
||||
network_provider: network.clone(),
|
||||
is_validator: role.is_authority(),
|
||||
enable_http_requests: false,
|
||||
custom_extensions: move |_| vec![],
|
||||
})
|
||||
.run(client.clone(), task_manager.spawn_handle())
|
||||
.boxed(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -981,6 +987,9 @@ where
|
||||
overseer_message_channel_capacity_override,
|
||||
req_protocol_names,
|
||||
peerset_protocol_names,
|
||||
offchain_transaction_pool_factory: OffchainTransactionPoolFactory::new(
|
||||
transaction_pool.clone(),
|
||||
),
|
||||
},
|
||||
)
|
||||
.map_err(|e| {
|
||||
@@ -1026,7 +1035,7 @@ where
|
||||
let proposer = sc_basic_authorship::ProposerFactory::new(
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
transaction_pool,
|
||||
transaction_pool.clone(),
|
||||
prometheus_registry.as_ref(),
|
||||
telemetry.as_ref().map(|x| x.handle()),
|
||||
);
|
||||
@@ -1186,6 +1195,7 @@ where
|
||||
prometheus_registry: prometheus_registry.clone(),
|
||||
shared_voter_state,
|
||||
telemetry: telemetry.as_ref().map(|x| x.handle()),
|
||||
offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool.clone()),
|
||||
};
|
||||
|
||||
task_manager.spawn_essential_handle().spawn_blocking(
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use super::{AuthorityDiscoveryApi, Block, Error, Hash, IsCollator, Registry};
|
||||
use polkadot_node_subsystem_types::DefaultSubsystemClient;
|
||||
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
|
||||
use sp_core::traits::SpawnNamed;
|
||||
|
||||
use lru::LruCache;
|
||||
@@ -125,6 +127,8 @@ where
|
||||
pub req_protocol_names: ReqProtocolNames,
|
||||
/// [`PeerSet`] protocol names to protocols mapping.
|
||||
pub peerset_protocol_names: PeerSetProtocolNames,
|
||||
/// The offchain transaction pool factory.
|
||||
pub offchain_transaction_pool_factory: OffchainTransactionPoolFactory<Block>,
|
||||
}
|
||||
|
||||
/// Obtain a prepared `OverseerBuilder`, that is initialized
|
||||
@@ -155,11 +159,12 @@ pub fn prepared_overseer_builder<Spawner, RuntimeClient>(
|
||||
overseer_message_channel_capacity_override,
|
||||
req_protocol_names,
|
||||
peerset_protocol_names,
|
||||
offchain_transaction_pool_factory,
|
||||
}: OverseerGenArgs<Spawner, RuntimeClient>,
|
||||
) -> Result<
|
||||
InitializedOverseerBuilder<
|
||||
SpawnGlue<Spawner>,
|
||||
Arc<RuntimeClient>,
|
||||
Arc<DefaultSubsystemClient<RuntimeClient>>,
|
||||
CandidateValidationSubsystem,
|
||||
PvfCheckerSubsystem,
|
||||
CandidateBackingSubsystem,
|
||||
@@ -169,7 +174,7 @@ pub fn prepared_overseer_builder<Spawner, RuntimeClient>(
|
||||
BitfieldSigningSubsystem,
|
||||
BitfieldDistributionSubsystem,
|
||||
ProvisionerSubsystem,
|
||||
RuntimeApiSubsystem<RuntimeClient>,
|
||||
RuntimeApiSubsystem<DefaultSubsystemClient<RuntimeClient>>,
|
||||
AvailabilityStoreSubsystem,
|
||||
NetworkBridgeRxSubsystem<
|
||||
Arc<sc_network::NetworkService<Block, Hash>>,
|
||||
@@ -204,6 +209,11 @@ where
|
||||
|
||||
let network_bridge_metrics: NetworkBridgeMetrics = Metrics::register(registry)?;
|
||||
|
||||
let runtime_api_client = Arc::new(DefaultSubsystemClient::new(
|
||||
runtime_client.clone(),
|
||||
offchain_transaction_pool_factory,
|
||||
));
|
||||
|
||||
let builder = Overseer::builder()
|
||||
.network_bridge_tx(NetworkBridgeTxSubsystem::new(
|
||||
network_service.clone(),
|
||||
@@ -273,7 +283,7 @@ where
|
||||
})
|
||||
.provisioner(ProvisionerSubsystem::new(Metrics::register(registry)?))
|
||||
.runtime_api(RuntimeApiSubsystem::new(
|
||||
runtime_client.clone(),
|
||||
runtime_api_client.clone(),
|
||||
Metrics::register(registry)?,
|
||||
spawner.clone(),
|
||||
))
|
||||
@@ -312,7 +322,7 @@ where
|
||||
.activation_external_listeners(Default::default())
|
||||
.span_per_active_leaf(Default::default())
|
||||
.active_leaves(Default::default())
|
||||
.supports_parachains(runtime_client)
|
||||
.supports_parachains(runtime_api_client)
|
||||
.known_leaves(LruCache::new(KNOWN_LEAVES_CACHE_SIZE))
|
||||
.metrics(metrics)
|
||||
.spawner(spawner);
|
||||
@@ -334,7 +344,10 @@ pub trait OverseerGen {
|
||||
&self,
|
||||
connector: OverseerConnector,
|
||||
args: OverseerGenArgs<Spawner, RuntimeClient>,
|
||||
) -> Result<(Overseer<SpawnGlue<Spawner>, Arc<RuntimeClient>>, OverseerHandle), Error>
|
||||
) -> Result<
|
||||
(Overseer<SpawnGlue<Spawner>, Arc<DefaultSubsystemClient<RuntimeClient>>>, OverseerHandle),
|
||||
Error,
|
||||
>
|
||||
where
|
||||
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
|
||||
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
|
||||
@@ -358,7 +371,10 @@ impl OverseerGen for RealOverseerGen {
|
||||
&self,
|
||||
connector: OverseerConnector,
|
||||
args: OverseerGenArgs<Spawner, RuntimeClient>,
|
||||
) -> Result<(Overseer<SpawnGlue<Spawner>, Arc<RuntimeClient>>, OverseerHandle), Error>
|
||||
) -> Result<
|
||||
(Overseer<SpawnGlue<Spawner>, Arc<DefaultSubsystemClient<RuntimeClient>>>, OverseerHandle),
|
||||
Error,
|
||||
>
|
||||
where
|
||||
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
|
||||
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
|
||||
|
||||
@@ -18,6 +18,7 @@ sc-network = { git = "https://github.com/paritytech/substrate", branch = "master
|
||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
smallvec = "1.8.0"
|
||||
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
thiserror = "1.0.31"
|
||||
|
||||
@@ -31,7 +31,7 @@ pub mod errors;
|
||||
pub mod messages;
|
||||
|
||||
mod runtime_client;
|
||||
pub use runtime_client::RuntimeApiSubsystemClient;
|
||||
pub use runtime_client::{DefaultSubsystemClient, RuntimeApiSubsystemClient};
|
||||
|
||||
pub use jaeger::*;
|
||||
pub use polkadot_node_jaeger as jaeger;
|
||||
|
||||
@@ -23,10 +23,11 @@ use polkadot_primitives::{
|
||||
SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex,
|
||||
ValidatorSignature,
|
||||
};
|
||||
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
|
||||
use sp_api::{ApiError, ApiExt, ProvideRuntimeApi};
|
||||
use sp_authority_discovery::AuthorityDiscoveryApi;
|
||||
use sp_consensus_babe::{BabeApi, Epoch};
|
||||
use std::collections::BTreeMap;
|
||||
use std::{collections::BTreeMap, sync::Arc};
|
||||
|
||||
/// Exposes all runtime calls that are used by the runtime API subsystem.
|
||||
#[async_trait]
|
||||
@@ -231,28 +232,44 @@ pub trait RuntimeApiSubsystemClient {
|
||||
) -> std::result::Result<Vec<sp_authority_discovery::AuthorityId>, ApiError>;
|
||||
}
|
||||
|
||||
/// Default implementation of [`RuntimeApiSubsystemClient`] using the client.
|
||||
pub struct DefaultSubsystemClient<Client> {
|
||||
client: Arc<Client>,
|
||||
offchain_transaction_pool_factory: OffchainTransactionPoolFactory<Block>,
|
||||
}
|
||||
|
||||
impl<Client> DefaultSubsystemClient<Client> {
|
||||
/// Create new instance.
|
||||
pub fn new(
|
||||
client: Arc<Client>,
|
||||
offchain_transaction_pool_factory: OffchainTransactionPoolFactory<Block>,
|
||||
) -> Self {
|
||||
Self { client, offchain_transaction_pool_factory }
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<T> RuntimeApiSubsystemClient for T
|
||||
impl<Client> RuntimeApiSubsystemClient for DefaultSubsystemClient<Client>
|
||||
where
|
||||
T: ProvideRuntimeApi<Block> + Send + Sync,
|
||||
T::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
|
||||
Client: ProvideRuntimeApi<Block> + Send + Sync,
|
||||
Client::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
|
||||
{
|
||||
async fn validators(&self, at: Hash) -> Result<Vec<ValidatorId>, ApiError> {
|
||||
self.runtime_api().validators(at)
|
||||
self.client.runtime_api().validators(at)
|
||||
}
|
||||
|
||||
async fn validator_groups(
|
||||
&self,
|
||||
at: Hash,
|
||||
) -> Result<(Vec<Vec<ValidatorIndex>>, GroupRotationInfo<BlockNumber>), ApiError> {
|
||||
self.runtime_api().validator_groups(at)
|
||||
self.client.runtime_api().validator_groups(at)
|
||||
}
|
||||
|
||||
async fn availability_cores(
|
||||
&self,
|
||||
at: Hash,
|
||||
) -> Result<Vec<CoreState<Hash, BlockNumber>>, ApiError> {
|
||||
self.runtime_api().availability_cores(at)
|
||||
self.client.runtime_api().availability_cores(at)
|
||||
}
|
||||
|
||||
async fn persisted_validation_data(
|
||||
@@ -261,7 +278,7 @@ where
|
||||
para_id: Id,
|
||||
assumption: OccupiedCoreAssumption,
|
||||
) -> Result<Option<PersistedValidationData<Hash, BlockNumber>>, ApiError> {
|
||||
self.runtime_api().persisted_validation_data(at, para_id, assumption)
|
||||
self.client.runtime_api().persisted_validation_data(at, para_id, assumption)
|
||||
}
|
||||
|
||||
async fn assumed_validation_data(
|
||||
@@ -271,7 +288,7 @@ where
|
||||
expected_persisted_validation_data_hash: Hash,
|
||||
) -> Result<Option<(PersistedValidationData<Hash, BlockNumber>, ValidationCodeHash)>, ApiError>
|
||||
{
|
||||
self.runtime_api().assumed_validation_data(
|
||||
self.client.runtime_api().assumed_validation_data(
|
||||
at,
|
||||
para_id,
|
||||
expected_persisted_validation_data_hash,
|
||||
@@ -284,11 +301,11 @@ where
|
||||
para_id: Id,
|
||||
outputs: CandidateCommitments,
|
||||
) -> Result<bool, ApiError> {
|
||||
self.runtime_api().check_validation_outputs(at, para_id, outputs)
|
||||
self.client.runtime_api().check_validation_outputs(at, para_id, outputs)
|
||||
}
|
||||
|
||||
async fn session_index_for_child(&self, at: Hash) -> Result<SessionIndex, ApiError> {
|
||||
self.runtime_api().session_index_for_child(at)
|
||||
self.client.runtime_api().session_index_for_child(at)
|
||||
}
|
||||
|
||||
async fn validation_code(
|
||||
@@ -297,7 +314,7 @@ where
|
||||
para_id: Id,
|
||||
assumption: OccupiedCoreAssumption,
|
||||
) -> Result<Option<ValidationCode>, ApiError> {
|
||||
self.runtime_api().validation_code(at, para_id, assumption)
|
||||
self.client.runtime_api().validation_code(at, para_id, assumption)
|
||||
}
|
||||
|
||||
async fn candidate_pending_availability(
|
||||
@@ -305,11 +322,11 @@ where
|
||||
at: Hash,
|
||||
para_id: Id,
|
||||
) -> Result<Option<CommittedCandidateReceipt<Hash>>, ApiError> {
|
||||
self.runtime_api().candidate_pending_availability(at, para_id)
|
||||
self.client.runtime_api().candidate_pending_availability(at, para_id)
|
||||
}
|
||||
|
||||
async fn candidate_events(&self, at: Hash) -> Result<Vec<CandidateEvent<Hash>>, ApiError> {
|
||||
self.runtime_api().candidate_events(at)
|
||||
self.client.runtime_api().candidate_events(at)
|
||||
}
|
||||
|
||||
async fn dmq_contents(
|
||||
@@ -317,7 +334,7 @@ where
|
||||
at: Hash,
|
||||
recipient: Id,
|
||||
) -> Result<Vec<InboundDownwardMessage<BlockNumber>>, ApiError> {
|
||||
self.runtime_api().dmq_contents(at, recipient)
|
||||
self.client.runtime_api().dmq_contents(at, recipient)
|
||||
}
|
||||
|
||||
async fn inbound_hrmp_channels_contents(
|
||||
@@ -325,7 +342,7 @@ where
|
||||
at: Hash,
|
||||
recipient: Id,
|
||||
) -> Result<BTreeMap<Id, Vec<InboundHrmpMessage<BlockNumber>>>, ApiError> {
|
||||
self.runtime_api().inbound_hrmp_channels_contents(at, recipient)
|
||||
self.client.runtime_api().inbound_hrmp_channels_contents(at, recipient)
|
||||
}
|
||||
|
||||
async fn validation_code_by_hash(
|
||||
@@ -333,14 +350,14 @@ where
|
||||
at: Hash,
|
||||
hash: ValidationCodeHash,
|
||||
) -> Result<Option<ValidationCode>, ApiError> {
|
||||
self.runtime_api().validation_code_by_hash(at, hash)
|
||||
self.client.runtime_api().validation_code_by_hash(at, hash)
|
||||
}
|
||||
|
||||
async fn on_chain_votes(
|
||||
&self,
|
||||
at: Hash,
|
||||
) -> Result<Option<ScrapedOnChainVotes<Hash>>, ApiError> {
|
||||
self.runtime_api().on_chain_votes(at)
|
||||
self.client.runtime_api().on_chain_votes(at)
|
||||
}
|
||||
|
||||
async fn session_executor_params(
|
||||
@@ -348,7 +365,7 @@ where
|
||||
at: Hash,
|
||||
session_index: SessionIndex,
|
||||
) -> Result<Option<ExecutorParams>, ApiError> {
|
||||
self.runtime_api().session_executor_params(at, session_index)
|
||||
self.client.runtime_api().session_executor_params(at, session_index)
|
||||
}
|
||||
|
||||
async fn session_info(
|
||||
@@ -356,7 +373,7 @@ where
|
||||
at: Hash,
|
||||
index: SessionIndex,
|
||||
) -> Result<Option<SessionInfo>, ApiError> {
|
||||
self.runtime_api().session_info(at, index)
|
||||
self.client.runtime_api().session_info(at, index)
|
||||
}
|
||||
|
||||
async fn submit_pvf_check_statement(
|
||||
@@ -365,11 +382,17 @@ where
|
||||
stmt: PvfCheckStatement,
|
||||
signature: ValidatorSignature,
|
||||
) -> Result<(), ApiError> {
|
||||
self.runtime_api().submit_pvf_check_statement(at, stmt, signature)
|
||||
let mut runtime_api = self.client.runtime_api();
|
||||
|
||||
runtime_api.register_extension(
|
||||
self.offchain_transaction_pool_factory.offchain_transaction_pool(at),
|
||||
);
|
||||
|
||||
runtime_api.submit_pvf_check_statement(at, stmt, signature)
|
||||
}
|
||||
|
||||
async fn pvfs_require_precheck(&self, at: Hash) -> Result<Vec<ValidationCodeHash>, ApiError> {
|
||||
self.runtime_api().pvfs_require_precheck(at)
|
||||
self.client.runtime_api().pvfs_require_precheck(at)
|
||||
}
|
||||
|
||||
async fn validation_code_hash(
|
||||
@@ -378,36 +401,36 @@ where
|
||||
para_id: Id,
|
||||
assumption: OccupiedCoreAssumption,
|
||||
) -> Result<Option<ValidationCodeHash>, ApiError> {
|
||||
self.runtime_api().validation_code_hash(at, para_id, assumption)
|
||||
self.client.runtime_api().validation_code_hash(at, para_id, assumption)
|
||||
}
|
||||
|
||||
async fn current_epoch(&self, at: Hash) -> Result<Epoch, ApiError> {
|
||||
self.runtime_api().current_epoch(at)
|
||||
self.client.runtime_api().current_epoch(at)
|
||||
}
|
||||
|
||||
async fn authorities(
|
||||
&self,
|
||||
at: Hash,
|
||||
) -> std::result::Result<Vec<sp_authority_discovery::AuthorityId>, ApiError> {
|
||||
self.runtime_api().authorities(at)
|
||||
self.client.runtime_api().authorities(at)
|
||||
}
|
||||
|
||||
async fn api_version_parachain_host(&self, at: Hash) -> Result<Option<u32>, ApiError> {
|
||||
self.runtime_api().api_version::<dyn ParachainHost<Block>>(at)
|
||||
self.client.runtime_api().api_version::<dyn ParachainHost<Block>>(at)
|
||||
}
|
||||
|
||||
async fn disputes(
|
||||
&self,
|
||||
at: Hash,
|
||||
) -> Result<Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)>, ApiError> {
|
||||
self.runtime_api().disputes(at)
|
||||
self.client.runtime_api().disputes(at)
|
||||
}
|
||||
|
||||
async fn unapplied_slashes(
|
||||
&self,
|
||||
at: Hash,
|
||||
) -> Result<Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)>, ApiError> {
|
||||
self.runtime_api().unapplied_slashes(at)
|
||||
self.client.runtime_api().unapplied_slashes(at)
|
||||
}
|
||||
|
||||
async fn key_ownership_proof(
|
||||
@@ -415,7 +438,7 @@ where
|
||||
at: Hash,
|
||||
validator_id: ValidatorId,
|
||||
) -> Result<Option<vstaging::slashing::OpaqueKeyOwnershipProof>, ApiError> {
|
||||
self.runtime_api().key_ownership_proof(at, validator_id)
|
||||
self.client.runtime_api().key_ownership_proof(at, validator_id)
|
||||
}
|
||||
|
||||
async fn submit_report_dispute_lost(
|
||||
@@ -424,7 +447,12 @@ where
|
||||
dispute_proof: vstaging::slashing::DisputeProof,
|
||||
key_ownership_proof: vstaging::slashing::OpaqueKeyOwnershipProof,
|
||||
) -> Result<Option<()>, ApiError> {
|
||||
self.runtime_api()
|
||||
.submit_report_dispute_lost(at, dispute_proof, key_ownership_proof)
|
||||
let mut runtime_api = self.client.runtime_api();
|
||||
|
||||
runtime_api.register_extension(
|
||||
self.offchain_transaction_pool_factory.offchain_transaction_pool(at),
|
||||
);
|
||||
|
||||
runtime_api.submit_report_dispute_lost(at, dispute_proof, key_ownership_proof)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,12 +75,7 @@ impl TestClientBuilderExt for TestClientBuilder {
|
||||
self.backend().clone(),
|
||||
executor.clone(),
|
||||
Default::default(),
|
||||
ExecutionExtensions::new(
|
||||
Default::default(),
|
||||
None,
|
||||
sc_offchain::OffchainDb::factory_from_backend(&*self.backend()),
|
||||
Arc::new(executor),
|
||||
),
|
||||
ExecutionExtensions::new(Default::default(), Arc::new(executor)),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ use polkadot_test_runtime::{
|
||||
};
|
||||
|
||||
use sc_chain_spec::ChainSpec;
|
||||
use sc_client_api::{execution_extensions::ExecutionStrategies, BlockchainEvents};
|
||||
use sc_client_api::BlockchainEvents;
|
||||
use sc_network::{
|
||||
config::{NetworkConfiguration, TransportConfig},
|
||||
multiaddr, NetworkStateInfo,
|
||||
@@ -157,14 +157,6 @@ pub fn node_config(
|
||||
instantiation_strategy: WasmtimeInstantiationStrategy::PoolingCopyOnWrite,
|
||||
},
|
||||
wasm_runtime_overrides: Default::default(),
|
||||
// NOTE: we enforce the use of the native runtime to make the errors more debuggable
|
||||
execution_strategies: ExecutionStrategies {
|
||||
syncing: sc_client_api::ExecutionStrategy::NativeWhenPossible,
|
||||
importing: sc_client_api::ExecutionStrategy::NativeWhenPossible,
|
||||
block_construction: sc_client_api::ExecutionStrategy::NativeWhenPossible,
|
||||
offchain_worker: sc_client_api::ExecutionStrategy::NativeWhenPossible,
|
||||
other: sc_client_api::ExecutionStrategy::NativeWhenPossible,
|
||||
},
|
||||
rpc_addr: Default::default(),
|
||||
rpc_max_request_size: Default::default(),
|
||||
rpc_max_response_size: Default::default(),
|
||||
|
||||
+13
-6
@@ -89,12 +89,13 @@ pub struct FullDeps<C, P, SC, B> {
|
||||
pub grandpa: GrandpaDeps<B>,
|
||||
/// BEEFY specific dependencies.
|
||||
pub beefy: BeefyDeps,
|
||||
/// Backend used by the node.
|
||||
pub backend: Arc<B>,
|
||||
}
|
||||
|
||||
/// Instantiate all RPC extensions.
|
||||
pub fn create_full<C, P, SC, B>(
|
||||
deps: FullDeps<C, P, SC, B>,
|
||||
backend: Arc<B>,
|
||||
FullDeps { client, pool, select_chain, chain_spec, deny_unsafe, babe, grandpa, beefy, backend } : FullDeps<C, P, SC, B>,
|
||||
) -> Result<RpcExtension, Box<dyn std::error::Error + Send + Sync>>
|
||||
where
|
||||
C: ProvideRuntimeApi<Block>
|
||||
@@ -124,8 +125,6 @@ where
|
||||
use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer};
|
||||
|
||||
let mut io = RpcModule::new(());
|
||||
let FullDeps { client, pool, select_chain, chain_spec, deny_unsafe, babe, grandpa, beefy } =
|
||||
deps;
|
||||
let BabeDeps { babe_worker_handle, keystore } = babe;
|
||||
let GrandpaDeps {
|
||||
shared_voter_state,
|
||||
@@ -135,10 +134,18 @@ where
|
||||
finality_provider,
|
||||
} = grandpa;
|
||||
|
||||
io.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?;
|
||||
io.merge(StateMigration::new(client.clone(), backend.clone(), deny_unsafe).into_rpc())?;
|
||||
io.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?;
|
||||
io.merge(TransactionPayment::new(client.clone()).into_rpc())?;
|
||||
io.merge(Mmr::new(client.clone()).into_rpc())?;
|
||||
io.merge(
|
||||
Mmr::new(
|
||||
client.clone(),
|
||||
backend
|
||||
.offchain_storage()
|
||||
.ok_or("Backend doesn't provide the required offchain storage")?,
|
||||
)
|
||||
.into_rpc(),
|
||||
)?;
|
||||
io.merge(
|
||||
Babe::new(client.clone(), babe_worker_handle.clone(), keystore, select_chain, deny_unsafe)
|
||||
.into_rpc(),
|
||||
|
||||
@@ -14,7 +14,7 @@ short-benchmark-polkadot: &short-bench
|
||||
variables:
|
||||
RUNTIME: polkadot
|
||||
script:
|
||||
- ./artifacts/polkadot benchmark pallet --execution wasm --wasm-execution compiled --chain $RUNTIME-dev --pallet "*" --extrinsic "*" --steps 2 --repeat 1
|
||||
- ./artifacts/polkadot benchmark pallet --wasm-execution compiled --chain $RUNTIME-dev --pallet "*" --extrinsic "*" --steps 2 --repeat 1
|
||||
|
||||
short-benchmark-kusama:
|
||||
<<: *short-bench
|
||||
|
||||
@@ -42,7 +42,6 @@ for PALLET in "${PALLETS[@]}"; do
|
||||
--repeat=20 \
|
||||
--pallet="$PALLET" \
|
||||
--extrinsic="*" \
|
||||
--execution=wasm \
|
||||
--wasm-execution=compiled \
|
||||
--header=./file_header.txt \
|
||||
--output="./runtime/${runtime}/src/weights/${output_file}" 2>&1
|
||||
@@ -58,7 +57,6 @@ echo "[+] Benchmarking block and extrinsic overheads..."
|
||||
OUTPUT=$(
|
||||
./target/production/polkadot benchmark overhead \
|
||||
--chain="${runtime}-dev" \
|
||||
--execution=wasm \
|
||||
--wasm-execution=compiled \
|
||||
--weight-path="runtime/${runtime}/constants/src/weights/" \
|
||||
--warmup=10 \
|
||||
|
||||
@@ -82,7 +82,7 @@ fn benchmark_block(runtime: &str, base_path: &Path, block: u32) -> Result<(), St
|
||||
.arg(base_path)
|
||||
.args(["--from", &block.to_string(), "--to", &block.to_string()])
|
||||
.args(["--repeat", "1"])
|
||||
.args(["--execution", "wasm", "--wasm-execution", "compiled"])
|
||||
.args(["--wasm-execution", "compiled"])
|
||||
.status()
|
||||
.map_err(|e| format!("command failed: {:?}", e))?;
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
use frame_support::{codec::Encode, dispatch::GetDispatchInfo, weights::Weight};
|
||||
use polkadot_test_client::{
|
||||
BlockBuilderExt, ClientBlockImportExt, DefaultTestClientBuilderExt, ExecutionStrategy,
|
||||
InitPolkadotBlockBuilder, TestClientBuilder, TestClientBuilderExt,
|
||||
BlockBuilderExt, ClientBlockImportExt, DefaultTestClientBuilderExt, InitPolkadotBlockBuilder,
|
||||
TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
use polkadot_test_runtime::{pallet_test_notifier, xcm_config::XcmConfig};
|
||||
use polkadot_test_service::construct_extrinsic;
|
||||
@@ -32,9 +32,7 @@ use xcm_executor::traits::WeightBounds;
|
||||
#[test]
|
||||
fn basic_buy_fees_message_executes() {
|
||||
sp_tracing::try_init_simple();
|
||||
let mut client = TestClientBuilder::new()
|
||||
.set_execution_strategy(ExecutionStrategy::AlwaysWasm)
|
||||
.build();
|
||||
let mut client = TestClientBuilder::new().build();
|
||||
|
||||
let msg = Xcm(vec![
|
||||
WithdrawAsset((Parent, 100).into()),
|
||||
@@ -75,9 +73,7 @@ fn basic_buy_fees_message_executes() {
|
||||
#[test]
|
||||
fn transact_recursion_limit_works() {
|
||||
sp_tracing::try_init_simple();
|
||||
let mut client = TestClientBuilder::new()
|
||||
.set_execution_strategy(ExecutionStrategy::AlwaysWasm)
|
||||
.build();
|
||||
let mut client = TestClientBuilder::new().build();
|
||||
|
||||
let mut msg = Xcm(vec![ClearOrigin]);
|
||||
let max_weight = <XcmConfig as xcm_executor::Config>::Weigher::weight(&mut msg).unwrap();
|
||||
@@ -132,9 +128,7 @@ fn query_response_fires() {
|
||||
use polkadot_test_runtime::RuntimeEvent::TestNotifier;
|
||||
|
||||
sp_tracing::try_init_simple();
|
||||
let mut client = TestClientBuilder::new()
|
||||
.set_execution_strategy(ExecutionStrategy::AlwaysWasm)
|
||||
.build();
|
||||
let mut client = TestClientBuilder::new().build();
|
||||
|
||||
let mut block_builder = client.init_polkadot_block_builder();
|
||||
|
||||
@@ -216,9 +210,7 @@ fn query_response_elicits_handler() {
|
||||
use polkadot_test_runtime::RuntimeEvent::TestNotifier;
|
||||
|
||||
sp_tracing::try_init_simple();
|
||||
let mut client = TestClientBuilder::new()
|
||||
.set_execution_strategy(ExecutionStrategy::AlwaysWasm)
|
||||
.build();
|
||||
let mut client = TestClientBuilder::new().build();
|
||||
|
||||
let mut block_builder = client.init_polkadot_block_builder();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user