Skip to content

Commit

Permalink
Fix compliaton
Browse files Browse the repository at this point in the history
  • Loading branch information
imstar15 committed Aug 2, 2024
1 parent 75fc19c commit d8e96ab
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 79 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ polkadot-service = { git = "https://github.com/paritytech/polkadot-sdk", branch
xcm = { package="staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }

# Moonbeam Dependencies
pallet-parachain-staking = { git = "https://github.com/moonbeam-foundation/moonbeam", tag = "v0.35.0" }
# pallet-parachain-staking = { git = "https://github.com/moonbeam-foundation/moonbeam", tag = "runtime-2602" }

# ORML Dependencies
orml-asset-registry = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v1.1.0" }
Expand Down
50 changes: 25 additions & 25 deletions node/src/chain_spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use sp_runtime::{
Perbill,
};

use pallet_parachain_staking::{InflationInfo, Range};
// use pallet_parachain_staking::{InflationInfo, Range};

use primitives::{AccountId, AuraId, Balance, Signature};

Expand Down Expand Up @@ -91,30 +91,30 @@ where
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
}

pub fn inflation_config(
blocks_per_round: u32,
annual_inflation_percentage: u32,
) -> InflationInfo<Balance> {
fn to_round_inflation(annual: Range<Perbill>, blocks_per_round: u32) -> Range<Perbill> {
use pallet_parachain_staking::inflation::{
perbill_annual_to_perbill_round, BLOCKS_PER_YEAR,
};
perbill_annual_to_perbill_round(annual, BLOCKS_PER_YEAR / blocks_per_round)
}

let annual = Range {
min: Perbill::from_percent(annual_inflation_percentage),
ideal: Perbill::from_percent(annual_inflation_percentage),
max: Perbill::from_percent(annual_inflation_percentage),
};

InflationInfo {
// We have no staking expectations since inflation range is a singular value
expect: Range { min: 0, ideal: 0, max: 0 },
annual,
round: to_round_inflation(annual, blocks_per_round),
}
}
// pub fn inflation_config(
// blocks_per_round: u32,
// annual_inflation_percentage: u32,
// ) -> InflationInfo<Balance> {
// fn to_round_inflation(annual: Range<Perbill>, blocks_per_round: u32) -> Range<Perbill> {
// use pallet_parachain_staking::inflation::{
// perbill_annual_to_perbill_round, BLOCKS_PER_YEAR,
// };
// perbill_annual_to_perbill_round(annual, BLOCKS_PER_YEAR / blocks_per_round)
// }

// let annual = Range {
// min: Perbill::from_percent(annual_inflation_percentage),
// ideal: Perbill::from_percent(annual_inflation_percentage),
// max: Perbill::from_percent(annual_inflation_percentage),
// };

// InflationInfo {
// // We have no staking expectations since inflation range is a singular value
// expect: Range { min: 0, ideal: 0, max: 0 },
// annual,
// round: to_round_inflation(annual, blocks_per_round),
// }
// }

pub mod test {
use super::*;
Expand Down
30 changes: 16 additions & 14 deletions node/src/chain_spec/neumann.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use sp_runtime::{Perbill, Percent};

use super::TELEMETRY_URL;
use crate::chain_spec::{
get_account_id_from_seed, get_collator_keys_from_seed, inflation_config, DummyChainSpec,
get_account_id_from_seed, get_collator_keys_from_seed,
// inflation_config,
DummyChainSpec,
Extensions,
};
use common_runtime::constants::currency::{DOLLAR, TOKEN_DECIMALS};
Expand Down Expand Up @@ -328,19 +330,19 @@ fn testnet_genesis(
})
.collect(),
},
parachain_staking: neumann_runtime::ParachainStakingConfig {
candidates: invulnerables
.iter()
.cloned()
.map(|(acc, _)| (acc, candidate_stake))
.collect(),
delegations: vec![],
inflation_config: inflation_config(25, 5),
blocks_per_round: 25,
collator_commission: Perbill::from_percent(20),
parachain_bond_reserve_percent: Percent::from_percent(30),
num_selected_candidates: NUM_SELECTED_CANDIDATES,
},
// parachain_staking: neumann_runtime::ParachainStakingConfig {
// candidates: invulnerables
// .iter()
// .cloned()
// .map(|(acc, _)| (acc, candidate_stake))
// .collect(),
// delegations: vec![],
// inflation_config: inflation_config(25, 5),
// blocks_per_round: 25,
// collator_commission: Perbill::from_percent(20),
// parachain_bond_reserve_percent: Percent::from_percent(30),
// num_selected_candidates: NUM_SELECTED_CANDIDATES,
// },
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this.
aura: Default::default(),
Expand Down
29 changes: 15 additions & 14 deletions node/src/chain_spec/oak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use sp_runtime::{Perbill, Percent};

