Skip to content
Merged
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions node/service/src/lazy_loading/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ use crate::{
};
use cumulus_client_parachain_inherent::{MockValidationDataInherentDataProvider, MockXcmConfig};
use cumulus_client_service::ParachainTracingExecuteBlock;
use cumulus_primitives_core::{relay_chain, BlockT, CollectCollationInfo, ParaId};
use cumulus_primitives_core::{
relay_chain, BlockT, CollectCollationInfo, ParaId, RelayParentOffsetApi,
};
use fc_rpc::StorageOverrideHandler;
use fc_rpc_core::types::{FeeHistoryCache, FilterPool};
use frontier_backend::LazyLoadingFrontierBackend;
Expand Down Expand Up @@ -358,7 +360,8 @@ pub async fn new_lazy_loading_service<RuntimeApi, Customizations, Net>(
) -> Result<TaskManager, ServiceError>
where
RuntimeApi: ConstructRuntimeApi<Block, LazyLoadingClient<RuntimeApi>> + Send + Sync + 'static,
RuntimeApi::RuntimeApi: RuntimeApiCollection,
RuntimeApi::RuntimeApi:
RuntimeApiCollection + cumulus_primitives_core::RelayParentOffsetApi<Block>,
Customizations: ClientCustomizations + 'static,
Net: NetworkBackend<Block, Hash>,
{
Expand Down Expand Up @@ -654,6 +657,11 @@ where
}
};

let relay_parent_offset = client_for_xcm
.runtime_api()
.relay_parent_offset(block)
.unwrap_or_default();

let mocked_parachain = MockValidationDataInherentDataProvider {
current_para_block,
para_id: parachain_id,
Expand All @@ -664,7 +672,8 @@ where
UpgradeGoAhead::GoAhead
}),
current_para_block_head,
relay_offset: additional_relay_offset.load(Ordering::SeqCst),
relay_offset: relay_parent_offset
.saturating_add(additional_relay_offset.load(Ordering::SeqCst)),
relay_blocks_per_para_block: 1,
para_blocks_per_relay_epoch: 10,
relay_randomness_config: (),
Expand Down
13 changes: 10 additions & 3 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use cumulus_client_service::{
};
use cumulus_primitives_core::{
relay_chain::{self, well_known_keys, CollatorPair},
CollectCollationInfo, ParaId,
CollectCollationInfo, ParaId, RelayParentOffsetApi,
};
use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain;
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface, RelayChainResult};
Expand Down Expand Up @@ -1297,7 +1297,8 @@ pub async fn new_dev<RuntimeApi, Customizations, Net>(
) -> Result<TaskManager, ServiceError>
where
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi>> + Send + Sync + 'static,
RuntimeApi::RuntimeApi: RuntimeApiCollection,
RuntimeApi::RuntimeApi:
RuntimeApiCollection + cumulus_primitives_core::RelayParentOffsetApi<Block>,
Customizations: ClientCustomizations + 'static,
Net: NetworkBackend<Block, Hash>,
{
Expand Down Expand Up @@ -1548,6 +1549,11 @@ where
}
};

let relay_parent_offset = client_for_xcm
.runtime_api()
.relay_parent_offset(block)
.unwrap_or_default();

let mocked_parachain = MockValidationDataInherentDataProvider {
current_para_block,
para_id: parachain_id,
Expand All @@ -1559,7 +1565,8 @@ where
UpgradeGoAhead::GoAhead
}),
current_para_block_head,
relay_offset: additional_relay_offset.load(Ordering::SeqCst),
relay_offset: relay_parent_offset
.saturating_add(additional_relay_offset.load(Ordering::SeqCst)),
relay_blocks_per_para_block: 1,
para_blocks_per_relay_epoch: 10,
relay_randomness_config: (),
Expand Down
14 changes: 9 additions & 5 deletions node/service/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use sp_block_builder::BlockBuilder;

