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

Merge Subkey into sc-cli #4954

Merged
111 commits merged into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
73b899b
draft
seunlanlege Feb 17, 2020
3c6d4fd
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege Mar 4, 2020
742df00
revert
seunlanlege Mar 4, 2020
f118c3a
WIP
seunlanlege Mar 10, 2020
0490b61
Merge branch 'seun-merge-sc-cli-and-subkey' of github.com:paritytech/…
seunlanlege Mar 10, 2020
0a1df9c
all that remains is tests
seunlanlege Mar 11, 2020
fa92dfa
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege Mar 13, 2020
386cfcf
update Cargo.lock
seunlanlege Mar 13, 2020
fccf7ba
tests WIP
seunlanlege Mar 13, 2020
26e21da
WIP refactor node-template-runtime and node-runtime
seunlanlege Mar 16, 2020
aea449b
implments sc_cli::RuntimeAdapter for node_template_runtime::Runtime
seunlanlege Mar 17, 2020
f96d007
final draft
seunlanlege Mar 17, 2020
ddbf1a8
fix update_config for subcommands
seunlanlege Mar 18, 2020
fa4feb1
proper AccountId decoding
seunlanlege Mar 18, 2020
4815f3d
test-runtime tests
seunlanlege Mar 18, 2020
f8a6728
revert
seunlanlege Mar 20, 2020
d186457
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege Mar 20, 2020
70d1dbe
move RuntimeAdapter to cli-utils
seunlanlege Mar 20, 2020
aa71995
use &'static str for TryFrom::<&'a str>::Error for Ss58AddressFormat
seunlanlege Mar 20, 2020
65eeefc
tests
seunlanlege Mar 20, 2020
1ee33bb
add frame-system to sc-cli dev-dependencies
seunlanlege Mar 20, 2020
e5336b6
add frame-system to sc-cli dev-dependencies
seunlanlege Mar 20, 2020
643ba68
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege Apr 14, 2020
cf6f0b9
fix ui test
seunlanlege Apr 15, 2020
428d7aa
merge with master
seunlanlege Apr 30, 2020
6a4d66a
wip
seunlanlege May 5, 2020
8536991
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege May 5, 2020
e23b87b
fixed inspect test
seunlanlege May 6, 2020
62e9e0d
bump impl version
seunlanlege May 6, 2020
03ca897
bump impl version, fixx spaces remove todos
seunlanlege May 6, 2020
cd4cad5
pallet-balances-cli, rustc for some reason cannot resolve pallet_bala…
seunlanlege May 7, 2020
5e351b9
wip
seunlanlege May 8, 2020
07413ef
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege May 8, 2020
de123f2
Subcommand::run takes &self
seunlanlege May 8, 2020
c1a5b31
can't believe i missed that 🤦🏾‍♂️
seunlanlege May 8, 2020
57228de
bump wasm-bindgen for some reason
seunlanlege May 8, 2020
9a49f10
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege May 11, 2020
1c84698
adds key subcommand, rename generate-node-key to generate-node-id
seunlanlege May 11, 2020
66d1494
cargo update and crossed fingers 🤞🏽
seunlanlege May 11, 2020
fa4de23
update ui test
seunlanlege May 11, 2020
000b4ad
update more ui tests
seunlanlege May 11, 2020
1c4048a
should be all good now
seunlanlege May 12, 2020
93c38bf
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege May 12, 2020
fce2b0d
revert subkey change
seunlanlege May 12, 2020
cc46757
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege May 12, 2020
f06ce66
revert subkey change
seunlanlege May 12, 2020
f279e14
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege May 15, 2020
7ac9a2e
adds frame-utilities-cli
seunlanlege May 18, 2020
ce642a2
Apply suggestions from code review
seunlanlege May 18, 2020
de582ee
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege May 18, 2020
2937b8c
removes frame from sc-cli, fix license
seunlanlege May 18, 2020
a9d25a3
my editor and ci disagrees on line width
seunlanlege May 18, 2020
f5d0e46
bump spec version
seunlanlege May 18, 2020
1a556ca
turn off default features for parity-scale-codec
seunlanlege May 18, 2020
5a0616b
enable full_crypto feature for sp-core in cli-utils
seunlanlege May 18, 2020
ec22841
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege May 18, 2020
69ab3ee
merge frame-utilities-cli with pallet-balances-cli
seunlanlege May 18, 2020
5f670a6
remove full_crypto feature from sp_core in cli-utils
seunlanlege May 19, 2020
627aa69
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege May 19, 2020
0ad4d48
bump Cargo.lock
seunlanlege May 19, 2020
7b4cd95
cli-utils -> frame-utils
seunlanlege May 21, 2020
6f12be9
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege May 21, 2020
aa8ecb9
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege May 21, 2020
a0fe47d
rename BlockNumber to GenericNumber, fix spaces
seunlanlege May 25, 2020
1ee5967
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege May 25, 2020
2573c91
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege May 25, 2020
762ed30
fix spaces
seunlanlege May 25, 2020
9130156
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege May 29, 2020
8c19813
construct additional_signed manually
seunlanlege Jun 1, 2020
b0d21d8
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege Jun 2, 2020
753f5eb
sign test
seunlanlege Jun 2, 2020
2a4374b
remove unused vars
seunlanlege Jun 2, 2020
3342d06
implement subkey with frame-utilities-cli and sc_cli
seunlanlege Jun 2, 2020
0590bbf
fix moduleid test
seunlanlege Jun 2, 2020
5ac0694
CI and clion disagree on line widths
seunlanlege Jun 2, 2020
daeed15
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege Jun 8, 2020
aa16d9c
adds associated Params type to SignedExtensionProvider
seunlanlege Jun 9, 2020
83d9487
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege Jun 11, 2020
54277a7
Apply suggestions from code review
seunlanlege Jun 11, 2020
22049d3
move some code around
seunlanlege Jun 11, 2020
c683181
removes unneccesary generic params
seunlanlege Jun 11, 2020
a1535f6
moves module_id back to frame_utilities_cli
seunlanlege Jun 15, 2020
655e53a
Apply suggestions from code review
seunlanlege Jun 15, 2020
974ef0a
remove print_ext
seunlanlege Jun 15, 2020
c78e838
Merge branch 'seun-sc-cli-subkey' of github.com:paritytech/substrate …
seunlanlege Jun 15, 2020
86f149a
remove MaybeDisplay from pallet_balances::Trait::Balance
seunlanlege Jun 15, 2020
e7f732b
a lot of stuff tbh
seunlanlege Jun 15, 2020
2be821f
adds ExtrasParamsBuilder
seunlanlege Jun 15, 2020
a7dd087
remove tests for ModuleIdCmd
seunlanlege Jun 15, 2020
51c35c4
address comments from PR
seunlanlege Jun 16, 2020
cddc46d
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege Jun 16, 2020
20d695a
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege Jun 18, 2020
e5e8b59
bump Cargo.lock
seunlanlege Jun 18, 2020
08d4f24
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege Jun 19, 2020
e7820c7
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege Jun 22, 2020
faab8db
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege Jul 14, 2020
bbb9079
manually insert key into keystore
seunlanlege Jul 14, 2020
cc7542c
remove unnecessary SharedParams
seunlanlege Jul 14, 2020
f4af111
add validation to vanity pattern, remove unused arg
seunlanlege Jul 22, 2020
2553e0e
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege Jul 22, 2020
e24b0c5
Merge remote-tracking branch 'origin/master' into seun-sc-cli-subkey
gnunicorn Aug 10, 2020
cd0f083
remove SharedParams from Sign, Vanity, Verify
seunlanlege Aug 10, 2020
153c346
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege Aug 11, 2020
4dc44e7
remove SharedParams from ModuleIdCmd, remove expect from Verify, new …
seunlanlege Aug 11, 2020
3bb63c0
remove SharedParams from InsertCmd
seunlanlege Aug 11, 2020
30b49fd
🤦🏾‍♂️
seunlanlege Aug 11, 2020
9598c0b
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege Aug 11, 2020
f145c8e
deleted prometheus.yml
seunlanlege Aug 11, 2020
94511ab
move a few things around
seunlanlege Aug 17, 2020
b342028
Merge branch 'master' of github.com:paritytech/substrate into seun-sc…
seunlanlege Aug 17, 2020
0a50728
fix vanity test
seunlanlege Aug 20, 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
1,367 changes: 857 additions & 510 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ members = [
"utils/build-script-utils",
"utils/fork-tree",
"utils/frame/benchmarking-cli",
"utils/frame/frame-utilities-cli",
"utils/frame/rpc/support",
"utils/frame/rpc/system",
"utils/wasm-builder",
Expand Down
2 changes: 1 addition & 1 deletion bin/node-template/node/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use sc_cli::{RunCmd, Subcommand};
use structopt::StructOpt;
use sc_cli::{RunCmd, Subcommand};

#[derive(Debug, StructOpt)]
pub struct Cli {
Expand Down
4 changes: 2 additions & 2 deletions bin/node-template/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ impl SubstrateCli for Cli {
pub fn run() -> sc_cli::Result<()> {
let cli = Cli::from_args();

match &cli.subcommand {
Some(subcommand) => {
match cli.subcommand {
Some(ref subcommand) => {
let runner = cli.create_runner(subcommand)?;
runner.run_subcommand(subcommand, |config| {
let PartialComponents { client, backend, task_manager, import_queue, .. }
Expand Down
2 changes: 2 additions & 0 deletions bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ structopt = { version = "0.3.8", optional = true }
node-inspect = { version = "0.8.0-rc5", optional = true, path = "../inspect" }
frame-benchmarking-cli = { version = "2.0.0-rc5", optional = true, path = "../../../utils/frame/benchmarking-cli" }
substrate-build-script-utils = { version = "2.0.0-rc5", optional = true, path = "../../../utils/build-script-utils" }
substrate-frame-cli = { version = "2.0.0-rc5", optional = true, path = "../../../utils/frame/frame-utilities-cli" }

[build-dependencies.sc-cli]
version = "0.8.0-rc5"
Expand All @@ -150,6 +151,7 @@ cli = [
"node-inspect",
"sc-cli",
"frame-benchmarking-cli",
"substrate-frame-cli",
"sc-service/db",
"structopt",
"substrate-build-script-utils",
Expand Down
14 changes: 13 additions & 1 deletion bin/node/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use sc_cli::RunCmd;
use sc_cli::{RunCmd, KeySubcommand, SignCmd, VanityCmd, VerifyCmd};
use structopt::StructOpt;

/// An overarching CLI command definition.
Expand All @@ -37,6 +37,9 @@ pub enum Subcommand {
#[structopt(flatten)]
Base(sc_cli::Subcommand),

/// Key management cli utilities
Key(KeySubcommand),

/// The custom inspect subcommmand for decoding blocks and extrinsics.
#[structopt(
name = "inspect",
Expand All @@ -47,4 +50,13 @@ pub enum Subcommand {
/// The custom benchmark subcommmand benchmarking runtime pallets.
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),

/// Verify a signature for a message, provided on STDIN, with a given (public or secret) key.
Verify(VerifyCmd),

/// Generate a seed that provides a vanity address.
Vanity(VanityCmd),

/// Sign a message, with a given (secret) key.
Sign(SignCmd),
}
4 changes: 4 additions & 0 deletions bin/node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ pub fn run() -> Result<()> {
Ok(())
}
}
Some(Subcommand::Key(cmd)) => cmd.run(),
Some(Subcommand::Sign(cmd)) => cmd.run(),
Some(Subcommand::Verify(cmd)) => cmd.run(),
Some(Subcommand::Vanity(cmd)) => cmd.run(),
Some(Subcommand::Base(subcommand)) => {
let runner = cli.create_runner(subcommand)?;
runner.run_subcommand(subcommand, |config| {
Expand Down
29 changes: 17 additions & 12 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ use impls::{CurrencyToVoteHandler, Author};
/// Constant values used within the runtime.
pub mod constants;
use constants::{time::*, currency::*};
use sp_runtime::generic::Era;

/// Weights for pallets used in the runtime.
mod weights;
Expand Down Expand Up @@ -654,16 +655,17 @@ parameter_types! {
pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2;
}


impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime where
Call: From<LocalCall>,
impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime
where
Call: From<LocalCall>,
{
fn create_transaction<C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>>(
call: Call,
public: <Signature as traits::Verify>::Signer,
account: AccountId,
nonce: Index,
) -> Option<(Call, <UncheckedExtrinsic as traits::Extrinsic>::SignaturePayload)> {
let tip = 0;
// take the biggest period possible.
let period = BlockHashCount::get()
.checked_next_power_of_two()
Expand All @@ -674,22 +676,25 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
// The `System::block_number` is initialized with `n+1`,
// so the actual block number is `n`.
.saturating_sub(1);
let tip = 0;
let extra: SignedExtra = (
let era = Era::mortal(period, current_block);
let extra = (
frame_system::CheckSpecVersion::<Runtime>::new(),
frame_system::CheckTxVersion::<Runtime>::new(),
frame_system::CheckGenesis::<Runtime>::new(),
frame_system::CheckEra::<Runtime>::from(generic::Era::mortal(period, current_block)),
frame_system::CheckEra::<Runtime>::from(era),
frame_system::CheckNonce::<Runtime>::from(nonce),
frame_system::CheckWeight::<Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
);
let raw_payload = SignedPayload::new(call, extra).map_err(|e| {
debug::warn!("Unable to create signed payload: {:?}", e);
}).ok()?;
let signature = raw_payload.using_encoded(|payload| {
C::sign(payload, public)
})?;
let raw_payload = SignedPayload::new(call, extra)
.map_err(|e| {
debug::warn!("Unable to create signed payload: {:?}", e);
})
.ok()?;
let signature = raw_payload
.using_encoded(|payload| {
C::sign(payload, public)
})?;
let address = Indices::unlookup(account);
let (call, extra, _) = raw_payload.deconstruct();
Some((call, (address, signature.into(), extra)))
Expand Down
29 changes: 8 additions & 21 deletions bin/utils/subkey/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,21 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
homepage = "https://substrate.dev"
repository = "https://github.com/paritytech/substrate/"

[[bin]]
path = "src/main.rs"
name = "subkey"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
futures = "0.1.29"
sp-core = { version = "2.0.0-rc5", path = "../../../primitives/core" }
node-runtime = { version = "2.0.0-rc5", path = "../../node/runtime" }
node-primitives = { version = "2.0.0-rc5", path = "../../node/primitives" }
sp-runtime = { version = "2.0.0-rc5", path = "../../../primitives/runtime" }
rand = "0.7.2"
clap = "2.33.0"
tiny-bip39 = "0.7"
substrate-bip39 = "0.4.1"
hex = "0.4.0"
hex-literal = "0.2.1"
codec = { package = "parity-scale-codec", version = "1.3.4" }
sc-cli = { version = "0.8.0-rc5", path = "../../../client/cli" }
substrate-frame-cli = { version = "2.0.0-rc5", path = "../../../utils/frame/frame-utilities-cli" }
structopt = "0.3.14"
frame-system = { version = "2.0.0-rc5", path = "../../../frame/system" }
pallet-balances = { version = "2.0.0-rc5", path = "../../../frame/balances" }
pallet-transaction-payment = { version = "2.0.0-rc5", path = "../../../frame/transaction-payment" }
pallet-grandpa = { version = "2.0.0-rc5", path = "../../../frame/grandpa" }
rpassword = "4.0.1"
itertools = "0.8.2"
derive_more = { version = "0.99.2" }
sc-rpc = { version = "2.0.0-rc5", path = "../../../client/rpc" }
jsonrpc-core-client = { version = "14.2.0", features = ["http"] }
hyper = "0.12.35"
libp2p = { version = "0.23.0", default-features = false }
serde_json = "1.0"
sp-core = { version = "2.0.0-rc5", path = "../../../primitives/core" }

[features]
bench = []
4 changes: 2 additions & 2 deletions bin/utils/subkey/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ OUTPUT:
`subkey` expects a message to come in on STDIN, one way to sign a message would look like this:

```bash
echo -n <msg> | subkey sign <seed,mnemonic>
echo -n <msg> | subkey sign --suri <seed,mnemonic>

OUTPUT:
a69da4a6ccbf81dbbbfad235fa12cf8528c18012b991ae89214de8d20d29c1280576ced6eb38b7406d1b7e03231df6dd4a5257546ddad13259356e1c3adfb509
Expand Down Expand Up @@ -72,7 +72,7 @@ Will output a signed and encoded `UncheckedMortalCompactExtrinsic` as hex.
=== Inspecting a module ID

```bash
subkey --network kusama moduleid "py/trsry"
subkey module-id "py/trsry" --network kusama

OUTPUT:
Public Key URI `F3opxRbN5ZbjJNU511Kj2TLuzFcDq9BGduA9TgiECafpg29` is account:
Expand Down
81 changes: 81 additions & 0 deletions bin/utils/subkey/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// This file is part of Substrate.

// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use structopt::StructOpt;
use sc_cli::{
Error, VanityCmd, SignCmd, VerifyCmd, InsertCmd,
GenerateNodeKeyCmd, GenerateCmd, InspectCmd, InspectNodeKeyCmd
};
use substrate_frame_cli::ModuleIdCmd;
use sp_core::crypto::Ss58Codec;

#[derive(Debug, StructOpt)]
#[structopt(
name = "subkey",
author = "Parity Team <admin@parity.io>",
about = "Utility for generating and restoring with Substrate keys",
)]
pub enum Subkey {
/// Generate a random node libp2p key, save it to file and print its peer ID
GenerateNodeKey(GenerateNodeKeyCmd),

/// Generate a random account
Generate(GenerateCmd),

/// Gets a public key and a SS58 address from the provided Secret URI
InspectKey(InspectCmd),

/// Print the peer ID corresponding to the node key in the given file
InspectNodeKey(InspectNodeKeyCmd),

/// Insert a key to the keystore of a node.
Insert(InsertCmd),

/// Inspect a module ID address
ModuleId(ModuleIdCmd),

/// Sign a message, with a given (secret) key.
Sign(SignCmd),

/// Generate a seed that provides a vanity address.
Vanity(VanityCmd),

/// Verify a signature for a message, provided on STDIN, with a given (public or secret) key.
Verify(VerifyCmd),
}

/// Run the subkey command, given the apropriate runtime.
pub fn run<R>() -> Result<(), Error>
where
R: frame_system::Trait,
R::AccountId: Ss58Codec
{
match Subkey::from_args() {
Subkey::GenerateNodeKey(cmd) => cmd.run()?,
Subkey::Generate(cmd) => cmd.run()?,
Subkey::InspectKey(cmd) => cmd.run()?,
Subkey::InspectNodeKey(cmd) => cmd.run()?,
Subkey::Insert(cmd) => cmd.run()?,
Subkey::ModuleId(cmd) => cmd.run::<R>()?,
Subkey::Vanity(cmd) => cmd.run()?,
Subkey::Verify(cmd) => cmd.run()?,
Subkey::Sign(cmd) => cmd.run()?,
};

Ok(())
}
Loading