Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request paritytech#500 from subspace/remove-testnet
Browse files Browse the repository at this point in the history
Remove testnet, add support for removing its data when purging chain
  • Loading branch information
nazar-pc authored May 26, 2022
2 parents 3b05374 + de1a8ca commit 934549b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 204 deletions.
114 changes: 0 additions & 114 deletions crates/subspace-node/res/chain-spec-raw-snapshot-2022-mar-09.json

This file was deleted.

12 changes: 12 additions & 0 deletions crates/subspace-node/src/bin/subspace-node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@ fn main() -> Result<(), Error> {
}
}

// Delete testnet data folder
// TODO: Remove this after next snapshot, this is a compatibility layer to make sure we
// wipe old data from disks of our users
if let Some(base_dir) = dirs::data_local_dir() {
let _ = std::fs::remove_dir_all(
base_dir
.join("subspace-node")
.join("chains")
.join("subspace_test"),
);
}

let runner = cli.create_runner(&cmd.base)?;

runner.sync_run(|primary_chain_config| {
Expand Down
88 changes: 0 additions & 88 deletions crates/subspace-node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use subspace_runtime_primitives::{AccountId, Balance, BlockNumber, SSC};

const POLKADOT_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
const SUBSPACE_TELEMETRY_URL: &str = "wss://telemetry.subspace.network/submit/";
const TESTNET_CHAIN_SPEC: &[u8] = include_bytes!("../res/chain-spec-raw-snapshot-2022-mar-09.json");
// const TESTNET_BOOTSTRAP_NODE: &str = "/dns/farm-rpc.subspace.network/tcp/30333/p2p/12D3KooWPjMZuSYj35ehced2MTJFf95upwpHKgKUrFRfHwohzJXr";

/// List of accounts which should receive token grants, amounts are specified in SSC.
Expand Down Expand Up @@ -77,93 +76,6 @@ pub struct ChainSpecExtensions {
/// The `ChainSpec` parameterized for the consensus runtime.
pub type ConsensusChainSpec = SerializableChainSpec<GenesisConfig, ChainSpecExtensions>;

pub fn testnet_config_json() -> Result<ConsensusChainSpec, String> {
ConsensusChainSpec::from_json_bytes(TESTNET_CHAIN_SPEC)
}
pub fn testnet_config_compiled() -> Result<ConsensusChainSpec, String> {
Ok(ConsensusChainSpec::from_genesis(
// Name
"Subspace testnet",
// ID
"subspace_test",
ChainType::Custom("Subspace testnet".to_string()),
|| {
let sudo_account =
AccountId::from_ss58check("5CXTmJEusve5ixyJufqHThmy4qUrrm6FyLCR7QfE4bbyMTNC")
.expect("Wrong root account address");

let mut balances = vec![(sudo_account.clone(), 1_000 * SSC)];
let vesting_schedules = TOKEN_GRANTS
.iter()
.flat_map(|&(account_address, amount)| {
let account_id = AccountId::from_ss58check(account_address)
.expect("Wrong vesting account address");
let amount: Balance = amount * SSC;

// TODO: Adjust start block to real value before mainnet launch
let start_block = 100_000_000;
let one_month_in_blocks =
u32::try_from(3600 * 24 * 30 * MILLISECS_PER_BLOCK / 1000)
.expect("One month of blocks always fits in u32; qed");

// Add balance so it can be locked
balances.push((account_id.clone(), amount));

[
// 1/4 of tokens are released after 1 year.
(
account_id.clone(),
start_block,
one_month_in_blocks * 12,
1,
amount / 4,
),
// 1/48 of tokens are released every month after that for 3 more years.
(
account_id,
start_block + one_month_in_blocks * 12,
one_month_in_blocks,
36,
amount / 48,
),
]
})
.collect::<Vec<_>>();
subspace_genesis_config(
WASM_BINARY.expect("Wasm binary must be built for testnet"),
sudo_account,
balances,
vesting_schedules,
(
get_account_id_from_seed("Alice"),
get_public_key_from_seed::<ExecutorId>("Alice"),
),
)
},
// Bootnodes
vec![
// TESTNET_BOOTSTRAP_NODE.parse().expect("Bootstrap node must be correct")
],
// Telemetry
Some(
TelemetryEndpoints::new(vec![
(POLKADOT_TELEMETRY_URL.into(), 1),
(SUBSPACE_TELEMETRY_URL.into(), 1),
])
.map_err(|error| error.to_string())?,
),
// Protocol ID
Some("subspace-substrate"),
None,
// Properties
Some(chain_spec_properties()),
// Extensions
ChainSpecExtensions {
execution_chain_spec: secondary_chain::chain_spec::local_testnet_config(),
},
))
}

pub fn gemini_config() -> Result<ConsensusChainSpec, String> {
todo!("Distribute the gemini ChainSpec once finalized")
}
Expand Down
2 changes: 0 additions & 2 deletions crates/subspace-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ impl SubstrateCli for Cli {
let mut chain_spec = match id {
"gemini-1" => chain_spec::gemini_config()?,
"gemini-1-compiled" => chain_spec::gemini_config_compiled()?,
"testnet" => chain_spec::testnet_config_json()?,
"testnet-compiled" => chain_spec::testnet_config_compiled()?,
"dev" => chain_spec::dev_config()?,
"" | "local" => chain_spec::local_config()?,
path => ConsensusChainSpec::from_json_file(std::path::PathBuf::from(path))?,
Expand Down

0 comments on commit 934549b

Please sign in to comment.