Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
1 change: 1 addition & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ impl pallet_contracts::Config for Runtime {
type MaxValueSize = MaxValueSize;
type WeightPrice = pallet_transaction_payment::Module<Self>;
type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
type ChainExtension = ();
}

impl pallet_sudo::Config for Runtime {
Expand Down
46 changes: 46 additions & 0 deletions frame/contracts/fixtures/chain_extension.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
;; Call chain extension by passing through input and output of this contract
(module
(import "seal0" "seal_call_chain_extension"
(func $seal_call_chain_extension (param i32 i32 i32 i32 i32) (result i32))
)
(import "seal0" "seal_input" (func $seal_input (param i32 i32)))
(import "seal0" "seal_return" (func $seal_return (param i32 i32 i32)))
(import "env" "memory" (memory 16 16))

(func $assert (param i32)
(block $ok
(br_if $ok (get_local 0))
(unreachable)
)
)

;; [0, 4) len of input output
(data (i32.const 0) "\02")

;; [4, 12) buffer for input

;; [12, 16) len of output buffer
(data (i32.const 12) "\02")

;; [16, inf) buffer for output

(func (export "deploy"))

(func (export "call")
(call $seal_input (i32.const 4) (i32.const 0))

;; the chain extension passes through the input and returns it as output
(call $seal_call_chain_extension
(i32.load8_u (i32.const 4)) ;; func_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
(call $assert (i32.eq (i32.load8_u (i32.const 4))))

(call $seal_return (i32.const 0) (i32.const 16) (i32.load (i32.const 12)))
)
)
6 changes: 3 additions & 3 deletions frame/contracts/fixtures/set_rent.wat
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@
)
(i32.store (i32.const 128) (i32.const 64))
(call $seal_input
(i32.const 104)
(i32.const 100)
(i32.const 132)
(i32.const 128)
)
(call $seal_set_rent_allowance
(i32.const 104)
(i32.const 132)
(i32.load (i32.const 128))
)
)
Expand Down
Loading