Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contracts: update wasmi to 0.32 #3679

Merged
merged 104 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
94fe749
Only load module once when validating
pgherveou Mar 22, 2024
a38c8a6
bump wasmi to 0.32
pgherveou Mar 22, 2024
bada63e
Merge branch 'master' into pg/wasmi-to-v0.32.0-beta.7
pgherveou Apr 10, 2024
0b96f38
fix lock
pgherveou Apr 10, 2024
88abfcf
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Apr 10, 2024
21e5e33
Merge branch 'master' into pg/wasmi-to-v0.32.0-beta.7
pgherveou Apr 11, 2024
4503590
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Apr 11, 2024
c275207
Use eager compilation mode when benchmarking a host fn
pgherveou Apr 11, 2024
3e835d0
tmp: Use eager compilation
pgherveou Apr 11, 2024
3892688
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Apr 11, 2024
63d8663
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Apr 11, 2024
59138ba
Disable unchecked compilation for now
pgherveou Apr 11, 2024
4d5b935
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Apr 11, 2024
b1db093
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Apr 11, 2024
213c84e
Merge branch 'master' into pg/wasmi-to-v0.32.0-beta.7
pgherveou Apr 16, 2024
1f6f926
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Apr 16, 2024
4c84d87
Merge branch 'master' into pg/wasmi-to-v0.3t 2.0-beta.7
athei Apr 17, 2024
6b0acbd
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Apr 17, 2024
829d590
Merge branch 'master' into pg/wasmi-to-v0.32.0-beta.7
pgherveou Apr 17, 2024
0de9713
wip
pgherveou Apr 22, 2024
d4ab2a8
wip
pgherveou Apr 22, 2024
ecedf8c
wip
pgherveou Apr 22, 2024
00fa306
Merge branch 'master' into pg/rework-host-benchs
pgherveou Apr 22, 2024
f2152fe
wip
pgherveou Apr 23, 2024
75f1c8c
wip
pgherveou Apr 25, 2024
d3921cd
Fixes
pgherveou Apr 26, 2024
c727dd2
Fixes
pgherveou Apr 26, 2024
cf3362f
Update
pgherveou Apr 26, 2024
aed88a9
fixes
pgherveou Apr 26, 2024
f20aed7
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Apr 29, 2024
450ca08
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Apr 29, 2024
c2cd365
Fixes
pgherveou Apr 29, 2024
19fb7bf
fix
pgherveou Apr 29, 2024
5edcd18
Rm unused
pgherveou Apr 29, 2024
837b2d6
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Apr 29, 2024
b2eb314
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Apr 29, 2024
41b5f3a
add ;
pgherveou Apr 29, 2024
f4d65f6
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Apr 29, 2024
9ceb549
Undo
pgherveou May 3, 2024
c6df46a
Merge branch 'pg/rework-host-benchs' into pg/wasmi-to-v0.32.0-beta.7
pgherveou May 3, 2024
47b5291
restore unchecked & lazy compilation
pgherveou May 3, 2024
50c3b66
bump to latest beta
pgherveou May 3, 2024
92a27a1
Update fuel syncing.
pgherveou May 3, 2024
a75fa25
nit
pgherveou May 3, 2024
3466434
set_fuel can't error
pgherveou May 3, 2024
f398a9c
nit
pgherveou May 3, 2024
28acc56
Add PRdoc
pgherveou May 15, 2024
6d87585
Fix PRdoc
pgherveou May 15, 2024
8364456
Merge branch 'master' into pg/rework-host-benchs
athei May 16, 2024
0586b4a
benchmarks: whitelist account_id and contract_info for the root contract
pgherveou May 16, 2024
fbdc565
fix
pgherveou May 16, 2024
58517ee
PR review merge set_storage_per_new_byte & _old_bytes
pgherveou May 16, 2024
825a434
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
May 16, 2024
2cc19fb
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
May 16, 2024
a11e74b
Fix terminate
pgherveou May 17, 2024
da17374
Merge branch 'master' into pg/rework-host-benchs
pgherveou May 17, 2024
b806834
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
May 17, 2024
799134f
Merge branch 'pg/rework-host-benchs' into pg/wasmi-to-v0.32.0-beta.7
pgherveou May 17, 2024
ae17165
Bump beta version
pgherveou May 17, 2024
80dc606
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
May 17, 2024
87fa082
Merge branch 'master' into pg/rework-host-benchs
athei May 17, 2024
d235dfa
Remove internal events
pgherveou May 17, 2024
7ae8ac1
Add prdoc
pgherveou May 17, 2024
737e956
Fix tests
pgherveou May 17, 2024
2f34c0f
use whitelisted root contract origin for cross contract benchmarks
pgherveou May 17, 2024
8b24c9a
Merge branch 'pg/fix_legacy_bench' into pg/rework-host-benchs
pgherveou May 17, 2024
efd75a8
Merge branch 'pg/fix_legacy_bench' into pg/rework-host-benchs
pgherveou May 17, 2024
d5b08bb
Merge branch 'master' into pg/rework-host-benchs
pgherveou May 17, 2024
2926901
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
May 17, 2024
fb9355f
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
May 19, 2024
6b4eea3
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
May 19, 2024
2fa8edc
Simplify clone call
pgherveou May 20, 2024
46650ca
Fix weights
pgherveou May 20, 2024
d7ea304
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
May 20, 2024
8f15947
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
May 20, 2024
3532367
Bump wasmi beta
pgherveou May 23, 2024
1b186f6
Merge branch 'pg/rework-host-benchs' into pg/wasmi-to-v0.32.0-beta.7
pgherveou May 23, 2024
7ff3655
Update prdoc
pgherveou May 23, 2024
d054fcd
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
May 23, 2024
e2ec3cd
Add debug statement
pgherveou May 23, 2024
8e25cc9
Update to latest beta
pgherveou May 23, 2024
ca9da25
Merge branch 'master' into pg/wasmi-to-v0.32.0-beta.7
pgherveou May 23, 2024
d47a0d2
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
May 23, 2024
c116c66
Merge branch 'master' into pg/wasmi-to-v0.32.0-beta.7
pgherveou May 27, 2024
a058d38
Add assert
pgherveou May 27, 2024
ba61f59
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
May 27, 2024
8b7ca41
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
May 27, 2024
8fd1875
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=pallet_contr…
May 27, 2024
2d40ddd
Update wasmi version
pgherveou May 29, 2024
49e3c78
Merge branch 'pg/wasmi-to-v0.32.0-beta.7' of https://github.com/parit…
pgherveou May 29, 2024
99fb78c
Update PR doc
pgherveou May 30, 2024
ca61d1b
Merge branch 'master' into pg/wasmi-to-v0.32.0-beta.7
pgherveou May 30, 2024
78abbea
test roll-back beta
pgherveou May 30, 2024
72de0b5
fix lock
pgherveou May 30, 2024
6eae263
fix lock
pgherveou May 30, 2024
cf02fd7
roll back 0.32
pgherveou May 30, 2024
acd6dfb
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
May 30, 2024
08ea90b
Bump wasmi
pgherveou Jun 3, 2024
ac9f81c
Remove transfer_surcharge from instantiate
pgherveou Jun 3, 2024
b960a6d
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Jun 3, 2024
c2b7441
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Jun 3, 2024
7efe1e7
Fix PR doc and bump wasmi one last time
pgherveou Jun 7, 2024
99cd79e
Merge branch 'master' into pg/wasmi-to-v0.32.0-beta.7
pgherveou Jun 7, 2024
ee1a7ca
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Jun 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip
  • Loading branch information
