Skip to content

Commit

Permalink
feat: remove exteral runtimes deps
Browse files Browse the repository at this point in the history
  • Loading branch information
lrazovic authored and JuaniRios committed Dec 20, 2024
1 parent e4d65fe commit f44a1ac
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 1,472 deletions.
786 changes: 9 additions & 777 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ default-members = ["nodes/*", "pallets/*"]
resolver = "2"

[workspace.lints.clippy]
all = { level = "warn", priority = -1}
all = { level = "warn", priority = -1 }
inconsistent_digit_grouping = "allow"
zero_prefixed_literal = "allow"
missing_errors_doc = "allow"
must_use_candidate = "allow"
identity_op = "allow"
tabs_in_doc_comments= "allow"
tabs_in_doc_comments = "allow"

[workspace.lints.rust]
unreachable_patterns = "deny"
Expand Down Expand Up @@ -148,7 +148,7 @@ sp-authority-discovery = { version = "33.0.0", default-features = false }
sp-consensus-babe = { version = "0.39.0", default-features = false }
pallet-message-queue = { version = "38.0.0", default-features = false }
sp-weights = { version = "31.0.0", default-features = false }
sp-application-crypto = {version = "37.0.0", default-features = false}
sp-application-crypto = { version = "37.0.0", default-features = false }

