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

Uplift to v1.5 #1256

Merged
merged 26 commits into from
Jul 12, 2024
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
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
Loading