Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Cargo.lock

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

13 changes: 11 additions & 2 deletions parachain/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,19 @@ pub use polkadot_core_primitives::BlockNumber as RelayChainBlockNumber;

/// Parachain head data included in the chain.
#[derive(
PartialEq, Eq, Clone, PartialOrd, Ord, Encode, Decode, RuntimeDebug, derive_more::From, TypeInfo,
PartialEq,
Eq,
Clone,
PartialOrd,
Ord,
Encode,
Decode,
RuntimeDebug,
derive_more::From,
TypeInfo,
Default,
)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash, MallocSizeOf))]
#[cfg_attr(any(feature = "std", feature = "runtime-benchmarks"), derive(Default))]
pub struct HeadData(#[cfg_attr(feature = "std", serde(with = "bytes"))] pub Vec<u8>);

impl HeadData {
Expand Down
10 changes: 4 additions & 6 deletions primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-primitives"
version = "0.9.12"
version = "0.9.13"
authors = ["Parity Technologies <[email protected]>"]
edition = "2018"

Expand All @@ -26,9 +26,10 @@ polkadot-core-primitives = { path = "../core-primitives", default-features = fal
trie = { package = "sp-trie", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
hex-literal = "0.3.3"
hex-literal = "0.3.4"
parity-util-mem = { version = "0.10.0", default-features = false, optional = true }


[features]
default = ["std"]
std = [
Expand All @@ -54,7 +55,4 @@ std = [
"polkadot-core-primitives/std",
"bitvec/std",
"frame-system/std",
]
runtime-benchmarks = [
"polkadot-parachain/runtime-benchmarks",
]
]
9 changes: 3 additions & 6 deletions primitives/src/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,8 @@ fn check_collator_signature<H: AsRef<[u8]>>(
}

/// A unique descriptor of the candidate receipt.
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo, Default)]
#[cfg_attr(feature = "std", derive(Debug, Hash, MallocSizeOf))]
#[cfg_attr(any(feature = "std", feature = "runtime-benchmarks"), derive(Default))]
pub struct CandidateDescriptor<H = Hash> {
/// The ID of the para this is a candidate for.
pub para_id: Id,
Expand Down Expand Up @@ -408,9 +407,8 @@ pub struct FullCandidateReceipt<H = Hash, N = BlockNumber> {
}

/// A candidate-receipt with commitments directly included.
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo, Default)]
#[cfg_attr(feature = "std", derive(Debug, Hash, MallocSizeOf))]
#[cfg_attr(any(feature = "std", feature = "runtime-benchmarks"), derive(Default))]
pub struct CommittedCandidateReceipt<H = Hash> {
/// The descriptor of the candidate.
pub descriptor: CandidateDescriptor<H>,
Expand Down Expand Up @@ -511,9 +509,8 @@ impl<H: Encode, N: Encode> PersistedValidationData<H, N> {
}

/// Commitments made in a `CandidateReceipt`. Many of these are outputs of validation.
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo, Default)]
#[cfg_attr(feature = "std", derive(Debug, Hash, MallocSizeOf))]
#[cfg_attr(any(feature = "std", feature = "runtime-benchmarks"), derive(Default))]
pub struct CandidateCommitments<N = BlockNumber> {
/// Messages destined to be interpreted by the Relay chain itself.
pub upward_messages: Vec<UpwardMessage>,
Expand Down
8 changes: 6 additions & 2 deletions primitives/src/v1/signed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ impl<Payload: EncodeAs<RealPayload>, RealPayload: Encode> UncheckedSigned<Payloa
}

/// Sign this payload with the given context and pair.
#[cfg(any(feature = "runtime-benchmarks", feature = "std"))]
///
/// # WARNING
/// Only meant for usage in tests and and benchmarks.
pub fn benchmark_sign<H: Encode>(
public: &crate::v0::ValidatorId,
payload: Payload,
Expand All @@ -277,7 +279,9 @@ impl<Payload: EncodeAs<RealPayload>, RealPayload: Encode> UncheckedSigned<Payloa
}

