From ee7b0c05300c52036adb5468c5b6dd1649ac52ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Tue, 21 Apr 2020 14:14:50 +0200 Subject: [PATCH] Rescale the schedule to new gas definitaion (=1 weight) --- frame/contracts/src/lib.rs | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 6e20e4f5c2cf5..8ff1024d95031 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -936,24 +936,27 @@ pub struct Schedule { pub max_subject_len: u32, } +// This is 500 (2 instruction per nano second on 2GHZ) * 1000x slowdown through wasmi +const WASM_INSTRUCTION_COST: Gas = 500_000; + impl Default for Schedule { fn default() -> Schedule { Schedule { version: 0, - put_code_per_byte_cost: 1, - grow_mem_cost: 1, - regular_op_cost: 1, - return_data_per_byte_cost: 1, - event_data_per_byte_cost: 1, - event_per_topic_cost: 1, - event_base_cost: 1, - call_base_cost: 135, - dispatch_base_cost: 135, - instantiate_base_cost: 175, - sandbox_data_read_cost: 1, - sandbox_data_write_cost: 1, - transfer_cost: 100, - instantiate_cost: 200, + put_code_per_byte_cost: WASM_INSTRUCTION_COST, + grow_mem_cost: WASM_INSTRUCTION_COST, + regular_op_cost: WASM_INSTRUCTION_COST, + return_data_per_byte_cost: WASM_INSTRUCTION_COST, + event_data_per_byte_cost: WASM_INSTRUCTION_COST, + event_per_topic_cost: WASM_INSTRUCTION_COST, + event_base_cost: WASM_INSTRUCTION_COST, + call_base_cost: 135 * WASM_INSTRUCTION_COST, + dispatch_base_cost: 135 * WASM_INSTRUCTION_COST, + instantiate_base_cost: 175 * WASM_INSTRUCTION_COST, + sandbox_data_read_cost: WASM_INSTRUCTION_COST, + sandbox_data_write_cost: WASM_INSTRUCTION_COST, + transfer_cost: 100 * WASM_INSTRUCTION_COST, + instantiate_cost: 200 * WASM_INSTRUCTION_COST, max_event_topics: 4, max_stack_height: 64 * 1024, max_memory_pages: 16,