Skip to content

Commit

Permalink
Uplift to v1.5 (#1256)
Browse files Browse the repository at this point in the history
* update Cargo deps to v1.5 and uplift Astar runtime

* fmt

* uplift shiden and shibuya

* uplift genesis config

* updated client

* updated lift tests

* fmt

* fix try-runtime and runtime-benchmarks

* fmt

* clippy fix

* Fixed integration tests

* fix Cargo

* fix Cargo

* rollback fix  Cargo

* remove dep

* add rust-src to components

* fix try-runtime compilation

* merge

* Pr comments

* fix Shiden try-runtime dep

* Added migration

* updated weight

* updated benchmark

* fmt

---------

Co-authored-by: Ermal Kaleci <ermalkaleci@gmail.com>
  • Loading branch information
PierreOssun and ermalkaleci authored Jul 12, 2024
1 parent cf4d517 commit 7596fdc
Show file tree
Hide file tree
Showing 48 changed files with 1,978 additions and 1,391 deletions.
2,350 changes: 1,363 additions & 987 deletions Cargo.lock

Large diffs are not rendered by default.

301 changes: 151 additions & 150 deletions Cargo.toml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion bin/collator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ futures = { workspace = true }
log = { workspace = true, features = ["std"] }
parity-scale-codec = { workspace = true, features = ["std"] }
serde = { workspace = true }
serde_json = { workspace = true }
serde_json = { workspace = true, features = ["arbitrary_precision"] }
tokio = { workspace = true }
url = { workspace = true }

Expand Down Expand Up @@ -178,6 +178,7 @@ runtime-benchmarks = [
"sc-client-db/runtime-benchmarks",
"sc-service/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
]
cli = ["try-runtime-cli"]
try-runtime = [
Expand Down
74 changes: 33 additions & 41 deletions bin/collator/src/local/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use local_runtime::{
wasm_binary_unwrap, AccountId, AuraConfig, AuraId, BalancesConfig,
CommunityCouncilMembershipConfig, CommunityTreasuryPalletId, CouncilMembershipConfig,
DappStakingConfig, EVMConfig, GrandpaConfig, GrandpaId, InflationConfig, InflationParameters,
Precompiles, RuntimeGenesisConfig, Signature, SudoConfig, SystemConfig,
TechnicalCommitteeMembershipConfig, TierThreshold, TreasuryPalletId, VestingConfig, AST,
Precompiles, RuntimeGenesisConfig, Signature, SudoConfig, TechnicalCommitteeMembershipConfig,
TierThreshold, TreasuryPalletId, VestingConfig, AST,
};
use sc_service::ChainType;
use sp_core::{crypto::Ss58Codec, sr25519, Pair, Public};
Expand Down Expand Up @@ -62,46 +62,39 @@ pub fn development_config() -> ChainSpec {
let mut properties = serde_json::map::Map::new();
properties.insert("tokenSymbol".into(), "LOC".into());
properties.insert("tokenDecimals".into(), 18.into());
ChainSpec::from_genesis(
"Development",
"dev",
ChainType::Development,
move || {
testnet_genesis(
vec![authority_keys_from_seed("Alice")],
ChainSpec::builder(wasm_binary_unwrap(), None)
.with_name("Development")
.with_id("dev")
.with_chain_type(ChainType::Development)
.with_properties(properties)
.with_genesis_config(testnet_genesis(
vec![authority_keys_from_seed("Alice")],
get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
TreasuryPalletId::get().into_account_truncating(),
CommunityTreasuryPalletId::get().into_account_truncating(),
// Arrakis.TEST account in MetaMask
// Import known test account with private key
// 0x01ab6e801c06e59ca97a14fc0a1978b27fa366fc87450e0b65459dd3515b7391
// H160 address: 0xaaafB3972B05630fCceE866eC69CdADd9baC2771
AccountId::from_ss58check("5FQedkNQcF2fJPwkB6Z1ZcMgGti4vcJQNs6x85YPv3VhjBBT")
.unwrap(),
],
)
},
vec![],
None,
None,
None,
Some(properties),
None,
)
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
TreasuryPalletId::get().into_account_truncating(),
CommunityTreasuryPalletId::get().into_account_truncating(),
// Arrakis.TEST account in MetaMask
// Import known test account with private key
// 0x01ab6e801c06e59ca97a14fc0a1978b27fa366fc87450e0b65459dd3515b7391
// H160 address: 0xaaafB3972B05630fCceE866eC69CdADd9baC2771
AccountId::from_ss58check("5FQedkNQcF2fJPwkB6Z1ZcMgGti4vcJQNs6x85YPv3VhjBBT")
.unwrap(),
],
))
.build()
}

