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

Commit 3a5431f

Browse files
authored
Transaction queue integration + submission RPC (#99)
* Implement transaction queue RPC. * whitespace * Support without_std env in environmental! (#110) * Make environmental crate support without_std env. * Small doc fixes. * Remove dead code.
1 parent 9da1f10 commit 3a5431f

File tree

19 files changed

+209
-3
lines changed

19 files changed

+209
-3
lines changed

Cargo.lock

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

demo/cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ substrate-state-machine = { path = "../../substrate/state-machine" }
1919
substrate-executor = { path = "../../substrate/executor" }
2020
substrate-primitives = { path = "../../substrate/primitives" }
2121
substrate-rpc-servers = { path = "../../substrate/rpc-servers" }
22+
substrate-rpc = { path = "../../substrate/rpc" }
2223
demo-primitives = { path = "../primitives" }
2324
demo-executor = { path = "../executor" }
2425
demo-runtime = { path = "../runtime" }

demo/cli/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ extern crate substrate_runtime_io as runtime_io;
2626
extern crate substrate_state_machine as state_machine;
2727
extern crate substrate_client as client;
2828
extern crate substrate_primitives as primitives;
29+
extern crate substrate_rpc;
2930
extern crate substrate_rpc_servers as rpc;
3031
extern crate demo_primitives;
3132
extern crate demo_executor;
@@ -49,6 +50,13 @@ use demo_runtime::{GenesisConfig, ConsensusConfig, CouncilConfig, DemocracyConfi
4950
SessionConfig, StakingConfig, BuildExternalities};
5051
use client::genesis;
5152

53+
struct DummyPool;
54+
impl substrate_rpc::author::AuthorApi for DummyPool {
55+
fn submit_extrinsic(&self, _: primitives::block::Extrinsic) -> substrate_rpc::author::error::Result<()> {
56+
Err(substrate_rpc::author::error::ErrorKind::Unimplemented.into())
57+
}
58+
}
59+
5260
/// Parse command line arguments and start the node.
5361
///
5462
/// IANA unassigned port ranges that we could use:
@@ -126,7 +134,7 @@ pub fn run<I, T>(args: I) -> error::Result<()> where
126134
let client = Arc::new(client::new_in_mem(executor, prepare_genesis)?);
127135

128136
let address = "127.0.0.1:9933".parse().unwrap();
129-
let handler = rpc::rpc_handler(client);
137+
let handler = rpc::rpc_handler(client, DummyPool);
130138
let server = rpc::start_http(&address, handler)?;
131139

132140
if let Some(_) = matches.subcommand_matches("validator") {
Binary file not shown.
Binary file not shown.

polkadot/cli/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub fn run<I, T>(args: I, exit: mpsc::Receiver<()>) -> error::Result<()> where
118118
let rpc_port: u16 = port.parse().expect("Invalid RPC port value specified.");
119119
address.set_port(rpc_port);
120120
}
121-
let handler = rpc::rpc_handler(service.client());
121+
let handler = rpc::rpc_handler(service.client(), service.transaction_pool());
122122
let _server = rpc::start_http(&address, handler)?;
123123

124124
exit.recv().ok();
@@ -150,6 +150,7 @@ fn default_base_path() -> PathBuf {
150150
&app_info,
151151
).expect("app directories exist on all supported platforms; qed")
152152
}
153+
153154
fn init_logger(pattern: &str) {
154155
let mut builder = env_logger::LogBuilder::new();
155156
// Disable info logging by default for some modules:

polkadot/consensus/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,13 @@ impl<C: PolkadotApi, R: TableRouter> bft::Proposer for Proposer<C, R> {
570570
}
571571

572572
let polkadot_block = block_builder.bake();
573+
info!("Proposing block [number: {}; extrinsics: [{}], parent_hash: {}]", polkadot_block.header.number, polkadot_block.extrinsics.len(), polkadot_block.header.parent_hash);
574+
573575
let substrate_block = Slicable::decode(&mut polkadot_block.encode().as_slice())
574576
.expect("polkadot blocks defined to serialize to substrate blocks correctly; qed");
575577

578+
assert!(evaluate_proposal(&substrate_block, &*self.client, current_timestamp(), &self.parent_hash, &self.parent_id).is_ok());
579+
576580
Ok(substrate_block)
577581
}
578582

polkadot/runtime/wasm/genesis.wasm

202 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)