Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

CLI: refactoring: remove Options from sc_service::Configuration's fields #5271

Merged
merged 258 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
258 commits
Select commit Hold shift + click to select a range
32cf27d
WIP
cecton Mar 13, 2020
b455e22
Rename IntoConfiguration to CliConfiguration
cecton Mar 13, 2020
71ccb0f
Renamed into_configuration to create_configuration
cecton Mar 13, 2020
5c723ea
WIP
cecton Mar 13, 2020
94ac935
WIP
cecton Mar 13, 2020
ff7b3ff
Move keystore params to its own module
cecton Mar 13, 2020
88c3171
Use in-memory keystore even for build-spec
cecton Mar 13, 2020
5f3ec11
Enforce proper value for node name
cecton Mar 13, 2020
41a7e80
dev_key_seed
cecton Mar 13, 2020
541a6f2
Telemetry endpoints
cecton Mar 13, 2020
b055b38
rustfmt
cecton Mar 13, 2020
fe59624
Converted all RunCmd
cecton Mar 13, 2020
07e9bb5
rustfmt
cecton Mar 13, 2020
5794bb4
Added export-blocks
cecton Mar 13, 2020
1bcc01d
Missed something
cecton Mar 13, 2020
0e24aab
Removed config_path in NetworkConfiguration (not used)
cecton Mar 16, 2020
01e37fa
Fixed warnings
cecton Mar 16, 2020
2b973ba
public_addresses is used but never set, keeping it
cecton Mar 16, 2020
f22007c
Merge Configuration.node and NetworkConfiguration.node_name
cecton Mar 16, 2020
a5acb71
Added: import-blocks
cecton Mar 16, 2020
c2ac3d3
Adding a proc_macro to help impl SubstrateCli
cecton Mar 16, 2020
7b2a46f
WIP
cecton Mar 17, 2020
5430e1a
WIP
cecton Mar 17, 2020
2405569
WIP
cecton Mar 17, 2020
7c11cde
Re-export spec_factory from sc_cli
cecton Mar 17, 2020
ae65701
Re-added all the commands
cecton Mar 17, 2020
0e58648
Refactored node_key_params
cecton Mar 17, 2020
ed60ce7
Fixed previous refucktoring
cecton Mar 17, 2020
8a106a5
Clean-up and removed full_version()
cecton Mar 17, 2020
94f1d50
Renamed get_is_dev to not confuse with Configuration field
cecton Mar 17, 2020
38d64a5
Fixed sc-cli-derive example
cecton Mar 18, 2020
983bd5d
Fixing tests
cecton Mar 18, 2020
9875eeb
Fixing tests and removing some (will re-add later)
cecton Mar 18, 2020
505296e
Fixing more tests
cecton Mar 18, 2020
052de1a
Removes the need of type parameter
cecton Mar 18, 2020
defeda3
Converting bin/node and simplifying API
cecton Mar 18, 2020
349ab93
Converting more
cecton Mar 18, 2020
957b3c5
Converting last command
cecton Mar 18, 2020
9fdffdb
WIP
cecton Mar 18, 2020
c755a4a
Fixing tests and added default for WasmExecutionMethod
cecton Mar 18, 2020
09b6450
Fixing stuff
cecton Mar 18, 2020
98545b8
Fixed something I broke oops
cecton Mar 18, 2020
72981fc
Update Cargo.lock
cecton Mar 18, 2020
e18c782
Moving things around
cecton Mar 18, 2020
3f071cf
Convert everything to Result
cecton Mar 18, 2020
da453d1
Added new macros to simplify the impl of CliConfiguration
cecton Mar 19, 2020
9c516dd
Added a macro to generate CliConfiguration automatically for subcommands
cecton Mar 20, 2020
d41a269
Revert... too many macros (this one is not really useful)
cecton Mar 20, 2020
c8b00a6
Renamed is_dev to get_is_dev
cecton Mar 20, 2020
547ed24
Fixed name roles (this is plural, not singular)
cecton Mar 20, 2020
e1d73d5
Clean-up
cecton Mar 20, 2020
08294e6
Re-export NodeKeyConfig and TelemetryEndpoints from sc_service
cecton Mar 20, 2020
fcf9882
Improve styling/formatting
cecton Mar 20, 2020
b950f73
Added copyrights
cecton Mar 20, 2020
bd72413
Added doc and fixed warnings
cecton Mar 20, 2020
a94fb8f
Added myself to code owners
cecton Mar 20, 2020
e6464c0
Yes it is needed according to the history
cecton Mar 20, 2020
e55292e
Revert formatting
cecton Mar 20, 2020
3b3cbde
Update from parent 'origin/master' (no conflict)
cecton Mar 20, 2020
aaf4b48
Update from parent 'origin/master' (conflicts)
cecton Mar 20, 2020
39f60e0
Update from parent 'origin/master' (conflicts)
cecton Mar 20, 2020
c71fa1d
Update from parent 'origin/master' (no conflict)
cecton Mar 20, 2020
5db8b05
Update from parent 'origin/master' (conflicts)
cecton Mar 20, 2020
bfe8a75
Update from parent 'origin/master' (no conflict)
cecton Mar 20, 2020
924ca71
Update from parent 'origin/master' (conflicts)
cecton Mar 20, 2020
1b456c1
Update from parent 'origin/master' (no conflict)
cecton Mar 20, 2020
679c950
Update from parent 'origin/master' (conflicts)
cecton Mar 20, 2020
a201a5a
Update from parent 'origin/master' (no conflict)
cecton Mar 20, 2020
f60a930
Update from parent 'origin/master' (conflicts)
cecton Mar 20, 2020
f6154db
Update from parent 'origin/master' (no conflict)
cecton Mar 20, 2020
42e0068
Update from parent 'origin/master' (conflicts)
cecton Mar 20, 2020
005a152
Update from parent 'origin/master' (conflicts)
cecton Mar 20, 2020
6604f06
Update from parent 'origin/master' (no conflict)
cecton Mar 20, 2020
2c3c536
Update from parent 'origin/master' (conflicts)
cecton Mar 20, 2020
6e9914e
Update from parent 'origin/master' (no conflict)
cecton Mar 20, 2020
925c8ce
Update from parent 'origin/master' (conflicts)
cecton Mar 20, 2020
d1f9754
Update from parent 'origin/master' (no conflict)
cecton Mar 20, 2020
7925233
Update from parent 'origin/master' (conflicts)
cecton Mar 20, 2020
78b373b
Update from parent 'origin/master' (no conflict)
cecton Mar 20, 2020
e95097b
Update from parent 'origin/master' (conflicts)
cecton Mar 20, 2020
66fd4bc
Fixing conflict
cecton Mar 20, 2020
7852dd7
Update from parent 'origin/master' (conflicts)
cecton Mar 20, 2020
50613ce
Update from parent 'origin/master' (no conflict)
cecton Mar 20, 2020
86e5d89
Update from parent 'origin/master' (conflicts)
cecton Mar 20, 2020
c3ad5d4
Update from parent 'origin/master' (no conflict)
cecton Mar 20, 2020
8244a74
Update from parent 'origin/master' (conflicts)
cecton Mar 20, 2020
7efc74a
Update from parent 'origin/master' (no conflict)
cecton Mar 20, 2020
153f156
Update from parent 'origin/master' (conflicts)
cecton Mar 23, 2020
c527778
Updated build.rs
cecton Mar 23, 2020
d08a9c9
Update from parent 'origin/master' (no conflict)
cecton Mar 23, 2020
240b7ac
Update from parent 'origin/master' (conflicts)
cecton Mar 23, 2020
67aa412
Update from parent 'origin/master' (no conflict)
cecton Mar 23, 2020
4123a66
Update from parent 'origin/master' (conflicts)
cecton Mar 23, 2020
4b1070c
Update from parent 'origin/master' (no conflict)
cecton Mar 23, 2020
93bbb53
Update from parent 'origin/master' (conflicts)
cecton Mar 23, 2020
113c6e2
Update from parent 'origin/master' (no conflict)
cecton Mar 23, 2020
58e0c7c
Update from parent 'origin/master' (conflicts)
cecton Mar 23, 2020
bbc7d54
Update from parent 'origin/master' (no conflict)
cecton Mar 23, 2020
5fbab29
Update from parent 'origin/master' (conflicts)
cecton Mar 23, 2020
f9a9145
Update from parent 'origin/master' (no conflict)
cecton Mar 23, 2020
1131b3a
Update from parent 'origin/master' (conflicts)
cecton Mar 23, 2020
dd1b4cd
Update from parent 'origin/master' (no conflict)
cecton Mar 23, 2020
feb4d76
Update from parent 'origin/master' (conflicts)
cecton Mar 23, 2020
bd87787
Update from parent 'origin/master' (no conflict)
cecton Mar 23, 2020
9b39164
Update from parent 'origin/master' (conflicts)
cecton Mar 23, 2020
0016aa1
Update from parent 'origin/master' (no conflict)
cecton Mar 23, 2020
a423bbb
Update from parent 'origin/master' (conflicts)
cecton Mar 23, 2020
71cbf2e
Update from parent 'origin/master' (no conflict)
cecton Mar 23, 2020
97f281e
Cargo.lock
cecton Mar 23, 2020
07eb393
Clean-up
cecton Mar 23, 2020
1c88217
Update client/cli-derive/Cargo.toml
cecton Mar 23, 2020
c0ef8cb
Fail if using proc_macro and build.rs is not set properly
cecton Mar 23, 2020
85892f6
Dropped all get_ in front of methods
cecton Mar 23, 2020
7aa8040
Update from parent 'origin/master' (no conflict)
cecton Mar 23, 2020
dc7703c
Update from parent 'origin/master' (conflicts)
cecton Mar 23, 2020
af11693
Clean-up
cecton Mar 23, 2020
89b519c
Fixing proc macro missing env var
cecton Mar 23, 2020
65349dd
Get the configuration inside the Runtime (needed for polkadot)
cecton Mar 24, 2020
6331d26
Clean-up
cecton Mar 24, 2020
ff2e47f
Get is_dev from argument like the others
cecton Mar 24, 2020
3e03f69
Get chain ID instead of chain spec from shared params
cecton Mar 24, 2020
3c68411
&self is passed to spec_factory/load_spec
cecton Mar 25, 2020
86a7adc
Wrong text
cecton Mar 25, 2020
a62448b
Fix example
cecton Mar 25, 2020
ef5a2fd
Officialize macro and made a cool doc
cecton Mar 25, 2020
ad40ed7
Renamed spec_factory to load_spec (substrate_cli_configuration)
cecton Mar 25, 2020
b7b7e1a
Removed not so useful ChainSpec
cecton Mar 25, 2020
6599e13
Renamed SubstrateCLI to SubstrateCli
cecton Mar 25, 2020
f9102a2
Added changelog for impl_version being full now
cecton Mar 25, 2020
4ddbcd1
Renamed Runtime to Runner
cecton Mar 25, 2020
14c22ee
Update from parent 'origin/master' (no conflict)
cecton Mar 25, 2020
575343c
Update from parent 'origin/master' (conflicts)
cecton Mar 25, 2020
0e23a14
Update changelog to show example
cecton Mar 25, 2020
d32defd
Removed option on database cache size
cecton Mar 26, 2020
b4580b0
WIP
cecton Mar 26, 2020
1303520
Fix on removal of option
cecton Mar 26, 2020
ffeeea7
typo
cecton Mar 26, 2020
59208c7
Clean-up imports
cecton Mar 26, 2020
2fc46d7
Added info in Cargo.toml
cecton Mar 26, 2020
fb3b7c9
typo
cecton Mar 26, 2020
cc866bb
remarks
cecton Mar 26, 2020
7241a23
Moved function for build.rs to substrate-build-script-utils
cecton Mar 26, 2020
38db0bf
Fixed example & test of cli-derive
cecton Mar 26, 2020
61ef62f
Moved function for build.rs to substrate-build-script-utils
cecton Mar 26, 2020
4f7e1bc
Renamed substrate_cli_configuration to substrate_cli oops
cecton Mar 26, 2020
0598aa3
Added documentation and wrapper macro
cecton Mar 26, 2020
de25e87
Removed option on database cache size
cecton Mar 26, 2020
0aebd52
Removed option on database cache size
cecton Mar 26, 2020
2bd04e8
Clean-up
cecton Mar 26, 2020
30353d1
Reduce risk of errors due to typos
cecton Mar 26, 2020
2105c0c
Removed option on database cache size
cecton Mar 26, 2020
0ae2794
Added NOTE as suggested
cecton Mar 26, 2020
78b5243
Added doc as suggested
cecton Mar 26, 2020
e14fbab
Fixed test
cecton Mar 26, 2020
a84557e
typo
cecton Mar 26, 2020
6e7882c
Update from parent 'origin/master' (no conflict)
cecton Mar 26, 2020
ae303e4
Update from parent 'origin/master' (conflicts)
cecton Mar 26, 2020
8a03f2e
Update from parent 'origin/master' (no conflict)
cecton Mar 26, 2020
66539c7
renamed runtime to runner
cecton Mar 26, 2020
2ffad91
Fixed weird argument
cecton Mar 27, 2020
d4ebc23
More commas
cecton Mar 27, 2020
10db8cc
Moved client/cli-derive to client/cli/derive
cecton Mar 27, 2020
730dc61
Update from parent 'origin/master' (conflicts)
cecton Mar 27, 2020
3db9864
Update from parent 'origin/master' (no conflict)
cecton Mar 27, 2020
23f7d4b
Update from parent 'origin/master' (no conflict)
cecton Mar 29, 2020
9b35ad7
Update from parent 'origin/master' (conflicts)
cecton Mar 29, 2020
ceaab33
Added 7 tests for the macros
cecton Mar 30, 2020
7640777
Update from parent 'origin/master' (conflicts)
cecton Mar 30, 2020
02e6888
Improve error message
cecton Mar 30, 2020
efeff6a
Upgrade assert_cmd
cecton Mar 30, 2020
1db040d
Update from parent 'origin/master' (no conflict)
cecton Mar 31, 2020
36dfd43
Update from parent 'origin/master' (conflicts)
cecton Mar 31, 2020
e541885
Fixing missing stuff
cecton Mar 31, 2020
643f51a
Fixed unused import
cecton Mar 31, 2020
b34e607
Update from parent 'origin/master' (no conflict)
cecton Mar 31, 2020
834f041
Update from parent 'origin/master' (conflicts)
cecton Mar 31, 2020
f8f1cdb
Improve SubstrateCli doc
cecton Mar 31, 2020
099f6b3
Applied suggestions
cecton Mar 31, 2020
8956dca
Fix and clean-up imports
cecton Apr 1, 2020
d99c601
Update from parent 'origin/master' (no conflict)
cecton Apr 1, 2020
5744513
Update from parent 'origin/master' (conflicts)
cecton Apr 2, 2020
bf706c6
Update from parent 'origin/master' (no conflict)
cecton Apr 2, 2020
1e71e46
Update from parent 'origin/master' (conflicts)
cecton Apr 2, 2020
ec13b54
Update from parent 'origin/master' (no conflict)
cecton Apr 2, 2020
d45601a
Update from parent 'origin/master' (conflicts)
cecton Apr 2, 2020
71216f4
Update from parent 'origin/master' (no conflict)
cecton Apr 2, 2020
743ff72
Started replacing macros WIP
cecton Apr 2, 2020
e553696
WIP
cecton Apr 2, 2020
c559485
WIP
cecton Apr 2, 2020
deec407
WIP
cecton Apr 3, 2020
02d3b54
Started removing substrate_cli
cecton Apr 3, 2020
6db9ff4
WIP
cecton Apr 3, 2020
da487d1
WIP
cecton Apr 3, 2020
a7a57c1
WIP
cecton Apr 3, 2020
b6e9a91
fixed bug introduced while refactoring
cecton Apr 3, 2020
26e4d4a
Update from parent 'origin/master' (no conflict)
cecton Apr 3, 2020
2ad3b76
Update from parent 'origin/master' (conflicts)
cecton Apr 3, 2020
db7c9ca
Update from parent 'origin/master' (conflicts)
cecton Apr 3, 2020
41295e6
Update from parent 'origin/master' (no conflict)
cecton Apr 3, 2020
53e8ec2
Renamed NetworkConfigurationParams to NetworkParams for consistency sake
cecton Apr 3, 2020
2e72f3d
Fixed test
cecton Apr 3, 2020
93e74cf
Update client/cli/src/commands/runcmd.rs
cecton Apr 4, 2020
11d527b
Update client/cli/src/commands/runcmd.rs
cecton Apr 4, 2020
8d57c05
Update client/cli/src/commands/export_blocks_cmd.rs
cecton Apr 4, 2020
f705f42
Update client/cli/src/commands/check_block_cmd.rs
cecton Apr 4, 2020
5c30229
Update bin/node/cli/src/command.rs
cecton Apr 4, 2020
3351723
Update bin/node/cli/src/command.rs
cecton Apr 4, 2020
5906776
Update client/cli/src/commands/export_blocks_cmd.rs
cecton Apr 4, 2020
319f249
Revert "Update client/cli/src/commands/export_blocks_cmd.rs"
cecton Apr 4, 2020
489ab74
Revert "Update client/cli/src/commands/check_block_cmd.rs"
cecton Apr 4, 2020
6c3698f
Revert "Update client/cli/src/commands/export_blocks_cmd.rs"
cecton Apr 4, 2020
b675a90
Revert "Update client/cli/src/commands/runcmd.rs"
cecton Apr 4, 2020
a2f4c94
Revert "Update client/cli/src/commands/runcmd.rs"
cecton Apr 4, 2020
9ec0673
Update client/cli/src/commands/export_blocks_cmd.rs
cecton Apr 4, 2020
84e6eba
Update client/cli/src/commands/import_blocks_cmd.rs
cecton Apr 4, 2020
4546a72
Update client/cli/src/commands/purge_chain_cmd.rs
cecton Apr 4, 2020
c5f7973
Update from parent 'origin/master' (no conflict)
cecton Apr 4, 2020
2a53d03
Update from parent 'origin/master' (conflicts)
cecton Apr 4, 2020
4b6b39c
Changed ::sc_cli to $crate in the macro
cecton Apr 4, 2020
f7f8a4d
fixed tests
cecton Apr 4, 2020
b8f56b2
Update from parent 'origin/master' (no conflict)
cecton Apr 4, 2020
ca83720
Update from parent 'origin/master' (conflicts)
cecton Apr 4, 2020
c760c01
fixed conflicts
cecton Apr 6, 2020
03ac706
Update from parent 'origin/master' (no conflict)
cecton Apr 6, 2020
40367eb
Update from parent 'origin/master' (conflicts)
cecton Apr 6, 2020
24160a7
Fixing test
cecton Apr 6, 2020
f27416c
Merge commit f1d7d1d4d4f648536eefce6eefda6d0d2d1abb63 (no conflict)
cecton Apr 6, 2020
1215407
Update client/cli/src/commands/purge_chain_cmd.rs
cecton Apr 6, 2020
9ea4bf1
Update client/cli/src/params/pruning_params.rs
cecton Apr 6, 2020
d36910d
Remove comment as suggested
cecton Apr 6, 2020
925a378
Apply suggestion
cecton Apr 6, 2020
210eda0
Update client/cli/src/commands/purge_chain_cmd.rs
cecton Apr 6, 2020
7801a1e
Update client/cli/src/commands/purge_chain_cmd.rs
cecton Apr 6, 2020
1ad4b0f
Update client/cli/src/commands/purge_chain_cmd.rs
cecton Apr 6, 2020
242f1c9
Update utils/frame/benchmarking-cli/src/command.rs
cecton Apr 6, 2020
2d976c6
Update client/cli/src/runner.rs
cecton Apr 6, 2020
75d7dd7
Update client/cli/src/runner.rs
cecton Apr 6, 2020
d8e765b
Update client/cli/src/runner.rs
cecton Apr 6, 2020
0574d06
Update client/cli/src/params/pruning_params.rs
cecton Apr 6, 2020
68689b7
Update client/cli/src/params/node_key_params.rs
cecton Apr 6, 2020
8ff0472
Update client/cli/src/params/network_params.rs
cecton Apr 6, 2020
ef5af47
Update client/cli/src/lib.rs
cecton Apr 6, 2020
70d1df3
Update client/cli/src/config.rs
cecton Apr 6, 2020
aa73acf
Added doc
cecton Apr 6, 2020
3bc37fe
Fixed error introduced after applying suggestion
cecton Apr 6, 2020
387f6f4
Revert "Update client/cli/src/params/pruning_params.rs"
cecton Apr 6, 2020
993b86c
Print error
cecton Apr 6, 2020
be5960b
Apply suggestions from code review
bkchr Apr 6, 2020
526029f
Remove useless Results
cecton Apr 6, 2020
4b07043
Fixed CI failing on polkadot approval
cecton Apr 7, 2020
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
3 changes: 2 additions & 1 deletion .maintain/gitlab/check_polkadot_companion_status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ fi
curl -H "${github_header}" -sS -o companion_pr_reviews.json \
${github_api_polkadot_pull_url}/${pr_companion}/reviews