fn testnet_genesis(
initial_authorities: Vec<(AuraId, GrandpaId)>,
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
) -> RuntimeGenesisConfig {
) -> serde_json::Value {
let accounts: Vec<AccountId> = vec!["Alice", "Bob", "Charlie", "Dave", "Eve"]
.iter()
.map(|s| get_account_id_from_seed::<sr25519::Public>(s))
Expand All @@ -112,11 +105,8 @@ fn testnet_genesis(
// within contracts.
// (PUSH1 0x00 PUSH1 0x00 REVERT)
let revert_bytecode = vec![0x60, 0x00, 0x60, 0x00, 0xFD];
RuntimeGenesisConfig {
system: SystemConfig {
code: wasm_binary_unwrap().to_vec(),
..Default::default()
},
let config = RuntimeGenesisConfig {
system: Default::default(),
balances: BalancesConfig {
balances: endowed_accounts
.iter()
Expand Down Expand Up @@ -221,7 +211,9 @@ fn testnet_genesis(
democracy: Default::default(),
treasury: Default::default(),
community_treasury: Default::default(),
}
};

serde_json::to_value(&config).expect("Could not build genesis config.")
}

#[cfg(test)]
Expand Down
7 changes: 6 additions & 1 deletion bin/collator/src/local/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,11 @@ pub fn start_node(
.expect("Genesis block exists; qed"),
&config.chain_spec,
);
let net_config = sc_network::config::FullNetworkConfiguration::new(&config.network);
let mut net_config = sc_network::config::FullNetworkConfiguration::new(&config.network);

let (grandpa_protocol_config, grandpa_notification_service) =
sc_consensus_grandpa::grandpa_peers_set_config(protocol_name.clone());
net_config.add_notification_protocol(grandpa_protocol_config);

let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) =
sc_service::build_network(sc_service::BuildNetworkParams {
Expand Down Expand Up @@ -523,6 +527,7 @@ pub fn start_node(
link: grandpa_link,
network,
sync: Arc::new(sync_service),
notification_service: grandpa_notification_service,
voting_rule: sc_consensus_grandpa::VotingRulesBuilder::default().build(),
prometheus_registry,
shared_voter_state: SharedVoterState::empty(),
Expand Down
40 changes: 20 additions & 20 deletions bin/collator/src/parachain/chain_spec/astar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

//! Astar chain specifications.

use super::{get_from_seed, Extensions};
use astar_primitives::oracle::CurrencyAmount;
use astar_runtime::{
wasm_binary_unwrap, AccountId, AuraId, Balance, DappStakingConfig, EVMConfig, InflationConfig,
InflationParameters, OracleMembershipConfig, ParachainInfoConfig, Precompiles,
PriceAggregatorConfig, Signature, SystemConfig, TierThreshold, ASTR,
PriceAggregatorConfig, Signature, TierThreshold, ASTR,
};
use cumulus_primitives_core::ParaId;
use sc_service::ChainType;
Expand All @@ -32,8 +33,6 @@ use sp_runtime::{
Permill,
};

use super::{get_from_seed, Extensions};

const PARA_ID: u32 = 2006;

/// Specialized `ChainSpec` for Astar Network.
Expand All @@ -59,22 +58,24 @@ pub fn get_chain_spec() -> AstarChainSpec {
properties.insert("tokenSymbol".into(), "ASTR".into());
properties.insert("tokenDecimals".into(), 18.into());

AstarChainSpec::from_genesis(
"Astar Testnet",
"astar",
ChainType::Development,
move || make_genesis(endowned.clone(), sudo_key.clone(), PARA_ID.into()),
vec![],
None,
None,
None,
Some(properties),
AstarChainSpec::builder(
wasm_binary_unwrap(),
Extensions {
bad_blocks: Default::default(),
relay_chain: "tokyo".into(),
para_id: PARA_ID,
},
)
.with_name("Astar Testnet")
.with_id("astar")
.with_chain_type(ChainType::Development)
.with_properties(properties)
.with_genesis_config(make_genesis(
endowned.clone(),
sudo_key.clone(),
PARA_ID.into(),
))
.build()
}

fn session_keys(aura: AuraId) -> astar_runtime::SessionKeys {
Expand All @@ -86,7 +87,7 @@ fn make_genesis(
balances: Vec<(AccountId, Balance)>,
root_key: AccountId,
parachain_id: ParaId,
) -> astar_runtime::RuntimeGenesisConfig {
) -> serde_json::Value {
let authorities = vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
Expand All @@ -104,11 +105,8 @@ fn make_genesis(
// (PUSH1 0x00 PUSH1 0x00 REVERT)
let revert_bytecode = vec![0x60, 0x00, 0x60, 0x00, 0xFD];

astar_runtime::RuntimeGenesisConfig {
system: SystemConfig {
code: wasm_binary_unwrap().to_vec(),
..Default::default()
},
let config = astar_runtime::RuntimeGenesisConfig {
system: Default::default(),
sudo: astar_runtime::SudoConfig {
key: Some(root_key),
},
Expand Down Expand Up @@ -208,7 +206,9 @@ fn make_genesis(
.try_into()
.expect("Must work since buffer should have at least a single value."),
},
}
};

serde_json::to_value(&config).expect("Could not build genesis config.")
}

type AccountPublic = <Signature as Verify>::Signer;
Expand Down
37 changes: 19 additions & 18 deletions bin/collator/src/parachain/chain_spec/shibuya.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use shibuya_runtime::{
CollatorSelectionConfig, CommunityCouncilMembershipConfig, CouncilMembershipConfig,
DappStakingConfig, EVMChainIdConfig, EVMConfig, InflationConfig, InflationParameters,
OracleMembershipConfig, ParachainInfoConfig, Precompiles, PriceAggregatorConfig,
RuntimeGenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig,
RuntimeGenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig,
TechnicalCommitteeMembershipConfig, TierThreshold, VestingConfig, SBY,
};
use sp_core::{sr25519, Pair, Public};
Expand Down Expand Up @@ -62,22 +62,24 @@ pub fn get_chain_spec() -> ShibuyaChainSpec {
properties.insert("tokenSymbol".into(), "SBY".into());
properties.insert("tokenDecimals".into(), 18.into());

ShibuyaChainSpec::from_genesis(
"Shibuya Testnet",
"shibuya",
ChainType::Development,
move || make_genesis(endowned.clone(), sudo_key.clone(), PARA_ID.into()),
vec![],
None,
None,
None,
Some(properties),
ShibuyaChainSpec::builder(
wasm_binary_unwrap(),
Extensions {
bad_blocks: Default::default(),
relay_chain: "tokyo".into(),
para_id: PARA_ID,
},
)
.with_name("Shibuya Testnet")
.with_id("shibuya")
.with_chain_type(ChainType::Development)
.with_properties(properties)
.with_genesis_config(make_genesis(
endowned.clone(),
sudo_key.clone(),
PARA_ID.into(),
))
.build()
}

fn session_keys(aura: AuraId) -> SessionKeys {
Expand All @@ -89,7 +91,7 @@ fn make_genesis(
balances: Vec<(AccountId, Balance)>,
root_key: AccountId,
parachain_id: ParaId,
) -> RuntimeGenesisConfig {
) -> serde_json::Value {
let authorities = vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
Expand All @@ -111,11 +113,8 @@ fn make_genesis(
// (PUSH1 0x00 PUSH1 0x00 REVERT)
let revert_bytecode = vec![0x60, 0x00, 0x60, 0x00, 0xFD];

RuntimeGenesisConfig {
system: SystemConfig {
code: wasm_binary_unwrap().to_vec(),
..Default::default()
},
let config = RuntimeGenesisConfig {
system: Default::default(),
sudo: SudoConfig {
key: Some(root_key),
},
Expand Down Expand Up @@ -243,7 +242,9 @@ fn make_genesis(
democracy: Default::default(),
treasury: Default::default(),
community_treasury: Default::default(),
}
};

serde_json::to_value(&config).expect("Could not build genesis config.")
}

type AccountPublic = <Signature as Verify>::Signer;
Expand Down
37 changes: 19 additions & 18 deletions bin/collator/src/parachain/chain_spec/shiden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use sc_service::ChainType;
use shiden_runtime::{
wasm_binary_unwrap, AccountId, AuraId, Balance, DappStakingConfig, EVMConfig, InflationConfig,
InflationParameters, OracleMembershipConfig, ParachainInfoConfig, Precompiles,
PriceAggregatorConfig, Signature, SystemConfig, TierThreshold, SDN,
PriceAggregatorConfig, RuntimeGenesisConfig, Signature, TierThreshold, SDN,
};
use sp_core::{sr25519, Pair, Public};

Expand Down Expand Up @@ -60,22 +60,24 @@ pub fn get_chain_spec() -> ShidenChainSpec {
properties.insert("tokenSymbol".into(), "SDN".into());
properties.insert("tokenDecimals".into(), 18.into());

ShidenChainSpec::from_genesis(
"Shiden Testnet",
"shiden",
ChainType::Development,
move || make_genesis(endowned.clone(), sudo_key.clone(), PARA_ID.into()),
vec![],
None,
None,
None,
Some(properties),
ShidenChainSpec::builder(
wasm_binary_unwrap(),
Extensions {
bad_blocks: Default::default(),
relay_chain: "tokyo".into(),
para_id: PARA_ID,
},
)
.with_name("Shiden Testnet")
.with_id("shiden")
.with_chain_type(ChainType::Development)
.with_properties(properties)
.with_genesis_config(make_genesis(
endowned.clone(),
sudo_key.clone(),
PARA_ID.into(),
))
.build()
}

fn session_keys(aura: AuraId) -> shiden_runtime::SessionKeys {
Expand All @@ -87,7 +89,7 @@ fn make_genesis(
balances: Vec<(AccountId, Balance)>,
root_key: AccountId,
parachain_id: ParaId,
) -> shiden_runtime::RuntimeGenesisConfig {
) -> serde_json::Value {
let authorities = vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
Expand All @@ -105,11 +107,8 @@ fn make_genesis(
// (PUSH1 0x00 PUSH1 0x00 REVERT)
let revert_bytecode = vec![0x60, 0x00, 0x60, 0x00, 0xFD];

shiden_runtime::RuntimeGenesisConfig {
system: SystemConfig {
code: wasm_binary_unwrap().to_vec(),
..Default::default()
},
let config = RuntimeGenesisConfig {
system: Default::default(),
sudo: shiden_runtime::SudoConfig {
key: Some(root_key),
},
Expand Down Expand Up @@ -207,7 +206,9 @@ fn make_genesis(
.try_into()
.expect("Must work since buffer should have at least a single value."),
},
}
};

serde_json::to_value(&config).expect("Could not build genesis config.")
}

type AccountPublic = <Signature as Verify>::Signer;
Expand Down
Loading

0 comments on commit 7596fdc

Please sign in to comment.