mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-07 10:48:04 +00:00
a670208a33
* Introduce first groundwork for Wasm executor. * Remove old Rust-runtime code. * Avoid commiting compled files. * Add runtime precompile. * Rename so module makes more sense. * Further renaming. * Ensure tests work. * Allow bringing in of externalities. - Add util functions/macros. - Add uncompacted runtime. - Add some external crates from pwasm-std for managing allocs/memory stuff. * Nice macros for imports. * Allow passing in of data through allocators. Make memcpy and malloc work. Basic allocator. * Can now pass in bytes to WasmExecutor. * Additional cleanup. * Switch usages of `OutData` to `u64` No need to be able to return bytes anymore. * convert to safe but extremely verbose type conversion. @rphmeier any more concise way of doing this? * Remove StaticExternalities distinction. * Remove another unused use. * Refactor wasm utils out * Remove extraneous copies that weren't really testing anything. * Try to use wasm 0.15 * Make it work! * Call-time externalities working. * Add basic externalities. * Fix grumbles and note unwraps to be sorted. * Test storage externality. Unforunately had to change signatures of externalities to avoid immutable function returning a reference. Not sure what to do about this... * Fix nits. * Compile collation logic. * Move back to refs. Yey. * Remove "object" id for storage access. * Fix test. * Fix up rest of tests. * remove unwrap. * Expose set/get code in externalities Also improve tests and add nice wrappers in rust-wasm. * Add validator set. * Introduce validator set into externalities and test. * Add another external function. * Remove code and validators; use storage for everything. * Introduce validators function. * Tests (and a fix) for the validators getter. * Allow calls into runtime to return data. * Remove unneeded trace. * Make runtime printing a bit nicer. * Create separate runtimes for testing and polkadot. * Remove commented code. * Use new path. * Refactor into shared support module. * Fix warning. * Remove unwraps. * Make macro a little less unhygenic. * Add wasm files.
113 lines
3.1 KiB
Rust
113 lines
3.1 KiB
Rust
// Copyright 2017 Parity Technologies (UK) Ltd.
|
|
// This file is part of Polkadot.
|
|
|
|
// Polkadot 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.
|
|
|
|
// Polkadot 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 Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//! Polkadot CLI library.
|
|
|
|
#![warn(missing_docs)]
|
|
|
|
extern crate env_logger;
|
|
extern crate polkadot_client as client;
|
|
extern crate polkadot_executor as executor;
|
|
extern crate polkadot_primitives as primitives;
|
|
extern crate polkadot_rpc_servers as rpc;
|
|
|
|
#[macro_use]
|
|
extern crate clap;
|
|
#[macro_use]
|
|
extern crate error_chain;
|
|
#[macro_use]
|
|
extern crate log;
|
|
|
|
pub mod error;
|
|
|
|
/// Parse command line arguments and start the node.
|
|
///
|
|
/// IANA unassigned port ranges that we could use:
|
|
/// 6717-6766 Unassigned
|
|
/// 8504-8553 Unassigned
|
|
/// 9556-9591 Unassigned
|
|
/// 9803-9874 Unassigned
|
|
/// 9926-9949 Unassigned
|
|
pub fn run<I, T>(args: I) -> error::Result<()> where
|
|
I: IntoIterator<Item = T>,
|
|
T: Into<std::ffi::OsString> + Clone,
|
|
{
|
|
let yaml = load_yaml!("./cli.yml");
|
|
let matches = clap::App::from_yaml(yaml).version(crate_version!()).get_matches_from_safe(args)?;
|
|
|
|
// TODO [ToDr] Split paremeters parsing from actual execution.
|
|
let log_pattern = matches.value_of("log").unwrap_or("");
|
|
init_logger(log_pattern);
|
|
|
|
// Create client
|
|
let blockchain = DummyBlockchain;
|
|
let executor = executor::executor();
|
|
let client = client::Client::new(blockchain, executor);
|
|
|
|
let address = "127.0.0.1:9933".parse().unwrap();
|
|
let handler = rpc::rpc_handler(client);
|
|
let server = rpc::start_http(&address, handler)?;
|
|
|
|
if let Some(_) = matches.subcommand_matches("collator") {
|
|
info!("Starting collator.");
|
|
server.wait();
|
|
return Ok(());
|
|
}
|
|
|
|
if let Some(_) = matches.subcommand_matches("validator") {
|
|
info!("Starting validator.");
|
|
server.wait();
|
|
return Ok(());
|
|
}
|
|
|
|
println!("No command given.\n");
|
|
let _ = clap::App::from_yaml(yaml).print_long_help();
|
|
|
|
Ok(())
|
|
}
|
|
|
|
fn init_logger(pattern: &str) {
|
|
let mut builder = env_logger::LogBuilder::new();
|
|
// Disable info logging by default for some modules:
|
|
builder.filter(Some("hyper"), log::LogLevelFilter::Warn);
|
|
// Enable info for others.
|
|
builder.filter(None, log::LogLevelFilter::Info);
|
|
|
|
if let Ok(lvl) = std::env::var("RUST_LOG") {
|
|
builder.parse(&lvl);
|
|
}
|
|
|
|
builder.parse(pattern);
|
|
|
|
|
|
builder.init().expect("Logger initialized only once.");
|
|
}
|
|
|
|
#[derive(Debug, Default)]
|
|
struct DummyBlockchain;
|
|
|
|
impl client::Blockchain for DummyBlockchain {
|
|
type Error = ();
|
|
|
|
fn latest_hash(&self) -> Result<primitives::block::HeaderHash, Self::Error> {
|
|
Ok(0.into())
|
|
}
|
|
|
|
fn header(&self, _hash: &primitives::block::HeaderHash) -> Result<Option<primitives::block::Header>, Self::Error> {
|
|
Ok(None)
|
|
}
|
|
}
|