# FRAME
assets-common = { version = "0.14.0", default-features = false }
Expand Down Expand Up @@ -246,7 +246,5 @@ cumulus-pallet-session-benchmarking = { version = "16.0.0", default-features = f

# Runtimes
polimec-runtime = { path = "runtimes/polimec" }
asset-hub-polkadot-runtime = { git = 'https://github.com/polkadot-fellows/runtimes', default-features = false, rev = 'c5080e43321476ec82d69b710ebfaafb634f7475' }
polkadot-runtime-constants = { git = 'https://github.com/polkadot-fellows/runtimes', default-features = false, rev = 'c5080e43321476ec82d69b710ebfaafb634f7475' }
system-parachains-constants = { git = 'https://github.com/polkadot-fellows/runtimes', default-features = false, rev = 'c5080e43321476ec82d69b710ebfaafb634f7475' }
polkadot-runtime = { git = 'https://github.com/polkadot-fellows/runtimes', default-features = false, rev = 'c5080e43321476ec82d69b710ebfaafb634f7475' }
rococo-runtime-constants = { version = "14.0.0" }
rococo-runtime = { version = "14.0.0" }
18 changes: 6 additions & 12 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ workspace = true
substrate-wasm-builder.workspace = true

[dependencies]
serde = { workspace = true }
serde = { workspace = true }
parity-scale-codec = { workspace = true, features = ["derive"] }
scale-info = { workspace = true, features = ["derive"] }

Expand Down Expand Up @@ -62,8 +62,7 @@ polkadot-service.workspace = true
sp-authority-discovery.workspace = true
sp-consensus-babe.workspace = true
sp-consensus-beefy.workspace = true
polkadot-runtime-constants.workspace = true
system-parachains-constants.workspace = true
rococo-runtime-constants.workspace = true
pallet-staking.workspace = true
pallet-membership.workspace = true
orml-oracle.workspace = true
Expand All @@ -86,8 +85,7 @@ hex.workspace = true
assets-common.workspace = true

# Runtimes
polkadot-runtime.workspace = true
asset-hub-polkadot-runtime.workspace = true
rococo-runtime.workspace = true
polimec-runtime.workspace = true
penpal-runtime = { path = "penpal", default-features = false }

Expand All @@ -96,7 +94,6 @@ penpal-runtime = { path = "penpal", default-features = false }
default = [ "development-settings", "instant-mode", "std" ]
instant-mode = [ "polimec-runtime/instant-mode" ]
std = [
"asset-hub-polkadot-runtime/std",
"cumulus-pallet-xcm/std",
"cumulus-primitives-core/std",
"frame-metadata-hash-extension/std",
Expand Down Expand Up @@ -139,9 +136,7 @@ std = [
"polkadot-core-primitives/std",
"polkadot-parachain-primitives/std",
"polkadot-primitives/std",
"polkadot-runtime-constants/std",
"polkadot-runtime-parachains/std",
"polkadot-runtime/std",
"scale-info/std",
"serde/std",
"sp-arithmetic/std",
Expand All @@ -153,15 +148,15 @@ std = [
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"system-parachains-constants/std",
"rococo-runtime-constants/std",
"rococo-runtime/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm-fee-payment-runtime-api/std",
"xcm/std",
]
development-settings = [ "polimec-runtime/development-settings" ]
runtime-benchmarks = [
"asset-hub-polkadot-runtime/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
Expand Down Expand Up @@ -195,11 +190,10 @@ runtime-benchmarks = [
"polkadot-parachain-primitives/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"polkadot-runtime-parachains/runtime-benchmarks",
"polkadot-runtime/runtime-benchmarks",
"polkadot-service/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"rococo-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm-fee-payment-runtime-api/runtime-benchmarks",
]

109 changes: 11 additions & 98 deletions integration-tests/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,7 @@ const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
// Polkadot
pub mod polkadot {
use super::*;
pub const ED: Balance = polkadot_runtime_constants::currency::EXISTENTIAL_DEPOSIT;
const STASH: u128 = 100 * polkadot_runtime_constants::currency::UNITS;
pub const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT;

pub fn get_host_config() -> HostConfiguration<BlockNumber> {
HostConfiguration {
Expand All @@ -254,17 +253,16 @@ pub mod polkadot {
para_assignment: AssignmentId,
authority_discovery: AuthorityDiscoveryId,
beefy: BeefyId,
) -> polkadot_runtime::SessionKeys {
polkadot_runtime::SessionKeys { babe, grandpa, para_validator, para_assignment, authority_discovery, beefy }
) -> rococo_runtime::SessionKeys {
rococo_runtime::SessionKeys { babe, grandpa, para_validator, para_assignment, authority_discovery, beefy }
}

pub fn genesis() -> Storage {
let genesis_config = polkadot_runtime::RuntimeGenesisConfig {
system: Default::default(),
balances: polkadot_runtime::BalancesConfig {
let genesis_config = rococo_runtime::RuntimeGenesisConfig {
balances: rococo_runtime::BalancesConfig {
balances: accounts::init_balances().iter().cloned().map(|k| (k, INITIAL_DEPOSIT)).collect(),
},
session: polkadot_runtime::SessionConfig {
session: rococo_runtime::SessionConfig {
keys: validators::initial_authorities()
.iter()
.map(|x| {
Expand All @@ -284,99 +282,19 @@ pub mod polkadot {
})
.collect::<Vec<_>>(),
},
staking: polkadot_runtime::StakingConfig {
validator_count: validators::initial_authorities().len() as u32,
minimum_validator_count: 1,
stakers: validators::initial_authorities()
.iter()
.map(|x| (x.0.clone(), x.1.clone(), STASH, polkadot_runtime::StakerStatus::Validator))
.collect(),
invulnerables: validators::initial_authorities().iter().map(|x| x.0.clone()).collect(),
force_era: pallet_staking::Forcing::ForceNone,
slash_reward_fraction: Perbill::from_percent(10),
..Default::default()
},
babe: polkadot_runtime::BabeConfig {
babe: rococo_runtime::BabeConfig {
authorities: Default::default(),
epoch_config: polkadot_runtime::BABE_GENESIS_EPOCH_CONFIG,
epoch_config: rococo_runtime::BABE_GENESIS_EPOCH_CONFIG,
..Default::default()
},
configuration: polkadot_runtime::ConfigurationConfig { config: get_host_config() },
configuration: rococo_runtime::ConfigurationConfig { config: get_host_config() },
..Default::default()
};

genesis_config.build_storage().unwrap()
}
}

// AssetHub
pub mod asset_hub {
use super::*;
use crate::{AssetHub, PolkadotNet};
use xcm::v4::Parent;

pub const PARA_ID: u32 = 1000;
pub const ED: Balance = system_parachains_constants::polkadot::currency::SYSTEM_PARA_EXISTENTIAL_DEPOSIT;

pub fn genesis() -> Storage {
let mut funded_accounts = vec![
(
<AssetHub<PolkadotNet>>::sovereign_account_id_of(
(Parent, xcm::prelude::Parachain(penpal::PARA_ID)).into(),
),
INITIAL_DEPOSIT,
),
(
<AssetHub<PolkadotNet>>::sovereign_account_id_of(
(Parent, xcm::prelude::Parachain(polimec::PARA_ID)).into(),
),
INITIAL_DEPOSIT,
),
];
funded_accounts.extend(accounts::init_balances().iter().cloned().map(|k| (k, INITIAL_DEPOSIT)));

let genesis_config = asset_hub_polkadot_runtime::RuntimeGenesisConfig {
system: Default::default(),
balances: asset_hub_polkadot_runtime::BalancesConfig { balances: funded_accounts },
parachain_info: asset_hub_polkadot_runtime::ParachainInfoConfig {
parachain_id: PARA_ID.into(),
..Default::default()
},
collator_selection: asset_hub_polkadot_runtime::CollatorSelectionConfig {
invulnerables: collators::invulnerables_asset_hub().iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: ED * 16,
..Default::default()
},
session: asset_hub_polkadot_runtime::SessionConfig {
keys: collators::invulnerables_asset_hub()
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
asset_hub_polkadot_runtime::SessionKeys { aura }, // session keys
)
})
.collect(),
},
aura: Default::default(),
aura_ext: Default::default(),
parachain_system: Default::default(),
polkadot_xcm: asset_hub_polkadot_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
assets: Default::default(),
foreign_assets: Default::default(),
transaction_payment: Default::default(),
vesting: Default::default(),
pool_assets: Default::default(),
};

genesis_config.build_storage().unwrap()
}
}

// Penpal
pub mod penpal {
use super::*;
Expand All @@ -387,9 +305,7 @@ pub mod penpal {

pub fn genesis() -> Storage {
let mut funded_accounts = vec![(
<Penpal<PolkadotNet>>::sovereign_account_id_of(
(Parent, xcm::prelude::Parachain(asset_hub::PARA_ID)).into(),
),
<Penpal<PolkadotNet>>::sovereign_account_id_of((Parent, xcm::prelude::Parachain(1000)).into()),
INITIAL_DEPOSIT,
)];
funded_accounts.extend(accounts::init_balances().iter().cloned().map(|k| (k, INITIAL_DEPOSIT)));
Expand Down Expand Up @@ -500,10 +416,7 @@ pub mod polimec {
PolimecNet::sovereign_account_id_of((Parent, xcm::prelude::Parachain(penpal::PARA_ID)).into()),
INITIAL_DEPOSIT,
),
(
PolimecNet::sovereign_account_id_of((Parent, xcm::prelude::Parachain(asset_hub::PARA_ID)).into()),
INITIAL_DEPOSIT,
),
(PolimecNet::sovereign_account_id_of((Parent, xcm::prelude::Parachain(1000)).into()), INITIAL_DEPOSIT),
];
let alice_account = PolimecNet::account_id_of(accounts::ALICE);
let bob_account: AccountId = PolimecNet::account_id_of(accounts::BOB);
Expand Down
Loading

0 comments on commit f44a1ac

Please sign in to comment.