Skip to content

Commit 8e2a4f0

Browse files
authored
Upgrade to substrate 2.0.0 (paritytech#173)
* Upgrade to substrate 2.0.0 * WIP implement Subcommand manually (see paritytech#6894 (comment)) * Add pallet-staking/std to the std feature * Sort out the subcommand impl * Sort out the module index (ty @ascjones) Sort out the RefCount type (ty @dvc94ch) Random tweaks to make test-node more similar to the vanilla node-template * obey the fmt * cleanup * more cleanup
1 parent 56bd633 commit 8e2a4f0

File tree

14 files changed

+114
-102
lines changed

14 files changed

+114
-102
lines changed

Cargo.toml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,33 @@ serde_json = "1.0.57"
3434
url = "2.1.1"
3535
codec = { package = "parity-scale-codec", version = "1.3.5", default-features = false, features = ["derive", "full"] }
3636

37-
frame-metadata = { version = "11.0.0-rc6", package = "frame-metadata" }
38-
frame-support = { version = "2.0.0-rc6", package = "frame-support" }
39-
sp-runtime = { version = "2.0.0-rc6", package = "sp-runtime" }
40-
sp-version = { version = "2.0.0-rc6", package = "sp-version" }
41-
pallet-indices = { version = "2.0.0-rc6", package = "pallet-indices" }
37+
frame-metadata = { version = "12", package = "frame-metadata" }
38+
frame-support = { version = "2.0.0", package = "frame-support" }
39+
sp-runtime = { version = "2.0.0", package = "sp-runtime" }
40+
sp-version = { version = "2.0.0", package = "sp-version" }
41+
pallet-indices = { version = "2.0.0", package = "pallet-indices" }
4242
hex = "0.4.2"
43-
sp-std = "2.0.0-rc6"
44-
application-crypto = { version = "2.0.0-rc6", package = "sp-application-crypto" }
45-
sp-finality-grandpa = "2.0.0-rc6"
46-
sp-consensus-babe = "0.8.0-rc6"
47-
pallet-im-online = "2.0.0-rc6"
48-
sp-authority-discovery = "2.0.0-rc6"
49-
pallet-staking = "2.0.0-rc6"
43+
sp-std = "2.0.0"
44+
application-crypto = { version = "2.0.0", package = "sp-application-crypto" }
45+
sp-finality-grandpa = "2.0.0"
46+
sp-consensus-babe = "0.8.0"
47+
pallet-im-online = "2.0.0"
48+
sp-authority-discovery = "2.0.0"
49+
pallet-staking = "2.0.0"
5050

51-
sp-rpc = { version = "2.0.0-rc6", package = "sp-rpc" }
52-
sp-core = { version = "2.0.0-rc6", package = "sp-core" }
53-
sc-rpc-api = { version = "0.8.0-rc6", package = "sc-rpc-api" }
54-
sp-transaction-pool = { version = "2.0.0-rc6", package = "sp-transaction-pool" }
51+
sp-rpc = { version = "2.0.0", package = "sp-rpc" }
52+
sp-core = { version = "2.0.0", package = "sp-core" }
53+
sc-rpc-api = { version = "0.8.0", package = "sc-rpc-api" }
54+
sp-transaction-pool = { version = "2.0.0", package = "sp-transaction-pool" }
5555
substrate-subxt-client = { version = "0.4.0", path = "client", optional = true }
5656
substrate-subxt-proc-macro = { version = "0.12.0", path = "proc-macro" }
5757

5858
[dev-dependencies]
59-
async-std = { version = "1.6.3", features = ["attributes"] }
59+
async-std = { version = "1.6.4", features = ["attributes"] }
6060
env_logger = "0.7.1"
61-
frame-system = { version = "2.0.0-rc6", package = "frame-system" }
62-
pallet-balances = { version = "2.0.0-rc6", package = "pallet-balances" }
63-
sp-keyring = { version = "2.0.0-rc6", package = "sp-keyring" }
61+
frame-system = { version = "2.0.0", package = "frame-system" }
62+
pallet-balances = { version = "2.0.0", package = "pallet-balances" }
63+
sp-keyring = { version = "2.0.0", package = "sp-keyring" }
6464
substrate-subxt-client = { version = "0.4.0", path = "client" }
6565
tempdir = "0.3.7"
6666
test-node = { path = "test-node" }

client/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ description = "Embed a substrate node into your subxt application."
1212
keywords = ["parity", "substrate", "blockchain"]
1313

1414
[dependencies]
15-
async-std = "1.6.3"
15+
async-std = "1.6.4"
1616
futures = { version = "0.3.5", features = ["compat"] }
1717
futures01 = { package = "futures", version = "0.1.29" }
1818
jsonrpsee = "0.1.0"
1919
log = "0.4.11"
20-
sc-network = { version = "0.8.0-rc6", default-features = false }
21-
sc-service = { version = "0.8.0-rc6", default-features = false }
20+
sc-network = { version = "0.8.0", default-features = false }
21+
sc-service = { version = "0.8.0", default-features = false }
2222
serde_json = "1.0.57"
23-
sp-keyring = "2.0.0-rc6"
23+
sp-keyring = "2.0.0"
2424
thiserror = "1.0.20"
2525

2626
[dev-dependencies]
27-
async-std = { version = "1.6.3", features = ["attributes"] }
27+
async-std = { version = "1.6.4", features = ["attributes"] }
2828
env_logger = "0.7.1"
2929
substrate-subxt = { path = ".." }
3030
tempdir = "0.3.7"

proc-macro/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ syn = "1.0.38"
2424
synstructure = "0.12.4"
2525

2626
[dev-dependencies]
27-
async-std = { version = "1.6.3", features = ["attributes"] }
28-
codec = { package = "parity-scale-codec", version = "1.3.4", features = ["derive"] }
27+
async-std = { version = "1.6.4", features = ["attributes"] }
28+
codec = { package = "parity-scale-codec", version = "1.3.5", features = ["derive"] }
2929
env_logger = "0.7.1"
3030
pretty_assertions = "0.6.1"
31-
sp-keyring = "2.0.0-rc6"
31+
sp-keyring = "2.0.0"
3232
substrate-subxt = { path = ".." }
3333
trybuild = "1.0.32"
3434

src/frame/balances.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ mod tests {
146146
let event = client
147147
.transfer_and_watch(&alice, &bob.account_id(), 10_000)
148148
.await
149-
.unwrap()
149+
.expect("sending an xt works")
150150
.transfer()
151151
.unwrap()
152152
.unwrap();

src/frame/contracts.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ pub struct InstantiatedEvent<T: Contracts> {
116116
}
117117

118118
#[cfg(test)]
119+
#[cfg(feature = "integration-tests")]
119120
mod tests {
120121
use sp_keyring::AccountKeyring;
121122

src/frame/staking.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub struct ErasRewardPointsStore<T: Staking> {
5757
#[derive(Clone, Encode, Decode, Debug, Call)]
5858
pub struct SetPayeeCall<T: Staking> {
5959
/// The payee
60-
pub payee: RewardDestination,
60+
pub payee: RewardDestination<T::AccountId>,
6161
/// Marker for the runtime
6262
pub _runtime: PhantomData<T>,
6363
}
@@ -99,7 +99,7 @@ pub struct LedgerStore<T: Staking> {
9999
/// Where the reward payment should be made. Keyed by stash.
100100
#[derive(Encode, Copy, Clone, Debug, Hash, PartialEq, Eq, Ord, PartialOrd, Store)]
101101
pub struct PayeeStore<T: Staking> {
102-
#[store(returns = RewardDestination)]
102+
#[store(returns = RewardDestination<T::AccountId>)]
103103
/// Tٗhe stash account
104104
pub stash: T::AccountId,
105105
}

src/frame/system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub trait System {
118118
}
119119

120120
/// Type used to encode the number of references an account has.
121-
pub type RefCount = u8;
121+
pub type RefCount = u32;
122122

123123
/// Information of an account.
124124
#[derive(Clone, Debug, Eq, PartialEq, Default, Decode, Encode)]

src/metadata.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ impl Metadata {
163163

164164
#[derive(Clone, Debug)]
165165
pub struct ModuleMetadata {
166+
index: u8,
166167
name: String,
167168
storage: HashMap<String, StorageMetadata>,
168169
// constants
@@ -482,7 +483,7 @@ impl TryFrom<RuntimeMetadataPrefixed> for Metadata {
482483
return Err(ConversionError::InvalidPrefix.into())
483484
}
484485
let meta = match metadata.1 {
485-
RuntimeMetadata::V11(meta) => meta,
486+
RuntimeMetadata::V12(meta) => meta,
486487
_ => return Err(ConversionError::InvalidVersion.into()),
487488
};
488489
let mut modules = HashMap::new();
@@ -509,6 +510,7 @@ impl TryFrom<RuntimeMetadataPrefixed> for Metadata {
509510
modules.insert(
510511
module_name.clone(),
511512
ModuleMetadata {
513+
index: module.index,
512514
name: module_name.clone(),
513515
storage: storage_map,
514516
},
@@ -523,7 +525,7 @@ impl TryFrom<RuntimeMetadataPrefixed> for Metadata {
523525
modules_with_calls.insert(
524526
module_name.clone(),
525527
ModuleWithCalls {
526-
index: modules_with_calls.len() as u8,
528+
index: module.index,
527529
calls: call_map,
528530
},
529531
);
@@ -536,7 +538,7 @@ impl TryFrom<RuntimeMetadataPrefixed> for Metadata {
536538
modules_with_events.insert(
537539
module_name.clone(),
538540
ModuleWithEvents {
539-
index: modules_with_events.len() as u8,
541+
index: module.index,
540542
name: module_name.clone(),
541543
events: event_map,
542544
},
@@ -549,7 +551,7 @@ impl TryFrom<RuntimeMetadataPrefixed> for Metadata {
549551
modules_with_errors.insert(
550552
module_name.clone(),
551553
ModuleWithErrors {
552-
index: modules_with_errors.len() as u8,
554+
index: module.index,
553555
name: module_name.clone(),
554556
errors: error_map,
555557
},

test-node/Cargo.toml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,28 @@ targets = ["x86_64-unknown-linux-gnu"]
1515
[dependencies]
1616
futures = "0.3.5"
1717
log = "0.4.11"
18-
structopt = "0.3.16"
18+
structopt = "0.3.17"
1919
parking_lot = "0.11.0"
2020

21-
sc-cli = { version = "0.8.0-rc6", features = ["wasmtime"] }
22-
sp-core = "2.0.0-rc6"
23-
sc-executor = { version = "0.8.0-rc6", features = ["wasmtime"] }
24-
sc-service = { version = "0.8.0-rc6", features = ["wasmtime"] }
25-
sp-inherents = "2.0.0-rc6"
26-
sc-transaction-pool = "2.0.0-rc6"
27-
sp-transaction-pool = "2.0.0-rc6"
28-
sc-network = "0.8.0-rc6"
29-
sc-consensus-aura = "0.8.0-rc6"
30-
sp-consensus-aura = "0.8.0-rc6"
31-
sp-consensus = "0.8.0-rc6"
32-
sc-consensus = "0.8.0-rc6"
33-
sc-finality-grandpa = "0.8.0-rc6"
34-
sp-finality-grandpa = "2.0.0-rc6"
35-
sc-client-api = "2.0.0-rc6"
36-
sp-runtime = "2.0.0-rc6"
37-
sc-basic-authorship = "0.8.0-rc6"
21+
sc-cli = { version = "0.8.0", features = ["wasmtime"] }
22+
sp-core = "2.0.0"
23+
sc-executor = { version = "0.8.0", features = ["wasmtime"] }
24+
sc-service = { version = "0.8.0", features = ["wasmtime"] }
25+
sp-inherents = "2.0.0"
26+
sc-transaction-pool = "2.0.0"
27+
sp-transaction-pool = "2.0.0"
28+
sc-network = "0.8.0"
29+
sc-consensus-aura = "0.8.0"
30+
sp-consensus-aura = "0.8.0"
31+
sp-consensus = "0.8.0"
32+
sc-consensus = "0.8.0"
33+
sc-finality-grandpa = "0.8.0"
34+
sp-finality-grandpa = "2.0.0"
35+
sc-client-api = "2.0.0"
36+
sp-runtime = "2.0.0"
37+
sc-basic-authorship = "0.8.0"
3838

3939
test-node-runtime = { path = "runtime" }
4040

4141
[build-dependencies]
42-
substrate-build-script-utils = "2.0.0-rc6"
42+
substrate-build-script-utils = "2.0.0"

test-node/runtime/Cargo.toml

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,32 @@ repository = "https://github.com/paritytech/substrate/"
1111
targets = ["x86_64-unknown-linux-gnu"]
1212

1313
[dependencies]
14-
codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive"] }
14+
codec = { package = "parity-scale-codec", version = "1.3.5", default-features = false, features = ["derive"] }
1515

16-
frame-executive = { version = "2.0.0-rc6", default-features = false }
17-
frame-support = { version = "2.0.0-rc6", default-features = false }
18-
frame-system = { version = "2.0.0-rc6", default-features = false }
19-
pallet-aura = { version = "2.0.0-rc6", default-features = false }
20-
pallet-balances = { version = "2.0.0-rc6", default-features = false }
21-
pallet-grandpa = { version = "2.0.0-rc6", default-features = false }
22-
pallet-randomness-collective-flip = { version = "2.0.0-rc6", default-features = false }
23-
pallet-staking = { version = "2.0.0-rc6", default-features = false }
24-
pallet-sudo = { version = "2.0.0-rc6", default-features = false }
25-
pallet-timestamp = { version = "2.0.0-rc6", default-features = false }
26-
pallet-transaction-payment = { version = "2.0.0-rc6", default-features = false }
27-
serde = { version = "1.0.115", optional = true, features = ["derive"] }
28-
sp-api = { version = "2.0.0-rc6", default-features = false }
29-
sp-block-builder = { version = "2.0.0-rc6", default-features = false }
30-
sp-consensus-aura = { version = "0.8.0-rc6", default-features = false }
31-
sp-core = { version = "2.0.0-rc6", default-features = false }
32-
sp-inherents = { version = "2.0.0-rc6", default-features = false }
33-
sp-io = { version = "2.0.0-rc6", default-features = false }
34-
sp-offchain = { version = "2.0.0-rc6", default-features = false }
35-
sp-runtime = { version = "2.0.0-rc6", default-features = false }
36-
sp-session = { version = "2.0.0-rc6", default-features = false }
37-
sp-std = { version = "2.0.0-rc6", default-features = false }
38-
sp-transaction-pool = { version = "2.0.0-rc6", default-features = false }
39-
sp-version = { version = "2.0.0-rc6", default-features = false }
16+
frame-executive = { version = "2.0.0", default-features = false }
17+
frame-support = { version = "2.0.0", default-features = false }
18+
frame-system = { version = "2.0.0", default-features = false }
19+
pallet-aura = { version = "2.0.0", default-features = false }
20+
pallet-balances = { version = "2.0.0", default-features = false }
21+
pallet-grandpa = { version = "2.0.0", default-features = false }
22+
pallet-randomness-collective-flip = { version = "2.0.0", default-features = false }
23+
pallet-staking = { version = "2.0.0", default-features = false }
24+
pallet-sudo = { version = "2.0.0", default-features = false }
25+
pallet-timestamp = { version = "2.0.0", default-features = false }
26+
pallet-transaction-payment = { version = "2.0.0", default-features = false }
27+
serde = { version = "1.0.116", optional = true, features = ["derive"] }
28+
sp-api = { version = "2.0.0", default-features = false }
29+
sp-block-builder = { version = "2.0.0", default-features = false }
30+
sp-consensus-aura = { version = "0.8.0", default-features = false }
31+
sp-core = { version = "2.0.0", default-features = false }
32+
sp-inherents = { version = "2.0.0", default-features = false }
33+
sp-io = { version = "2.0.0", default-features = false }
34+
sp-offchain = { version = "2.0.0", default-features = false }
35+
sp-runtime = { version = "2.0.0", default-features = false }
36+
sp-session = { version = "2.0.0", default-features = false }
37+
sp-std = { version = "2.0.0", default-features = false }
38+
sp-transaction-pool = { version = "2.0.0", default-features = false }
39+
sp-version = { version = "2.0.0", default-features = false }
4040

4141
[build-dependencies]
4242
substrate-wasm-builder-runner = "1.0.6"
@@ -52,6 +52,7 @@ std = [
5252
"pallet-balances/std",
5353
"pallet-grandpa/std",
5454
"pallet-randomness-collective-flip/std",
55+
"pallet-staking/std",
5556
"pallet-sudo/std",
5657
"pallet-timestamp/std",
5758
"pallet-transaction-payment/std",

test-node/runtime/src/lib.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,16 @@ pub fn native_version() -> NativeVersion {
169169
}
170170
}
171171

172+
const AVERAGE_ON_INITIALIZE_WEIGHT: Perbill = Perbill::from_percent(10);
172173
parameter_types! {
173174
pub const BlockHashCount: BlockNumber = 2400;
174175
/// We allow for 2 seconds of compute with a 6 second average block time.
175176
pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;
176177
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
177178
/// Assume 10% of weight for average on_initialize calls.
178-
pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()
179-
.saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();
179+
pub MaximumExtrinsicWeight: Weight =
180+
AvailableBlockRatio::get().saturating_sub(AVERAGE_ON_INITIALIZE_WEIGHT)
181+
* MaximumBlockWeight::get();
180182
pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
181183
pub const Version: RuntimeVersion = VERSION;
182184
}
@@ -226,10 +228,6 @@ impl frame_system::Trait for Runtime {
226228
type AvailableBlockRatio = AvailableBlockRatio;
227229
/// Version of the runtime.
228230
type Version = Version;
229-
/// Converts a module to the index of the module in `construct_runtime!`.
230-
///
231-
/// This type is being generated by `construct_runtime!`.
232-
type ModuleToIndex = ModuleToIndex;
233231
/// What to do if a new account is created.
234232
type OnNewAccount = ();
235233
/// What to do if an account is fully reaped from the system.
@@ -238,6 +236,8 @@ impl frame_system::Trait for Runtime {
238236
type AccountData = pallet_balances::AccountData<Balance>;
239237
/// Weight information for the extrinsics of this pallet.
240238
type SystemWeightInfo = ();
239+
/// Provides information about the pallet setup in the runtime.
240+
type PalletInfo = PalletInfo;
241241
}
242242

243243
impl pallet_aura::Trait for Runtime {
@@ -259,6 +259,7 @@ impl pallet_grandpa::Trait for Runtime {
259259
)>>::IdentificationTuple;
260260

261261
type HandleEquivocation = ();
262+
type WeightInfo = ();
262263
}
263264

264265
parameter_types! {
@@ -286,6 +287,7 @@ impl pallet_balances::Trait for Runtime {
286287
type ExistentialDeposit = ExistentialDeposit;
287288
type AccountStore = System;
288289
type WeightInfo = ();
290+
type MaxLocks = ();
289291
}
290292

291293
parameter_types! {

test-node/src/chain_spec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub fn development_config() -> Result<ChainSpec, String> {
101101
// Properties
102102
None,
103103
// Extensions
104-
None,
104+
Default::default(),
105105
))
106106
}
107107

test-node/src/cli.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,20 @@
1515
// along with substrate-subxt. If not, see <http://www.gnu.org/licenses/>.
1616

1717
use sc_cli::{
18+
BuildSpecCmd,
19+
PurgeChainCmd,
1820
RunCmd,
19-
Subcommand,
2021
};
2122
use structopt::StructOpt;
2223

24+
#[derive(Debug, StructOpt)]
25+
pub enum Subcommand {
26+
/// Build a spec.json file, outputs to stdout.
27+
BuildSpec(BuildSpecCmd),
28+
/// Remove the whole chain data.
29+
PurgeChain(PurgeChainCmd),
30+
}
31+
2332
#[derive(Debug, StructOpt)]
2433
pub struct Cli {
2534
#[structopt(subcommand)]

0 commit comments

Comments
 (0)