diff --git a/.github/env b/.github/env new file mode 100644 index 0000000..17e6bea --- /dev/null +++ b/.github/env @@ -0,0 +1,2 @@ +RUST_STABLE_VERSION=1.77.0 +RUST_NIGHTLY_VERSION=2024-04-14 diff --git a/Cargo.lock b/Cargo.lock index 34a7252..e35db8f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1918,25 +1918,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "cumulus-pallet-dmp-queue" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ebf036bcb1e61c943cf588d14b903234594fb2538f2d7dae36e20fcc3c86e8" -dependencies = [ - "cumulus-primitives-core", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "sp-std", - "staging-xcm", -] - [[package]] name = "cumulus-pallet-parachain-system" version = "0.8.1" @@ -1985,6 +1966,21 @@ dependencies = [ "syn 2.0.58", ] +[[package]] +name = "cumulus-pallet-session-benchmarking" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f3259f743f70f39baa3abf2d9d8de864e18120465f8731b99bef039a3bf9329" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-session", + "parity-scale-codec", + "sp-runtime", + "sp-std", +] + [[package]] name = "cumulus-pallet-xcm" version = "0.8.0" @@ -2874,13 +2870,14 @@ dependencies = [ [[package]] name = "encointer-kusama-runtime" version = "1.0.0" -source = "git+https://github.com/encointer/runtimes.git?branch=ab/upgrade-encointer-to-6.1#ed797f41303814e555a488320067cd8d9d0a1736" +source = "git+https://github.com/encointer/runtimes.git?branch=ab/introduce_collator-selection#1a655369951601c0dfb3b107c0aba721fb935081" dependencies = [ "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", "cumulus-pallet-xcm", "cumulus-pallet-xcmp-queue", + "cumulus-primitives-aura", "cumulus-primitives-core", "cumulus-primitives-utility", "encointer-balances-tx-payment", @@ -2897,7 +2894,9 @@ dependencies = [ "log", "pallet-asset-tx-payment", "pallet-aura", + "pallet-authorship", "pallet-balances", + "pallet-collator-selection", "pallet-collective", "pallet-encointer-balances", "pallet-encointer-bazaar", @@ -2914,10 +2913,10 @@ dependencies = [ "pallet-message-queue", "pallet-proxy", "pallet-scheduler", + "pallet-session", "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", - "pallet-treasury", "pallet-utility", "pallet-xcm", "parachains-common", @@ -6462,15 +6461,16 @@ dependencies = [ [[package]] name = "pallet-collator-selection" -version = "10.0.0" +version = "10.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b5ad46601c613396e92292a24c5b5d76e904c456ece9deb10913f6ea2e2999" +checksum = "49d1157d9a4b7966040158a7b4f1fb29f0cefa8deb6eb9b3452df7ce4161a31c" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", "log", "pallet-authorship", + "pallet-balances", "pallet-session", "parity-scale-codec", "rand", @@ -6782,9 +6782,9 @@ dependencies = [ [[package]] name = "pallet-encointer-faucet" -version = "6.1.0" +version = "6.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef912a2cdd0f586054d5df1078037ef324fd64515671d6630cfbd1787c4ebe2a" +checksum = "3024bc49c1fd7fffa68f4aa636b199c7a0772690049d0471a6b60d17080024d8" dependencies = [ "approx", "encointer-primitives", @@ -6794,7 +6794,6 @@ dependencies = [ "log", "pallet-encointer-communities", "pallet-encointer-reputation-commitments", - "pallet-treasury", "parity-scale-codec", "scale-info", "sp-core", diff --git a/Cargo.toml b/Cargo.toml index fb7ad56..3b3e6c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ pallet-encointer-ceremonies = { default-features = false, version = "~6.1.0" } pallet-encointer-ceremonies-rpc-runtime-api = { default-features = false, version = "~6.1.0" } pallet-encointer-communities = { default-features = false, version = "~6.1.0" } pallet-encointer-communities-rpc-runtime-api = { default-features = false, version = "~6.1.0" } -pallet-encointer-faucet = { default-features = false, version = "~6.1.0" } +pallet-encointer-faucet = { default-features = false, version = "~6.2.0" } pallet-encointer-reputation-commitments = { default-features = false, version = "~6.1.0" } pallet-encointer-scheduler = { default-features = false, version = "~6.1.0" } # rpc [std] @@ -45,8 +45,8 @@ pallet-encointer-communities-rpc = "~6.1.0" encointer-balances-tx-payment-rpc = "~6.1.0" # fellowship runtimes. do not depend on fellow-runtimes directly, so we can upgrade at our own pace -kusama-runtime-constants = { default-features = false, git = "https://github.com/encointer/runtimes.git", branch = "ab/upgrade-encointer-to-6.1" } -parachain-runtime = { package = "encointer-kusama-runtime", git = "https://github.com/encointer/runtimes.git", branch = "ab/upgrade-encointer-to-6.1" } +kusama-runtime-constants = { default-features = false, git = "https://github.com/encointer/runtimes.git", branch = "ab/introduce_collator-selection" } +parachain-runtime = { package = "encointer-kusama-runtime", git = "https://github.com/encointer/runtimes.git", branch = "ab/introduce_collator-selection" } # polkadot-sdk [no_std] cumulus-pallet-aura-ext = { default-features = false, version = "0.8.0" } @@ -60,14 +60,14 @@ cumulus-primitives-utility = { default-features = false, version = "0.8.0" } frame-benchmarking = { default-features = false, version = "29.0.0" } frame-executive = { default-features = false, version = "29.0.0" } frame-rpc-system = { package = "substrate-frame-rpc-system", version = "29.0.0" } -frame-support = { default-features = false, version = "29.0.0" } +frame-support = { default-features = false, version = "29.0.2" } frame-system = { default-features = false, version = "29.0.0" } frame-system-benchmarking = { default-features = false, version = "29.0.0" } frame-system-rpc-runtime-api = { default-features = false, version = "27.0.0" } frame-try-runtime = { default-features = false, version = "0.35.0" } pallet-asset-tx-payment = { default-features = false, version = "29.0.0" } pallet-aura = { default-features = false, version = "28.0.0" } -pallet-balances = { default-features = false, version = "29.0.0" } +pallet-balances = { default-features = false, version = "29.0.1" } pallet-collective = { default-features = false, version = "29.0.0" } pallet-insecure-randomness-collective-flip = { default-features = false, version = "17.0.0" } pallet-membership = { default-features = false, version = "29.0.0" } @@ -145,9 +145,9 @@ substrate-build-script-utils = "11.0.0" substrate-prometheus-endpoint = "0.17.0" # ### only while debugging/developping -#[patch."https://github.com/encointer/runtimes"] -#kusama-runtime-constants = { path = "../runtimes/relay/kusama/constants" } -#parachain-runtime = { package = "encointer-kusama-runtime", path = "../runtimes/system-parachains/encointer" } +# [patch."https://github.com/encointer/runtimes"] +# kusama-runtime-constants = { path = "../runtimes/relay/kusama/constants" } +# parachain-runtime = { package = "encointer-kusama-runtime", path = "../runtimes/system-parachains/encointer" } # #[patch.crates-io] #encointer-balances-tx-payment = { path = "../pallets/balances-tx-payment" } diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 5c7d725..f15a0b1 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -16,7 +16,8 @@ use cumulus_primitives_core::ParaId; use parachain_runtime::{BalanceType, CeremonyPhaseType}; -use parachains_common::{AccountId, AuraId}; +use parachains_common::{AccountId, Balance}; +use parity_scale_codec::{Decode, Encode}; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; use serde::{Deserialize, Serialize}; @@ -26,6 +27,7 @@ pub use crate::chain_spec_helpers::{EncointerKeys, GenesisKeys, RelayChain, Well pub type ChainSpec = sc_service::GenericChainSpec<(), Extensions>; pub const ENDOWED_FUNDING: u128 = 1 << 60; +pub const ENCOINTER_KUSAMA_ED: Balance = parachain_runtime::ExistentialDeposit::get(); /// Configure `endowed_accounts` with initial balance of `ENDOWED_FUNDING`. pub fn allocate_endowance(endowed_accounts: Vec) -> Vec<(AccountId, u128)> { @@ -60,11 +62,11 @@ pub fn encointer_spec( ) -> ChainSpec { let (council, endowed, authorities) = match genesis_keys { GenesisKeys::Encointer => - (EncointerKeys::council(), [].to_vec(), EncointerKeys::authorities()), + (EncointerKeys::council(), [].to_vec(), EncointerKeys::invulnerables()), GenesisKeys::EncointerWithCouncilEndowed => - (EncointerKeys::council(), EncointerKeys::council(), EncointerKeys::authorities()), + (EncointerKeys::council(), EncointerKeys::council(), EncointerKeys::invulnerables()), GenesisKeys::WellKnown => - (WellKnownKeys::council(), WellKnownKeys::endowed(), WellKnownKeys::authorities()), + (WellKnownKeys::council(), WellKnownKeys::endowed(), WellKnownKeys::invulnerables()), }; #[allow(deprecated)] @@ -88,7 +90,7 @@ pub fn encointer_spec( pub fn sybil_dummy_spec(para_id: ParaId, relay_chain: RelayChain) -> ChainSpec { let (council, endowed, authorities) = - (WellKnownKeys::council(), WellKnownKeys::endowed(), WellKnownKeys::authorities()); + (WellKnownKeys::council(), WellKnownKeys::endowed(), WellKnownKeys::invulnerables()); let mut properties = sc_chain_spec::Properties::new(); properties.insert("tokenSymbol".into(), "DUM".into()); properties.insert("tokenDecimals".into(), 12.into()); @@ -115,7 +117,7 @@ pub fn sybil_dummy_spec(para_id: ParaId, relay_chain: RelayChain) -> ChainSpec { fn encointer_genesis( encointer_council: Vec, - initial_authorities: Vec, + invulnerables: Vec, endowance_allocation: Vec<(AccountId, u128)>, id: ParaId, ) -> serde_json::Value { @@ -129,8 +131,22 @@ fn encointer_genesis( "polkadotXcm": { "safeXcmVersion": Some(SAFE_XCM_VERSION), }, - "aura": { - "authorities": initial_authorities, + "collatorSelection": parachain_runtime::CollatorSelectionConfig { + invulnerables: invulnerables.clone(), + candidacy_bond: ENCOINTER_KUSAMA_ED * 16, + ..Default::default() + }, + "session": parachain_runtime::SessionConfig { + keys: invulnerables + .into_iter() + .map(|acc| { + ( + acc.clone(), // account id + acc.clone(), // validator id + parachain_runtime::SessionKeys { aura: Decode::decode(&mut acc.encode().as_ref()).unwrap() }, // session keys + ) + }) + .collect(), }, "membership": { "members": encointer_council, diff --git a/node/src/chain_spec_helpers.rs b/node/src/chain_spec_helpers.rs index 5b8ff00..c808a9c 100644 --- a/node/src/chain_spec_helpers.rs +++ b/node/src/chain_spec_helpers.rs @@ -19,7 +19,7 @@ //! Only moved stuff here that is not in the `chain_spec.rs` upstream to prevent upstream merge //! confusion. -use parachains_common::{AccountId, AuraId}; +use parachains_common::AccountId; use sc_chain_spec::Properties; use sc_service::ChainType; use sp_core::{crypto::Ss58Codec, sr25519, Public}; @@ -51,8 +51,8 @@ impl WellKnownKeys { vec![Alice.to_account_id(), Bob.to_account_id(), Charlie.to_account_id()] } - pub fn authorities() -> Vec { - vec![Alice.public().into()] + pub fn invulnerables() -> Vec { + vec![Alice.public().into(), Bob.public().into()] } pub fn council() -> Vec { @@ -63,7 +63,7 @@ impl WellKnownKeys { pub struct EncointerKeys; impl EncointerKeys { - pub fn authorities() -> Vec { + pub fn invulnerables() -> Vec { vec![ public_from_ss58::("5ECixNNkkfjHYqzwEkbuoVdzRqBpW2eTp8rp2SYR8fuNfQ4G") .into(), diff --git a/scripts/dump_essential_balances.sh b/scripts/dump_essential_balances.sh new file mode 100755 index 0000000..2d1d237 --- /dev/null +++ b/scripts/dump_essential_balances.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# make sure polkadot-js-api is in the path +# run zombienet locally +# +# example +# --------------- +# ./dump-essential-balances.sh > fee1.txt +# DO YOUR THING +# ./dump-essential-balances.sh > fee2.txt +# +# compare balances pre/post YOUR THING +# diff -y -W 80 fee1.txt fee2.txt + +#ASSET_HUB="ws://127.0.0.1:9954" +ENCOINTER="ws://127.0.0.1:9944" +ROCOCO="ws://127.0.0.1:9999" + +# dummy treasury subkey inspect --public 0x0000000000000000000000000000000000000000000000000000000000000000 +TREASURY=5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM +POT=5EYCAe5cKPAoFh2HnQQvpKqRYZGqBpaA87u4Zzw89qPE58is + +function print_balances() { + echo "*** print balances for $1" + # echo "Rococo ROC" + # polkadot-js-api --ws $ROCOCO query.system.account $1 | jq .account.data.free + echo "Encointer ROC" + polkadot-js-api --ws $ENCOINTER query.system.account $1 | jq .account.data.free +} + +echo "*** total supply of ROC@Encointer" +polkadot-js-api --ws $ENCOINTER query.balances.totalIssuance | jq .totalIssuance + +echo "*** Alice" +print_balances 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY +echo "*** Bob" +print_balances 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty +echo "*** author1 " +print_balances EXHoFmksfPoyTyuFgcJ2c11uLj9KPgCZ2wWxshxuDrvpZuq +echo "*** author2 " +print_balances E8Np37TgMvVNST2Qj7YpEMvNon2kBSPNSkMM9D2TuKjwKQZ +echo "*** staking pot" +print_balances $POT + + + + + +