pgherveou committed Apr 25, 2024
commit 75f1c8c7813483231bf550084b5392af798837c2
20 changes: 12 additions & 8 deletions substrate/frame/contracts/src/benchmarking/call_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,20 +179,24 @@ macro_rules! call_builder(
};
);

#[macro_export]
macro_rules! memory(
($($bytes:expr,)*) => {
vec![]
.into_iter()
$(.chain($bytes))*
.collect::<Vec<_>>()
};
);

#[macro_export]
macro_rules! build_runtime(
// ($runtime:ident, $memory:ident: $val:expr) => {
// $crate::build_runtime!($runtime, _contract, $memory: $val);
// };
($runtime:ident, $memory:ident: [$($segment:expr,)*]) => {
$crate::build_runtime!($runtime, _contract, $memory: [$($segment,)*]);
};
($runtime:ident, $contract:ident, $memory:ident: [$($segment:expr,)*]) => {
($runtime:ident, $contract:ident, $memory:ident: [$($bytes:expr,)*]) => {
$crate::build_runtime!($runtime, $contract);
let mut $memory = vec![]
.into_iter()
$(.chain($segment))*
.collect::<Vec<_>>();
let mut $memory = $crate::memory!($($bytes,)*);
};
($runtime:ident, $contract:ident) => {
let mut setup = CallSetup::<T>::default();
Expand Down
59 changes: 0 additions & 59 deletions substrate/frame/contracts/src/benchmarking/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,53 +317,12 @@ impl<T: Config> WasmModule<T> {
}
.into()
}

/// Creates a wasm module that calls the imported hash function named `name` `repeat` times
/// with an input of size `data_size`. Hash functions have the signature
/// (input_ptr: u32, input_len: u32, output_ptr: u32) -> ()
pub fn hasher(name: &'static str, repeat: u32, data_size: u32) -> Self {
ModuleDefinition {
memory: Some(ImportedMemory::max::<T>()),
imported_functions: vec![ImportedFunction {
module: "seal0",
name,
params: vec![ValueType::I32, ValueType::I32, ValueType::I32],
return_type: None,
}],
call_body: Some(body::repeated(
repeat,
&[
Instruction::I32Const(0), // input_ptr
Instruction::I32Const(data_size as i32), // input_len
Instruction::I32Const(0), // output_ptr
Instruction::Call(0),
],
)),
..Default::default()
}
.into()
}
}

/// Mechanisms to generate a function body that can be used inside a `ModuleDefinition`.
pub mod body {
use super::*;

/// When generating contract code by repeating a Wasm sequence, it's sometimes necessary
/// to change those instructions on each repetition. The variants of this enum describe
/// various ways in which this can happen.
pub enum DynInstr {
/// Insert the associated instruction.
Regular(Instruction),
/// Insert a I32Const with incrementing value for each insertion.
/// (start_at, increment_by)
Counter(u32, u32),
}

pub fn plain(instructions: Vec<Instruction>) -> FuncBody {
FuncBody::new(Vec::new(), Instructions::new(instructions))
}

pub fn repeated(repetitions: u32, instructions: &[Instruction]) -> FuncBody {
repeated_with_locals(&[], repetitions, instructions)
}
Expand Down Expand Up @@ -397,24 +356,6 @@ pub mod body {
instructions.push(Instruction::End);
FuncBody::new(locals.to_vec(), Instructions::new(instructions))
}

pub fn repeated_dyn(repetitions: u32, mut instructions: Vec<DynInstr>) -> FuncBody {
// We need to iterate over indices because we cannot cycle over mutable references
let body = (0..instructions.len())
.cycle()
.take(instructions.len() * usize::try_from(repetitions).unwrap())
.flat_map(|idx| match &mut instructions[idx] {
DynInstr::Regular(instruction) => vec![instruction.clone()],
DynInstr::Counter(offset, increment_by) => {
let current = *offset;
*offset += *increment_by;
vec![Instruction::I32Const(current as i32)]
},
})
.chain(sp_std::iter::once(Instruction::End))
.collect();
FuncBody::new(Vec::new(), Instructions::new(body))
}
}

/// The maximum amount of pages any contract is allowed to have according to the current `Schedule`.
Expand Down
Loading
Loading