mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-23 07:21:17 +00:00
contracts: Replace sp-sandbox and wasmi-validation by newest wasmi (#12501)
* Replace sp-sandbox and wasmi-validation by just wasmi * ".git/.scripts/bench-bot.sh" pallet dev pallet_contracts * Re-check original code on re-instrumentation * Fix clippy * ".git/.scripts/bench-bot.sh" pallet dev pallet_contracts * Apply suggestions from code review Co-authored-by: Robin Freyler <robin.freyler@gmail.com> * Replace wasmi by ::wasmi * Bump wasmi to 0.20 * Add explanation for `unreachable` * Change proof * Fixup master merge * ".git/.scripts/bench-bot.sh" pallet dev pallet_contracts * Fixup naming inconsistencies introduced by reentrancy PR * Fix `scan_imports` docs * Apply suggestions from code review Co-authored-by: Sasha Gryaznov <hi@agryaznov.com> * Fixup suggestions * Remove unnecessary &mut * Fix test * ".git/.scripts/bench-bot.sh" pallet dev pallet_contracts * Fix benchmark merge fail * ".git/.scripts/bench-bot.sh" pallet dev pallet_contracts * Fix docs as suggested by code review * Improve docs for `CodeRejected` * Apply suggestions from code review Co-authored-by: Sasha Gryaznov <hi@agryaznov.com> * Fix logic bug when setting `deterministic_only` * Don't panic when module fails to compile * Apply suggestions from code review Co-authored-by: Robin Freyler <robin.freyler@gmail.com> Co-authored-by: command-bot <> Co-authored-by: Robin Freyler <robin.freyler@gmail.com> Co-authored-by: Sasha Gryaznov <hi@agryaznov.com>
This commit is contained in:
committed by
GitHub
parent
e69c3649b5
commit
08657f14b7
+1
-3
@@ -3,8 +3,7 @@
|
||||
(import "seal0" "seal_deposit_event" (func $seal_deposit_event (param i32 i32 i32 i32)))
|
||||
(import "env" "memory" (memory 1 1))
|
||||
|
||||
(start $start)
|
||||
(func $start
|
||||
(func (export "deploy")
|
||||
(call $seal_deposit_event
|
||||
(i32.const 0) ;; The topics buffer
|
||||
(i32.const 0) ;; The topics buffer's length
|
||||
@@ -22,7 +21,6 @@
|
||||
(func (export "call")
|
||||
(unreachable)
|
||||
)
|
||||
(func (export "deploy"))
|
||||
|
||||
(data (i32.const 8) "\01\02\03\04")
|
||||
)
|
||||
@@ -0,0 +1,4 @@
|
||||
;; Valid module but missing the call function
|
||||
(module
|
||||
(func (export "deploy"))
|
||||
)
|
||||
@@ -1,6 +0,0 @@
|
||||
;; A valid contract which does nothing at all but imports an invalid function
|
||||
(module
|
||||
(import "invalid" "invalid_88_99" (func (param i32 i32 i32)))
|
||||
(func (export "deploy"))
|
||||
(func (export "call"))
|
||||
)
|
||||
@@ -0,0 +1,8 @@
|
||||
;; An invalid module
|
||||
(module
|
||||
(func (export "deploy"))
|
||||
(func (export "call")
|
||||
;; imbalanced stack
|
||||
(i32.const 7)
|
||||
)
|
||||
)
|
||||
+7
-7
@@ -1,10 +1,10 @@
|
||||
;; This fixture recursively tests if reentrant_count returns correct reentrant count value when
|
||||
;; This fixture recursively tests if reentrance_count returns correct reentrant count value when
|
||||
;; using seal_call to make caller contract call to itself
|
||||
(module
|
||||
(import "seal0" "seal_input" (func $seal_input (param i32 i32)))
|
||||
(import "seal0" "seal_address" (func $seal_address (param i32 i32)))
|
||||
(import "seal1" "seal_call" (func $seal_call (param i32 i32 i64 i32 i32 i32 i32 i32) (result i32)))
|
||||
(import "__unstable__" "reentrant_count" (func $reentrant_count (result i32)))
|
||||
(import "__unstable__" "reentrance_count" (func $reentrance_count (result i32)))
|
||||
(import "env" "memory" (memory 1 1))
|
||||
|
||||
;; [0, 32) reserved for $seal_address output
|
||||
@@ -26,7 +26,7 @@
|
||||
)
|
||||
)
|
||||
(func (export "call")
|
||||
(local $expected_reentrant_count i32)
|
||||
(local $expected_reentrance_count i32)
|
||||
(local $seal_call_exit_code i32)
|
||||
|
||||
;; reading current contract address
|
||||
@@ -36,19 +36,19 @@
|
||||
(call $seal_input (i32.const 32) (i32.const 36))
|
||||
|
||||
;; reading manually passed reentrant count
|
||||
(set_local $expected_reentrant_count (i32.load (i32.const 32)))
|
||||
(set_local $expected_reentrance_count (i32.load (i32.const 32)))
|
||||
|
||||
;; reentrance count is calculated correctly
|
||||
(call $assert
|
||||
(i32.eq (call $reentrant_count) (get_local $expected_reentrant_count))
|
||||
(i32.eq (call $reentrance_count) (get_local $expected_reentrance_count))
|
||||
)
|
||||
|
||||
;; re-enter 5 times in a row and assert that the reentrant counter works as expected
|
||||
(i32.eq (call $reentrant_count) (i32.const 5))
|
||||
(i32.eq (call $reentrance_count) (i32.const 5))
|
||||
(if
|
||||
(then) ;; recursion exit case
|
||||
(else
|
||||
;; incrementing $expected_reentrant_count passed to the contract
|
||||
;; incrementing $expected_reentrance_count passed to the contract
|
||||
(i32.store (i32.const 32) (i32.add (i32.load (i32.const 32)) (i32.const 1)))
|
||||
|
||||
;; Call to itself
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
;; This fixture recursively tests if reentrant_count returns correct reentrant count value when
|
||||
;; This fixture recursively tests if reentrance_count returns correct reentrant count value when
|
||||
;; using seal_delegate_call to make caller contract delegate call to itself
|
||||
(module
|
||||
(import "seal0" "seal_input" (func $seal_input (param i32 i32)))
|
||||
(import "seal0" "seal_set_storage" (func $seal_set_storage (param i32 i32 i32)))
|
||||
(import "seal0" "seal_delegate_call" (func $seal_delegate_call (param i32 i32 i32 i32 i32 i32) (result i32)))
|
||||
(import "__unstable__" "reentrant_count" (func $reentrant_count (result i32)))
|
||||
(import "__unstable__" "reentrance_count" (func $reentrance_count (result i32)))
|
||||
(import "env" "memory" (memory 1 1))
|
||||
|
||||
;; [0, 32) buffer where code hash is copied
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
;; reentrance count stays 0
|
||||
(call $assert
|
||||
(i32.eq (call $reentrant_count) (i32.const 0))
|
||||
(i32.eq (call $reentrance_count) (i32.const 0))
|
||||
)
|
||||
|
||||
(i32.eq (get_local $callstack_height) (i32.const 5))
|
||||
Reference in New Issue
Block a user