Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the development runtime #428

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ members = [
"runtime/amplitude",
"runtime/foucoco",
"runtime/pendulum",
"runtime/development",
"runtime/integration-tests",
]

Expand Down
2 changes: 0 additions & 2 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", re
amplitude-runtime = { path = "../runtime/amplitude" }
foucoco-runtime = { path = "../runtime/foucoco" }
pendulum-runtime = { path = "../runtime/pendulum" }
development-runtime = { path = "../runtime/development" }
runtime-common = { path = "../runtime/common" }

# Substrate
Expand Down Expand Up @@ -103,7 +102,6 @@ runtime-benchmarks = [
"amplitude-runtime/runtime-benchmarks",
"foucoco-runtime/runtime-benchmarks",
"pendulum-runtime/runtime-benchmarks",
"development-runtime/runtime-benchmarks",
"runtime-common/runtime-benchmarks",
"polkadot-cli/runtime-benchmarks",
]
Expand Down
149 changes: 3 additions & 146 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
use cumulus_primitives_core::ParaId;
use runtime_common::{
AccountId, AuraId, Balance, BlockNumber, Signature, EXISTENTIAL_DEPOSIT, UNIT,
};
use runtime_common::{AccountId, AuraId, Balance, BlockNumber, UNIT};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
use sp_core::{
crypto::{Ss58Codec, UncheckedInto},
sr25519, Pair, Public,
};
use sp_runtime::{
traits::{IdentifyAccount, Verify},
FixedPointNumber, FixedU128, Perquintill,
};
use sp_core::crypto::{Ss58Codec, UncheckedInto};
use sp_runtime::{FixedPointNumber, FixedU128, Perquintill};
use spacewalk_primitives::{oracle::Key, Asset, CurrencyId, CurrencyId::XCM, VaultCurrencyPair};

use crate::constants::{
Expand All @@ -30,19 +22,9 @@ pub type FoucocoChainSpec =
pub type PendulumChainSpec =
sc_service::GenericChainSpec<pendulum_runtime::GenesisConfig, ParachainExtensions>;

pub type DevelopmentChainSpec =
sc_service::GenericChainSpec<development_runtime::GenesisConfig, ParachainExtensions>;

/// The default XCM version to set in genesis config.
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;

/// Helper function to generate a crypto pair from seed
pub fn get_public_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
<TPublic::Pair as Pair>::from_string(&format!("//{seed}"), None)
.expect("static values are valid; qed")
.public()
}

pub fn create_pendulum_multisig_account(id: &str) -> AccountId {
let mut signatories: Vec<_> = pendulum::SUDO_SIGNATORIES
.iter()
Expand Down Expand Up @@ -71,23 +53,6 @@ impl ParachainExtensions {
}
}

type AccountPublic = <Signature as Verify>::Signer;

/// Generate collator keys from seed.
///
/// This function's return type must always match the session keys of the chain in tuple format.
pub fn get_collator_keys_from_seed(seed: &str) -> AuraId {
get_public_from_seed::<AuraId>(seed)
}

/// Helper function to generate an account ID from seed
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
where
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
{
AccountPublic::from(get_public_from_seed::<TPublic>(seed)).into_account()
}

/// Generate the session keys from individual elements.
///
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
Expand All @@ -103,10 +68,6 @@ pub fn get_pendulum_session_keys(keys: AuraId) -> pendulum_runtime::SessionKeys
pendulum_runtime::SessionKeys { aura: keys }
}

pub fn get_development_session_keys(keys: AuraId) -> development_runtime::SessionKeys {
development_runtime::SessionKeys { aura: keys }
}

pub fn amplitude_config() -> AmplitudeChainSpec {
sp_core::crypto::set_default_ss58_version(amplitude_runtime::SS58Prefix::get().into());

Expand Down Expand Up @@ -352,67 +313,6 @@ pub fn pendulum_config() -> PendulumChainSpec {
)
}

