Skip to content

Commit

Permalink
Make node capable of handling minimal runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
sea212 committed Jan 25, 2023
1 parent fc6265b commit b91aef7
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 263 deletions.
15 changes: 1 addition & 14 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ default-members = [
"zrml/rikiddo",
"zrml/simple-disputes",
"zrml/swaps",
"zrml/swaps/rpc",
"zrml/swaps/runtime-api",
# "zrml/swaps/rpc",
# "zrml/swaps/runtime-api",
"zrml/styx",
]
members = [
Expand All @@ -41,8 +41,8 @@ members = [
"zrml/simple-disputes",
"zrml/swaps",
"zrml/swaps/fuzz",
"zrml/swaps/rpc",
"zrml/swaps/runtime-api",
# "zrml/swaps/rpc",
# "zrml/swaps/runtime-api",
"zrml/styx",
]
resolver = "2"
Expand Down
1 change: 0 additions & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ battery-station-runtime = { path = "../runtime/battery-station", optional = true
zeitgeist-primitives = { path = "../primitives" }
zeitgeist-runtime = { path = "../runtime/zeitgeist", optional = true }
zrml-liquidity-mining = { path = "../zrml/liquidity-mining" }
zrml-swaps-rpc = { path = "../zrml/swaps/rpc" }
[features]
default = ["with-battery-station-runtime", "with-zeitgeist-runtime"]
parachain = [
Expand Down
1 change: 0 additions & 1 deletion node/src/chain_spec/additional_chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub struct AdditionalChainSpec {
pub blocks_per_round: u32,
pub candidates: Vec<(AccountId, NimbusId, Balance)>,
pub collator_commission: Perbill,
pub crowdloan_fund_pot: Balance,
pub inflation_info: InflationInfo<Balance>,
pub nominations: Vec<(AccountId, AccountId, Balance, Percent)>,
pub parachain_bond_reserve_percent: Percent,
Expand Down
24 changes: 0 additions & 24 deletions node/src/chain_spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ macro_rules! generate_generic_genesis_function {
) -> $runtime::GenesisConfig {
$runtime::GenesisConfig {
// Common genesis
advisory_committee: Default::default(),
advisory_committee_membership: $runtime::AdvisoryCommitteeMembershipConfig {
members: vec![].try_into().unwrap(),
phantom: Default::default(),
},
#[cfg(feature = "parachain")]
asset_registry: Default::default(),
#[cfg(not(feature = "parachain"))]
Expand All @@ -130,22 +125,10 @@ macro_rules! generate_generic_genesis_function {
balances: $runtime::BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k.0, k.1)).collect(),
},
council: Default::default(),
council_membership: $runtime::CouncilMembershipConfig {
members: vec![].try_into().unwrap(),
phantom: Default::default(),
},
#[cfg(feature = "parachain")]
crowdloan: $runtime::CrowdloanConfig { funded_amount: acs.crowdloan_fund_pot },
democracy: Default::default(),
#[cfg(not(feature = "parachain"))]
grandpa: $runtime::GrandpaConfig {
authorities: acs.initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(),
},
liquidity_mining: $runtime::LiquidityMiningConfig {
initial_balance: LIQUIDITY_MINING,
per_block_distribution: LIQUIDITY_MINING_PTD.mul_ceil(LIQUIDITY_MINING),
},
#[cfg(feature = "parachain")]
parachain_info: $runtime::ParachainInfoConfig { parachain_id: acs.parachain_id },
#[cfg(feature = "parachain")]
Expand All @@ -168,15 +151,8 @@ macro_rules! generate_generic_genesis_function {
// Default should use the pallet configuration
polkadot_xcm: PolkadotXcmConfig::default(),
system: $runtime::SystemConfig { code: wasm_binary.to_vec() },
technical_committee: Default::default(),
technical_committee_membership: $runtime::TechnicalCommitteeMembershipConfig {
members: vec![].try_into().unwrap(),
phantom: Default::default(),
},
treasury: Default::default(),
transaction_payment: Default::default(),
tokens: Default::default(),
vesting: Default::default(),

// Additional genesis
$($additional_genesis)*
Expand Down
86 changes: 51 additions & 35 deletions node/src/chain_spec/zeitgeist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ use sc_service::ChainType;
use sp_core::crypto::UncheckedInto;
use zeitgeist_runtime::parameters::SS58Prefix;

use zeitgeist_primitives::constants::ztg::{LIQUIDITY_MINING, LIQUIDITY_MINING_PTD};
use zeitgeist_primitives::{types::{AccountId,Balance}, constants::{
BASE,
ztg::{LIQUIDITY_MINING, LIQUIDITY_MINING_PTD}
}};

#[cfg(feature = "parachain")]
use {
Expand All @@ -48,26 +51,29 @@ cfg_if::cfg_if! {
}
}

const DEFAULT_SUDO_BALANCE: Balance = 1000 * BASE;

fn endowed_accounts_staging_zeitgeist() -> Vec<EndowedAccountWithBalance> {
vec![
// dDzt4vaprRfHqGBat44bWD4i36WMDXjsGXmCHoxMom2eQgQCd
// dE4NNpcWPCk8TH3GM9eJV1jauEmHC3rQcxMdnTtrc3NgDGUNo
#[cfg(feature = "parachain")]
EndowedAccountWithBalance(
hex!["524e9aac979cbb9ecdb7acd1635755c3b15696321a3345ca77f0ab0ae23f675a"].into(),
DEFAULT_COLLATOR_BALANCE_ZEITGEIST.unwrap(),
hex!["ec9a6c37972582ce411546f96f806cfc2bb0670f60c30cbc3ad4276834b0253c"].into(),
DEFAULT_COLLATOR_BALANCE_RAUMGEIST.unwrap(),
),
// dDy7WSPy4pvWBKsUta8MdWxduWFTpJtv9zgBiVGtqWmMh6bi6
// dDzXWuvDPSRXMQFAq2cJdr9NtEjtB8bohFhE3Ap9yM9s7rUQf
#[cfg(feature = "parachain")]
EndowedAccountWithBalance(
hex!["04163722a7f1f900c1ec502383d4959360e374c8808e13d47b3e553d761a6329"].into(),
DEFAULT_COLLATOR_BALANCE_ZEITGEIST.unwrap(),
hex!["42a1ef95149913305fb05b6ac325ab9ed4b68c8d7aa60e3ea4daf4237dd9fc09"].into(),
DEFAULT_COLLATOR_BALANCE_RAUMGEIST.unwrap(),
),
// dE36Y98QpX8hEkLANntbtUvt7figSPGxSrDxU4sscuX989CTJ
// dE375YCauT8vxvXwzBGaeCfPsKTXuuBpJaqCsBqRhoySNdmtE
#[cfg(feature = "parachain")]
EndowedAccountWithBalance(
hex!["b449a256f73e59602eb742071a07e4d94aaae91e6872f28e161f34982a0bfc0d"].into(),
DEFAULT_COLLATOR_BALANCE_ZEITGEIST.unwrap(),
hex!["b4b3541a95c83a71de977a6f1e7e66e594a4d47c48b030802c90ba589c8bba16"].into(),
DEFAULT_COLLATOR_BALANCE_RAUMGEIST.unwrap(),
),
EndowedAccountWithBalance(root_key_staging_zeitgeist(), DEFAULT_SUDO_BALANCE),
]
}

Expand All @@ -76,32 +82,29 @@ fn additional_chain_spec_staging_zeitgeist(
parachain_id: cumulus_primitives_core::ParaId,
) -> AdditionalChainSpec {
AdditionalChainSpec {
blocks_per_round: DefaultBlocksPerRound::get(),
candidates: vec![
(
hex!["524e9aac979cbb9ecdb7acd1635755c3b15696321a3345ca77f0ab0ae23f675a"].into(),
hex!["e251731d35dd19aeb7db1ffe06227d0b7da3b3eabb5ec1d79da453ac9949e80b"]
hex!["ec9a6c37972582ce411546f96f806cfc2bb0670f60c30cbc3ad4276834b0253c"].into(),
hex!["725d4d2948ae3a703f7a4911daa6d3022b45dc54fe1998ea88cb33a6f2bd805a"]
.unchecked_into(),
DEFAULT_STAKING_AMOUNT_ZEITGEIST,
DEFAULT_STAKING_AMOUNT_RAUMGEIST,
),
(
hex!["04163722a7f1f900c1ec502383d4959360e374c8808e13d47b3e553d761a6329"].into(),
hex!["76d3384620053d1eb67e0f7fa8af93a8028e5cf74f22a12a5f2393b286463753"]
hex!["42a1ef95149913305fb05b6ac325ab9ed4b68c8d7aa60e3ea4daf4237dd9fc09"].into(),
hex!["2cb04566bb52665950acf535c6b03312b00d896a3e33534e09dc948e16c06042"]
.unchecked_into(),
DEFAULT_STAKING_AMOUNT_ZEITGEIST,
DEFAULT_STAKING_AMOUNT_RAUMGEIST,
),
(
hex!["b449a256f73e59602eb742071a07e4d94aaae91e6872f28e161f34982a0bfc0d"].into(),
hex!["14a3becfeeb700ff6a41927a2924493717aea238d9c5bea15368d61550f63e44"]
hex!["b4b3541a95c83a71de977a6f1e7e66e594a4d47c48b030802c90ba589c8bba16"].into(),
hex!["e23846832242a083b94df7640257a243fe1c5a730890b254600d953ddd65011c"]
.unchecked_into(),
DEFAULT_STAKING_AMOUNT_ZEITGEIST,
DEFAULT_STAKING_AMOUNT_RAUMGEIST,
),
],
collator_commission: DefaultCollatorCommission::get(),
crowdloan_fund_pot: DEFAULT_INITIAL_CROWDLOAN_FUNDS_ZEITGEIST,
inflation_info: DEFAULT_COLLATOR_INFLATION_INFO,
crowdloan_fund_pot: DEFAULT_INITIAL_CROWDLOAN_FUNDS_RAUMGEIST,
inflation_info: inflation_config(Perbill::from_percent(5), TOTAL_INITIAL_ZTG * BASE),
nominations: vec![],
parachain_bond_reserve_percent: DefaultParachainBondReservePercent::get(),
parachain_id,
}
}
Expand All @@ -110,11 +113,11 @@ fn additional_chain_spec_staging_zeitgeist(
fn additional_chain_spec_staging_zeitgeist() -> AdditionalChainSpec {
AdditionalChainSpec {
initial_authorities: vec![(
// 5FCSJzvmeUW1hBo3ASnLzSxpUdn5QUDt1Eqobj1meiQB7mLu
hex!["8a9a54bdf73fb4a757f5ab81fabe2f173922fdb92bb8b6e8bedf8b17fa38f500"]
// Aura
hex!["5ce5033dba3f6f730f11c20d00c34c4d3fbe23eb81471255bfde689f25dc966e"]
.unchecked_into(),
// 5HGProUwcyCDMJDxjBBKbv8u7ehr5uoTBS3bckYHPcZMTifW
hex!["e61786c6426b55a034f9c4b78dc57d4183927cef8e64b2e496225ed6fca41758"]
// Grandpa
hex!["ffd00bcb47e83ed435ce55264cf89969041a5108fdfb3198c79dfe0b75f66600"]
.unchecked_into(),
)],
}
Expand All @@ -125,20 +128,33 @@ pub(super) fn get_wasm() -> Result<&'static [u8], String> {
zeitgeist_runtime::WASM_BINARY.ok_or_else(|| "WASM binary is not available".to_string())
}

generate_generic_genesis_function!(zeitgeist_runtime,);
#[inline]
fn root_key_staging_zeitgeist() -> AccountId {
hex!["e6c622c6f2eaba444b68955501e535247c192b35e7b3e44e4c1dc24a514b4965"].into()
}

generate_generic_genesis_function!(
zeitgeist_runtime,
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() -> Result<ZeitgeistChainSpec, String> {
pub fn zeitgeist_staging_config(
#[cfg(feature = "parachain")] parachain_id: cumulus_primitives_core::ParaId,
) -> Result<ZeitgeistChainSpec, String> {
let wasm = get_wasm()?;

Ok(ZeitgeistChainSpec::from_genesis(
"Zeitgeist Staging",
"Raumgeist Staging",
"zeitgeist_staging",
ChainType::Live,
move || {
generic_genesis(
additional_chain_spec_staging_zeitgeist(
#[cfg(feature = "parachain")]
KUSAMA_PARACHAIN_ID.into(),
parachain_id,
),
endowed_accounts_staging_zeitgeist(),
wasm,
Expand All @@ -148,11 +164,11 @@ pub fn zeitgeist_staging_config() -> Result<ZeitgeistChainSpec, String> {
telemetry_endpoints(),
Some("zeitgeist"),
None,
Some(token_properties("ZTG", SS58Prefix::get())),
Some(token_properties("RGT", SS58Prefix::get())),
#[cfg(feature = "parachain")]
crate::chain_spec::Extensions {
relay_chain: "kusama".into(),
parachain_id: KUSAMA_PARACHAIN_ID,
relay_chain: "polkadot".into(),
parachain_id: parachain_id.into(),
},
#[cfg(not(feature = "parachain"))]
Default::default(),
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 = 2101;
const KUSAMA_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
3 changes: 0 additions & 3 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,17 @@ where
+ 'static,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: zrml_swaps_rpc::SwapsRuntimeApi<Block, PoolId, AccountId, Balance, MarketId>,
C::Api: BlockBuilder<Block>,
P: TransactionPool + Sync + Send + 'static,
{
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use substrate_frame_rpc_system::{System, SystemApiServer};
use zrml_swaps_rpc::{Swaps, SwapsApiServer};

let mut io = RpcModule::new(());
let FullDeps { client, pool, deny_unsafe } = deps;

io.merge(System::new(Arc::clone(&client), Arc::clone(&pool), deny_unsafe).into_rpc())?;
io.merge(TransactionPayment::new(Arc::clone(&client)).into_rpc())?;
io.merge(Swaps::new(client).into_rpc())?;

Ok(io)
}
4 changes: 1 addition & 3 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ pub trait RuntimeApiCollection:
+ sp_api::Metadata<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>
+ zrml_swaps_rpc::SwapsRuntimeApi<Block, PoolId, AccountId, Balance, MarketId>
where
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
{
Expand All @@ -121,8 +120,7 @@ where
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ sp_api::Metadata<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>
+ zrml_swaps_rpc::SwapsRuntimeApi<Block, PoolId, AccountId, Balance, MarketId>,
+ sp_session::SessionKeys<Block>,
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
{
}
Expand Down
34 changes: 1 addition & 33 deletions runtime/battery-station/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,46 +101,14 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
#[derive(scale_info::TypeInfo)]
pub struct IsCallable;

// Currently disables Court, Rikiddo and creation of markets using Court.
impl Contains<Call> for IsCallable {
fn contains(call: &Call) -> bool {
use zeitgeist_primitives::types::{
MarketDisputeMechanism::Court, ScoringRule::RikiddoSigmoidFeeMarketEma,
};
use zrml_prediction_markets::Call::{
create_cpmm_market_and_deploy_assets, create_market, edit_market,
};

#[allow(clippy::match_like_matches_macro)]
match call {
Call::Court(_) => false,
Call::LiquidityMining(_) => false,
Call::PredictionMarkets(inner_call) => {
match inner_call {
// Disable Rikiddo markets
create_market { scoring_rule: RikiddoSigmoidFeeMarketEma, .. } => false,
edit_market { scoring_rule: RikiddoSigmoidFeeMarketEma, .. } => false,
// Disable Court dispute resolution mechanism
create_market { dispute_mechanism: Court, .. } => false,
create_cpmm_market_and_deploy_assets { dispute_mechanism: Court, .. } => false,
edit_market { dispute_mechanism: Court, .. } => false,
_ => true,
}
}
_ => true,
}
true
}
}

decl_common_types!();

#[cfg(feature = "with-global-disputes")]
create_runtime_with_additional_pallets!(
GlobalDisputes: zrml_global_disputes::{Call, Event<T>, Pallet, Storage} = 59,
Sudo: pallet_sudo::{Call, Config<T>, Event<T>, Pallet, Storage} = 150,
);

#[cfg(not(feature = "with-global-disputes"))]
create_runtime_with_additional_pallets!(
Sudo: pallet_sudo::{Call, Config<T>, Event<T>, Pallet, Storage} = 150,
);
Expand Down
Loading

0 comments on commit b91aef7

Please sign in to comment.