contracts: Allow ChainExtension::call() to access &mut self (#11874)

* Give chain extensions the ability to store some temporary values

* Update frame/contracts/src/wasm/runtime.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* Rename func_id -> id

* Replace `id` param by two functions on `env`

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
This commit is contained in:
Alexander Theißen
2022-07-25 17:48:01 +02:00
committed by GitHub
parent 626140454d
commit c470e9d11d
6 changed files with 254 additions and 56 deletions
@@ -31,14 +31,14 @@
;; the chain extension passes through the input and returns it as output
(call $seal_call_chain_extension
(i32.load (i32.const 4)) ;; func_id
(i32.load (i32.const 4)) ;; id
(i32.const 4) ;; input_ptr
(i32.load (i32.const 0)) ;; input_len
(i32.const 16) ;; output_ptr
(i32.const 12) ;; output_len_ptr
)
;; the chain extension passes through the func_id
;; the chain extension passes through the id
(call $assert (i32.eq (i32.load (i32.const 4))))
(call $seal_return (i32.const 0) (i32.const 16) (i32.load (i32.const 12)))