Skip to content

Commit a27bf19

Browse files
authored
Update/substrate (paritytech#125)
* add NetworkType for polkadot.js * replace rc3 to rc4 * update XContracts to match rc4 Contracts * update transaction-payment to rc4 * update runtime and cli crate
1 parent 87a02ae commit a27bf19

42 files changed

Lines changed: 1350 additions & 1666 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 352 additions & 202 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,32 @@ edition = "2018"
66

77
[dependencies]
88
futures = "0.3.4"
9-
jsonrpc-core = "14.2.0"
109
log = "0.4.8"
1110
parking_lot = "0.10.0"
1211
structopt = "0.3.8"
1312
log4rs = { version = "0.12", features = ["rolling_file_appender", "compound_policy", "size_trigger", "fixed_window_roller"] }
1413

1514
# Substrate client
16-
sc-basic-authorship = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
17-
sc-cli = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
18-
sc-client-api = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
19-
sc-consensus = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
20-
sc-consensus-aura = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
21-
sc-executor = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
22-
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
23-
sc-network = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
24-
sc-rpc = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
25-
sc-service = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
26-
sc-transaction-pool = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
15+
sc-basic-authorship = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
16+
sc-cli = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
17+
sc-client-api = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
18+
sc-consensus = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
19+
sc-consensus-aura = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
20+
sc-executor = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
21+
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
22+
sc-network = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
23+
sc-rpc = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
24+
sc-service = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
25+
sc-transaction-pool = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
2726

2827
# Substrate primitives
29-
sp-core = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
30-
sp-consensus = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
31-
sp-consensus-aura = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
32-
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
33-
sp-inherents = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
34-
sp-runtime = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
35-
sp-transaction-pool = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
28+
sp-core = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
29+
sp-consensus = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
30+
sp-consensus-aura = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
31+
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
32+
sp-inherents = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
33+
sp-runtime = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
34+
sp-transaction-pool = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
3635

3736
chainx-primitives = { path = "../primitives" }
3837
chainx-runtime = { path = "../runtime" }
@@ -41,4 +40,4 @@ chainx-rpc = { path = "../rpc" }
4140
xpallet-protocol = { path = "../xpallets/protocol" }
4241

4342
[build-dependencies]
44-
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
43+
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }

