mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 05:11:09 +00:00
[contracts] Port host functions to Weight V2 and storage deposit limit (#13565)
* added [unstable][seal2] call() * updated test to cover new seal_call proof_limit * docs updated * add [seal2][unstable] instantiate() and test * add [seal2][unstable] weight_to_fee() + docs and test * add [seal2][unstable] gas_left() + docs and test * update benchmarks * add DefaultDepositLimit to pallet Config * specify deposit limit for nested call add test for nested call deposit limit save: separate deposit limit for nested calls * specify deposit limit for nested instantiate save: works with test cleaned up debugging outputs * update benchmarks * added missing fixtures * fix benches * pass explicit deposit limit to storage bench * explicit deposit limit for another set_storage bench * add more deposit limit for storage benches * moving to simplified benchmarks * moved to simplified benchmarks * fix seal_weight_to_fee bench * fix seal_instantiate benchmark * doc typo fix * 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 * max_runtime_mem to Schedule limits * add default deposit limit fallback check to test * weight params renaming * fmt * Update frame/contracts/src/benchmarking/mod.rs Co-authored-by: PG Herveou <pgherveou@gmail.com> * prettify inputs in tests * typestate param refactored --------- Co-authored-by: PG Herveou <pgherveou@gmail.com>
This commit is contained in:
@@ -15,9 +15,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! # Contract Pallet
|
||||
//! # Contracts Pallet
|
||||
//!
|
||||
//! The Contract module provides functionality for the runtime to deploy and execute WebAssembly
|
||||
//! The Contracts module provides functionality for the runtime to deploy and execute WebAssembly
|
||||
//! smart-contracts.
|
||||
//!
|
||||
//! - [`Config`]
|
||||
@@ -73,7 +73,7 @@
|
||||
//!
|
||||
//! ## Usage
|
||||
//!
|
||||
//! The Contract module is a work in progress. The following examples show how this Contract module
|
||||
//! The Contracts module is a work in progress. The following examples show how this module
|
||||
//! can be used to instantiate and call contracts.
|
||||
//!
|
||||
//! * [`ink!`](https://use.ink) is
|
||||
@@ -265,6 +265,10 @@ pub mod pallet {
|
||||
#[pallet::constant]
|
||||
type DepositPerByte: Get<BalanceOf<Self>>;
|
||||
|
||||
/// Fallback value to limit the storage deposit if it's not being set by the caller.
|
||||
#[pallet::constant]
|
||||
type DefaultDepositLimit: Get<BalanceOf<Self>>;
|
||||
|
||||
/// The amount of balance a caller has to pay for each storage item.
|
||||
///
|
||||
/// # Note
|
||||
@@ -315,8 +319,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
fn integrity_test() {
|
||||
// Total runtime memory is expected to have 128Mb upper limit
|
||||
const MAX_RUNTIME_MEM: u32 = 1024 * 1024 * 128;
|
||||
// Total runtime memory limit
|
||||
let max_runtime_mem: u32 = T::Schedule::get().limits.runtime_memory;
|
||||
// Memory limits for a single contract:
|
||||
// Value stack size: 1Mb per contract, default defined in wasmi
|
||||
const MAX_STACK_SIZE: u32 = 1024 * 1024;
|
||||
@@ -350,10 +354,10 @@ pub mod pallet {
|
||||
// This gives us the following formula:
|
||||
//
|
||||
// `(MaxCodeLen * 18 * 4 + MAX_STACK_SIZE + max_heap_size) * max_call_depth <
|
||||
// MAX_RUNTIME_MEM/2`
|
||||
// max_runtime_mem/2`
|
||||
//
|
||||
// Hence the upper limit for the `MaxCodeLen` can be defined as follows:
|
||||
let code_len_limit = MAX_RUNTIME_MEM
|
||||
let code_len_limit = max_runtime_mem
|
||||
.saturating_div(2)
|
||||
.saturating_div(max_call_depth)
|
||||
.saturating_sub(max_heap_size)
|
||||
|
||||
Reference in New Issue
Block a user