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

Commit 8ce75ce

Browse files
committed
Merge branch 'master' into light_tries
2 parents 8bffa45 + e8be27c commit 8ce75ce

File tree

47 files changed

+1218
-584
lines changed

Some content is hidden

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

47 files changed

+1218
-584
lines changed

Cargo.lock

+16-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ members = [
2222
"polkadot/parachain",
2323
"polkadot/primitives",
2424
"polkadot/runtime",
25+
"polkadot/service",
2526
"polkadot/statement-table",
2627
"polkadot/transaction-pool",
27-
"polkadot/service",
28-
2928
"substrate/bft",
3029
"substrate/client",
3130
"substrate/client/db",
3231
"substrate/codec",
3332
"substrate/environmental",
3433
"substrate/executor",
34+
"substrate/extrinsic-pool",
3535
"substrate/keyring",
36-
"substrate/network",
3736
"substrate/misbehavior-check",
37+
"substrate/network",
3838
"substrate/primitives",
39-
"substrate/rpc-servers",
4039
"substrate/rpc",
40+
"substrate/rpc-servers",
4141
"substrate/runtime-io",
4242
"substrate/runtime-sandbox",
4343
"substrate/runtime-std",
@@ -55,10 +55,10 @@ members = [
5555
"substrate/state-machine",
5656
"substrate/test-runtime",
5757

58-
"demo/runtime",
59-
"demo/primitives",
60-
"demo/executor",
6158
"demo/cli",
59+
"demo/executor",
60+
"demo/primitives",
61+
"demo/runtime",
6262
"safe-mix",
6363
"subkey",
6464
]

demo/cli/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ tokio-core = "0.1.12"
1717
triehash = "0.1"
1818
substrate-client = { path = "../../substrate/client" }
1919
substrate-codec = { path = "../../substrate/codec" }
20+
substrate-extrinsic-pool = { path = "../../substrate/extrinsic-pool" }
2021
substrate-runtime-io = { path = "../../substrate/runtime-io" }
2122
substrate-state-machine = { path = "../../substrate/state-machine" }
2223
substrate-executor = { path = "../../substrate/executor" }

demo/cli/src/lib.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ extern crate substrate_rpc;
3131
extern crate substrate_rpc_servers as rpc;
3232
extern crate substrate_runtime_io as runtime_io;
3333
extern crate substrate_state_machine as state_machine;
34+
extern crate substrate_extrinsic_pool as extrinsic_pool;
3435
extern crate demo_executor;
3536
extern crate demo_primitives;
3637
extern crate demo_runtime;
@@ -53,11 +54,14 @@ use demo_runtime::{GenesisConfig, ConsensusConfig, CouncilConfig, DemocracyConfi
5354
SessionConfig, StakingConfig, BuildExternalities};
5455
use futures::{Future, Sink, Stream};
5556

56-
5757
struct DummyPool;
58-
impl substrate_rpc::author::AuthorApi for DummyPool {
59-
fn submit_extrinsic(&self, _: primitives::block::Extrinsic) -> substrate_rpc::author::error::Result<()> {
60-
Err(substrate_rpc::author::error::ErrorKind::Unimplemented.into())
58+
impl extrinsic_pool::api::ExtrinsicPool for DummyPool {
59+
type Error = extrinsic_pool::txpool::Error;
60+
61+
fn submit(&self, _: Vec<primitives::block::Extrinsic>)
62+
-> Result<Vec<primitives::block::ExtrinsicHash>, Self::Error>
63+
{
64+
Err("unimplemented".into())
6165
}
6266
}
6367

@@ -115,7 +119,8 @@ pub fn run<I, T>(args: I) -> error::Result<()> where
115119
staking: Some(StakingConfig {
116120
current_era: 0,
117121
intentions: vec![],
118-
transaction_fee: 100,
122+
transaction_base_fee: 100,
123+
transaction_byte_fee: 1,
119124
balances: vec![(god_key.clone(), 1u64 << 63)].into_iter().collect(),
120125
validator_count: 12,
121126
sessions_per_era: 24, // 24 hours per era.
@@ -155,7 +160,7 @@ pub fn run<I, T>(args: I) -> error::Result<()> where
155160
let _rpc_servers = {
156161
let handler = || {
157162
let chain = rpc::apis::chain::Chain::new(client.clone(), core.remote());
158-
rpc::rpc_handler(client.clone(), chain, DummyPool, DummySystem)
163+
rpc::rpc_handler(client.clone(), chain, Arc::new(DummyPool), DummySystem)
159164
};
160165
let http_address = "127.0.0.1:9933".parse().unwrap();
161166
let ws_address = "127.0.0.1:9944".parse().unwrap();

demo/executor/src/lib.rs

+19-12
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ mod tests {
8282
#[test]
8383
fn panic_execution_with_foreign_code_gives_error() {
8484
let mut t: TestExternalities = map![
85-
twox_128(&<staking::FreeBalance<Concrete>>::key_for(*Alice)).to_vec() => vec![68u8, 0, 0, 0, 0, 0, 0, 0],
86-
twox_128(<staking::TransactionFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
85+
twox_128(&<staking::FreeBalance<Concrete>>::key_for(*Alice)).to_vec() => vec![69u8, 0, 0, 0, 0, 0, 0, 0],
86+
twox_128(<staking::TransactionBaseFee<Concrete>>::key()).to_vec() => vec![70u8; 8],
87+
twox_128(<staking::TransactionByteFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
8788
twox_128(&<system::BlockHash<Concrete>>::key_for(0)).to_vec() => vec![0u8; 32]
8889
];
8990

@@ -96,8 +97,9 @@ mod tests {
9697
#[test]
9798
fn panic_execution_with_native_equivalent_code_gives_error() {
9899
let mut t: TestExternalities = map![
99-
twox_128(&<staking::FreeBalance<Concrete>>::key_for(*Alice)).to_vec() => vec![68u8, 0, 0, 0, 0, 0, 0, 0],
100-
twox_128(<staking::TransactionFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
100+
twox_128(&<staking::FreeBalance<Concrete>>::key_for(*Alice)).to_vec() => vec![69u8, 0, 0, 0, 0, 0, 0, 0],
101+
twox_128(<staking::TransactionBaseFee<Concrete>>::key()).to_vec() => vec![70u8; 8],
102+
twox_128(<staking::TransactionByteFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
101103
twox_128(&<system::BlockHash<Concrete>>::key_for(0)).to_vec() => vec![0u8; 32]
102104
];
103105

@@ -111,7 +113,8 @@ mod tests {
111113
fn successful_execution_with_native_equivalent_code_gives_ok() {
112114
let mut t: TestExternalities = map![
113115
twox_128(&<staking::FreeBalance<Concrete>>::key_for(*Alice)).to_vec() => vec![111u8, 0, 0, 0, 0, 0, 0, 0],
114-
twox_128(<staking::TransactionFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
116+
twox_128(<staking::TransactionBaseFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
117+
twox_128(<staking::TransactionByteFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
115118
twox_128(&<system::BlockHash<Concrete>>::key_for(0)).to_vec() => vec![0u8; 32]
116119
];
117120

@@ -130,7 +133,8 @@ mod tests {
130133
fn successful_execution_with_foreign_code_gives_ok() {
131134
let mut t: TestExternalities = map![
132135
twox_128(&<staking::FreeBalance<Concrete>>::key_for(*Alice)).to_vec() => vec![111u8, 0, 0, 0, 0, 0, 0, 0],
133-
twox_128(<staking::TransactionFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
136+
twox_128(<staking::TransactionBaseFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
137+
twox_128(<staking::TransactionByteFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
134138
twox_128(&<system::BlockHash<Concrete>>::key_for(0)).to_vec() => vec![0u8; 32]
135139
];
136140

@@ -162,7 +166,8 @@ mod tests {
162166
intentions: vec![Alice.into(), Bob.into(), Charlie.into()],
163167
validator_count: 3,
164168
bonding_duration: 0,
165-
transaction_fee: 1,
169+
transaction_base_fee: 1,
170+
transaction_byte_fee: 0,
166171
}),
167172
democracy: Some(Default::default()),
168173
council: Some(Default::default()),
@@ -197,7 +202,7 @@ mod tests {
197202
construct_block(
198203
1,
199204
[69u8; 32].into(),
200-
hex!("a63d59c6a7347cd7a1dc1ec139723b531f0ac450e39b1c532d5ca69ff74ad811").into(),
205+
hex!("76b0393b4958d3cb98bb51d9f4edb316af48485142b8721e94c3b52c75ec3243").into(),
201206
vec![Extrinsic {
202207
signed: Alice.into(),
203208
index: 0,
@@ -210,7 +215,7 @@ mod tests {
210215
construct_block(
211216
2,
212217
block1().1,
213-
hex!("1c3623b2e3f7e43752debb9015bace4f6931593579b5af34457b931315f5e2ab").into(),
218+
hex!("8ae9828a5988459d35fb428086170dead660176ee0766e89bc1a4b48153d4e88").into(),
214219
vec![
215220
Extrinsic {
216221
signed: Bob.into(),
@@ -267,8 +272,9 @@ mod tests {
267272
#[test]
268273
fn panic_execution_gives_error() {
269274
let mut t: TestExternalities = map![
270-
twox_128(&<staking::FreeBalance<Concrete>>::key_for(*Alice)).to_vec() => vec![68u8, 0, 0, 0, 0, 0, 0, 0],
271-
twox_128(<staking::TransactionFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
275+
twox_128(&<staking::FreeBalance<Concrete>>::key_for(*Alice)).to_vec() => vec![69u8, 0, 0, 0, 0, 0, 0, 0],
276+
twox_128(<staking::TransactionBaseFee<Concrete>>::key()).to_vec() => vec![70u8; 8],
277+
twox_128(<staking::TransactionByteFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
272278
twox_128(&<system::BlockHash<Concrete>>::key_for(0)).to_vec() => vec![0u8; 32]
273279
];
274280

@@ -283,7 +289,8 @@ mod tests {
283289
fn successful_execution_gives_ok() {
284290
let mut t: TestExternalities = map![
285291
twox_128(&<staking::FreeBalance<Concrete>>::key_for(*Alice)).to_vec() => vec![111u8, 0, 0, 0, 0, 0, 0, 0],
286-
twox_128(<staking::TransactionFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
292+
twox_128(<staking::TransactionBaseFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
293+
twox_128(<staking::TransactionByteFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
287294
twox_128(&<system::BlockHash<Concrete>>::key_for(0)).to_vec() => vec![0u8; 32]
288295
];
289296

Binary file not shown.
Binary file not shown.

polkadot/cli/src/cli.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ args:
6565
- chain:
6666
long: chain
6767
value_name: CHAIN_SPEC
68-
help: Specify the chain specification (one of dev, local or poc-1)
68+
help: Specify the chain specification (one of dev, local or poc-2)
6969
takes_value: true
7070
subcommands:

polkadot/cli/src/lib.rs

+9-36
Original file line numberDiff line numberDiff line change
@@ -61,39 +61,11 @@ mod informant;
6161
use std::io;
6262
use std::net::SocketAddr;
6363
use std::path::{Path, PathBuf};
64-
use std::sync::Arc;
6564

6665
use futures::sync::mpsc;
6766
use futures::{Sink, Future, Stream};
6867
use tokio_core::reactor;
69-
use parking_lot::Mutex;
7068
use service::ChainSpec;
71-
use primitives::block::Extrinsic;
72-
73-
struct RpcTransactionPool {
74-
inner: Arc<Mutex<txpool::TransactionPool>>,
75-
network: Arc<network::Service>,
76-
}
77-
78-
impl substrate_rpc::author::AuthorApi for RpcTransactionPool {
79-
fn submit_extrinsic(&self, xt: Extrinsic) -> substrate_rpc::author::error::Result<()> {
80-
use primitives::hexdisplay::HexDisplay;
81-
use polkadot_runtime::UncheckedExtrinsic;
82-
use codec::Slicable;
83-
84-
info!("Extrinsic submitted: {}", HexDisplay::from(&xt.0));
85-
let decoded = xt.using_encoded(|ref mut s| UncheckedExtrinsic::decode(s))
86-
.ok_or(substrate_rpc::author::error::ErrorKind::InvalidFormat)?;
87-
88-
info!("Correctly formatted: {:?}", decoded);
89-
90-
self.inner.lock().import(decoded)
91-
.map_err(|_| substrate_rpc::author::error::ErrorKind::PoolError)?;
92-
93-
self.network.trigger_repropagate();
94-
Ok(())
95-
}
96-
}
9769

9870
struct Configuration(service::Configuration);
9971

@@ -110,7 +82,7 @@ impl substrate_rpc::system::SystemApi for Configuration {
11082
Ok(match self.0.chain_spec {
11183
ChainSpec::Development => "dev",
11284
ChainSpec::LocalTestnet => "local",
113-
ChainSpec::PoC1Testnet => "poc-1",
85+
ChainSpec::PoC2Testnet => "poc-2",
11486
}.into())
11587
}
11688
}
@@ -174,14 +146,14 @@ pub fn run<I, T>(args: I) -> error::Result<()> where
174146
match matches.value_of("chain") {
175147
Some("dev") => config.chain_spec = ChainSpec::Development,
176148
Some("local") => config.chain_spec = ChainSpec::LocalTestnet,
177-
Some("poc-1") => config.chain_spec = ChainSpec::PoC1Testnet,
149+
Some("poc-2") => config.chain_spec = ChainSpec::PoC2Testnet,
178150
None => (),
179151
Some(unknown) => panic!("Invalid chain name: {}", unknown),
180152
}
181153
info!("Chain specification: {}", match config.chain_spec {
182154
ChainSpec::Development => "Development",
183155
ChainSpec::LocalTestnet => "Local Testnet",
184-
ChainSpec::PoC1Testnet => "PoC-1 Testnet",
156+
ChainSpec::PoC2Testnet => "PoC-2 Testnet",
185157
});
186158

187159
config.roles = role;
@@ -238,11 +210,12 @@ fn run_until_exit<B, E>(mut core: reactor::Core, service: service::Service<B, E>
238210

239211
let handler = || {
240212
let chain = rpc::apis::chain::Chain::new(service.client(), core.remote());
241-
let pool = RpcTransactionPool {
242-
inner: service.transaction_pool(),
243-
network: service.network(),
244-
};
245-
rpc::rpc_handler(service.client(), chain, pool, Configuration(config.clone()))
213+
rpc::rpc_handler(
214+
service.client(),
215+
chain,
216+
service.transaction_pool(),
217+
Configuration(config.clone()),
218+
)
246219
};
247220
(
248221
start_server(http_address, |address| rpc::start_http(address, handler())),

0 commit comments

Comments
 (0)