Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polkadot Release v1.5.0 migration #330

Merged
merged 13 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
4,809 changes: 2,182 additions & 2,627 deletions Cargo.lock

Large diffs are not rendered by default.

245 changes: 120 additions & 125 deletions Cargo.toml

Large diffs are not rendered by default.

5,791 changes: 5,791 additions & 0 deletions cargo.tree
darkforest0202 marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ wasm-bindgen = { version = "0.2.87", optional = true }
[features]
alloc = []
js = ["alloc", "wasm-bindgen"]

5 changes: 1 addition & 4 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ serde = { workspace = true }
serde_json = { workspace = true }

# Local
virto-runtime = { workspace = true, optional = true }
kreivo-runtime = { workspace = true, optional = true }
jsonrpsee = { workspace = true, features = ["server"] }

Expand Down Expand Up @@ -101,13 +100,11 @@ wait-timeout = { workspace = true }
polkadot-cli = { workspace = true }

[features]
default = ["virto-runtime", "kreivo-runtime"]
default = ["kreivo-runtime"]
runtime-benchmarks = [
"virto-runtime?/runtime-benchmarks",
"kreivo-runtime?/runtime-benchmarks",
"polkadot-cli/runtime-benchmarks"
]
try-runtime = [
"virto-runtime?/try-runtime",
"kreivo-runtime?/try-runtime"
]
62 changes: 1 addition & 61 deletions node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,67 +85,6 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder<kreivo_runtime::
}
}

#[cfg(feature = "virto-runtime")]
impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder<virto_runtime::RuntimeApi> {
fn pallet(&self) -> &str {
"system"
}

fn extrinsic(&self) -> &str {
"remark"
}

fn build(&self, nonce: u32) -> Result<OpaqueExtrinsic, &'static str> {
use virto_runtime as runtime;

let call: runtime::RuntimeCall = runtime::SystemCall::remark { remark: vec![] }.into();
let period = runtime::BlockHashCount::get()
.checked_next_power_of_two()
.map(|c| c / 2)
.unwrap_or(2) as u64;
let best_block = self.client.chain_info().best_number;
let tip = 0;
let extra: runtime::SignedExtra = (
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
frame_system::CheckTxVersion::<runtime::Runtime>::new(),
frame_system::CheckGenesis::<runtime::Runtime>::new(),
frame_system::CheckEra::<runtime::Runtime>::from(generic::Era::mortal(period, best_block.saturated_into())),
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
frame_system::CheckWeight::<runtime::Runtime>::new(),
pallet_asset_tx_payment::ChargeAssetTxPayment::<runtime::Runtime>::from(tip, None),
);

let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists");
let best_hash = self.client.chain_info().best_hash;
let payload = runtime::SignedPayload::from_raw(
call.clone(),
extra.clone(),
(
(),
runtime::VERSION.spec_version,
runtime::VERSION.transaction_version,
genesis_hash,
best_hash,
(),
(),
(),
),
);

let sender = Sr25519Keyring::Bob.pair();
let signature = payload.using_encoded(|x| sender.sign(x));
let extrinsic = runtime::UncheckedExtrinsic::new_signed(
call,
sp_runtime::AccountId32::from(sender.public()).into(),
runtime::Signature::Sr25519(signature),
extra,
);

Ok(extrinsic.into())
}
}