cli/src/service.rs

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ macro_rules! new_full_start {
3232
($config:expr) => {{
3333
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
3434
use std::sync::Arc;
35-
type RpcExtension = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
3635

3736
let mut import_setup = None;
3837
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
@@ -85,12 +84,25 @@ macro_rules! new_full_start {
8584
Ok(import_queue)
8685
},
8786
)?
88-
.with_rpc_extensions(|builder| -> std::result::Result<RpcExtension, _> {
89-
let deps = chainx_rpc::FullDeps {
90-
client: builder.client().clone(),
91-
pool: builder.pool(),
92-
};
93-
Ok(chainx_rpc::create_full(deps))
87+
.with_rpc_extensions_builder(|builder| {
88+
// let grandpa_link = import_setup
89+
// .as_ref()
90+
// .map(|s| &s.1)
91+
// .expect("GRANDPA LinkHalf is present for full services or set up failed; qed.");
92+
// let shared_authority_set = grandpa_link.shared_authority_set().clone();
93+
// let shared_voter_state = grandpa::SharedVoterState::empty();
94+
//
95+
// rpc_setup = Some((shared_voter_state.clone()));
96+
let client = builder.client().clone();
97+
let pool = builder.pool().clone();
98+
Ok(move |deny_unsafe| {
99+
let deps = chainx_rpc::FullDeps {
100+
client: client.clone(),
101+
pool: pool.clone(),
102+
deny_unsafe,
103+
};
104+
chainx_rpc::create_full(deps)
105+
})
94106
})?;
95107

96108
(builder, import_setup, inherent_data_providers)
@@ -116,7 +128,7 @@ pub fn new_full(config: Configuration) -> Result<impl AbstractService, ServiceEr
116128
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
117129
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
118130
})?
119-
.build()?;
131+
.build_full()?;
120132

121133
if role.is_authority() {
122134
let proposer = sc_basic_authorship::ProposerFactory::new(
@@ -148,13 +160,15 @@ pub fn new_full(config: Configuration) -> Result<impl AbstractService, ServiceEr
148160

149161
// the AURA authoring task is considered essential, i.e. if it
150162
// fails we take down the service with it.
151-
service.spawn_essential_task("aura", aura);
163+
service
164+
.spawn_essential_task_handle()
165+
.spawn_blocking("aura", aura);
152166
}
153167

154168
// if the node isn't actively participating in consensus then it doesn't
155169
// need a keystore, regardless of which protocol we use below.
156170
let keystore = if role.is_authority() {
157-
Some(service.keystore())
171+
Some(service.keystore() as sp_core::traits::BareCryptoStorePtr)
158172
} else {
159173
None
160174
};
@@ -190,7 +204,7 @@ pub fn new_full(config: Configuration) -> Result<impl AbstractService, ServiceEr
190204

191205
// the GRANDPA voter task is considered infallible, i.e.
192206
// if it fails we take down the service with it.
193-
service.spawn_essential_task(
207+
service.spawn_essential_task_handle().spawn_blocking(
194208
"grandpa-voter",
195209
sc_finality_grandpa::run_grandpa_voter(grandpa_config)?,
196210
);
@@ -207,7 +221,6 @@ pub fn new_full(config: Configuration) -> Result<impl AbstractService, ServiceEr
207221

208222
/// Builds a new service for a light client.
209223
pub fn new_light(config: Configuration) -> Result<impl AbstractService, ServiceError> {
210-
type RpcExtension = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
211224
let inherent_data_providers = InherentDataProviders::new();
212225

213226
ServiceBuilder::new_light::<Block, RuntimeApi, Executor>(config)?
@@ -270,7 +283,7 @@ pub fn new_light(config: Configuration) -> Result<impl AbstractService, ServiceE
270283
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
271284
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
272285
})?
273-
.with_rpc_extensions(|builder| -> Result<RpcExtension, _> {
286+
.with_rpc_extensions(|builder| {
274287
let fetcher = builder
275288
.fetcher()
276289
.ok_or_else(|| "Trying to start node RPC without active fetcher")?;
@@ -286,5 +299,5 @@ pub fn new_light(config: Configuration) -> Result<impl AbstractService, ServiceE
286299
};
287300
Ok(chainx_rpc::create_light(light_deps))
288301
})?
289-
.build()
302+
.build_light()
290303
}

polkadotjs.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
"Desc": "Text",
88
"Memo": "Text",
99
"AddrStr": "Text",
10+
"NetworkType": {
11+
"_enum": [
12+
"Mainnet",
13+
"Testnet"
14+
]
15+
},
1016
"Chain": {
1117
"_enum": [
1218
"ChainX",

primitives/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ authors = ["ChainX community <https://www.chainx.org>"]
55
edition = "2018"
66

77
[dependencies]
8-
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false }
8+
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false }
99
serde = { version = "1.0.101", optional = true, features = ["derive"] }
1010

1111
# Substrate primitives
12-
sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
13-
sp-core = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
14-
sp-runtime = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
15-
sp-std = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
12+
sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4", default-features = false }
13+
sp-core = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4", default-features = false }
14+
sp-runtime = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4", default-features = false }
15+
sp-std = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4", default-features = false }
1616

1717
# Substrate pallets
18-
frame-system = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
18+
frame-system = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4", default-features = false }
1919

2020
# ChainX pallets
2121
xpallet-support = { path = "../xpallets/support", default-features = false }

rpc/Cargo.toml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,30 @@ authors = ["ChainX community <https://www.chainx.org>"]
55
edition = "2018"
66

77
[dependencies]
8-
codec = { package = "parity-scale-codec", version = "1.3.0", features = ["derive"] }
8+
codec = { package = "parity-scale-codec", version = "1.3.1", features = ["derive"] }
99
hex = "0.4"
1010
jsonrpc-core = "14.2.0"
1111
jsonrpc-core-client = "14.2.0"
1212
jsonrpc-derive = "14.2.1"
1313
serde_json = "1.0"
1414

1515
# Substrate client
16-
sc-client-api = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
17-
sc-service = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3", features = ["test-helpers"] }
16+
sc-client-api = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
17+
sc-service = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4", features = ["test-helpers"] }
18+
sc-rpc-api = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
1819

1920
# Substrate primitives
20-
sp-api = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
21-
sp-blockchain = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
22-
sp-consensus = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
23-
sp-runtime = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
24-
sp-state-machine = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
25-
sp-transaction-pool = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
21+
sp-api = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
22+
sp-blockchain = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
23+
sp-block-builder = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
24+
sp-consensus = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
25+
sp-runtime = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
26+
sp-state-machine = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
27+
sp-transaction-pool = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
2628

2729
# Substrate pallets
28-
frame-support = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
29-
substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
30+
frame-support = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
31+
substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc4" }
3032

3133
chainx-runtime = { path = "../runtime" }
3234

rpc/src/lib.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ use std::fmt;
1212
use std::sync::Arc;
1313

1414
use sc_client_api::{backend::Backend, CallExecutor, StorageProvider};
15+
use sc_rpc_api::DenyUnsafe;
1516
use sc_service::client::Client;
1617
use sp_api::ProvideRuntimeApi;
18+
use sp_block_builder::BlockBuilder;
1719
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
1820
use sp_transaction_pool::TransactionPool;
1921

2022
use chainx_primitives::Block;
21-
use chainx_runtime::{AccountId, Balance, BlockNumber, Index, UncheckedExtrinsic};
23+
use chainx_runtime::{AccountId, Balance, BlockNumber, Hash, Index, UncheckedExtrinsic};
2224

2325
use apis::ChainXApi;
2426
use impls::ChainXRpc;
@@ -41,6 +43,8 @@ pub struct FullDeps<P, BE, E, RA> {
4143
pub client: Arc<Client<BE, E, Block, RA>>,
4244
/// Transaction pool instance.
4345
pub pool: Arc<P>,
46+
/// Whether to deny unsafe calls
47+
pub deny_unsafe: DenyUnsafe,
4448
}
4549

4650
/// Instantiate all Full RPC extensions.
@@ -57,6 +61,7 @@ where
5761
+ StorageProvider<Block, BE>
5862
+ 'static,
5963
Client<BE, E, Block, RA>: Send + Sync + 'static,
64+
<Client<BE, E, Block, RA> as ProvideRuntimeApi<Block>>::Api: BlockBuilder<Block>,
6065
<Client<BE, E, Block, RA> as ProvideRuntimeApi<Block>>::Api:
6166
substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
6267
<Client<BE, E, Block, RA> as ProvideRuntimeApi<Block>>::Api:
@@ -80,11 +85,16 @@ where
8085
use xpallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
8186

8287
let mut io = jsonrpc_core::IoHandler::default();
83-
let FullDeps { client, pool } = deps;
88+
let FullDeps {
89+
client,
90+
pool,
91+
deny_unsafe,
92+
} = deps;
8493

8594
io.extend_with(SystemApi::to_delegate(FullSystem::new(
8695
client.clone(),
8796
pool,
97+
deny_unsafe,
8898
)));
8999
io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(
90100
client.clone(),
@@ -112,7 +122,7 @@ where
112122
fetcher,
113123
} = deps;
114124
let mut io = jsonrpc_core::IoHandler::default();
115-
io.extend_with(SystemApi::<AccountId, Index>::to_delegate(
125+
io.extend_with(SystemApi::<Hash, AccountId, Index>::to_delegate(
116126
LightSystem::new(client, remote_blockchain, fetcher, pool),
117127
));
118128

0 commit comments

Comments
 (0)