Skip to content

Commit

Permalink
Create minimal Zeitgeist (Polkadot) runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
sea212 committed Jan 26, 2023
1 parent b91aef7 commit c19b75e
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 133 deletions.
140 changes: 69 additions & 71 deletions node/res/zeitgeist_parachain.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion node/src/chain_spec/battery_station.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ fn additional_chain_spec_staging_battery_station(
DEFAULT_STAKING_AMOUNT_BATTERY_STATION,
)],
collator_commission: DefaultCollatorCommission::get(),
crowdloan_fund_pot: DEFAULT_INITIAL_CROWDLOAN_FUNDS_BATTERY_STATION,
inflation_info: DEFAULT_COLLATOR_INFLATION_INFO,
nominations: vec![],
parachain_bond_reserve_percent: DefaultParachainBondReservePercent::get(),
Expand Down
1 change: 0 additions & 1 deletion node/src/chain_spec/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ pub fn dev_config() -> Result<BatteryStationChainSpec, String> {
super::battery_station::DEFAULT_STAKING_AMOUNT_BATTERY_STATION,
)],
collator_commission: DefaultCollatorCommission::get(),
crowdloan_fund_pot: zeitgeist_primitives::constants::BASE.saturating_mul(100),
inflation_info: crate::chain_spec::DEFAULT_COLLATOR_INFLATION_INFO,
nominations: vec![],
parachain_bond_reserve_percent: DefaultParachainBondReservePercent::get(),
Expand Down
35 changes: 16 additions & 19 deletions node/src/chain_spec/zeitgeist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use zeitgeist_primitives::{types::{AccountId,Balance}, constants::{
#[cfg(feature = "parachain")]
use {
super::{Extensions, DEFAULT_COLLATOR_INFLATION_INFO},
crate::KUSAMA_PARACHAIN_ID,
crate::ZEITGEIST_POLKADOT_PARACHAIN_ID,
zeitgeist_runtime::{
CollatorDeposit, DefaultBlocksPerRound, DefaultCollatorCommission,
DefaultParachainBondReservePercent, EligibilityValue, MinCollatorStk, PolkadotXcmConfig,
Expand All @@ -59,19 +59,19 @@ fn endowed_accounts_staging_zeitgeist() -> Vec<EndowedAccountWithBalance> {
#[cfg(feature = "parachain")]
EndowedAccountWithBalance(
hex!["ec9a6c37972582ce411546f96f806cfc2bb0670f60c30cbc3ad4276834b0253c"].into(),
DEFAULT_COLLATOR_BALANCE_RAUMGEIST.unwrap(),
DEFAULT_COLLATOR_BALANCE_ZEITGEIST.unwrap(),
),
// dDzXWuvDPSRXMQFAq2cJdr9NtEjtB8bohFhE3Ap9yM9s7rUQf
#[cfg(feature = "parachain")]
EndowedAccountWithBalance(
hex!["42a1ef95149913305fb05b6ac325ab9ed4b68c8d7aa60e3ea4daf4237dd9fc09"].into(),
DEFAULT_COLLATOR_BALANCE_RAUMGEIST.unwrap(),
DEFAULT_COLLATOR_BALANCE_ZEITGEIST.unwrap(),
),
// dE375YCauT8vxvXwzBGaeCfPsKTXuuBpJaqCsBqRhoySNdmtE
#[cfg(feature = "parachain")]
EndowedAccountWithBalance(
hex!["b4b3541a95c83a71de977a6f1e7e66e594a4d47c48b030802c90ba589c8bba16"].into(),
DEFAULT_COLLATOR_BALANCE_RAUMGEIST.unwrap(),
DEFAULT_COLLATOR_BALANCE_ZEITGEIST.unwrap(),
),
EndowedAccountWithBalance(root_key_staging_zeitgeist(), DEFAULT_SUDO_BALANCE),
]
Expand All @@ -82,29 +82,31 @@ fn additional_chain_spec_staging_zeitgeist(
parachain_id: cumulus_primitives_core::ParaId,
) -> AdditionalChainSpec {
AdditionalChainSpec {
blocks_per_round: DefaultBlocksPerRound::get(),
candidates: vec![
(
hex!["ec9a6c37972582ce411546f96f806cfc2bb0670f60c30cbc3ad4276834b0253c"].into(),
hex!["725d4d2948ae3a703f7a4911daa6d3022b45dc54fe1998ea88cb33a6f2bd805a"]
.unchecked_into(),
DEFAULT_STAKING_AMOUNT_RAUMGEIST,
DEFAULT_STAKING_AMOUNT_ZEITGEIST,
),
(
hex!["42a1ef95149913305fb05b6ac325ab9ed4b68c8d7aa60e3ea4daf4237dd9fc09"].into(),
hex!["2cb04566bb52665950acf535c6b03312b00d896a3e33534e09dc948e16c06042"]
.unchecked_into(),
DEFAULT_STAKING_AMOUNT_RAUMGEIST,
DEFAULT_STAKING_AMOUNT_ZEITGEIST,
),
(
hex!["b4b3541a95c83a71de977a6f1e7e66e594a4d47c48b030802c90ba589c8bba16"].into(),
hex!["e23846832242a083b94df7640257a243fe1c5a730890b254600d953ddd65011c"]
.unchecked_into(),
DEFAULT_STAKING_AMOUNT_RAUMGEIST,
DEFAULT_STAKING_AMOUNT_ZEITGEIST,
),
],
crowdloan_fund_pot: DEFAULT_INITIAL_CROWDLOAN_FUNDS_RAUMGEIST,
inflation_info: inflation_config(Perbill::from_percent(5), TOTAL_INITIAL_ZTG * BASE),
collator_commission: DefaultCollatorCommission::get(),
inflation_info: DEFAULT_COLLATOR_INFLATION_INFO,
nominations: vec![],
parachain_bond_reserve_percent: DefaultParachainBondReservePercent::get(),
parachain_id,
}
}
Expand Down Expand Up @@ -138,23 +140,18 @@ generate_generic_genesis_function!(
sudo: zeitgeist_runtime::SudoConfig { key: Some(root_key_staging_zeitgeist()) },
);

#[cfg(feature = "parachain")]
super::generate_inflation_config_function!(zeitgeist_runtime);

pub fn zeitgeist_staging_config(
#[cfg(feature = "parachain")] parachain_id: cumulus_primitives_core::ParaId,
) -> Result<ZeitgeistChainSpec, String> {
pub fn zeitgeist_staging_config() -> Result<ZeitgeistChainSpec, String> {
let wasm = get_wasm()?;

Ok(ZeitgeistChainSpec::from_genesis(
"Raumgeist Staging",
"Zeitgeist Staging",
"zeitgeist_staging",
ChainType::Live,
move || {
generic_genesis(
additional_chain_spec_staging_zeitgeist(
#[cfg(feature = "parachain")]
parachain_id,
ZEITGEIST_POLKADOT_PARACHAIN_ID.into(),
),
endowed_accounts_staging_zeitgeist(),
wasm,
Expand All @@ -164,11 +161,11 @@ pub fn zeitgeist_staging_config(
telemetry_endpoints(),
Some("zeitgeist"),
None,
Some(token_properties("RGT", SS58Prefix::get())),
Some(token_properties("ZTG", SS58Prefix::get())),
#[cfg(feature = "parachain")]
crate::chain_spec::Extensions {
relay_chain: "polkadot".into(),
parachain_id: parachain_id.into(),
parachain_id: ZEITGEIST_POLKADOT_PARACHAIN_ID.into(),
},
#[cfg(not(feature = "parachain"))]
Default::default(),
Expand Down
6 changes: 4 additions & 2 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
#[cfg(feature = "parachain")]
mod cli_parachain;

use super::service::{
use super::{
ZEITGEIST_POLKADOT_PARACHAIN_ID,
service::{
AdditionalRuntimeApiCollection, FullBackend, FullClient, IdentifyVariant, RuntimeApiCollection,
};
}};
use clap::Parser;
#[cfg(feature = "parachain")]
pub use cli_parachain::RelayChainCli;
Expand Down
2 changes: 1 addition & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ fn none_command(cli: &Cli) -> sc_cli::Result<()> {
);

let parachain_id = cumulus_primitives_core::ParaId::from(
cli.parachain_id.or(parachain_id_extension).unwrap_or(super::KUSAMA_PARACHAIN_ID),
cli.parachain_id.or(parachain_id_extension).unwrap_or(super::ZEITGEIST_POLKADOT_PARACHAIN_ID),
);

let parachain_account =
Expand Down
2 changes: 1 addition & 1 deletion node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub const ZEITGEIST_RUNTIME_NOT_AVAILABLE: &str = "Zeitgeist runtime is not avai

cfg_if::cfg_if!(
if #[cfg(feature = "parachain")] {
const KUSAMA_PARACHAIN_ID: u32 = 2092;
const ZEITGEIST_POLKADOT_PARACHAIN_ID: u32 = 2092;
const BATTERY_STATION_PARACHAIN_ID: u32 = 2050;
const KUSAMA_BLOCK_DURATION: core::time::Duration = core::time::Duration::from_secs(6);
const SOFT_DEADLINE_PERCENT: sp_runtime::Percent = sp_runtime::Percent::from_percent(100);
Expand Down
42 changes: 10 additions & 32 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,60 +85,38 @@ macro_rules! decl_common_types {

// Council vote proportions
// At least 50%
type EnsureRootOrHalfCouncil =
EitherOfDiverse<EnsureRoot<AccountId>, EnsureProportionAtLeast<AccountId, CouncilInstance, 1, 2>>;
type EnsureRootOrHalfCouncil = EnsureRoot<AccountId>;

// At least 66%
type EnsureRootOrTwoThirdsCouncil =
EitherOfDiverse<EnsureRoot<AccountId>, EnsureProportionAtLeast<AccountId, CouncilInstance, 2, 3>>;
type EnsureRootOrTwoThirdsCouncil = EnsureRoot<AccountId>;

// At least 75%
type EnsureRootOrThreeFourthsCouncil =
EitherOfDiverse<EnsureRoot<AccountId>, EnsureProportionAtLeast<AccountId, CouncilInstance, 3, 4>>;
type EnsureRootOrThreeFourthsCouncil = EnsureRoot<AccountId>;

// At least 100%
type EnsureRootOrAllCouncil =
EitherOfDiverse<EnsureRoot<AccountId>, EnsureProportionAtLeast<AccountId, CouncilInstance, 1, 1>>;
type EnsureRootOrAllCouncil = EnsureRoot<AccountId>;

// Technical committee vote proportions
// At least 50%
#[cfg(feature = "parachain")]
type EnsureRootOrHalfTechnicalCommittee = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureProportionAtLeast<AccountId, TechnicalCommitteeInstance, 1, 2>,
>;
type EnsureRootOrHalfTechnicalCommittee = EnsureRoot<AccountId>;

// At least 66%
type EnsureRootOrTwoThirdsTechnicalCommittee = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureProportionAtLeast<AccountId, TechnicalCommitteeInstance, 2, 3>,
>;
type EnsureRootOrTwoThirdsTechnicalCommittee = EnsureRoot<AccountId>;

// At least 100%
type EnsureRootOrAllTechnicalCommittee = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureProportionAtLeast<AccountId, TechnicalCommitteeInstance, 1, 1>,
>;
type EnsureRootOrAllTechnicalCommittee = EnsureRoot<AccountId>;

// Advisory committee vote proportions
// At least 50%
type EnsureRootOrHalfAdvisoryCommittee = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureProportionAtLeast<AccountId, AdvisoryCommitteeInstance, 1, 2>,
>;
type EnsureRootOrHalfAdvisoryCommittee = EnsureRoot<AccountId>;

// Technical committee vote proportions
// At least 66%
type EnsureRootOrTwoThirdsAdvisoryCommittee = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureProportionAtLeast<AccountId, AdvisoryCommitteeInstance, 2, 3>,
>;
type EnsureRootOrTwoThirdsAdvisoryCommittee = EnsureRoot<AccountId>;

// At least 100%
type EnsureRootOrAllAdvisoryCommittee = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureProportionAtLeast<AccountId, AdvisoryCommitteeInstance, 1, 1>,
>;
type EnsureRootOrAllAdvisoryCommittee = EnsureRoot<AccountId>;

#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
Expand Down
10 changes: 5 additions & 5 deletions scripts/build-parachain-spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
set -euxo pipefail

# For example, node/res/bs_parachain.json
OUTPUT_FILE=
OUTPUT_FILE=""
# For example, "Battery Station"
PROD_CHAIN_NAME=
PROD_CHAIN_NAME=""
# For example, battery_station
PROD_CHAIN_PROTOCOL_ID=
PROD_CHAIN_PROTOCOL_ID=""
# For example, battery_station_mainnet
PROD_CHAIN_ID=
PROD_CHAIN_ID=""
# For example, battery_station_staging
STAGE_CHAIN=
STAGE_CHAIN=""

cargo build --profile=production --bin zeitgeist --features parachain
./target/production/zeitgeist build-spec --chain $STAGE_CHAIN --disable-default-bootnode > $OUTPUT_FILE
Expand Down

0 comments on commit c19b75e

Please sign in to comment.