if [ "$(jq -r -e '.[].state' < companion_pr_reviews.json | uniq)" != "APPROVED" ]
if [ -n "$(jq -r -e '.[].state | select(. == "CHANGES_REQUESTED")' < companion_pr_reviews.json)" ] && \
[ -z "$(jq -r -e '.[].state | select(. == "APPROVED")' < companion_pr_reviews.json)" ]
then
boldprint "polkadot pr #${pr_companion} not APPROVED"
exit 1
Expand Down
30 changes: 11 additions & 19 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions bin/node-template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "node-template"
version = "2.0.0-alpha.5"
authors = ["Anonymous"]
description = "Substrate Node template"
edition = "2018"
license = "Unlicense"
build = "build.rs"
Expand Down Expand Up @@ -37,8 +38,7 @@ sc-basic-authorship = { path = "../../../client/basic-authorship", version = "0.
node-template-runtime = { version = "2.0.0-alpha.5", path = "../runtime" }

[build-dependencies]
vergen = "3.0.4"
build-script-utils = { version = "2.0.0-alpha.5", package = "substrate-build-script-utils", path = "../../../utils/build-script-utils" }
substrate-build-script-utils = { version = "2.0.0-alpha.5", path = "../../../utils/build-script-utils" }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
8 changes: 3 additions & 5 deletions bin/node-template/node/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use vergen::{ConstantsFlags, generate_cargo_keys};

const ERROR_MSG: &str = "Failed to generate metadata files";
use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};