pub fn development_config() -> DevelopmentChainSpec {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "UNIT".into());
properties.insert("tokenDecimals".into(), foucoco::TOKEN_DECIMALS.into());
properties.insert("ss58Format".into(), 42.into());

DevelopmentChainSpec::from_genesis(
// Name
"Development",
// ID
"dev",
ChainType::Development,
move || {
testnet_genesis(
// initial collators.
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed("Alice"),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_collator_keys_from_seed("Bob"),
),
],
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
1000.into(),
)
},
// Bootnodes
Vec::new(),
// Telemetry
None,
// Protocol ID
Some("pendulum-development"),
// Fork ID
None,
// Properties
Some(properties),
// Extensions
ParachainExtensions {
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
para_id: 1000,
},
)
}

fn default_pair(currency_id: CurrencyId) -> VaultCurrencyPair<CurrencyId> {
VaultCurrencyPair { collateral: currency_id, wrapped: MAINNET_USDC_CURRENCY_ID }
}
Expand Down Expand Up @@ -994,46 +894,3 @@ fn pendulum_genesis(
nomination: pendulum_runtime::NominationConfig { is_nomination_enabled: false },
}
}

fn testnet_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> development_runtime::GenesisConfig {
development_runtime::GenesisConfig {
system: development_runtime::SystemConfig {
code: development_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
},
balances: development_runtime::BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
},
parachain_info: development_runtime::ParachainInfoConfig { parachain_id: id },
collator_selection: development_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: EXISTENTIAL_DEPOSIT * 16,
..Default::default()
},
session: development_runtime::SessionConfig {
keys: invulnerables
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
get_development_session_keys(aura), // session keys
)
})
.collect(),
},
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this.
aura: Default::default(),
aura_ext: Default::default(),
parachain_system: Default::default(),
polkadot_xcm: amplitude_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
},
}
}
42 changes: 2 additions & 40 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ use crate::{
chain_spec::{self, ParachainExtensions},
cli::{Cli, RelayChainCli, Subcommand},
service::{
new_partial, AmplitudeRuntimeExecutor, DevelopmentRuntimeExecutor, FoucocoRuntimeExecutor,
PendulumRuntimeExecutor,
new_partial, AmplitudeRuntimeExecutor, FoucocoRuntimeExecutor, PendulumRuntimeExecutor,
},
};

Expand All @@ -29,7 +28,6 @@ enum ChainIdentity {
Amplitude,
Foucoco,
Pendulum,
Development,
}

impl ChainIdentity {
Expand All @@ -38,7 +36,6 @@ impl ChainIdentity {
"amplitude" => Some(ChainIdentity::Amplitude),
"foucoco" => Some(ChainIdentity::Foucoco),
"pendulum" => Some(ChainIdentity::Pendulum),
"" | "dev" => Some(ChainIdentity::Development),
_ => None,
}
}
Expand All @@ -57,7 +54,6 @@ impl ChainIdentity {
ChainIdentity::Amplitude => &amplitude_runtime::VERSION,
ChainIdentity::Foucoco => &foucoco_runtime::VERSION,
ChainIdentity::Pendulum => &pendulum_runtime::VERSION,
ChainIdentity::Development => &development_runtime::VERSION,
}
}

Expand All @@ -66,7 +62,6 @@ impl ChainIdentity {
ChainIdentity::Amplitude => Box::new(chain_spec::amplitude_config()),
ChainIdentity::Foucoco => Box::new(chain_spec::foucoco_config()),
ChainIdentity::Pendulum => Box::new(chain_spec::pendulum_config()),
ChainIdentity::Development => Box::new(chain_spec::development_config()),
}
}