/// Generates inherent data for the `benchmark overhead` command.
pub fn inherent_benchmark_data() -> sc_cli::Result<InherentData> {
let mut inherent_data = InherentData::new();
Expand All @@ -163,6 +102,7 @@ pub fn inherent_benchmark_data() -> sc_cli::Result<InherentData> {
xcm_config: Default::default(),
raw_downward_messages: Default::default(),
raw_horizontal_messages: Default::default(),
additional_key_values: Default::default(),
};

futures::executor::block_on(parachain_inherent.provide_inherent_data(&mut inherent_data))
Expand Down
164 changes: 108 additions & 56 deletions node/src/chain_spec/virto.rs → node/src/chain_spec/kreivo copy.rs
darkforest0202 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
use crate::chain_spec::{get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION};
use cumulus_primitives_core::ParaId;
use hex_literal::hex;

use sc_service::ChainType;

use sp_core::{crypto::UncheckedInto, sr25519};
use virto_runtime::{
use kreivo_runtime::{
constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AuraId, BalancesConfig, RuntimeGenesisConfig, SessionConfig,
SessionKeys, SudoConfig, SystemConfig,
};

const DEFAULT_PROTOCOL_ID: &str = "virto";
use sc_service::ChainType;
use sp_core::{crypto::UncheckedInto, sr25519};
const DEFAULT_PROTOCOL_ID: &str = "kreivo";

/// Specialized `ChainSpec` for the normal parachain runtime.
pub type ChainSpec = sc_service::GenericChainSpec<virto_runtime::RuntimeGenesisConfig, Extensions>;
pub type ChainSpec = sc_service::GenericChainSpec<kreivo_runtime::RuntimeGenesisConfig, Extensions>;

const VIRTO_PARA_ID: u32 = 2000;
const KREIVO_PARA_ID: u32 = 2281;

/// Generate the session keys from individual elements.
///
Expand All @@ -25,19 +22,19 @@ fn session_keys(aura: AuraId) -> SessionKeys {
SessionKeys { aura }
}

pub fn virto_polkadot_chain_spec_local() -> ChainSpec {
pub fn kreivo_rococo_chain_spec_local() -> ChainSpec {
// Give your kreivo currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "DOT".into());
properties.insert("tokenDecimals".into(), 10.into());
properties.insert("ss58Format".into(), 1.into());
properties.insert("tokenSymbol".into(), "KSM".into());
properties.insert("tokenDecimals".into(), 12.into());
properties.insert("ss58Format".into(), 2.into());

ChainSpec::from_genesis(
// Name
"Virto Development",
"Kreivo Local-Rococo Local",
// ID
"virto_dev",
ChainType::Development,
"kreivo_rococo_local",
ChainType::Local,
move || {
testnet_genesis(
// Initial collators.
Expand All @@ -58,8 +55,11 @@ pub fn virto_polkadot_chain_spec_local() -> ChainSpec {
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
],
VIRTO_PARA_ID.into(),
KREIVO_PARA_ID.into(),
)
},
// Bootnodes
Expand All @@ -74,7 +74,64 @@ pub fn virto_polkadot_chain_spec_local() -> ChainSpec {
// Extensions
Extensions {
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
para_id: VIRTO_PARA_ID,
para_id: KREIVO_PARA_ID,
},
)
}

pub fn kreivo_kusama_chain_spec_local() -> ChainSpec {
// Give your kreivo currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 2.into());
properties.insert("tokenSymbol".into(), "KSM".into());
properties.insert("tokenDecimals".into(), 12.into());

ChainSpec::from_genesis(
// Name
"Kreivo Local-Kusama Local",
// ID
"kreivo-kusama-local",
ChainType::Local,
move || {
testnet_genesis(
// Initial collators.
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed::<AuraId>("Alice"),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_collator_keys_from_seed::<AuraId>("Bob"),
),
],
// Sudo account
hex!("49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a").into(),
// Pre-funded accounts
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
],
KREIVO_PARA_ID.into(),
)
},
// Bootnodes
vec![],
// Telemetry
None,
// Protocol ID
Some(DEFAULT_PROTOCOL_ID),
None,
// Properties
Some(properties),
// Extensions
Extensions {
relay_chain: "kusama-local".into(), // You MUST set this to the correct network!
para_id: KREIVO_PARA_ID,
},
)
}
Expand All @@ -88,20 +145,24 @@ fn testnet_genesis(
) -> RuntimeGenesisConfig {
RuntimeGenesisConfig {
system: SystemConfig {
code: virto_runtime::WASM_BINARY
code: kreivo_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
_config: Default::default(),
},
balances: BalancesConfig {
// Configure endowed accounts with initial balance of 1 << 60.
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, 2_000_000_000_000_000))
.collect(),
},
parachain_info: virto_runtime::ParachainInfoConfig {
parachain_info: kreivo_runtime::ParachainInfoConfig {
parachain_id: id,
_config: Default::default(),
},
collator_selection: virto_runtime::CollatorSelectionConfig {
collator_selection: kreivo_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: EXISTENTIAL_DEPOSIT * 16,
..Default::default()
Expand All @@ -123,7 +184,7 @@ fn testnet_genesis(
aura: Default::default(),
aura_ext: Default::default(),
parachain_system: Default::default(),
polkadot_xcm: virto_runtime::PolkadotXcmConfig {
polkadot_xcm: kreivo_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
_config: Default::default(),
},
Expand All @@ -138,42 +199,39 @@ fn testnet_genesis(
}
}

pub fn virto_polkadot_chain_spec() -> ChainSpec {
pub fn kreivo_kusama_chain_spec() -> ChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "DOT".into());
properties.insert("tokenDecimals".into(), 10.into());
properties.insert("ss58Format".into(), 1.into());
properties.insert("ss58Format".into(), 2.into());
properties.insert("tokenSymbol".into(), "KSM".into());
properties.insert("tokenDecimals".into(), 12.into());

ChainSpec::from_genesis(
// Name
"Virto",
"Kreivo",
// ID
"virto",
"kreivo",
ChainType::Live,
move || {
virto_live_genesis(
kreivo_live_genesis(
// initial collators.
vec![
(
hex!("441f1878b52468c7f4da41cec27dc13e6843c283a58d33485212ae48cf94fb3c").into(),
hex!("441f1878b52468c7f4da41cec27dc13e6843c283a58d33485212ae48cf94fb3c").unchecked_into(),
hex!("203aec61cedbfa0cd23f183a972b8646794b9106e62d141c6af4fbbbe293847b").into(),
hex!("203aec61cedbfa0cd23f183a972b8646794b9106e62d141c6af4fbbbe293847b").unchecked_into(),
),
(
hex!("441f1878b52468c7f4da41cec27dc13e6843c283a58d33485212ae48cf94fb3c").into(),
hex!("441f1878b52468c7f4da41cec27dc13e6843c283a58d33485212ae48cf94fb3c").unchecked_into(),
hex!("74d538cee938b3f988567a3d0ad4b0dd84735ceab8b51cdfb850ecf58accfd7e").into(),
hex!("74d538cee938b3f988567a3d0ad4b0dd84735ceab8b51cdfb850ecf58accfd7e").unchecked_into(),
),
],
hex!("441f1878b52468c7f4da41cec27dc13e6843c283a58d33485212ae48cf94fb3c").into(),
hex!("7b953019065b4342a4f1fcf62be8f3e83c8d15303b674fd7191e598f699e764f").into(),
vec![
// This account will have root origin
hex!("441f1878b52468c7f4da41cec27dc13e6843c283a58d33485212ae48cf94fb3c").into(),
hex!("441f1878b52468c7f4da41cec27dc13e6843c283a58d33485212ae48cf94fb3c").into(),
hex!("441f1878b52468c7f4da41cec27dc13e6843c283a58d33485212ae48cf94fb3c").into(),
hex!("441f1878b52468c7f4da41cec27dc13e6843c283a58d33485212ae48cf94fb3c").into(),
hex!("441f1878b52468c7f4da41cec27dc13e6843c283a58d33485212ae48cf94fb3c").into(),
hex!("441f1878b52468c7f4da41cec27dc13e6843c283a58d33485212ae48cf94fb3c").into(),
hex!("68170716ab7c6735dd0a1012045d9ea33891b5f6596cf97eb217d0962d86a518").into(),
hex!("556d3b25d068997f358622cc0f9531e4175d0d10d8ae8511c091d61efc21f65c").into(),
hex!("8a0b6ddc780dbeb1c943caeadc7d09d85b2dc5b74026153f7931e068390d4441").into(),
],
VIRTO_PARA_ID.into(),
KREIVO_PARA_ID.into(),
)
},
vec![],
Expand All @@ -182,21 +240,21 @@ pub fn virto_polkadot_chain_spec() -> ChainSpec {
None,
Some(properties),
Extensions {
relay_chain: "polkadot".into(),
para_id: VIRTO_PARA_ID,
relay_chain: "kusama".into(),
para_id: KREIVO_PARA_ID,
},
)
}

fn virto_live_genesis(
fn kreivo_live_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> RuntimeGenesisConfig {
RuntimeGenesisConfig {
system: SystemConfig {
code: virto_runtime::WASM_BINARY
code: kreivo_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
_config: Default::default(),
Expand All @@ -206,20 +264,14 @@ fn virto_live_genesis(
.iter()
.cloned()
.chain(std::iter::once(root_key.clone()))
.map(|k| {
if k == root_key {
(k, 1_000_000_000_000_000_000)
} else {
(k, 1_500_000_000_000_000_000)
}
})
.map(|k| (k, 2_000_000_000_000_000))
.collect(),
},
parachain_info: virto_runtime::ParachainInfoConfig {
parachain_info: kreivo_runtime::ParachainInfoConfig {
parachain_id: id,
_config: Default::default(),
},
collator_selection: virto_runtime::CollatorSelectionConfig {
collator_selection: kreivo_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: EXISTENTIAL_DEPOSIT * 16,
..Default::default()
Expand All @@ -239,7 +291,7 @@ fn virto_live_genesis(
aura: Default::default(),
aura_ext: Default::default(),
parachain_system: Default::default(),
polkadot_xcm: virto_runtime::PolkadotXcmConfig {
polkadot_xcm: kreivo_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
_config: Default::default(),
},
Expand Down
Loading
Loading