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

Commit c2ec5bc

Browse files
authored
Bump parity-wasm and pwasm-utils to the newest versions everywhere (#8928)
1 parent 426d57b commit c2ec5bc

File tree

18 files changed

+78
-88
lines changed

18 files changed

+78
-88
lines changed

Cargo.lock

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

client/executor/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ sp-trie = { version = "3.0.0", path = "../../primitives/trie" }
2323
sp-serializer = { version = "3.0.0", path = "../../primitives/serializer" }
2424
sp-version = { version = "3.0.0", path = "../../primitives/version" }
2525
sp-panic-handler = { version = "3.0.0", path = "../../primitives/panic-handler" }
26-
wasmi = "0.6.2"
27-
parity-wasm = "0.41.0"
26+
wasmi = "0.9.0"
27+
parity-wasm = "0.42.0"
2828
lazy_static = "1.4.0"
2929
sp-api = { version = "3.0.0", path = "../../primitives/api" }
3030
sp-wasm-interface = { version = "3.0.0", path = "../../primitives/wasm-interface" }

client/executor/common/Cargo.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ targets = ["x86_64-unknown-linux-gnu"]
1515

1616
[dependencies]
1717
derive_more = "0.99.2"
18-
parity-wasm = "0.41.0"
19-
pwasm-utils = "0.14.0"
18+
pwasm-utils = "0.18.0"
2019
codec = { package = "parity-scale-codec", version = "2.0.0" }
21-
wasmi = "0.6.2"
20+
wasmi = "0.9.0"
2221
sp-core = { version = "3.0.0", path = "../../../primitives/core" }
2322
sp-allocator = { version = "3.0.0", path = "../../../primitives/allocator" }
2423
sp-wasm-interface = { version = "3.0.0", path = "../../../primitives/wasm-interface" }

client/executor/common/src/runtime_blob/data_segments_snapshot.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use crate::error::{self, Error};
2020
use super::RuntimeBlob;
2121
use std::mem;
22-
use parity_wasm::elements::Instruction;
22+
use pwasm_utils::parity_wasm::elements::Instruction;
2323

2424
/// This is a snapshot of data segments specialzied for a particular instantiation.
2525
///

client/executor/common/src/runtime_blob/runtime_blob.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@
1616
// You should have received a copy of the GNU General Public License
1717
// along with this program. If not, see <https://www.gnu.org/licenses/>.
1818

19-
use parity_wasm::elements::{DataSegment, Module as RawModule, deserialize_buffer, serialize};
20-
19+
use pwasm_utils::{
20+
parity_wasm::elements::{
21+
DataSegment, Module, deserialize_buffer, serialize, Internal,
22+
},
23+
export_mutable_globals,
24+
};
2125
use crate::error::WasmError;
2226

2327
/// A bunch of information collected from a WebAssembly module.
2428
#[derive(Clone)]
2529
pub struct RuntimeBlob {
26-
raw_module: RawModule,
30+
raw_module: Module,
2731
}
2832

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

7579
/// Perform an instrumentation that makes sure that the mutable globals are exported.
7680
pub fn expose_mutable_globals(&mut self) {
77-
pwasm_utils::export_mutable_globals(&mut self.raw_module, "exported_internal_global");
81+
export_mutable_globals(&mut self.raw_module, "exported_internal_global");
7882
}
7983

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

114118
/// Destructure this structure into the underlying parity-wasm Module.
115-
pub fn into_inner(self) -> RawModule {
119+
pub fn into_inner(self) -> Module {
116120
self.raw_module
117121
}
118122
}

client/executor/wasmi/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
1515

1616
[dependencies]
1717
log = "0.4.8"
18-
wasmi = "0.6.2"
18+
wasmi = "0.9.0"
1919
codec = { package = "parity-scale-codec", version = "2.0.0" }
2020
sc-executor-common = { version = "0.9.0", path = "../common" }
2121
sp-wasm-interface = { version = "3.0.0", path = "../../../primitives/wasm-interface" }

client/executor/wasmtime/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@ targets = ["x86_64-unknown-linux-gnu"]
1515
[dependencies]
1616
log = "0.4.8"
1717
scoped-tls = "1.0"
18-
parity-wasm = "0.41.0"
18+
parity-wasm = "0.42.0"
1919
codec = { package = "parity-scale-codec", version = "2.0.0" }
2020
sc-executor-common = { version = "0.9.0", path = "../common" }
2121
sp-wasm-interface = { version = "3.0.0", path = "../../../primitives/wasm-interface" }
2222
sp-runtime-interface = { version = "3.0.0", path = "../../../primitives/runtime-interface" }
2323
sp-core = { version = "3.0.0", path = "../../../primitives/core" }
2424
sp-allocator = { version = "3.0.0", path = "../../../primitives/allocator" }
2525
wasmtime = "0.24.0"
26-
pwasm-utils = "0.14.0"
2726

2827
[dev-dependencies]
2928
assert_matches = "1.3.0"

frame/contracts/Cargo.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
1515
[dependencies]
1616
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
1717
log = { version = "0.4", default-features = false }
18-
parity-wasm = { version = "0.42", default-features = false }
19-
pwasm-utils = { version = "0.17", default-features = false }
18+
pwasm-utils = { version = "0.18", default-features = false }
2019
serde = { version = "1", optional = true, features = ["derive"] }
2120
smallvec = { version = "1", default-features = false, features = ["const_generics"] }
2221
wasmi-validation = { version = "0.4", default-features = false }
@@ -61,7 +60,6 @@ std = [
6160
"sp-sandbox/std",
6261
"frame-support/std",
6362
"frame-system/std",
64-
"parity-wasm/std",
6563
"pwasm-utils/std",
6664
"wasmi-validation/std",
6765
"pallet-contracts-primitives/std",

frame/contracts/src/benchmarking/code.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@
2525
//! compiles it down into a `WasmModule` that can be used as a contract's code.
2626
2727
use crate::Config;
28-
use parity_wasm::elements::{
29-
Instruction, Instructions, FuncBody, ValueType, BlockType, Section, CustomSection,
28+
use pwasm_utils::{
29+
stack_height::inject_limiter,
30+
parity_wasm::{
31+
elements::{
32+
self, Instruction, Instructions, FuncBody, ValueType, BlockType, Section,
33+
CustomSection,
34+
},
35+
builder,
36+
},
3037
};
31-
use pwasm_utils::stack_height::inject_limiter;
3238
use sp_core::crypto::UncheckedFrom;
3339
use sp_runtime::traits::Hash;
3440
use sp_sandbox::{EnvironmentDefinitionBuilder, Memory};
@@ -127,7 +133,7 @@ where
127133
let func_offset = u32::try_from(def.imported_functions.len()).unwrap();
128134

129135
// Every contract must export "deploy" and "call" functions
130-
let mut contract = parity_wasm::builder::module()
136+
let mut contract = builder::module()
131137
// deploy function (first internal function)
132138
.function()
133139
.signature().build()
@@ -166,15 +172,15 @@ where
166172

167173
// Import supervisor functions. They start with idx 0.
168174
for func in def.imported_functions {
169-
let sig = parity_wasm::builder::signature()
175+
let sig = builder::signature()
170176
.with_params(func.params)
171177
.with_results(func.return_type.into_iter().collect())
172178
.build_sig();
173179
let sig = contract.push_signature(sig);
174180
contract = contract.import()
175181
.module(func.module)
176182
.field(func.name)
177-
.with_external(parity_wasm::elements::External::Function(sig))
183+
.with_external(elements::External::Function(sig))
178184
.build();
179185
}
180186

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

497503
/// Replace the locals of the supplied `body` with `num` i64 locals.
498504
pub fn inject_locals(body: &mut FuncBody, num: u32) {
499-
use parity_wasm::elements::Local;
505+
use self::elements::Local;
500506
*body.locals_mut() = (0..num).map(|i| Local::new(i, ValueType::I64)).collect()
501507
}
502508
}

frame/contracts/src/benchmarking/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use self::{
3939
use codec::Encode;
4040
use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite};
4141
use frame_system::{Pallet as System, RawOrigin};
42-
use parity_wasm::elements::{Instruction, ValueType, BlockType};
42+
use pwasm_utils::parity_wasm::elements::{Instruction, ValueType, BlockType, BrTableData};
4343
use sp_runtime::traits::{Hash, Bounded, Zero};
4444
use sp_std::{default::Default, convert::{TryInto}, vec::Vec, vec};
4545
use pallet_contracts_primitives::RentProjection;
@@ -1934,7 +1934,7 @@ benchmarks! {
19341934
// 1 * w_param + 0.5 * 2 * w_param + 0.25 * 4 * w_param
19351935
instr_br_table {
19361936
let r in 0 .. INSTR_BENCHMARK_BATCHES;
1937-
let table = Box::new(parity_wasm::elements::BrTableData {
1937+
let table = Box::new(BrTableData {
19381938
table: Box::new([0, 1, 2]),
19391939
default: 1,
19401940
});
@@ -1968,7 +1968,7 @@ benchmarks! {
19681968
.cloned()
19691969
.cycle()
19701970
.take((e / 2) as usize).collect();
1971-
let table = Box::new(parity_wasm::elements::BrTableData {
1971+
let table = Box::new(BrTableData {
19721972
table: entry.into_boxed_slice(),
19731973
default: 0,
19741974
});

frame/contracts/src/schedule.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ use pallet_contracts_proc_macro::{ScheduleDebug, WeightDebug};
2626
use frame_support::{DefaultNoBound, weights::Weight};
2727
use sp_std::{marker::PhantomData, vec::Vec};
2828
use codec::{Encode, Decode};
29-
use parity_wasm::elements;
30-
use pwasm_utils::rules;
29+
use pwasm_utils::{parity_wasm::elements, rules};
3130
use sp_runtime::RuntimeDebug;
3231

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

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

0 commit comments

Comments
 (0)