Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
eacb017
added [unstable][seal2] call()
agryaznov Mar 7, 2023
b3c9265
updated test to cover new seal_call proof_limit
agryaznov Mar 7, 2023
e226add
docs updated
agryaznov Mar 7, 2023
aba8782
add [seal2][unstable] instantiate() and test
agryaznov Mar 7, 2023
53d8fde
add [seal2][unstable] weight_to_fee() + docs and test
agryaznov Mar 7, 2023
09d1df6
add [seal2][unstable] gas_left() + docs and test
agryaznov Mar 8, 2023
c644fa1
update benchmarks
agryaznov Mar 8, 2023
2cb30c7
add DefaultDepositLimit to pallet Config
agryaznov Mar 8, 2023
a968b29
specify deposit limit for nested call
agryaznov Mar 9, 2023
45b48c2
specify deposit limit for nested instantiate
agryaznov Mar 13, 2023
ec58346
Merge branch 'master' into ag-proof_limit
agryaznov Mar 14, 2023
edf1aac
update benchmarks
agryaznov Mar 14, 2023
2bfb866
added missing fixtures
agryaznov Mar 16, 2023
1ff3f16
fix benches
agryaznov Mar 16, 2023
b0f3103
pass explicit deposit limit to storage bench
agryaznov Mar 16, 2023
3af8712
explicit deposit limit for another set_storage bench
agryaznov Mar 16, 2023
825a6bc
add more deposit limit for storage benches
agryaznov Mar 16, 2023
8f9ea17
moving to simplified benchmarks
agryaznov Mar 16, 2023
6ac5355
Merge branch 'master' into ag-proof_limit
agryaznov Mar 16, 2023
04ead1b
moved to simplified benchmarks
agryaznov Mar 16, 2023
7d1023d
fix seal_weight_to_fee bench
agryaznov Mar 16, 2023
8e6c6d2
fix seal_instantiate benchmark
agryaznov Mar 16, 2023
d618957
Merge branch 'master' into ag-proof_limit
agryaznov Mar 30, 2023
16f0994
doc typo fix
agryaznov Mar 31, 2023
24dcd0e
default dl for benchmarking
agryaznov Mar 31, 2023
d7eab4a
max_runtime_mem to Schedule limits
agryaznov Apr 3, 2023
91fd102
Merge branch 'master' into ag-proof_limit
agryaznov Apr 3, 2023
af1b353
add default deposit limit fallback check to test
agryaznov Apr 12, 2023
04bea78
weight params renaming
agryaznov Apr 12, 2023
c01f166
Merge branch 'master' into ag-proof_limit
agryaznov Apr 12, 2023
50c96da
fmt
agryaznov Apr 12, 2023
95c83ea
Update frame/contracts/src/benchmarking/mod.rs
agryaznov Apr 25, 2023
22c5794
prettify inputs in tests
agryaznov Apr 25, 2023
418aa50
Merge branch 'ag-proof_limit' of github.com:paritytech/substrate into…
agryaznov Apr 25, 2023
0dac6f6
typestate param refactored
agryaznov Apr 25, 2023
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
default dl for benchmarking
more dl for tests

dl for tests to max

deposit_limit fix in instantiate bench

fix instantiate bench

fix instantiate benchmark

fix instantiate bench again

remove dbg

fix seal bench again

fixing it still

seal_instantiate zero deposit

less runs to check if deposit enough

try

try 2

try 3

try 4
  • Loading branch information
agryaznov committed Apr 3, 2023
commit 24dcd0e2e66b7f93e4b7f6e1505420233a60960b
33 changes: 12 additions & 21 deletions frame/contracts/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1771,17 +1771,17 @@ benchmarks! {
}: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, bytes)