fn main() {
generate_cargo_keys(ConstantsFlags::SHA_SHORT).expect(ERROR_MSG);
generate_cargo_keys();

build_script_utils::rerun_if_git_head_changed();
rerun_if_git_head_changed();
}
142 changes: 57 additions & 85 deletions bin/node-template/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ use sp_runtime::traits::{Verify, IdentifyAccount};
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;

/// The chain specification option. This is expected to come in from the CLI and
/// is little more than one of a number of alternatives which can easily be converted
/// from a string (`--chain=...`) into a `ChainSpec`.
#[derive(Clone, Debug)]
pub enum Alternative {
/// Whatever the current runtime is, with just Alice as an auth.
Development,
/// Whatever the current runtime is, with simple Alice/Bob auths.
LocalTestnet,
}

/// Helper function to 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)
Expand All @@ -42,80 +31,70 @@ pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId where
}

/// Helper function to generate an authority key for Aura
pub fn get_authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) {
pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) {
(
get_from_seed::<AuraId>(s),
get_from_seed::<GrandpaId>(s),
)
}

impl Alternative {
/// Get an actual chain config from one of the alternatives.
pub(crate) fn load(self) -> Result<ChainSpec, String> {
Ok(match self {
Alternative::Development => ChainSpec::from_genesis(
"Development",
"dev",
|| testnet_genesis(
vec![
get_authority_keys_from_seed("Alice"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
],
true,
),
vec![],
None,
None,
None,
None
),
Alternative::LocalTestnet => ChainSpec::from_genesis(
"Local Testnet",
"local_testnet",
|| testnet_genesis(
vec![
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
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"),
],
true,
),
vec![],
None,
None,
None,
None
),
})
}
pub fn development_config() -> ChainSpec {
ChainSpec::from_genesis(
"Development",
"dev",
|| testnet_genesis(
vec![
authority_keys_from_seed("Alice"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
],
true,
),
vec![],
None,
None,
None,
None,
)
}

pub(crate) fn from(s: &str) -> Option<Self> {
match s {
"dev" => Some(Alternative::Development),
"" | "local" => Some(Alternative::LocalTestnet),
_ => None,
}
}
pub fn local_testnet_config() -> ChainSpec {
ChainSpec::from_genesis(
"Local Testnet",
"local_testnet",
|| testnet_genesis(
vec![
authority_keys_from_seed("Alice"),
authority_keys_from_seed("Bob"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
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"),
],
true,
),
vec![],
None,
None,
None,
None,
)
}

fn testnet_genesis(initial_authorities: Vec<(AuraId, GrandpaId)>,
Expand All @@ -141,10 +120,3 @@ fn testnet_genesis(initial_authorities: Vec<(AuraId, GrandpaId)>,
}),
}
}

pub fn load_spec(id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
Ok(match Alternative::from(id) {
Some(spec) => Box::new(spec.load()?),
None => Box::new(ChainSpec::from_json_file(std::path::PathBuf::from(id))?),
})
}
76 changes: 52 additions & 24 deletions bin/node-template/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,64 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.

use sp_consensus_aura::sr25519::{AuthorityPair as AuraPair};
use sc_cli::VersionInfo;
use crate::service;
use crate::chain_spec;
use crate::cli::Cli;
use crate::service;
use sc_cli::SubstrateCli;
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;

/// Parse and run command line arguments
pub fn run(version: VersionInfo) -> sc_cli::Result<()> {
let opt = sc_cli::from_args::<Cli>(&version);
impl SubstrateCli for Cli {
cecton marked this conversation as resolved.
Show resolved Hide resolved
fn impl_name() -> &'static str {
"Substrate Node"
}

fn impl_version() -> &'static str {
env!("SUBSTRATE_CLI_IMPL_VERSION")
}

fn description() -> &'static str {
env!("CARGO_PKG_DESCRIPTION")
}

fn author() -> &'static str {
env!("CARGO_PKG_AUTHORS")
}

