Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

contracts: Replace sp-sandbox and wasmi-validation by newest wasmi #12501

Merged
merged 39 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6ffeb48
Replace sp-sandbox and wasmi-validation by just wasmi
athei Oct 11, 2022
c50559e
Merge branch 'master' of https://github.com/paritytech/substrate into…
Oct 28, 2022
8198e35
".git/.scripts/bench-bot.sh" pallet dev pallet_contracts
Oct 28, 2022
6fb5d29
Merge branch 'master' into at/contracts-wasmi
athei Oct 29, 2022
d0f29e4
Merge branch 'master' into at/contracts-wasmi
athei Oct 30, 2022
e3d3dfb
Re-check original code on re-instrumentation
athei Oct 30, 2022
cf4224b
Merge branch 'master' into at/contracts-wasmi
athei Oct 30, 2022
0386a55
Fix clippy
athei Oct 30, 2022
722fd97
Merge branch 'master' of https://github.com/paritytech/substrate into…
Oct 31, 2022
29a48fe
".git/.scripts/bench-bot.sh" pallet dev pallet_contracts
Oct 31, 2022
5b762e2
Merge branch 'master' into at/contracts-wasmi
athei Nov 13, 2022
6641366
Apply suggestions from code review
athei Nov 13, 2022
59aaea8
Replace wasmi by ::wasmi
athei Nov 13, 2022
ac6c957
Bump wasmi to 0.20
athei Nov 13, 2022
8339073
Add explanation for `unreachable`
athei Nov 13, 2022
4a32321
Change proof
athei Nov 13, 2022
f3af361
Merge branch 'master' into at/contracts-wasmi
athei Nov 15, 2022
f161f9d
Fixup master merge
athei Nov 15, 2022
6a847b0
Merge branch 'master' into at/contracts-wasmi
athei Nov 15, 2022
938901b
".git/.scripts/bench-bot.sh" pallet dev pallet_contracts
Nov 15, 2022
204be29
Merge branch 'master' into at/contracts-wasmi
athei Nov 17, 2022
f3ce2fd
Fixup naming inconsistencies introduced by reentrancy PR
athei Nov 17, 2022
589a100
Fix `scan_imports` docs
athei Nov 17, 2022
8505a54
Apply suggestions from code review
athei Nov 17, 2022
9244642
Fixup suggestions
athei Nov 17, 2022
af4e34f
Remove unnecessary &mut
athei Nov 17, 2022
94b30c2
Fix test
athei Nov 17, 2022
ec7522e
".git/.scripts/bench-bot.sh" pallet dev pallet_contracts
Nov 17, 2022
8df8b70
Fix benchmark merge fail
athei Nov 18, 2022
2a2af0b
Merge branch 'master' of https://github.com/paritytech/substrate into…
Nov 18, 2022
fee21da
".git/.scripts/bench-bot.sh" pallet dev pallet_contracts
Nov 18, 2022
6e0cd71
Merge branch 'master' into at/contracts-wasmi
athei Nov 22, 2022
8dcab8f
Fix docs as suggested by code review
athei Nov 22, 2022
a79fc1a
Improve docs for `CodeRejected`
athei Nov 22, 2022
442917e
Apply suggestions from code review
athei Nov 22, 2022
b6e79c3
Merge branch 'master' into at/contracts-wasmi
athei Nov 24, 2022
4b10d3f
Fix logic bug when setting `deterministic_only`
athei Nov 24, 2022
631d6df
Don't panic when module fails to compile
athei Nov 24, 2022
d39f085
Apply suggestions from code review
athei Nov 24, 2022
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
70 changes: 60 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions frame/contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ serde = { version = "1", optional = true, features = ["derive"] }
smallvec = { version = "1", default-features = false, features = [
"const_generics",
] }
wasmi-validation = { version = "0.5", default-features = false }
wasmi = { version = "0.20", default-features = false }
wasmparser = { package = "wasmparser-nostd", version = "0.91", default-features = false }
impl-trait-for-tuples = "0.2"

# Only used in benchmarking to generate random contract code
Expand All @@ -42,7 +43,6 @@ sp-api = { version = "4.0.0-dev", default-features = false, path = "../../primit
sp-core = { version = "7.0.0", default-features = false, path = "../../primitives/core" }
sp-io = { version = "7.0.0", default-features = false, path = "../../primitives/io" }
sp-runtime = { version = "7.0.0", default-features = false, path = "../../primitives/runtime" }
sp-sandbox = { version = "0.10.0-dev", default-features = false, path = "../../primitives/sandbox" }
sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" }

[dev-dependencies]
Expand All @@ -69,16 +69,16 @@ std = [
"sp-runtime/std",
"sp-io/std",
"sp-std/std",
"sp-sandbox/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"wasm-instrument/std",
"wasmi-validation/std",
"wasmi/std",
"pallet-contracts-primitives/std",
"pallet-contracts-proc-macro/full",
"log/std",
"rand/std",
"wasmparser/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,7 +21,6 @@
(func (export "call")
(unreachable)
)
(func (export "deploy"))

(data (i32.const 8) "\01\02\03\04")
)
4 changes: 4 additions & 0 deletions frame/contracts/fixtures/invalid_contract.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
;; Valid module but missing the call function
(module
(func (export "deploy"))
)
6 changes: 0 additions & 6 deletions frame/contracts/fixtures/invalid_import.wat

This file was deleted.

8 changes: 8 additions & 0 deletions frame/contracts/fixtures/invalid_module.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
;; An invalid module
(module
(func (export "deploy"))
(func (export "call")
;; imbalanced stack
(i32.const 7)
)
)
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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))
Expand Down
Loading