use super::TELEMETRY_URL;
use crate::chain_spec::{
get_account_id_from_seed, get_collator_keys_from_seed, inflation_config,
get_account_id_from_seed, get_collator_keys_from_seed,
// inflation_config,
test::{validate_allocation, validate_vesting},
Extensions,
};
Expand Down Expand Up @@ -365,19 +366,19 @@ fn testnet_genesis(
})
.collect(),
},
parachain_staking: oak_runtime::ParachainStakingConfig {
candidates: invulnerables
.iter()
.cloned()
.map(|(acc, _)| (acc, candidate_stake))
.collect(),
delegations: vec![],
inflation_config: inflation_config(1800, 5),
blocks_per_round: 1800,
collator_commission: Perbill::from_percent(20),
parachain_bond_reserve_percent: Percent::from_percent(30),
num_selected_candidates: NUM_SELECTED_CANDIDATES,
},
// parachain_staking: oak_runtime::ParachainStakingConfig {
// candidates: invulnerables
// .iter()
// .cloned()
// .map(|(acc, _)| (acc, candidate_stake))
// .collect(),
// delegations: vec![],
// inflation_config: inflation_config(1800, 5),
// blocks_per_round: 1800,
// collator_commission: Perbill::from_percent(20),
// parachain_bond_reserve_percent: Percent::from_percent(30),
// num_selected_candidates: NUM_SELECTED_CANDIDATES,
// },
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this.
aura: Default::default(),
Expand Down
14 changes: 11 additions & 3 deletions node/src/chain_spec/turing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use sp_core::sr25519;
use sp_runtime::{Perbill, Percent};