// We assume that every instantiate sends at least the minimum balance.
// This is a slow call: We redeuce the number of runs.
// This is a slow call: we reduce the number of runs.
#[pov_mode = Measured]
seal_instantiate {
let r in 0 .. API_BENCHMARK_RUNS / 2;
let r in 1 .. API_BENCHMARK_RUNS / 2;
let hashes = (0..r)
.map(|i| {
let code = WasmModule::<T>::from(ModuleDefinition {
memory: Some(ImportedMemory::max::<T>()),
call_body: Some(body::plain(vec![
// we need to add this in order to make contracts unique
// so that they can be deployed from the same sender
// We need to add this in order to make contracts unique,
// so that they can be deployed from the same sender.
Instruction::I32Const(i as i32),
Instruction::Drop,
Instruction::End,
Expand All @@ -1794,21 +1794,16 @@ benchmarks! {
.collect::<Result<Vec<_>, &'static str>>()?;
let hash_len = hashes.get(0).map(|x| x.encode().len()).unwrap_or(0);
let hashes_bytes = hashes.iter().flat_map(|x| x.encode()).collect::<Vec<_>>();
let hashes_len = hashes_bytes.len();
let hashes_len = &hashes_bytes.len();
let value = Pallet::<T>::min_balance();
assert!(value > 0u32.into());
let value_bytes = value.encode();
let value_len = BalanceOf::<T>::max_encoded_len();
// Set an own deposit limit for every call
let deposit_limit: u32 = (u32::MAX - 100).into();
let deposit_bytes = deposit_limit.to_le_bytes().to_vec();
let addr_len = T::AccountId::max_encoded_len();
// offsets where to place static data in contract memory
let value_offset = 0;
let hashes_offset = value_offset + value_len;
// Offsets where to place static data in contract memory.
let hashes_offset = value_len;
let addr_len_offset = hashes_offset + hashes_len;
let deposit_offset = addr_len_offset + addr_len;
let addr_offset = deposit_offset + 4;
let addr_offset = addr_len_offset + addr_len;
let code = WasmModule::<T>::from(ModuleDefinition {
memory: Some(ImportedMemory::max::<T>()),
imported_functions: vec![ImportedFunction {
Expand All @@ -1833,7 +1828,7 @@ benchmarks! {
}],
data_segments: vec![
DataSegment {
offset: value_offset as u32,
offset: 0,
value: value_bytes,
},
DataSegment {
Expand All @@ -1844,17 +1839,13 @@ benchmarks! {
offset: addr_len_offset as u32,
value: addr_len.to_le_bytes().into(),
},
DataSegment {
offset: addr_offset as u32,
value: deposit_bytes,
},
],
call_body: Some(body::repeated_dyn(r, vec![
Counter(hashes_offset as u32, hash_len as u32), // code_hash_ptr
Regular(Instruction::I64Const(0)), // ref_time weight
Regular(Instruction::I64Const(0)), // proof_size weight
Regular(Instruction::I32Const(deposit_offset as i32)), // deposit limit ptr
Regular(Instruction::I32Const(value_offset as i32)), // value_ptr
Regular(Instruction::I32Const(SENTINEL as i32)), // deposit limit ptr: use parent's limit
Regular(Instruction::I32Const(0)), // value_ptr
Regular(Instruction::I32Const(0)), // input_data_ptr
Regular(Instruction::I32Const(0)), // input_data_len
Regular(Instruction::I32Const(addr_offset as i32)), // address_ptr
Expand Down Expand Up @@ -1884,7 +1875,7 @@ benchmarks! {
return Err("Expected that contract does not exist at this point.".into());
}
}
}: call(origin, callee, 0u32.into(), Weight::MAX, Some(BalanceOf::<T>::from(u32::MAX).into()), vec![])
}: call(origin, callee, 0u32.into(), Weight::MAX, None, vec![])
verify {
for addr in &addresses {
ContractInfoOf::<T>::get(&addr)
Expand Down
4 changes: 2 additions & 2 deletions frame/contracts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ parameter_types! {
};
pub static DepositPerByte: BalanceOf<Test> = 1;
pub const DepositPerItem: BalanceOf<Test> = 2;
// We need this one set high enough for running benchmarks.
pub const DefaultDepositLimit: BalanceOf<Test> = 10_000_000;
// We set it to maximum for running benchmarks
pub const DefaultDepositLimit: BalanceOf<Test> = Balance::max_value();
}

impl Convert<Weight, BalanceOf<Self>> for Test {
Expand Down
5 changes: 2 additions & 3 deletions frame/contracts/src/wasm/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1579,9 +1579,8 @@ pub mod env {
/// - `input_data_len`: length of the input data buffer.
/// - `address_ptr`: a pointer where the new account's address is copied to. `SENTINEL` means
/// not to copy.
/// - `address_len_ptr`: in-out pointer to where the length of the buffer is read from and the
/// actual length is written to.
/// - `output_ptr`: a pointer where the output buffer is copied to. `SENTINEL` means not to
/// - `address_len_ptr`: pointer to where put the length of the address.
/// - `output_ptr`: a pointer where the output buffer is copied to. `SENTINEL` means not to
/// copy.
/// - `output_len_ptr`: in-out pointer to where the length of the buffer is read from and the
/// actual length is written to.
Expand Down