Skip to content

Commit

Permalink
introduce collator-selection and remove treasury (#219)
Browse files Browse the repository at this point in the history
* use new runtime with collator-selection. zombienet produces blocks

* fmt

* bump 1.7.6

* fee debug helper script. copy from integritee

* lift patches

* github env file
  • Loading branch information
brenzi authored Jun 6, 2024
1 parent fa450a2 commit 2eff262
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 47 deletions.
2 changes: 2 additions & 0 deletions .github/env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RUST_STABLE_VERSION=1.77.0
RUST_NIGHTLY_VERSION=2024-04-14
53 changes: 26 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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" }
Expand All @@ -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" }
Expand Down Expand Up @@ -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" }
Expand Down
32 changes: 24 additions & 8 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -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<AccountId>) -> Vec<(AccountId, u128)> {
Expand Down Expand Up @@ -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)]
Expand All @@ -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());
Expand All @@ -115,7 +117,7 @@ pub fn sybil_dummy_spec(para_id: ParaId, relay_chain: RelayChain) -> ChainSpec {

fn encointer_genesis(
encointer_council: Vec<AccountId>,
initial_authorities: Vec<AuraId>,
invulnerables: Vec<AccountId>,
endowance_allocation: Vec<(AccountId, u128)>,
id: ParaId,
) -> serde_json::Value {
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions node/src/chain_spec_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -51,8 +51,8 @@ impl WellKnownKeys {
vec![Alice.to_account_id(), Bob.to_account_id(), Charlie.to_account_id()]
}

pub fn authorities() -> Vec<AuraId> {
vec![Alice.public().into()]
pub fn invulnerables() -> Vec<AccountId> {
vec![Alice.public().into(), Bob.public().into()]
}

pub fn council() -> Vec<AccountId> {
Expand All @@ -63,7 +63,7 @@ impl WellKnownKeys {
pub struct EncointerKeys;

impl EncointerKeys {
pub fn authorities() -> Vec<AuraId> {
pub fn invulnerables() -> Vec<AccountId> {
vec![
public_from_ss58::<sr25519::Public>("5ECixNNkkfjHYqzwEkbuoVdzRqBpW2eTp8rp2SYR8fuNfQ4G")
.into(),
Expand Down
48 changes: 48 additions & 0 deletions scripts/dump_essential_balances.sh
Original file line number Diff line number Diff line change
@@ -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






0 comments on commit 2eff262

Please sign in to comment.