forked from paritytech/substrate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set_code_hash impl, tests, benchmark
- Loading branch information
1 parent
b1dd3d7
commit 3d525a2
Showing
8 changed files
with
841 additions
and
625 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(module | ||
(import "seal0" "seal_return" (func $seal_return (param i32 i32 i32))) | ||
(import "env" "memory" (memory 1 1)) | ||
|
||
;; [0, 32) return value | ||
(data (i32.const 0) "\11") | ||
|
||
(func (export "deploy")) | ||
|
||
(func (export "call") | ||
(call $seal_return (i32.const 0) (i32.const 0) (i32.const 4)) | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
(module | ||
(import "seal0" "seal_input" (func $seal_input (param i32 i32))) | ||
(import "seal0" "seal_return" (func $seal_return (param i32 i32 i32))) | ||
(import "__unstable__" "seal_set_code_hash" (func $seal_set_code_hash (param i32) (result i32))) | ||
|
||
(import "env" "memory" (memory 1 1)) | ||
|
||
;; [0, 32) here we store input | ||
|
||
;; [32, 36) input size | ||
(data (i32.const 32) "\20") | ||
|
||
;; [36, 40) return value | ||
(data (i32.const 36) "\01") | ||
|
||
(func $assert (param i32) | ||
(block $ok | ||
(br_if $ok | ||
(get_local 0) | ||
) | ||
(unreachable) | ||
) | ||
) | ||
|
||
(func (export "call") | ||
(local $exit_code i32) | ||
|
||
(call $seal_input (i32.const 0) (i32.const 32)) | ||
|
||
(set_local $exit_code | ||
(call $seal_set_code_hash (i32.const 0)) ;; Pointer to the input data. | ||
) | ||
(call $assert | ||
(i32.eq (get_local $exit_code) (i32.const 0)) ;; ReturnCode::Success | ||
) | ||
|
||
;; we return 1 after setting new code_hash | ||
;; next call will NOT return this value, because contract code has been changed | ||
(call $seal_return (i32.const 0) (i32.const 36) (i32.const 4)) | ||
) | ||
|
||
(func (export "deploy")) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.