Proof of concept: Add a new runtime that uses pallet_contracts (#186)

* seal: Copy over a legacy version of pallet_contracts from substrate

* seal: Fix substrate dependency pathes and add as dependency to runtime

* seal: Adapt pallet to current substrate version

* seal: Add contracts pallet to runtime

* seal: Implement rpc runtime api

* seal: Update to latest rpc output format

* seal: Replace child trie by prefix trie

* seal: Add contracts endpoint to the client

* seal: fixup rpc test

* Fix whitespace issue

Co-authored-by: Sergei Shulepov <sergei@parity.io>

* seal: Move pallet out of the runtime directory

* seal: Create a seperate runtime for contracts

* Move parachains to top level directory

* seal: Disable rent for easier testing

Co-authored-by: Sergei Shulepov <sergei@parity.io>
This commit is contained in:
Alexander Theißen
2020-08-07 17:41:15 +02:00
committed by GitHub
parent 10533db948
commit 8a6e29eef9
63 changed files with 13517 additions and 148 deletions
@@ -0,0 +1,54 @@
(module
(import "env" "ext_scratch_size" (func $ext_scratch_size (result i32)))
(import "env" "ext_scratch_read" (func $ext_scratch_read (param i32 i32 i32)))
(import "env" "ext_balance" (func $ext_balance))
(import "env" "ext_call" (func $ext_call (param i32 i32 i64 i32 i32 i32 i32) (result i32)))
(import "env" "memory" (memory 1 1))
(func $assert (param i32)
(block $ok
(br_if $ok
(get_local 0)
)
(unreachable)
)
)
(func (export "deploy")
;; Send entire remaining balance to the 0 address.
(call $ext_balance)
;; Balance should be encoded as a u64.
(call $assert
(i32.eq
(call $ext_scratch_size)
(i32.const 8)
)
)
;; Read balance into memory.
(call $ext_scratch_read
(i32.const 8) ;; Pointer to write balance to
(i32.const 0) ;; Offset into scratch buffer
(i32.const 8) ;; Length of encoded balance
)
;; Self-destruct by sending full balance to the 0 address.
(call $assert
(i32.eq
(call $ext_call
(i32.const 0) ;; Pointer to destination address
(i32.const 8) ;; Length of destination address
(i64.const 0) ;; How much gas to devote for the execution. 0 = all.
(i32.const 8) ;; Pointer to the buffer with value to transfer
(i32.const 8) ;; Length of the buffer with value to transfer
(i32.const 0) ;; Pointer to input data buffer address
(i32.const 0) ;; Length of input data buffer
)
(i32.const 0)
)
)
)
(func (export "call"))
)