contracts: Remove state rent (#9669)

* Remove storage rent

* Add storage migration

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Add migration for deletetion queue

* Fix compilation

* Increase gas supplied to out_of_gas to be sure that it won't deplete too early

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs

Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
Alexander Theißen
2021-09-06 18:40:58 +02:00
committed by GitHub
parent 13f3e25ebb
commit 522e77e243
20 changed files with 1158 additions and 4641 deletions
@@ -1,43 +0,0 @@
(module
(import "seal0" "seal_rent_allowance" (func $seal_rent_allowance (param i32 i32)))
(import "env" "memory" (memory 1 1))
;; [0, 8) reserved for $seal_rent_allowance output
;; [8, 16) length of the buffer
(data (i32.const 8) "\08")
;; [16, inf) zero initialized
(func $assert (param i32)
(block $ok
(br_if $ok
(get_local 0)
)
(unreachable)
)
)
(func (export "call"))
(func (export "deploy")
;; fill the buffer with the rent allowance.
(call $seal_rent_allowance (i32.const 0) (i32.const 8))
;; assert len == 8
(call $assert
(i32.eq
(i32.load (i32.const 8))
(i32.const 8)
)
)
;; assert that contents of the buffer is equal to <BalanceOf<T>>::max_value().
(call $assert
(i64.eq
(i64.load (i32.const 0))
(i64.const 0xFFFFFFFFFFFFFFFF)
)
)
)
)
@@ -145,7 +145,7 @@
;; Calling the destination address with non-empty input data should now work since the
;; contract has been removed. Also transfer a balance to the address so we can ensure this
;; does not keep the contract alive.
;; does not hinder the contract from being removed.
(call $assert
(i32.eq
(call $seal_transfer
@@ -1,72 +0,0 @@
(module
(import "seal0" "seal_set_storage" (func $seal_set_storage (param i32 i32 i32)))
(import "seal0" "seal_input" (func $seal_input (param i32 i32)))
(import "seal1" "seal_restore_to"
(func $seal_restore_to
(param i32 i32 i32 i32 i32)
)
)
(import "env" "memory" (memory 1 1))
(func $assert (param i32)
(block $ok
(br_if $ok
(get_local 0)
)
(unreachable)
)
)
(func (export "call")
;; copy code hash to contract memory
(call $seal_input (i32.const 308) (i32.const 304))
(call $assert
(i32.eq
(i32.load (i32.const 304))
(i32.const 64)
)
)
(call $seal_restore_to
;; Pointer to the encoded dest buffer.
(i32.const 340)
;; Pointer to the encoded code hash buffer
(i32.const 308)
;; Pointer to the encoded rent_allowance buffer
(i32.const 296)
;; Pointer and number of items in the delta buffer.
;; This buffer specifies multiple keys for removal before restoration.
(i32.const 100)
(i32.const 1)
)
)
(func (export "deploy")
;; Data to restore
(call $seal_set_storage
(i32.const 0)
(i32.const 0)
(i32.const 4)
)
;; ACL
(call $seal_set_storage
(i32.const 100)
(i32.const 0)
(i32.const 4)
)
)
;; Data to restore
(data (i32.const 0) "\28")
;; Buffer that has ACL storage keys.
(data (i32.const 100) "\01")
;; [296, 304) Rent allowance
(data (i32.const 296) "\32\00\00\00\00\00\00\00")
;; [304, 308) Size of the buffer that holds code_hash + addr
(data (i32.const 304) "\40")
;; [308, 340) code hash of bob (copied by seal_input)
;; [340, 372) addr of bob (copied by seal_input)
)
@@ -1,105 +0,0 @@
(module
(import "seal0" "seal_transfer" (func $seal_transfer (param i32 i32 i32 i32) (result i32)))
(import "seal0" "seal_set_storage" (func $seal_set_storage (param i32 i32 i32)))
(import "seal0" "seal_clear_storage" (func $seal_clear_storage (param i32)))
(import "seal0" "seal_set_rent_allowance" (func $seal_set_rent_allowance (param i32 i32)))
(import "seal0" "seal_input" (func $seal_input (param i32 i32)))
(import "env" "memory" (memory 1 1))
;; insert a value of 4 bytes into storage
(func $call_0
(call $seal_set_storage
(i32.const 1)
(i32.const 0)
(i32.const 4)
)
)
;; remove the value inserted by call_1
(func $call_1
(call $seal_clear_storage
(i32.const 1)
)
)
;; transfer 50 to CHARLIE
(func $call_2
(call $assert
(i32.eq
(call $seal_transfer (i32.const 136) (i32.const 32) (i32.const 100) (i32.const 8))
(i32.const 0)
)
)
)
;; do nothing
(func $call_else)
(func $assert (param i32)
(block $ok
(br_if $ok
(get_local 0)
)
(unreachable)
)
)
;; Dispatch the call according to input size
(func (export "call")
(local $input_size i32)
;; 4 byte i32 for br_table followed by 32 byte destination for transfer
(i32.store (i32.const 128) (i32.const 36))
(call $seal_input (i32.const 132) (i32.const 128))
(set_local $input_size
(i32.load (i32.const 132))
)
(block $IF_ELSE
(block $IF_2
(block $IF_1
(block $IF_0
(br_table $IF_0 $IF_1 $IF_2 $IF_ELSE
(get_local $input_size)
)
(unreachable)
)
(call $call_0)
return
)
(call $call_1)
return
)
(call $call_2)
return
)
(call $call_else)
)
;; Set into storage a 4 bytes value
;; Set call set_rent_allowance with input
(func (export "deploy")
(call $seal_set_storage
(i32.const 0)
(i32.const 0)
(i32.const 4)
)
(i32.store (i32.const 128) (i32.const 64))
(call $seal_input
(i32.const 132)
(i32.const 128)
)
(call $seal_set_rent_allowance
(i32.const 132)
(i32.load (i32.const 128))
)
)
;; Encoding of 10 in balance
(data (i32.const 0) "\28")
;; encoding of 50 balance
(data (i32.const 100) "\32")
;; [128, 132) size of seal input buffer
;; [132, inf) output buffer for seal input
)