Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
Bump parity-wasm and pwasm-utils to the newest versions everywhere (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
athei authored and nazar-pc committed Aug 8, 2021
1 parent 9a89a5c commit 9a82cc0
Show file tree
Hide file tree
Showing 18 changed files with 78 additions and 88 deletions.
58 changes: 18 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions client/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ sp-trie = { version = "3.0.0", path = "../../primitives/trie" }
sp-serializer = { version = "3.0.0", path = "../../primitives/serializer" }
sp-version = { version = "3.0.0", path = "../../primitives/version" }
sp-panic-handler = { version = "3.0.0", path = "../../primitives/panic-handler" }
wasmi = "0.6.2"
parity-wasm = "0.41.0"
wasmi = "0.9.0"
parity-wasm = "0.42.0"
lazy_static = "1.4.0"
sp-api = { version = "3.0.0", path = "../../primitives/api" }
sp-wasm-interface = { version = "3.0.0", path = "../../primitives/wasm-interface" }
Expand Down
5 changes: 2 additions & 3 deletions client/executor/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
derive_more = "0.99.2"
parity-wasm = "0.41.0"
pwasm-utils = "0.14.0"
pwasm-utils = "0.18.0"
codec = { package = "parity-scale-codec", version = "2.0.0" }
wasmi = "0.6.2"
wasmi = "0.9.0"
sp-core = { version = "3.0.0", path = "../../../primitives/core" }
sp-allocator = { version = "3.0.0", path = "../../../primitives/allocator" }
sp-wasm-interface = { version = "3.0.0", path = "../../../primitives/wasm-interface" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use crate::error::{self, Error};
use super::RuntimeBlob;
use std::mem;
use parity_wasm::elements::Instruction;
use pwasm_utils::parity_wasm::elements::Instruction;

/// This is a snapshot of data segments specialzied for a particular instantiation.
///
Expand Down
18 changes: 11 additions & 7 deletions client/executor/common/src/runtime_blob/runtime_blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use parity_wasm::elements::{DataSegment, Module as RawModule, deserialize_buffer, serialize};

use pwasm_utils::{
parity_wasm::elements::{
DataSegment, Module, deserialize_buffer, serialize, Internal,
},
export_mutable_globals,
};
use crate::error::WasmError;

/// A bunch of information collected from a WebAssembly module.
#[derive(Clone)]
pub struct RuntimeBlob {
raw_module: RawModule,
raw_module: Module,
}

impl RuntimeBlob {
Expand All @@ -42,7 +46,7 @@ impl RuntimeBlob {
///
/// Returns `Err` if the wasm code cannot be deserialized.
pub fn new(wasm_code: &[u8]) -> Result<Self, WasmError> {
let raw_module: RawModule = deserialize_buffer(wasm_code)
let raw_module: Module = deserialize_buffer(wasm_code)
.map_err(|e| WasmError::Other(format!("cannot deserialize module: {:?}", e)))?;
Ok(Self { raw_module })
}
Expand Down Expand Up @@ -74,7 +78,7 @@ impl RuntimeBlob {

/// Perform an instrumentation that makes sure that the mutable globals are exported.
pub fn expose_mutable_globals(&mut self) {
pwasm_utils::export_mutable_globals(&mut self.raw_module, "exported_internal_global");
export_mutable_globals(&mut self.raw_module, "exported_internal_global");
}

/// Returns an iterator of all globals which were exported by [`expose_mutable_globals`].
Expand All @@ -87,7 +91,7 @@ impl RuntimeBlob {
.map(|es| es.entries())
.unwrap_or(&[]);
exports.iter().filter_map(|export| match export.internal() {
parity_wasm::elements::Internal::Global(_)
Internal::Global(_)
if export.field().starts_with("exported_internal_global") =>
{
Some(export.field())
Expand All @@ -112,7 +116,7 @@ impl RuntimeBlob {
}

/// Destructure this structure into the underlying parity-wasm Module.
pub fn into_inner(self) -> RawModule {
pub fn into_inner(self) -> Module {
self.raw_module
}
}
2 changes: 1 addition & 1 deletion client/executor/wasmi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
log = "0.4.8"
wasmi = "0.6.2"
wasmi = "0.9.0"
codec = { package = "parity-scale-codec", version = "2.0.0" }
sc-executor-common = { version = "0.9.0", path = "../common" }
sp-wasm-interface = { version = "3.0.0", path = "../../../primitives/wasm-interface" }
Expand Down
3 changes: 1 addition & 2 deletions client/executor/wasmtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
log = "0.4.8"
scoped-tls = "1.0"
parity-wasm = "0.41.0"
parity-wasm = "0.42.0"
codec = { package = "parity-scale-codec", version = "2.0.0" }
sc-executor-common = { version = "0.9.0", path = "../common" }
sp-wasm-interface = { version = "3.0.0", path = "../../../primitives/wasm-interface" }
sp-runtime-interface = { version = "3.0.0", path = "../../../primitives/runtime-interface" }
sp-core = { version = "3.0.0", path = "../../../primitives/core" }
sp-allocator = { version = "3.0.0", path = "../../../primitives/allocator" }
wasmtime = "0.24.0"
pwasm-utils = "0.14.0"

[dev-dependencies]
assert_matches = "1.3.0"
4 changes: 1 addition & 3 deletions frame/contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
log = { version = "0.4", default-features = false }
parity-wasm = { version = "0.42", default-features = false }
pwasm-utils = { version = "0.17", default-features = false }
pwasm-utils = { version = "0.18", default-features = false }
serde = { version = "1", optional = true, features = ["derive"] }
smallvec = { version = "1", default-features = false, features = ["const_generics"] }
wasmi-validation = { version = "0.4", default-features = false }
Expand Down Expand Up @@ -61,7 +60,6 @@ std = [
"sp-sandbox/std",
"frame-support/std",
"frame-system/std",
"parity-wasm/std",
"pwasm-utils/std",
"wasmi-validation/std",
"pallet-contracts-primitives/std",
Expand Down
22 changes: 14 additions & 8 deletions frame/contracts/src/benchmarking/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@
//! compiles it down into a `WasmModule` that can be used as a contract's code.

use crate::Config;
use parity_wasm::elements::{
Instruction, Instructions, FuncBody, ValueType, BlockType, Section, CustomSection,
use pwasm_utils::{
stack_height::inject_limiter,
parity_wasm::{
elements::{
self, Instruction, Instructions, FuncBody, ValueType, BlockType, Section,
CustomSection,
},
builder,
},
};
use pwasm_utils::stack_height::inject_limiter;
use sp_core::crypto::UncheckedFrom;
use sp_runtime::traits::Hash;
use sp_sandbox::{EnvironmentDefinitionBuilder, Memory};
Expand Down Expand Up @@ -127,7 +133,7 @@ where
let func_offset = u32::try_from(def.imported_functions.len()).unwrap();

// Every contract must export "deploy" and "call" functions
let mut contract = parity_wasm::builder::module()
let mut contract = builder::module()
// deploy function (first internal function)
.function()
.signature().build()
Expand Down Expand Up @@ -166,15 +172,15 @@ where

// Import supervisor functions. They start with idx 0.
for func in def.imported_functions {
let sig = parity_wasm::builder::signature()
let sig = builder::signature()
.with_params(func.params)
.with_results(func.return_type.into_iter().collect())
.build_sig();
let sig = contract.push_signature(sig);
contract = contract.import()
.module(func.module)
.field(func.name)
.with_external(parity_wasm::elements::External::Function(sig))
.with_external(elements::External::Function(sig))
.build();
}

Expand Down Expand Up @@ -264,7 +270,7 @@ where
/// `instantiate_with_code` for different sizes of wasm modules. The generated module maximizes
/// instrumentation runtime by nesting blocks as deeply as possible given the byte budget.
pub fn sized(target_bytes: u32) -> Self {
use parity_wasm::elements::Instruction::{If, I32Const, Return, End};
use self::elements::Instruction::{If, I32Const, Return, End};
// Base size of a contract is 63 bytes and each expansion adds 6 bytes.
// We do one expansion less to account for the code section and function body
// size fields inside the binary wasm module representation which are leb128 encoded
Expand Down Expand Up @@ -496,7 +502,7 @@ pub mod body {

/// Replace the locals of the supplied `body` with `num` i64 locals.
pub fn inject_locals(body: &mut FuncBody, num: u32) {
use parity_wasm::elements::Local;
use self::elements::Local;
*body.locals_mut() = (0..num).map(|i| Local::new(i, ValueType::I64)).collect()
}
}
Expand Down
6 changes: 3 additions & 3 deletions frame/contracts/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use self::{
use codec::Encode;
use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite};
use frame_system::{Pallet as System, RawOrigin};
use parity_wasm::elements::{Instruction, ValueType, BlockType};
use pwasm_utils::parity_wasm::elements::{Instruction, ValueType, BlockType, BrTableData};
use sp_runtime::traits::{Hash, Bounded, Zero};
use sp_std::{default::Default, convert::{TryInto}, vec::Vec, vec};
use pallet_contracts_primitives::RentProjection;
Expand Down Expand Up @@ -1934,7 +1934,7 @@ benchmarks! {
// 1 * w_param + 0.5 * 2 * w_param + 0.25 * 4 * w_param
instr_br_table {
let r in 0 .. INSTR_BENCHMARK_BATCHES;
let table = Box::new(parity_wasm::elements::BrTableData {
let table = Box::new(BrTableData {
table: Box::new([0, 1, 2]),
default: 1,
});
Expand Down Expand Up @@ -1968,7 +1968,7 @@ benchmarks! {
.cloned()
.cycle()
.take((e / 2) as usize).collect();
let table = Box::new(parity_wasm::elements::BrTableData {
let table = Box::new(BrTableData {
table: entry.into_boxed_slice(),
default: 0,
});
Expand Down
5 changes: 2 additions & 3 deletions frame/contracts/src/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ use pallet_contracts_proc_macro::{ScheduleDebug, WeightDebug};
use frame_support::{DefaultNoBound, weights::Weight};
use sp_std::{marker::PhantomData, vec::Vec};
use codec::{Encode, Decode};
use parity_wasm::elements;
use pwasm_utils::rules;
use pwasm_utils::{parity_wasm::elements, rules};
use sp_runtime::RuntimeDebug;

/// How many API calls are executed in a single batch. The reason for increasing the amount
Expand Down Expand Up @@ -635,7 +634,7 @@ impl<T: Config> Schedule<T> {

impl<'a, T: Config> rules::Rules for ScheduleRules<'a, T> {
fn instruction_cost(&self, instruction: &elements::Instruction) -> Option<u32> {
use parity_wasm::elements::Instruction::*;
use self::elements::Instruction::*;
let w = &self.schedule.instruction_weights;
let max_params = self.schedule.limits.parameters;

Expand Down
Loading

0 comments on commit 9a82cc0

Please sign in to comment.