let mut config = sc_service::Configuration::from_version(&version);
fn support_url() -> &'static str {
"support.anonymous.an"
}

fn copyright_start_year() -> i32 {
2017
}

fn executable_name() -> &'static str {
env!("CARGO_PKG_NAME")
cecton marked this conversation as resolved.
Show resolved Hide resolved
}

fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
Ok(match id {
"dev" => Box::new(chain_spec::development_config()),
"" | "local" => Box::new(chain_spec::local_testnet_config()),
path => Box::new(chain_spec::ChainSpec::from_json_file(
std::path::PathBuf::from(path),
)?),
})
}
}

/// Parse and run command line arguments
pub fn run() -> sc_cli::Result<()> {
let cli = Cli::from_args();

match opt.subcommand {
match &cli.subcommand {
Some(subcommand) => {
subcommand.init(&version)?;
subcommand.update_config(&mut config, chain_spec::load_spec, &version)?;
subcommand.run(
config,
|config: _| Ok(new_full_start!(config).0),
)
},
let runner = cli.create_runner(subcommand)?;
runner.run_subcommand(subcommand, |config| Ok(new_full_start!(config).0))
}
None => {
opt.run.init(&version)?;
opt.run.update_config(&mut config, chain_spec::load_spec, &version)?;
opt.run.run(
config,
service::new_light,
service::new_full,
&version,
)
},
let runner = cli.create_runner(&cli.run)?;
runner.run_node(service::new_light, service::new_full)
}
}
}
Loading