use crate::chain_spec::{
get_account_id_from_seed, get_collator_keys_from_seed, inflation_config, DummyChainSpec,
get_account_id_from_seed, get_collator_keys_from_seed,
// inflation_config,
DummyChainSpec,
Extensions,
};
use codec::Encode;
Expand All @@ -16,6 +18,7 @@ use primitives::{assets::CustomMetadata, AccountId, AuraId, Balance, TokenId};
use turing_runtime::{
AssetRegistryConfig, CouncilConfig, PolkadotXcmConfig, TechnicalMembershipConfig,
// ValveConfig, VestingConfig,
CollatorSelectionConfig,
};
use xcm::{prelude::*, VersionedMultiLocation::V3};
use frame_support::{
Expand Down Expand Up @@ -214,7 +217,7 @@ fn testnet_genesis(
general_councils: Vec<AccountId>,
technical_memberships: Vec<AccountId>,
additional_assets: Vec<(TokenId, Vec<u8>)>,
) -> turing_runtime::GenesisConfig {
) -> turing_runtime::RuntimeGenesisConfig {
let candidate_stake = turing_runtime::MinCandidateStk::get();

let assets = [
Expand All @@ -240,7 +243,7 @@ fn testnet_genesis(

let last_asset_id = assets.iter().map(|asset| asset.0).max().expect("At least 1 item!");

turing_runtime::GenesisConfig {
turing_runtime::RuntimeGenesisConfig {
system: turing_runtime::SystemConfig {
code: turing_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
Expand Down Expand Up @@ -292,6 +295,11 @@ fn testnet_genesis(
// valve: ValveConfig { start_with_valve_closed: false, closed_gates: pallet_gates_closed },
// vesting: VestingConfig { vesting_schedule },
asset_registry: AssetRegistryConfig { assets, last_asset_id },
collator_selection: CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: common_runtime::constants::currency::EXISTENTIAL_DEPOSIT * 16,
..Default::default()
},
}
}

Expand Down
56 changes: 37 additions & 19 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use sp_runtime::traits::{AccountIdConversion, Block as BlockT};
use crate::{
chain_spec::{self, IdentifyVariant},
cli::{Cli, RelayChainCli, Subcommand},
service,
service, service::new_partial,
};

fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
Expand Down Expand Up @@ -268,17 +268,35 @@ pub fn run() -> Result<()> {
})
},
Some(Subcommand::ExportGenesisState(cmd)) => {
// let runner = cli.create_runner(cmd)?;
// let chain_spec = &runner.config().chain_spec;
// with_runtime_or_err!(chain_spec, {
// {
// runner.sync_run(|_config| {
// let spec =
// cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
// let state_version = Cli::native_runtime_version(&spec).state_version();
// cmd.run::<Block>(&*spec, state_version)
// })
// }
// })
// let runner = cli.create_runner(cmd)?;
// runner.sync_run(|config| {
// // let spec =
// // cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
// let partials = service::new_partial::<RuntimeApi, Executor, _>(
// &config,
// crate::service::parachain_build_import_queue,
// )?;

// // cmd.run(partials.client)
// cmd.run(&*config.chain_spec, &*partials.client)
// })

let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;
with_runtime_or_err!(chain_spec, {
{
runner.sync_run(|_config| {
let spec =
cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
let state_version = Cli::native_runtime_version(&spec).state_version();
cmd.run::<Block>(&*spec, state_version)
})
}
runner.sync_run(|_config| {
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
cmd.run(&*spec)
})
},
Some(Subcommand::ExportGenesisWasm(cmd)) => {
Expand Down Expand Up @@ -395,18 +413,18 @@ pub fn run() -> Result<()> {
SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, tokio_handle)
.map_err(|err| format!("Relay chain argument error: {}", err))?;

let state_version = Cli::native_runtime_version(&config.chain_spec).state_version();
// let state_version = Cli::native_runtime_version(&config.chain_spec).state_version();

let genesis_state = with_runtime_or_err!(chain_spec, {
{
let block: Block = generate_genesis_block(&**chain_spec, state_version)?;
format!("0x{:?}", HexDisplay::from(&block.header().encode()))
}
});
// let genesis_state = with_runtime_or_err!(chain_spec, {
// {
// let block: Block = generate_genesis_block(&**chain_spec, state_version)?;
// format!("0x{:?}", HexDisplay::from(&block.header().encode()))
// }
// });

info!("Parachain id: {:?}", id);
info!("Parachain Account: {}", parachain_account);
info!("Parachain genesis state: {:?}", genesis_state);
// info!("Parachain genesis state: {:?}", genesis_state);
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });

with_runtime_or_err!(chain_spec, {
Expand Down
4 changes: 2 additions & 2 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ where
+ cumulus_primitives_core::CollectCollationInfo<Block>
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
+ substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_automation_time_rpc::AutomationTimeRuntimeApi<Block, AccountId, Hash, Balance>
// + pallet_automation_time_rpc::AutomationTimeRuntimeApi<Block, AccountId, Hash, Balance>
+ pallet_automation_price_rpc::AutomationPriceRuntimeApi<Block, AccountId, Hash, Balance>
+ pallet_xcmp_handler_rpc::XcmpHandlerRuntimeApi<Block, Balance>,
RuntimeApi::RuntimeApi: sp_consensus_aura::AuraApi<Block, AuraId>,
Expand Down Expand Up @@ -538,7 +538,7 @@ where
+ cumulus_primitives_core::CollectCollationInfo<Block>
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
+ substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_automation_time_rpc::AutomationTimeRuntimeApi<Block, AccountId, Hash, Balance>
// + pallet_automation_time_rpc::AutomationTimeRuntimeApi<Block, AccountId, Hash, Balance>
+ pallet_automation_price_rpc::AutomationPriceRuntimeApi<Block, AccountId, Hash, Balance>
+ pallet_xcmp_handler_rpc::XcmpHandlerRuntimeApi<Block, Balance>,
RuntimeApi::RuntimeApi: sp_consensus_aura::AuraApi<Block, AuraId>,
Expand Down

0 comments on commit d8e96ab

Please sign in to comment.