Expand All @@ -81,8 +76,6 @@ impl ChainIdentity {
Box::new(chain_spec::FoucocoChainSpec::from_json_file(path.into())?),
ChainIdentity::Pendulum =>
Box::new(chain_spec::PendulumChainSpec::from_json_file(path.into())?),
ChainIdentity::Development =>
Box::new(chain_spec::DevelopmentChainSpec::from_json_file(path.into())?),
})
}
}
Expand All @@ -93,7 +86,7 @@ trait IdentifyChain {

impl IdentifyChain for dyn sc_service::ChainSpec {
fn identify(&self) -> ChainIdentity {
ChainIdentity::identify(self.id()).unwrap_or(ChainIdentity::Development)
ChainIdentity::identify(self.id()).unwrap_or(ChainIdentity::Foucoco)
}
}

Expand Down Expand Up @@ -208,13 +201,6 @@ macro_rules! construct_sync_run {
new_partial::<pendulum_runtime::RuntimeApi, PendulumRuntimeExecutor>(&$config)?;
$code
}),
ChainIdentity::Development => runner.sync_run(|$config| {
let $components = new_partial::<
development_runtime::RuntimeApi,
DevelopmentRuntimeExecutor,
>(&$config)?;
$code
}),
}
}};
}
Expand All @@ -241,13 +227,6 @@ macro_rules! construct_generic_async_run {
new_partial::<pendulum_runtime::RuntimeApi, PendulumRuntimeExecutor>(&$config)?;
$code
}),
ChainIdentity::Development => runner.async_run(|$config| {
let $components = new_partial::<
development_runtime::RuntimeApi,
DevelopmentRuntimeExecutor,
>(&$config)?;
$code
}),
}
}};
}
Expand Down Expand Up @@ -341,9 +320,6 @@ pub fn run() -> Result<()> {
.sync_run(|config| cmd.run::<Block, FoucocoRuntimeExecutor>(config)),
ChainIdentity::Pendulum => runner
.sync_run(|config| cmd.run::<Block, PendulumRuntimeExecutor>(config)),
ChainIdentity::Development => runner.sync_run(|config| {
cmd.run::<Block, DevelopmentRuntimeExecutor>(config)
}),
}
} else {
Err("Benchmarking wasn't enabled when building the node. \
Expand Down Expand Up @@ -398,9 +374,6 @@ pub fn run() -> Result<()> {
ChainIdentity::Pendulum => runner.async_run(|config| {
Ok((cmd.run::<Block, PendulumRuntimeExecutor>(config), task_manager))
}),
ChainIdentity::Development => runner.async_run(|config| {
Ok((cmd.run::<Block, DevelopmentRuntimeExecutor>(config), task_manager))
}),
}
} else {
Err("Try-runtime must be enabled by `--features try-runtime`.".into())
Expand Down Expand Up @@ -499,17 +472,6 @@ pub fn run() -> Result<()> {
.map(|r| r.0)
.map_err(Into::into)
},

ChainIdentity::Development => crate::service::start_parachain_node_development(
config,
polkadot_config,
collator_options,
id,
hwbench,
)
.await
.map(|r| r.0)
.map_err(Into::into),
}
})
},
Expand Down
16 changes: 1 addition & 15 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use module_vault_registry_rpc::{VaultRegistry, VaultRegistryApiServer};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use substrate_frame_rpc_system::{System, SystemApiServer};

use crate::service::{AmplitudeClient, DevelopmentClient, FoucocoClient, PendulumClient};
use crate::service::{AmplitudeClient, FoucocoClient, PendulumClient};

/// A type representing all RPC extensions.
type RpcExtension = jsonrpsee::RpcModule<()>;
Expand Down Expand Up @@ -63,20 +63,6 @@ where
}

/// Instantiate all RPC extensions.
pub fn create_full_development<P>(
deps: FullDeps<DevelopmentClient, P>,
) -> Result<RpcExtension, Box<dyn std::error::Error + Send + Sync>>
where
P: TransactionPool + Sync + Send + 'static,
{
let mut module = RpcExtension::new(());
let FullDeps { client, pool, deny_unsafe } = deps;

module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
module.merge(TransactionPayment::new(client).into_rpc())?;
Ok(module)
}

pub fn create_full_amplitude<P>(deps: FullDeps<AmplitudeClient, P>) -> ResultRpcExtension
where
P: TransactionPool + Sync + Send + 'static,
Expand Down
Loading
Loading