This repository has been archived by the owner on Feb 21, 2024. It is now read-only.
forked from paritytech/substrate
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request paritytech#266 from subspace/subspace-test-runtime…
…-service Introduce subspace-test-runtime and subspace-test-service
- Loading branch information
Showing
10 changed files
with
1,833 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[package] | ||
name = "subspace-test-client" | ||
version = "0.1.0" | ||
authors = ["Subspace Labs <https://subspace.network>"] | ||
edition = "2021" | ||
license = "GPL-3.0-or-later" | ||
homepage = "https://subspace.network" | ||
repository = "https://github.com/subspace/subspace" | ||
include = [ | ||
"/src", | ||
"/Cargo.toml", | ||
] | ||
|
||
[package.metadata.docs.rs] | ||
targets = ["x86_64-unknown-linux-gnu"] | ||
|
||
[dependencies] | ||
futures = "0.3.19" | ||
rand = "0.8.3" | ||
schnorrkel = "0.9.1" | ||
sc-chain-spec = { git = "https://github.com/paritytech/substrate", rev = "e6def65920d30029e42d498cb07cec5dd433b927" } | ||
sc-client-api = { git = "https://github.com/paritytech/substrate", rev = "e6def65920d30029e42d498cb07cec5dd433b927" } | ||
sc-consensus-subspace = { version = "0.1.0", path = "../../crates/sc-consensus-subspace" } | ||
sc-executor = { git = "https://github.com/paritytech/substrate", rev = "e6def65920d30029e42d498cb07cec5dd433b927", features = ["wasmtime"] } | ||
sc-service = { git = "https://github.com/paritytech/substrate", rev = "e6def65920d30029e42d498cb07cec5dd433b927", features = ["wasmtime"] } | ||
sp-api = { git = "https://github.com/paritytech/substrate", rev = "e6def65920d30029e42d498cb07cec5dd433b927" } | ||
sp-consensus-subspace = { version = "0.1.0", path = "../../crates/sp-consensus-subspace" } | ||
sp-core = { git = "https://github.com/paritytech/substrate", rev = "e6def65920d30029e42d498cb07cec5dd433b927" } | ||
sp-runtime = { git = "https://github.com/paritytech/substrate", rev = "e6def65920d30029e42d498cb07cec5dd433b927" } | ||
subspace-archiving = { path = "../../crates/subspace-archiving" } | ||
subspace-core-primitives = { path = "../../crates/subspace-core-primitives" } | ||
subspace-runtime-primitives = { path = "../../crates/subspace-runtime-primitives" } | ||
subspace-service = { path = "../../crates/subspace-service" } | ||
subspace-solving = { path = "../../crates/subspace-solving" } | ||
subspace-test-runtime = { version = "0.1.0", features = ["do-not-enforce-cost-of-storage"], path = "../subspace-test-runtime" } | ||
zeroize = "1.4.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
//! Chain specification for the test runtime. | ||
use sc_chain_spec::ChainType; | ||
use sp_core::{sr25519, Pair, Public}; | ||
use sp_runtime::traits::{IdentifyAccount, Verify}; | ||
use subspace_runtime_primitives::{AccountId, Balance, BlockNumber, Signature}; | ||
use subspace_test_runtime::{ | ||
BalancesConfig, GenesisConfig, SudoConfig, SystemConfig, VestingConfig, SSC, WASM_BINARY, | ||
}; | ||
|
||
/// The `ChainSpec` parameterized for subspace test runtime. | ||
pub type TestChainSpec = sc_service::GenericChainSpec<subspace_test_runtime::GenesisConfig>; | ||
|
||
/// Generate a crypto pair from seed. | ||
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public { | ||
TPublic::Pair::from_string(&format!("//{}", seed), None) | ||
.expect("static values are valid; qed") | ||
.public() | ||
} | ||
|
||
type AccountPublic = <Signature as Verify>::Signer; | ||
|
||
/// Generate an account ID from seed. | ||
pub fn get_account_id_from_seed(seed: &str) -> AccountId { | ||
AccountPublic::from(get_from_seed::<sr25519::Public>(seed)).into_account() | ||
} | ||
|
||
/// Local testnet config (multivalidator Alice + Bob). | ||
pub fn subspace_local_testnet_config() -> TestChainSpec { | ||
let wasm_binary = WASM_BINARY.expect("Development wasm not available"); | ||
TestChainSpec::from_genesis( | ||
"Local Testnet", | ||
"local_testnet", | ||
ChainType::Local, | ||
|| { | ||
create_genesis_config( | ||
wasm_binary, | ||
// Sudo account | ||
get_account_id_from_seed("Alice"), | ||
// Pre-funded accounts | ||
vec![ | ||
(get_account_id_from_seed("Alice"), 1_000 * SSC), | ||
(get_account_id_from_seed("Bob"), 1_000 * SSC), | ||
(get_account_id_from_seed("Charlie"), 1_000 * SSC), | ||
(get_account_id_from_seed("Dave"), 1_000 * SSC), | ||
(get_account_id_from_seed("Eve"), 1_000 * SSC), | ||
(get_account_id_from_seed("Ferdie"), 1_000 * SSC), | ||
(get_account_id_from_seed("Alice//stash"), 1_000 * SSC), | ||
(get_account_id_from_seed("Bob//stash"), 1_000 * SSC), | ||
(get_account_id_from_seed("Charlie//stash"), 1_000 * SSC), | ||
(get_account_id_from_seed("Dave//stash"), 1_000 * SSC), | ||
(get_account_id_from_seed("Eve//stash"), 1_000 * SSC), | ||
(get_account_id_from_seed("Ferdie//stash"), 1_000 * SSC), | ||
], | ||
vec![], | ||
) | ||
}, | ||
vec![], | ||
None, | ||
Some("subspace-test"), | ||
None, | ||
None, | ||
Default::default(), | ||
) | ||
} | ||
|
||
/// Configure initial storage state for FRAME modules. | ||
fn create_genesis_config( | ||
wasm_binary: &[u8], | ||
sudo_account: AccountId, | ||
balances: Vec<(AccountId, Balance)>, | ||
// who, start, period, period_count, per_period | ||
vesting: Vec<(AccountId, BlockNumber, BlockNumber, u32, Balance)>, | ||
) -> GenesisConfig { | ||
GenesisConfig { | ||
system: SystemConfig { | ||
// Add Wasm runtime to storage. | ||
code: wasm_binary.to_vec(), | ||
}, | ||
balances: BalancesConfig { balances }, | ||
transaction_payment: Default::default(), | ||
sudo: SudoConfig { | ||
// Assign network admin rights. | ||
key: Some(sudo_account), | ||
}, | ||
vesting: VestingConfig { vesting }, | ||
} | ||
} |
Oops, something went wrong.