mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 06:17:56 +00:00
e70ffbf44d
* poc logic * set_code_hash impl, tests, benchmark * Address @xgreenx's comments * Move func defs closer to set_storage * Check if code exists - increment/decrement codehash refcount * Document error for non-existing code hash * Revert unrelated change * Changes due to @athei's review * Fix error handling - comment errors: ReturnCodes - update mock ext implementation - return Error::CodeNotFound when no code for such hash * Emit ContractCodeUpdated when setting new code_hash * Address @athei's comments * Move related defs to the bottom * Minor comment update Co-authored-by: Alexander Theißen <alex.theissen@me.com> * Improve docs * Improve docs * Update frame/contracts/src/wasm/runtime.rs Co-authored-by: Alexander Theißen <alex.theissen@me.com> * Refactor set_code_hash test * Minor change to benchmark Co-authored-by: Alexander Theißen <alex.theissen@me.com> * Minor change to benchmark Co-authored-by: Alexander Theißen <alex.theissen@me.com> * Minor comment refactor Co-authored-by: Alexander Theißen <alex.theissen@me.com> * Address @HCastano's comments * Update seal_set_code_hash comment Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com> * Move set_code_hash after delegate_call * Move function to the bottom * Moved and changed banchmark, added verify block * Bring back previous benchmark * Remove skip_meta for seal_set_code_hash * Bring back skip_meta for seal_set_storage_per_new_kb * Apply weights Co-authored-by: Alexander Theißen <alex.theissen@me.com> Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
44 lines
1.0 KiB
WebAssembly Text Format
44 lines
1.0 KiB
WebAssembly Text Format
(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"))
|
|
)
|