use crate::client::RuntimeApiCollection;
use crate::RELAY_CHAIN_SLOT_DURATION_MILLIS;
use cumulus_primitives_core::{ParaId, PersistedValidationData};
use cumulus_primitives_core::{ParaId, PersistedValidationData, RelayParentOffsetApi};
use cumulus_primitives_parachain_inherent::ParachainInherentData;
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
use fc_mapping_sync::{kv::MappingSyncWorker, SyncStrategy};
Expand Down Expand Up @@ -175,7 +175,7 @@ where
C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
C: CallApiAt<Block>,
C: Send + Sync + 'static,
C::Api: RuntimeApiCollection,
C::Api: RuntimeApiCollection + RelayParentOffsetApi<Block>,
P: TransactionPool<Block = Block, Hash = <Block as BlockT>::Hash> + 'static,
{
use fc_rpc::{
Expand Down Expand Up @@ -241,6 +241,10 @@ where
);

let maybe_current_para_head = client_for_cidp.expect_header(block);
let relay_parent_offset = client_for_cidp
.runtime_api()
.relay_parent_offset(block)
.unwrap_or_default();
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
async move {
let current_para_block_head = Some(polkadot_primitives::HeadData(
maybe_current_para_head?.encode(),
Expand All @@ -262,8 +266,8 @@ where
// Create a dummy parachain inherent data provider which is required to pass
// the checks by the para chain system. We use dummy values because in the 'pending context'
// neither do we have access to the real values nor do we need them.
let (relay_parent_storage_root, relay_chain_state) =
builder.into_state_root_and_proof();
let (relay_parent_storage_root, relay_chain_state, relay_parent_descendants) =
builder.into_state_root_proof_and_descendants(u64::from(relay_parent_offset));

let vfp = PersistedValidationData {
// This is a hack to make `cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases`
Expand All @@ -277,7 +281,7 @@ where
relay_chain_state,
downward_messages: Default::default(),
horizontal_messages: Default::default(),
relay_parent_descendants: Default::default(),
relay_parent_descendants,
collator_peer_id: None,
};

Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ macro_rules! impl_runtime_apis_plus_common {

impl cumulus_primitives_core::RelayParentOffsetApi<Block> for Runtime {
fn relay_parent_offset() -> u32 {
crate::RELAY_PARENT_OFFSET
crate::AsyncBacking::relay_parent_offset()
}
}

Expand Down
4 changes: 1 addition & 3 deletions runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,8 +746,6 @@ const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
/// into the relay chain.
const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3;
/// Build with an offset of 1 behind the relay chain.
const RELAY_PARENT_OFFSET: u32 = 1;
/// How many parachain blocks are processed by the relay chain per parent. Limits the
/// number of blocks authored per slot.
const BLOCK_PROCESSING_VELOCITY: u32 = 1;
Expand All @@ -771,7 +769,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type ConsensusHook = ConsensusHook;
type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
type WeightInfo = moonbase_weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
type RelayParentOffset = ConstU32<0>;
type RelayParentOffset = AsyncBacking;
}

impl parachain_info::Config for Runtime {}
Expand Down
5 changes: 3 additions & 2 deletions runtime/moonbase/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ pub fn set_parachain_inherent_data() {

relay_sproof.additional_key_values = additional_key_values;

let (relay_parent_storage_root, relay_chain_state) = relay_sproof.into_state_root_and_proof();
let (relay_parent_storage_root, relay_chain_state, relay_parent_descendants) = relay_sproof
.into_state_root_proof_and_descendants(u64::from(AsyncBacking::relay_parent_offset()));

let vfp = PersistedValidationData {
relay_parent_number: 1u32,
Expand All @@ -440,7 +441,7 @@ pub fn set_parachain_inherent_data() {
validation_data: vfp,
relay_chain_state,
collator_peer_id: Default::default(),
relay_parent_descendants: Default::default(),
relay_parent_descendants,
};

let inbound_messages_data = InboundMessagesData {
Expand Down
4 changes: 1 addition & 3 deletions runtime/moonbeam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,8 +709,6 @@ const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
/// into the relay chain.
const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3;
/// Build with an offset of 1 behind the relay chain.
const RELAY_PARENT_OFFSET: u32 = 1;
/// How many parachain blocks are processed by the relay chain per parent. Limits the
/// number of blocks authored per slot.
const BLOCK_PROCESSING_VELOCITY: u32 = 1;
Expand All @@ -734,7 +732,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type ConsensusHook = ConsensusHook;
type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
type WeightInfo = moonbeam_weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
type RelayParentOffset = ConstU32<0>;
type RelayParentOffset = AsyncBacking;
}

pub struct EthereumXcmEnsureProxy;
Expand Down
5 changes: 3 additions & 2 deletions runtime/moonbeam/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ pub fn set_parachain_inherent_data() {

relay_sproof.additional_key_values = additional_key_values;

let (relay_parent_storage_root, relay_chain_state) = relay_sproof.into_state_root_and_proof();
let (relay_parent_storage_root, relay_chain_state, relay_parent_descendants) = relay_sproof
.into_state_root_proof_and_descendants(u64::from(AsyncBacking::relay_parent_offset()));

let vfp = PersistedValidationData {
relay_parent_number: 1u32,
Expand All @@ -455,7 +456,7 @@ pub fn set_parachain_inherent_data() {
validation_data: vfp,
relay_chain_state,
collator_peer_id: Default::default(),
relay_parent_descendants: Default::default(),
relay_parent_descendants,
};

let inbound_messages_data = InboundMessagesData {
Expand Down
4 changes: 1 addition & 3 deletions runtime/moonriver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,8 +747,6 @@ const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
/// into the relay chain.
const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3;
/// Build with an offset of 1 behind the relay chain.
const RELAY_PARENT_OFFSET: u32 = 1;
/// How many parachain blocks are processed by the relay chain per parent. Limits the
/// number of blocks authored per slot.
const BLOCK_PROCESSING_VELOCITY: u32 = 1;
Expand All @@ -772,7 +770,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type ConsensusHook = ConsensusHook;
type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
type WeightInfo = moonriver_weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
type RelayParentOffset = ConstU32<0>;
type RelayParentOffset = AsyncBacking;
}

impl parachain_info::Config for Runtime {}
Expand Down
5 changes: 3 additions & 2 deletions runtime/moonriver/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ pub fn set_parachain_inherent_data() {

relay_sproof.additional_key_values = additional_key_values;

let (relay_parent_storage_root, relay_chain_state) = relay_sproof.into_state_root_and_proof();
let (relay_parent_storage_root, relay_chain_state, relay_parent_descendants) = relay_sproof
.into_state_root_proof_and_descendants(u64::from(AsyncBacking::relay_parent_offset()));

let vfp = PersistedValidationData {
relay_parent_number: 1u32,
Expand All @@ -455,7 +456,7 @@ pub fn set_parachain_inherent_data() {
validation_data: vfp,
relay_chain_state,
collator_peer_id: Default::default(),
relay_parent_descendants: Default::default(),
relay_parent_descendants,
};

let inbound_messages_data = InboundMessagesData {
Expand Down
Loading