mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 19:38:02 +00:00
Replace ValidationData with PersistedValidationData (#291)
* Replace ValidationData with PersistedValidationData * Update polkadot
This commit is contained in:
Generated
+491
-446
File diff suppressed because it is too large
Load Diff
+7
-7
@@ -20,7 +20,7 @@ use cumulus_network::WaitToAnnounce;
|
||||
use cumulus_primitives::{
|
||||
inherents::{self, VALIDATION_DATA_IDENTIFIER},
|
||||
well_known_keys, InboundDownwardMessage, InboundHrmpMessage, OutboundHrmpMessage,
|
||||
ValidationData, relay_chain,
|
||||
PersistedValidationData, relay_chain,
|
||||
};
|
||||
use cumulus_runtime::ParachainBlockData;
|
||||
|
||||
@@ -271,7 +271,7 @@ where
|
||||
/// Get the inherent data with validation function parameters injected
|
||||
fn inherent_data(
|
||||
&mut self,
|
||||
validation_data: &ValidationData,
|
||||
validation_data: &PersistedValidationData,
|
||||
relay_parent: PHash,
|
||||
) -> Option<InherentData> {
|
||||
let mut inherent_data = self
|
||||
@@ -472,12 +472,12 @@ where
|
||||
async fn produce_candidate(
|
||||
mut self,
|
||||
relay_parent: PHash,
|
||||
validation_data: ValidationData,
|
||||
validation_data: PersistedValidationData,
|
||||
) -> Option<Collation> {
|
||||
trace!(target: "cumulus-collator", "Producing candidate");
|
||||
|
||||
let last_head =
|
||||
match Block::Header::decode(&mut &validation_data.persisted.parent_head.0[..]) {
|
||||
match Block::Header::decode(&mut &validation_data.parent_head.0[..]) {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
error!(target: "cumulus-collator", "Could not decode the head data: {:?}", e);
|
||||
@@ -582,7 +582,7 @@ where
|
||||
);
|
||||
|
||||
let collation =
|
||||
self.build_collation(b, block_hash, validation_data.persisted.block_number)?;
|
||||
self.build_collation(b, block_hash, validation_data.block_number)?;
|
||||
let pov_hash = collation.proof_of_validity.hash();
|
||||
|
||||
self.wait_to_announce
|
||||
@@ -842,8 +842,8 @@ mod tests {
|
||||
CollationGenerationMessage::Initialize(config) => config,
|
||||
};
|
||||
|
||||
let mut validation_data = ValidationData::default();
|
||||
validation_data.persisted.parent_head = header.encode().into();
|
||||
let mut validation_data = PersistedValidationData::default();
|
||||
validation_data.parent_head = header.encode().into();
|
||||
|
||||
let collation = block_on((config.collator)(relay_parent, &validation_data))
|
||||
.expect("Collation is build");
|
||||
|
||||
@@ -23,7 +23,7 @@ use polkadot_primitives::v1::{
|
||||
CommittedCandidateReceipt, CoreState, GroupRotationInfo, Hash as PHash, HeadData, Id as ParaId,
|
||||
InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, ParachainHost,
|
||||
PersistedValidationData, SessionIndex, SessionInfo, SigningContext, ValidationCode,
|
||||
ValidationData, ValidatorId, ValidatorIndex,
|
||||
ValidatorId, ValidatorIndex,
|
||||
};
|
||||
use polkadot_test_client::{
|
||||
Client as PClient, ClientBlockImportExt, DefaultTestClientBuilderExt, FullBackend as PBackend,
|
||||
@@ -400,10 +400,6 @@ sp_api::mock_impl_runtime_apis! {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
fn full_validation_data(&self, _: ParaId, _: OccupiedCoreAssumption) -> Option<ValidationData<BlockNumber>> {
|
||||
None
|
||||
}
|
||||
|
||||
fn persisted_validation_data(&self, _: ParaId, _: OccupiedCoreAssumption) -> Option<PersistedValidationData<BlockNumber>> {
|
||||
Some(PersistedValidationData {
|
||||
parent_head: HeadData(default_header().encode()),
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
use cumulus_primitives::{
|
||||
inherents::{ValidationDataType, VALIDATION_DATA_IDENTIFIER as INHERENT_IDENTIFIER},
|
||||
well_known_keys::{NEW_VALIDATION_CODE, VALIDATION_DATA}, AbridgedHostConfiguration,
|
||||
OnValidationData, ValidationData, ParaId, relay_chain,
|
||||
OnValidationData, PersistedValidationData, ParaId, relay_chain,
|
||||
};
|
||||
use frame_support::{
|
||||
decl_error, decl_event, decl_module, decl_storage, ensure, storage,
|
||||
@@ -143,18 +143,18 @@ decl_module! {
|
||||
// which means we can put the initialization logic here to remove the
|
||||
// sequencing problem.
|
||||
if let Some((apply_block, validation_function)) = PendingValidationFunction::get() {
|
||||
if vfp.persisted.block_number >= apply_block {
|
||||
if vfp.block_number >= apply_block {
|
||||
PendingValidationFunction::kill();
|
||||
LastUpgrade::put(&apply_block);
|
||||
Self::put_parachain_code(&validation_function);
|
||||
Self::deposit_event(Event::ValidationFunctionApplied(vfp.persisted.block_number));
|
||||
Self::deposit_event(Event::ValidationFunctionApplied(vfp.block_number));
|
||||
}
|
||||
}
|
||||
|
||||
let (host_config, relevant_messaging_state) =
|
||||
relay_state_snapshot::extract_from_proof(
|
||||
T::SelfParaId::get(),
|
||||
vfp.persisted.relay_storage_root,
|
||||
vfp.relay_storage_root,
|
||||
relay_chain_state
|
||||
)
|
||||
.map_err(|err| {
|
||||
@@ -196,7 +196,7 @@ impl<T: Config> Module<T> {
|
||||
/// Get validation data.
|
||||
///
|
||||
/// Returns `Some(_)` after the inherent set the data for the current block.
|
||||
pub fn validation_data() -> Option<ValidationData> {
|
||||
pub fn validation_data() -> Option<PersistedValidationData> {
|
||||
storage::unhashed::get(VALIDATION_DATA)
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ impl<T: Config> Module<T> {
|
||||
/// Returns if a PVF/runtime upgrade could be signalled at the current block, and if so
|
||||
/// when the new code will take the effect.
|
||||
fn code_upgrade_allowed(
|
||||
vfp: &ValidationData,
|
||||
vfp: &PersistedValidationData,
|
||||
cfg: &AbridgedHostConfiguration,
|
||||
) -> Option<relay_chain::BlockNumber> {
|
||||
if PendingValidationFunction::get().is_some() {
|
||||
@@ -233,7 +233,6 @@ impl<T: Config> Module<T> {
|
||||
}
|
||||
|
||||
let relay_blocks_since_last_upgrade = vfp
|
||||
.persisted
|
||||
.block_number
|
||||
.saturating_sub(LastUpgrade::get());
|
||||
|
||||
@@ -242,7 +241,7 @@ impl<T: Config> Module<T> {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(vfp.persisted.block_number + cfg.validation_upgrade_delay)
|
||||
Some(vfp.block_number + cfg.validation_upgrade_delay)
|
||||
}
|
||||
|
||||
/// The implementation of the runtime upgrade scheduling.
|
||||
@@ -325,7 +324,7 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
use codec::Encode;
|
||||
use cumulus_primitives::{PersistedValidationData, TransientValidationData};
|
||||
use cumulus_primitives::PersistedValidationData;
|
||||
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
|
||||
use frame_support::{
|
||||
assert_ok,
|
||||
@@ -543,13 +542,10 @@ mod tests {
|
||||
}
|
||||
let (relay_storage_root, relay_chain_state) =
|
||||
sproof_builder.into_state_root_and_proof();
|
||||
let vfp = ValidationData {
|
||||
persisted: PersistedValidationData {
|
||||
block_number: *n as RelayChainBlockNumber,
|
||||
relay_storage_root,
|
||||
..Default::default()
|
||||
},
|
||||
transient: TransientValidationData::default(),
|
||||
let vfp = PersistedValidationData {
|
||||
block_number: *n as RelayChainBlockNumber,
|
||||
relay_storage_root,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
storage::unhashed::put(VALIDATION_DATA, &vfp);
|
||||
@@ -582,7 +578,6 @@ mod tests {
|
||||
if self.pending_upgrade.is_some() {
|
||||
panic!("attempted to set validation code while upgrade was pending");
|
||||
}
|
||||
self.pending_upgrade = vfp.transient.code_upgrade_allowed;
|
||||
}
|
||||
|
||||
// clean up
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
pub use polkadot_core_primitives::InboundDownwardMessage;
|
||||
pub use polkadot_parachain::primitives::{Id as ParaId, UpwardMessage, ValidationParams};
|
||||
pub use polkadot_primitives::v1::{
|
||||
PersistedValidationData, TransientValidationData, ValidationData, AbridgedHostConfiguration,
|
||||
AbridgedHrmpChannel,
|
||||
PersistedValidationData, AbridgedHostConfiguration, AbridgedHrmpChannel,
|
||||
};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
@@ -66,7 +65,7 @@ pub mod inherents {
|
||||
/// The type of the inherent.
|
||||
#[derive(codec::Encode, codec::Decode, sp_core::RuntimeDebug, Clone, PartialEq)]
|
||||
pub struct ValidationDataType {
|
||||
pub validation_data: crate::ValidationData,
|
||||
pub validation_data: crate::PersistedValidationData,
|
||||
/// A storage proof of a predefined set of keys from the relay-chain.
|
||||
///
|
||||
/// Specifically this witness contains the data for:
|
||||
@@ -139,5 +138,5 @@ pub trait HrmpMessageSender {
|
||||
/// A trait which is called when the validation data is set.
|
||||
#[impl_trait_for_tuples::impl_for_tuples(30)]
|
||||
pub trait OnValidationData {
|
||||
fn on_validation_data(data: ValidationData);
|
||||
fn on_validation_data(data: PersistedValidationData);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ use cumulus_primitives::{
|
||||
HRMP_OUTBOUND_MESSAGES, HRMP_WATERMARK, NEW_VALIDATION_CODE, PROCESSED_DOWNWARD_MESSAGES,
|
||||
UPWARD_MESSAGES, VALIDATION_DATA,
|
||||
},
|
||||
OutboundHrmpMessage, UpwardMessage, ValidationData,
|
||||
OutboundHrmpMessage, UpwardMessage, PersistedValidationData,
|
||||
};
|
||||
use sp_core::storage::{ChildInfo, TrackedStorageKey};
|
||||
use sp_externalities::{
|
||||
@@ -164,11 +164,11 @@ pub fn validate_block<B: BlockT, E: ExecuteBlock<B>>(params: ValidationParams) -
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
let validation_data: ValidationData = overlay
|
||||
let validation_data: PersistedValidationData = overlay
|
||||
.storage(VALIDATION_DATA)
|
||||
.flatten()
|
||||
.and_then(|v| Decode::decode(&mut &v[..]).ok())
|
||||
.expect("`ValidationData` is required to be placed into the storage!");
|
||||
.expect("`PersistedValidationData` is required to be placed into the storage!");
|
||||
|
||||
let horizontal_messages = match overlay.storage(HRMP_OUTBOUND_MESSAGES).flatten() {
|
||||
Some(encoded) => Vec::<OutboundHrmpMessage>::decode(&mut &encoded[..])
|
||||
@@ -180,7 +180,7 @@ pub fn validate_block<B: BlockT, E: ExecuteBlock<B>>(params: ValidationParams) -
|
||||
.storage(HRMP_WATERMARK)
|
||||
.flatten()
|
||||
.map(|v| Decode::decode(&mut &v[..]).expect("HRMP watermark is not encoded correctly"))
|
||||
.unwrap_or(validation_data.persisted.block_number);
|
||||
.unwrap_or(validation_data.block_number);
|
||||
|
||||
ValidationResult {
|
||||
head_data,
|
||||
@@ -200,32 +200,33 @@ struct WitnessExt<'a, B: BlockT> {
|
||||
}
|
||||
|
||||
impl<'a, B: BlockT> WitnessExt<'a, B> {
|
||||
/// Checks that the encoded `ValidationData` in `data` is correct.
|
||||
/// Checks that the encoded `PersistedValidationData` in `data` is correct.
|
||||
///
|
||||
/// Should be removed with: https://github.com/paritytech/cumulus/issues/217
|
||||
/// When removed `WitnessExt` could also be removed.
|
||||
fn check_validation_data(&self, mut data: &[u8]) {
|
||||
let validation_data = ValidationData::decode(&mut data).expect("Invalid `ValidationData`");
|
||||
let validation_data = PersistedValidationData::decode(&mut data)
|
||||
.expect("Invalid `PersistedValidationData`");
|
||||
|
||||
assert_eq!(
|
||||
self.params.parent_head,
|
||||
validation_data.persisted.parent_head
|
||||
validation_data.parent_head
|
||||
);
|
||||
assert_eq!(
|
||||
self.params.relay_chain_height,
|
||||
validation_data.persisted.block_number
|
||||
validation_data.block_number
|
||||
);
|
||||
assert_eq!(
|
||||
self.params.hrmp_mqc_heads,
|
||||
validation_data.persisted.hrmp_mqc_heads
|
||||
validation_data.hrmp_mqc_heads
|
||||
);
|
||||
assert_eq!(
|
||||
self.params.dmq_mqc_head,
|
||||
validation_data.persisted.dmq_mqc_head,
|
||||
validation_data.dmq_mqc_head,
|
||||
);
|
||||
assert_eq!(
|
||||
self.params.relay_storage_root,
|
||||
validation_data.persisted.relay_storage_root,
|
||||
validation_data.relay_storage_root,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
use crate::ParachainBlockData;
|
||||
|
||||
use cumulus_primitives::{PersistedValidationData, ValidationData};
|
||||
use cumulus_primitives::PersistedValidationData;
|
||||
use cumulus_test_client::{
|
||||
runtime::{Block, Hash, Header, UncheckedExtrinsic, WASM_BINARY},
|
||||
transfer, Client, DefaultTestClientBuilderExt, InitBlockBuilder, LongestChain,
|
||||
@@ -100,12 +100,9 @@ fn build_block_with_witness(
|
||||
let block_id = BlockId::Hash(client.info().best_hash);
|
||||
let mut builder = client.init_block_builder_at(
|
||||
&block_id,
|
||||
Some(ValidationData {
|
||||
persisted: PersistedValidationData {
|
||||
block_number: 1,
|
||||
parent_head: parent_head.encode().into(),
|
||||
..Default::default()
|
||||
},
|
||||
Some(PersistedValidationData {
|
||||
block_number: 1,
|
||||
parent_head: parent_head.encode().into(),
|
||||
..Default::default()
|
||||
}),
|
||||
sproof_builder,
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
use crate::{Backend, Client};
|
||||
use cumulus_primitives::{
|
||||
inherents::{ValidationDataType, VALIDATION_DATA_IDENTIFIER},
|
||||
ValidationData,
|
||||
inherents::{ValidationDataType, VALIDATION_DATA_IDENTIFIER}, PersistedValidationData,
|
||||
};
|
||||
use cumulus_test_runtime::{Block, GetLastTimestamp};
|
||||
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
|
||||
@@ -37,7 +36,7 @@ pub trait InitBlockBuilder {
|
||||
/// just use a default one.
|
||||
fn init_block_builder(
|
||||
&self,
|
||||
validation_data: Option<ValidationData<PBlockNumber>>,
|
||||
validation_data: Option<PersistedValidationData<PBlockNumber>>,
|
||||
relay_sproof_builder: RelayStateSproofBuilder,
|
||||
) -> sc_block_builder::BlockBuilder<Block, Client, Backend>;
|
||||
|
||||
@@ -48,7 +47,7 @@ pub trait InitBlockBuilder {
|
||||
fn init_block_builder_at(
|
||||
&self,
|
||||
at: &BlockId<Block>,
|
||||
validation_data: Option<ValidationData<PBlockNumber>>,
|
||||
validation_data: Option<PersistedValidationData<PBlockNumber>>,
|
||||
relay_sproof_builder: RelayStateSproofBuilder,
|
||||
) -> sc_block_builder::BlockBuilder<Block, Client, Backend>;
|
||||
}
|
||||
@@ -56,7 +55,7 @@ pub trait InitBlockBuilder {
|
||||
impl InitBlockBuilder for Client {
|
||||
fn init_block_builder(
|
||||
&self,
|
||||
validation_data: Option<ValidationData<PBlockNumber>>,
|
||||
validation_data: Option<PersistedValidationData<PBlockNumber>>,
|
||||
relay_sproof_builder: RelayStateSproofBuilder,
|
||||
) -> BlockBuilder<Block, Client, Backend> {
|
||||
let chain_info = self.chain_info();
|
||||
@@ -70,7 +69,7 @@ impl InitBlockBuilder for Client {
|
||||
fn init_block_builder_at(
|
||||
&self,
|
||||
at: &BlockId<Block>,
|
||||
validation_data: Option<ValidationData<PBlockNumber>>,
|
||||
validation_data: Option<PersistedValidationData<PBlockNumber>>,
|
||||
relay_sproof_builder: RelayStateSproofBuilder,
|
||||
) -> BlockBuilder<Block, Client, Backend> {
|
||||
let mut block_builder = self
|
||||
@@ -94,11 +93,11 @@ impl InitBlockBuilder for Client {
|
||||
|
||||
let mut validation_data = validation_data.unwrap_or_default();
|
||||
assert_eq!(
|
||||
validation_data.persisted.relay_storage_root,
|
||||
validation_data.relay_storage_root,
|
||||
Default::default(),
|
||||
"Overriding the relay storage root is not implemented",
|
||||
);
|
||||
validation_data.persisted.relay_storage_root = relay_storage_root;
|
||||
validation_data.relay_storage_root = relay_storage_root;
|
||||
|
||||
inherent_data
|
||||
.put_data(
|
||||
|
||||
@@ -40,7 +40,7 @@ use sc_network::{config::TransportConfig, multiaddr, NetworkService};
|
||||
use sc_service::{
|
||||
config::{
|
||||
DatabaseConfig, KeystoreConfig, MultiaddrWithPeerId, NetworkConfiguration,
|
||||
OffchainWorkerConfig, PruningMode, WasmExecutionMethod,
|
||||
OffchainWorkerConfig, KeepBlocks, TransactionStorageMode, PruningMode, WasmExecutionMethod,
|
||||
},
|
||||
BasePath, ChainSpec, Configuration, Error as ServiceError, PartialComponents, Role,
|
||||
RpcHandlers, TFullBackend, TFullClient, TaskExecutor, TaskManager,
|
||||
@@ -395,7 +395,9 @@ pub fn node_config(
|
||||
},
|
||||
state_cache_size: 67108864,
|
||||
state_cache_child_ratio: None,
|
||||
pruning: PruningMode::ArchiveAll,
|
||||
state_pruning: PruningMode::ArchiveAll,
|
||||
keep_blocks: KeepBlocks::All,
|
||||
transaction_storage: TransactionStorageMode::BlockBody,
|
||||
chain_spec: spec,
|
||||
wasm_method: WasmExecutionMethod::Interpreted,
|
||||
// NOTE: we enforce the use of the native runtime to make the errors more debuggable
|
||||
|
||||
Reference in New Issue
Block a user