Skip to content
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
631 changes: 399 additions & 232 deletions runtimes/Cargo.lock

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions runtimes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ members = [

[workspace.dependencies]

ziggy = { version = "1.3.5", default-features = false }
ziggy = { version = "1.5.0", default-features = false }

polkadot-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.5", default-features = false }
asset-hub-polkadot-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.5", default-features = false }
polkadot-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.6", default-features = false }
asset-hub-polkadot-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.6", default-features = false }
# bridge-hub-polkadot-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.2", default-features = false }
collectives-polkadot-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.5", default-features = false }
coretime-polkadot-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.5", default-features = false }
people-polkadot-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.5", default-features = false }
collectives-polkadot-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.6", default-features = false }
coretime-polkadot-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.6", default-features = false }
people-polkadot-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.6", default-features = false }

staging-kusama-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.5", default-features = false }
asset-hub-kusama-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.5", default-features = false }
staging-kusama-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.6", default-features = false }
asset-hub-kusama-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.6", default-features = false }
# bridge-hub-kusama-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.2", default-features = false }
coretime-kusama-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.5", default-features = false }
coretime-kusama-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.6", default-features = false }
# encointer-kusama-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.2", default-features = false }
glutton-kusama-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.5", default-features = false }
people-kusama-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.5", default-features = false }
glutton-kusama-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.6", default-features = false }
people-kusama-runtime = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.6", default-features = false }

system-parachains-constants = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.5", default-features = false }
polkadot-runtime-constants = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.5", default-features = false }
kusama-runtime-constants = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.5", default-features = false }
system-parachains-constants = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.6", default-features = false }
polkadot-runtime-constants = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.6", default-features = false }
kusama-runtime-constants = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.6", default-features = false }

codec = { version = "3.7.5", features = ["derive", "max-encoded-len"], default-features = false, package = "parity-scale-codec" }
hex = "0.4.3"
Expand Down Expand Up @@ -68,18 +68,18 @@ pallet-utility = { default-features = false, version = "44.0.0" }
pallet-proxy = { default-features = false, version = "44.0.0" }
pallet-multisig = { default-features = false, version = "44.0.0" }
pallet-vesting = { default-features = false, version = "44.0.0" }
pallet-remote-proxy = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.5", default-features = false }
pallet-remote-proxy = { git = "https://github.com/polkadot-fellows/runtimes.git", tag = "v2.0.6", default-features = false }
pallet-recovery = { default-features = false, version = "44.0.0" }
pallet-whitelist = { default-features = false, version = "43.0.0" }
pallet-broker = { default-features = false, version = "0.23.0" }
pallet-staking-async-ah-client = { default-features = false, version = "0.6.0" }
pallet-bags-list = { default-features = false, version = "43.0.0" }
pallet-bounties = { default-features = false, version = "43.0.0" }
pallet-grandpa = { default-features = false, version = "44.0.0" }
pallet-grandpa = { default-features = false, version = "44.0.1" }
pallet-identity = { default-features = false, version = "44.0.0" }
pallet-referenda = { default-features = false, version = "44.0.0" }
pallet-society = { default-features = false, version = "44.0.0" }
pallet-staking = { default-features = false, version = "44.0.0" }
pallet-staking = { default-features = false, version = "44.0.1" }
pallet-treasury = { default-features = false, version = "43.0.0" }
pallet-revive = { default-features = false, version = "0.11.3" }

Expand All @@ -90,5 +90,5 @@ cumulus-test-relay-sproof-builder = { default-features = false , version = "0.23

polkadot-parachain-primitives = { default-features = false, version = "18.0.0" }
polkadot-primitives = { default-features = false, version = "20.0.0" }
polkadot-runtime-parachains = { version = "23.0.0", default-features = false }
polkadot-runtime-common = { version = "23.0.0", default-features = false }
polkadot-runtime-parachains = { version = "23.0.1", default-features = false }
polkadot-runtime-common = { version = "23.0.1", default-features = false }
1 change: 1 addition & 0 deletions runtimes/asset-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pallet-vesting = { workspace = true }
pallet-remote-proxy = { workspace = true }
pallet-recovery = { workspace = true }
pallet-whitelist = { workspace = true }
pallet-revive = { workspace = true }

cumulus-primitives-core = { workspace = true }
cumulus-primitives-parachain-inherent = { workspace = true }
Expand Down
39 changes: 24 additions & 15 deletions runtimes/asset-hub-kusama/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use frame_support::{
weights::constants::WEIGHT_REF_TIME_PER_SECOND,
};
use frame_system::Account;
use pallet_balances::{Holds, TotalIssuance};
use pallet_balances::{Freezes, Holds, TotalIssuance};
use parachains_common::{AccountId, Balance, SLOT_DURATION};
use sp_consensus_aura::{Slot, AURA_ENGINE_ID};
use sp_runtime::{
Expand Down Expand Up @@ -105,13 +105,13 @@ fn recursively_find_call(call: RuntimeCall, matches_on: fn(RuntimeCall) -> bool)
) = call
{
for call in calls {
if recursively_find_call(call.clone(), matches_on) {
if recursively_find_call(call, matches_on) {
return true;
}
}
} else if let RuntimeCall::Utility(pallet_utility::Call::if_else { main, fallback }) = call {
return recursively_find_call(*main.clone(), matches_on)
|| recursively_find_call(*fallback.clone(), matches_on);
return recursively_find_call(*main, matches_on)
|| recursively_find_call(*fallback, matches_on);
} else if let RuntimeCall::Multisig(pallet_multisig::Call::as_multi_threshold_1 {
call, ..
})
Expand All @@ -124,6 +124,10 @@ fn recursively_find_call(call: RuntimeCall, matches_on: fn(RuntimeCall) -> bool)
pallet_remote_proxy::Call::remote_proxy { call, .. }
| pallet_remote_proxy::Call::remote_proxy_with_registered_proof { call, .. },
)
| RuntimeCall::Revive(pallet_revive::Call::dispatch_as_fallback_account {
call,
..
})
| RuntimeCall::Recovery(pallet_recovery::Call::as_recovered { call, .. })
| RuntimeCall::Whitelist(
pallet_whitelist::Call::dispatch_whitelisted_call_with_preimage { call, .. },
Expand All @@ -132,11 +136,9 @@ fn recursively_find_call(call: RuntimeCall, matches_on: fn(RuntimeCall) -> bool)
pallet_proxy::Call::proxy { call, .. } | pallet_proxy::Call::proxy_announced { call, .. },
) = call
{
return recursively_find_call(*call.clone(), matches_on);
return recursively_find_call(*call, matches_on);
} else if matches_on(call.clone()) {
return true;
} else {
println!("innermost call: {:?}", call.clone());
}
false
}
Expand All @@ -155,10 +157,10 @@ fn process_input(accounts: &[AccountId], genesis: &Storage, data: &[u8]) {
iter::from_fn(|| DecodeLimit::decode_with_depth_limit(64, &mut extrinsic_data).ok())
.filter(|(_, _, x): &(_, _, RuntimeCall)| {
!recursively_find_call(x.clone(), |call| {
matches!(call.clone(), RuntimeCall::AhMigrator(_))
matches!(&call, RuntimeCall::AhMigrator(_))
// || matches!(call.clone(), RuntimeCall::NominationPools(_))
|| matches!(
call.clone(),
&call,
RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. })
)
})
Expand Down Expand Up @@ -260,8 +262,9 @@ fn initialize_block(block: u32, prev_header: Option<&Header>) {
..Default::default()
};

let (relay_parent_storage_root, relay_chain_state) =
sproof_builder.into_state_root_and_proof();
let relay_parent_offset = 1;
let (relay_parent_storage_root, relay_chain_state, relay_parent_descendants) =
sproof_builder.into_state_root_proof_and_descendants(relay_parent_offset);
BasicParachainInherentData {
validation_data: polkadot_primitives::PersistedValidationData {
parent_head,
Expand All @@ -271,7 +274,7 @@ fn initialize_block(block: u32, prev_header: Option<&Header>) {
},
relay_chain_state,
collator_peer_id: None,
relay_parent_descendants: vec![],
relay_parent_descendants,
}
};
let inbound_message_data = {
Expand Down Expand Up @@ -314,10 +317,16 @@ fn check_invariants(block: u32, initial_total_issuance: Balance) {
.iter()
.map(|l| l.amount)
.max()
.unwrap_or_default();
.unwrap_or(0);
let max_freeze = Freezes::<Runtime>::get(&account)
.iter()
.map(|freeze| freeze.amount)
.max()
.unwrap_or(0);
assert_eq!(
max_lock, info.data.frozen,
"Max lock should be equal to frozen balance"
info.data.frozen,
max_lock.max(max_freeze),
"Frozen balance should be the max of the max lock and max freeze"
);
let sum_holds: Balance = Holds::<Runtime>::get(&account)
.iter()
Expand Down
20 changes: 13 additions & 7 deletions runtimes/asset-hub-polkadot/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use frame_support::{
weights::constants::WEIGHT_REF_TIME_PER_SECOND,
};
use frame_system::Account;
use pallet_balances::{Holds, TotalIssuance};
use pallet_balances::{Freezes, Holds, TotalIssuance};
use parachains_common::{AccountId, Balance, SLOT_DURATION};
use sp_consensus_aura::{Slot, AURA_ENGINE_ID};
use sp_runtime::{
Expand Down Expand Up @@ -131,7 +131,7 @@ fn recursively_find_call(call: RuntimeCall, matches_on: fn(RuntimeCall) -> bool)
) = call
{
for call in calls {
if recursively_find_call(call.clone(), matches_on) {
if recursively_find_call(call, matches_on) {
return true;
}
}
Expand Down Expand Up @@ -162,7 +162,7 @@ fn recursively_find_call(call: RuntimeCall, matches_on: fn(RuntimeCall) -> bool)
pallet_proxy::Call::proxy { call, .. } | pallet_proxy::Call::proxy_announced { call, .. },
) = call
{
return recursively_find_call(*call.clone(), matches_on);
return recursively_find_call(*call, matches_on);
} else if matches_on(call) {
return true;
}
Expand All @@ -180,9 +180,9 @@ fn process_input(accounts: &[AccountId], genesis: &Storage, data: &[u8]) {
iter::from_fn(|| DecodeLimit::decode_with_depth_limit(64, &mut extrinsic_data).ok())
.filter(|(_, _, x): &(_, _, RuntimeCall)| {
!recursively_find_call(x.clone(), |call| {
matches!(call.clone(), RuntimeCall::AhMigrator(_))
matches!(&call, RuntimeCall::AhMigrator(_))
|| matches!(
call.clone(),
&call,
RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. })
)
})
Expand Down Expand Up @@ -344,9 +344,15 @@ fn check_invariants(block: u32, initial_total_issuance: Balance) {
.map(|l| l.amount)
.max()
.unwrap_or_default();
let max_freeze = Freezes::<Runtime>::get(&account)
.iter()
.map(|freeze| freeze.amount)
.max()
.unwrap_or(0);
assert_eq!(
max_lock, info.data.frozen,
"Max lock should be equal to frozen balance"
info.data.frozen,
max_lock.max(max_freeze),
"Frozen balance should be the max of the max lock and max freeze"
);
let sum_holds: Balance = Holds::<Runtime>::get(&account)
.iter()
Expand Down
5 changes: 4 additions & 1 deletion runtimes/coretime-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ system-parachains-constants = { workspace = true }
parachains-common = { workspace = true }

codec = { workspace = true }
scale-info = { workspace = true }

frame-support = { workspace = true }
frame-system = { workspace = true }
frame-metadata = { workspace = true }

sp-runtime = { workspace = true }
sp-state-machine = { workspace = true }
Expand Down Expand Up @@ -47,6 +49,7 @@ std = [
"pallet-timestamp/std",
"pallet-xcm/std",
"sp-consensus-aura/std",
"sp-state-machine/std",
"cumulus-primitives-core/std",
"cumulus-primitives-parachain-inherent/std",
"cumulus-pallet-parachain-system/std",
Expand All @@ -58,4 +61,4 @@ try-runtime = [
"frame-system/try-runtime",
"sp-runtime/try-runtime",
"pallet-timestamp/try-runtime",
]
]
127 changes: 127 additions & 0 deletions runtimes/coretime-kusama/src/bin/seedgen.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#![warn(clippy::pedantic)]
use codec::{Decode, Encode};
use coretime_kusama_runtime::{Runtime, RuntimeCall};
use frame_metadata::{RuntimeMetadata, RuntimeMetadataPrefixed};
use frame_support::traits::GetCallMetadata;
use scale_info::TypeDef;
use sp_state_machine::BasicExternalities;
use std::{collections::BTreeMap, fs, path::Path};

fn main() {
let seeds = build_seeds();

let out_dir = Path::new("seedgen");
fs::create_dir_all(out_dir).expect("create seedgen dir");
for (name, seed) in &seeds {
let path = out_dir.join(format!("{name}.seed"));
fs::write(&path, seed).expect("write seed file");
}

println!("wrote {} seeds to {}", seeds.len(), out_dir.display());
}

fn build_seeds() -> Vec<(String, Vec<u8>)> {
let mut seeds: Vec<(String, Vec<u8>)> = Vec::new();

let metadata = load_metadata_v14();
let call_map = build_call_map(&metadata);
for (pallet, calls) in call_map {
let expected =
pallet_call_variant_count(&metadata, pallet.as_str()).expect("pallet call count");
let actual = calls.len();
println!("created {actual}/{expected} seeds for {pallet}");
if actual != expected {
println!(
" skipped {} calls in {pallet} (unencodable with only zeroes)",
expected - actual
);
}

for call in calls {
let meta = call.get_call_metadata();
let name = format!(
"{}_{}",
meta.pallet_name.to_ascii_lowercase(),
meta.function_name
);
seeds.push((name, (0u8, 0u8, call).encode()));
}
}

seeds
}

fn build_call_map(
metadata: &frame_metadata::v14::RuntimeMetadataV14,
) -> BTreeMap<String, Vec<RuntimeCall>> {
let mut map: BTreeMap<String, Vec<RuntimeCall>> = BTreeMap::new();
for pallet in &metadata.pallets {
let calls = pallet.calls.as_ref();
if calls.is_none() {
continue;
}
let calls = calls.expect("checked");
let mut runtime_calls = Vec::new();
let call_def = metadata
.types
.resolve(calls.ty.id)
.expect("resolve pallet call type");
let TypeDef::Variant(variants) = &call_def.type_def else {
continue;
};
for variant in &variants.variants {
if variant.name == "__Ignore" {
continue;
}
if let Some(call) = runtime_call_from_metadata(metadata, pallet, variant) {
runtime_calls.push(call);
}
}
map.insert(pallet.name.clone(), runtime_calls);
}
map
}

fn load_metadata_v14() -> frame_metadata::v14::RuntimeMetadataV14 {
let bytes: Vec<u8> = BasicExternalities::default().execute_with(|| Runtime::metadata().into());
let metadata = RuntimeMetadataPrefixed::decode(&mut &bytes[..]).expect("decode metadata");
match metadata.1 {
RuntimeMetadata::V14(m) => m,
_ => panic!("unsupported metadata version"),
}
}

fn runtime_call_from_metadata(
metadata: &frame_metadata::v14::RuntimeMetadataV14,
pallet: &frame_metadata::v14::PalletMetadata<scale_info::form::PortableForm>,
variant: &scale_info::Variant<scale_info::form::PortableForm>,
) -> Option<RuntimeCall> {
let calls = pallet.calls.as_ref()?;
let call_def = metadata.types.resolve(calls.ty.id)?;
let TypeDef::Variant(_) = &call_def.type_def else {
return None;
};
let mut bytes = pallet.index.encode();
bytes.extend_from_slice(&variant.index.encode());
bytes.extend_from_slice(&[0u8; 1024]);
RuntimeCall::decode(&mut &bytes[..]).ok()
}

fn pallet_call_variant_count(
metadata: &frame_metadata::v14::RuntimeMetadataV14,
pallet_name: &str,
) -> Option<usize> {
let pallet = metadata.pallets.iter().find(|p| p.name == pallet_name)?;
let calls = pallet.calls.as_ref()?;
let ty = metadata.types.resolve(calls.ty.id)?;
let TypeDef::Variant(variants) = &ty.type_def else {
return None;
};
Some(
variants
.variants
.iter()
.filter(|variant| variant.name != "__Ignore")
.count(),
)
}
Loading