Skip to content

Commit

Permalink
Switch to Substrate monthly (#52)
Browse files Browse the repository at this point in the history
* Switch wasm-loader to substrate monthly

* Upgrade deps to substrate monthly

* Fixes for the latest substrate monthly

* Rebase master

* Cleanup
  • Loading branch information
chevdor authored Jul 7, 2022
1 parent ce8a40a commit fcc5908
Show file tree
Hide file tree
Showing 14 changed files with 547 additions and 600 deletions.
989 changes: 456 additions & 533 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ repository = "https://github.com/chevdor/subwasm"
version = "0.18.0"

[dependencies]
clap = {version = "3.0", features = ["derive", "env", "unicode", "cargo"]}
assert_cmd = "2.0"
clap = {version = "3.2", features = ["derive", "env", "unicode", "cargo"]}
color-eyre = "0.6"
env_logger = "0.9"
log = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ allow = [
"ISC",
"CC0-1.0",
"MPL-2.0",
"GPL-3.0",
"GPL-3.0"
#"Apache-2.0 WITH LLVM-exception",
]
# List of explictly disallowed licenses
Expand Down
33 changes: 24 additions & 9 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
authors = ["chevdor <[email protected]>"]
edition = "2021"
homepage = "https://github.com/chevdor/subwasm"
keywords = ["wasm", "cli", "substrate", "blockchain", "runtime", "polkadot", "kusama"]
keywords = [
"wasm",
"cli",
"substrate",
"blockchain",
"runtime",
"polkadot",
"kusama",
]
license = "MIT"
name = "subwasmlib"
readme = "README.md"
Expand All @@ -12,15 +20,22 @@ version = "0.18.0"
[dependencies]
calm_io = "0.1"
color-eyre = "0.6"
frame-metadata = {version = "14", package = "frame-metadata", features = ["v12", "v13", "v14", "std"]}
ipfs-hasher = {version = "0.18.0", path = "../libs/ipfs-hasher"}
frame-metadata = { version = "15", package = "frame-metadata", features = [
"v12",
"v13",
"v14",
"std",
] }
ipfs-hasher = { version = "0.18.0", path = "../libs/ipfs-hasher" }
log = "0.4"
num-format = "0.4"
rand = "0.8"
scale-info = {version = "1.0", default-features = false, features = ["derive"]}
serde = {version = "1.0", features = ["derive"]}
scale-info = { version = "2.1", default-features = false, features = [
"derive",
] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
substrate-differ = {version = "0.18.0", path = "../libs/substrate-differ"}
wasm-loader = {version = "0.18.0", path = "../libs/wasm-loader"}
wasm-testbed = {version = "0.18.0", path = "../libs/wasm-testbed"}
sp-version = "3.0"
substrate-differ = { version = "0.18.0", path = "../libs/substrate-differ" }
wasm-loader = { version = "0.18.0", path = "../libs/wasm-loader" }
wasm-testbed = { version = "0.18.0", path = "../libs/wasm-testbed" }
sp-version = { tag = "monthly-2022-07", git = "https://github.com/paritytech/substrate" }
2 changes: 0 additions & 2 deletions lib/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::fmt;

// pub type Result<T> = std::result::Result<T, Error>;

#[derive(Debug, Clone)]
pub enum Error {
// Generic,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{fmt::Display, str::FromStr};
/// While module is implemented, the filter on call is not and
/// if we filter on call, we may want to also filter on events, constants
/// etc... and that becomes likely too complex to be comfortable and useful
// when using the cli vs using json and filtering with jq.
/// when using the cli vs using json and filtering with jq.
#[derive(Debug, PartialEq, Eq, Default)]
pub struct Filter {
pub module: String,
Expand Down
2 changes: 1 addition & 1 deletion libs/ipfs-hasher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ version = "0.18.0"
ipfs-unixfs = "0.2"

[dev-dependencies]
wasm-loader = {version = "0.18", path = "../wasm-loader"}
wasm-loader = { version = "0.18", path = "../wasm-loader" }
16 changes: 10 additions & 6 deletions libs/substrate-differ/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ version = "0.18.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
frame-metadata = {version = "14", package = "frame-metadata", features = ["v12", "v13", "v14", "std"]}
frame-metadata = { version = "15", package = "frame-metadata", features = [
"v12",
"v13",
"v14",
"std",
] }
log = "0.4"
num-format = "0.4"
rustc-serialize = "0.3"
serde = {version = "1.0", features = ["derive"]}
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
treediff = {version = "4.0", features = ["with-serde-json", "with-rustc-serialize"]}
wasm-testbed = {version = "0.18.0", path = "../wasm-testbed"}
treediff = { version = "4.0", features = ["with-serde-json"] }
wasm-testbed = { version = "0.18.0", path = "../wasm-testbed" }

[dev-dependencies]
wasm-loader = {version = "0.18", path = "../wasm-loader"}
wasm-loader = { version = "0.18", path = "../wasm-loader" }
24 changes: 15 additions & 9 deletions libs/substrate-runtime-proposal-hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
authors = ["chevdor <[email protected]>"]
edition = "2021"
homepage = "https://github.com/chevdor/subwasm"
keywords = ["wasm", "cli", "substrate", "blockchain", "runtime", "polkadot", "kusama"]
keywords = [
"wasm",
"cli",
"substrate",
"blockchain",
"runtime",
"polkadot",
"kusama",
]
license = "MIT"
name = "substrate-runtime-proposal-hash"
readme = "README.md"
Expand All @@ -11,11 +19,9 @@ version = "0.18.0"

[dependencies]
blake2 = "0.10"
codec = {version = "2.3", package = "parity-scale-codec"}
frame-metadata = {version = "14", package = "frame-metadata", features = ["v12", "v13", "v14", "std"]}
hex = "0.4.3"
sc-executor = "0.9"
sp-core = "3.0"
sp-io = "3.0"
sp-runtime = "3.0"
sp-wasm-interface = "3.0"
codec = { version = "3.1", package = "parity-scale-codec" }
sp-core = { tag = "monthly-2022-07", git = "https://github.com/paritytech/substrate" }
sp-io = { tag = "monthly-2022-07", git = "https://github.com/paritytech/substrate" }
sp-runtime = { tag = "monthly-2022-07", git = "https://github.com/paritytech/substrate" }
sp-wasm-interface = { tag = "monthly-2022-07", git = "https://github.com/paritytech/substrate" }
hex = "0.4"
6 changes: 2 additions & 4 deletions libs/wasm-loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ jsonrpsee = { version = "0.14", git = "https://github.com/paritytech/jsonrpsee",
"client",
] }
log = "0.4"
multibase = "0.9"
multihash = "0.16"
serde = { version = "1.0", features = ["derive"] }
sp-maybe-compressed-blob = { version = "4.1.0-dev", git = "https://github.com/paritytech/substrate/" }
tokio = { version = "1.11", features = ["full"] }
sp-maybe-compressed-blob = { tag = "monthly-2022-07", git = "https://github.com/paritytech/substrate/" }
tokio = { version = "1.19", features = ["full"] }
2 changes: 0 additions & 2 deletions libs/wasm-loader/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::fmt;

// pub type Result<T> = std::result::Result<T, WasmTestbedError>;

#[derive(Debug, Clone)]
pub enum WasmLoaderError {
EndpointParsing(String),
Expand Down
2 changes: 0 additions & 2 deletions libs/wasm-loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use jsonrpsee::core::{Error, JsonValue};
use jsonrpsee::rpc_params;
use log::*;

// use jsonrpsee::types::types::{Error, JsonValue};
use jsonrpsee::{http_client::HttpClientBuilder, ws_client::WsClientBuilder};
pub use node_endpoint::NodeEndpoint;
pub use onchain_block::{BlockRef, OnchainBlock};
Expand All @@ -32,7 +31,6 @@ pub enum CompressedMaybe {

/// The WasmLoader is there to load wasm whether from a file, a node
/// or from raw bytes. The WasmLoader cannot execute any call into the wasm.
///
pub struct WasmLoader {
bytes: CompressedMaybe,
compression: Compression,
Expand Down
39 changes: 26 additions & 13 deletions libs/wasm-testbed/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,38 @@
authors = ["chevdor <[email protected]>"]
edition = "2021"
homepage = "https://github.com/chevdor/subwasm"
keywords = ["wasm", "cli", "substrate", "blockchain", "runtime", "polkadot", "kusama"]
keywords = [
"wasm",
"cli",
"substrate",
"blockchain",
"runtime",
"polkadot",
"kusama",
]
license = "MIT"
name = "wasm-testbed"
readme = "README.md"
repository = "https://github.com/chevdor/subwasm"
version = "0.18.0"

[dependencies]
frame-metadata = {version = "14", package = "frame-metadata", features = ["v12", "v13", "v14", "std"]}
frame-metadata = { version = "15", package = "frame-metadata", features = [
"v12",
"v13",
"v14",
"std",
] }
hex = "0.4"
log = "0.4"
sc-executor = "0.9"
scale = {version = "2.3", package = "parity-scale-codec", default-features = false}
scale-info = {version = "1.0", default-features = false, features = ["derive"]}
sp-core = "3.0"
sp-version = "3.0"
sp-io = "3.0"
sp-runtime = "3.0"
sp-state-machine = "0.9"
sp-wasm-interface = "3.0"
substrate-runtime-proposal-hash = {version = "0.18.0", path = "../substrate-runtime-proposal-hash"}
wasm-loader = {version = "0.18.0", path = "../wasm-loader"}
sc-executor = { tag = "monthly-2022-07", git = "https://github.com/paritytech/substrate" }
sc-executor-common = { tag = "monthly-2022-07", git = "https://github.com/paritytech/substrate" }
scale = { version = "3.1", package = "parity-scale-codec", default-features = false }
sp-core = { tag = "monthly-2022-07", git = "https://github.com/paritytech/substrate" }
sp-io = { tag = "monthly-2022-07", git = "https://github.com/paritytech/substrate" }
sp-runtime = { tag = "monthly-2022-07", git = "https://github.com/paritytech/substrate" }
sp-state-machine = { tag = "monthly-2022-07", git = "https://github.com/paritytech/substrate" }
sp-wasm-interface = { tag = "monthly-2022-07", git = "https://github.com/paritytech/substrate" }
substrate-runtime-proposal-hash = { version = "0.18.0", path = "../substrate-runtime-proposal-hash" }
wasm-loader = { version = "0.18.0", path = "../wasm-loader" }
sp-version = { tag = "monthly-2022-07", git = "https://github.com/paritytech/substrate" }
25 changes: 9 additions & 16 deletions libs/wasm-testbed/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ mod logger_mock;

pub use error::{Result, WasmTestbedError};
use frame_metadata::{RuntimeMetadata, RuntimeMetadataPrefixed};
use sc_executor::{CallInWasm, WasmExecutionMethod, WasmExecutor};
use sc_executor::{WasmExecutionMethod, WasmExecutor};
use sc_executor_common::runtime_blob::RuntimeBlob;
use scale::Decode;
use sp_core::Hasher;
use sp_runtime::traits::BlakeTwo256;
use sp_version::RuntimeVersion as SubstrateRuntimeVersion;
use sp_wasm_interface::HostFunctions;
use std::fmt;
use substrate_runtime_proposal_hash::{get_parachainsystem_authorize_upgrade, get_result, SrhResult};
use wasm_loader::*;
Expand Down Expand Up @@ -128,22 +128,15 @@ impl WasmTestBed {
/// as we have no blocks, storage, etc...
fn call(wasm: &[u8], method: &str, call_data: &[u8]) -> Result<Vec<u8>> {
let mut ext = sp_state_machine::BasicExternalities::default();
let mut host_functions = sp_io::SubstrateHostFunctions::host_functions();
host_functions.push(&logger_mock::LoggerMock);

let executor = WasmExecutor::new(
WasmExecutionMethod::Interpreted,
// At least 12 for Polkadot V12/V13.
// Substrate V14 requires 34.
// Polkadot V14 requires 20.
Some(64),
host_functions,
8,
None,
);

// Substrate V14 requires a heap of ~34.
// Polkadot V14 requires a heap of ~20.
let executor: WasmExecutor<sp_io::SubstrateHostFunctions> =
WasmExecutor::new(WasmExecutionMethod::Interpreted, Some(64), 8, None, 2);

let runtime_blob = RuntimeBlob::new(wasm).unwrap();
executor
.call_in_wasm(wasm, None, method, call_data, &mut ext, sp_core::traits::MissingHostFunctions::Allow)
.uncached_call(runtime_blob, &mut ext, true, method, call_data)
.map_err(|_| WasmTestbedError::Calling(method.to_string()))
}

Expand Down

0 comments on commit fcc5908

Please sign in to comment.