/// Immutably access the signature.
#[cfg(any(feature = "runtime-benchmarks", feature = "std"))]
///
/// # WARNING
/// Only meant for usage in tests and and benchmarks.
pub fn benchmark_signature(&self) -> ValidatorSignature {
self.signature.clone()
}
Expand Down
13 changes: 5 additions & 8 deletions runtime/parachains/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-runtime-parachains"
version = "0.9.12"
version = "0.9.13"
authors = ["Parity Technologies <[email protected]>"]
edition = "2018"

Expand Down Expand Up @@ -32,6 +32,7 @@ pallet-session = { git = "https://github.com/paritytech/substrate", branch = "ma
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }

Expand All @@ -42,16 +43,14 @@ primitives = { package = "polkadot-primitives", path = "../../primitives", defau
rand = { version = "0.8.3", default-features = false }
rand_chacha = { version = "0.3.1", default-features = false }

application-crypto = { package = "sp-application-crypto", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }

[dev-dependencies]
futures = "0.3.17"
hex-literal = "0.3.3"
hex-literal = "0.3.4"
keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "master" }
frame-support-test = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }


[features]
default = ["std"]
no_std = []
Expand Down Expand Up @@ -87,8 +86,6 @@ runtime-benchmarks = [
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"primitives/runtime-benchmarks",
"application-crypto/full_crypto",
]
try-runtime = [
"frame-support/try-runtime",
Expand All @@ -98,4 +95,4 @@ try-runtime = [
"pallet-staking/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-vesting/try-runtime",
]
]
14 changes: 7 additions & 7 deletions runtime/parachains/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use sp_std::{collections::btree_map::BTreeMap, convert::TryInto, prelude::Vec, v
/// This is directly from frame-benchmarking. Copy/pasted so we can use it when not compiling with
/// "features = runtime-benchmarks".
fn account<AccountId: Decode + Default>(name: &'static str, index: u32, seed: u32) -> AccountId {
let entropy = (name, index, seed).using_encoded(sp_core::blake2_256);
let entropy = (name, index, seed).using_encoded(sp_io::hashing::blake2_256);
AccountId::decode(&mut &entropy[..]).unwrap_or_default()
}

Expand Down Expand Up @@ -54,7 +54,7 @@ pub(crate) struct BenchBuilder<T: paras_inherent::Config> {
}

/// Paras inherent `enter` benchmark scenario.
#[cfg(any(feature = "runtime-benchmarks", test))]
#[allow(dead_code)]
pub(crate) struct Bench<T: paras_inherent::Config> {
pub(crate) data: ParachainsInherentData<T::Header>,
pub(crate) _session: u32,
Expand Down Expand Up @@ -113,7 +113,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
self.max_validators.unwrap_or(Self::fallback_max_validators())
}

#[cfg(not(feature = "runtime-benchmarks"))]
#[allow(dead_code)]
pub(crate) fn set_max_validators(mut self, n: u32) -> Self {
self.max_validators = Some(n);
self
Expand All @@ -129,7 +129,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
/// corresponding dispute statement set. Note that if the number of disputes is not specified it fallbacks
/// to having a dispute per every validator. Additionally, an entry is not guaranteed to have a dispute - it
/// must line up with the cores marked as disputed as defined in `Self::Build`.
#[cfg(not(feature = "runtime-benchmarks"))]
#[allow(dead_code)]
pub(crate) fn set_dispute_statements(mut self, m: BTreeMap<u32, u32>) -> Self {
self.dispute_statements = m;
self
Expand All @@ -140,7 +140,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
}

/// Set maximum number of validators per core.
#[cfg(not(feature = "runtime-benchmarks"))]
#[allow(dead_code)]
pub(crate) fn set_max_validators_per_core(mut self, n: u32) -> Self {
self.max_validators_per_core = Some(n);
self
Expand All @@ -152,7 +152,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
}

/// Minimum number of validity votes in order for a backed candidate to be included.
#[cfg(feature = "runtime-benchmarks")]
#[allow(dead_code)]
pub(crate) fn fallback_min_validity_votes() -> u32 {
(Self::fallback_max_validators() / 2) + 1
}
Expand Down Expand Up @@ -298,7 +298,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
frame_system::Pallet::<T>::initialize(
&header.number(),
&header.hash(),
&Digest::<T::Hash> { logs: Vec::new() },
&Digest { logs: Vec::new() },
Default::default(),
);

Expand Down