contracts: Allow runtime authors to define a chain extension (#7548)

* Make host functions return TrapReason

This avoids the need to manually store any trap reasons
to the `Runtime` from the host function. This adds the following
benefits:

* It properly composes with the upcoming chain extensions
* Missing to set a trap value is now a compile error

* Add chain extension

The chain extension is a way for the contract author to add new
host functions for contracts to call.

* Add tests for chain extensions

* Fix regression in set_rent.wat fixture

Not all offsets where properly updated when changing the fixtures
for the new salt on instantiate.

* Pre-charge a weight amount based off the specified length

* Improve fn write docs

* Renamed state to phantom

* Fix typo
This commit is contained in:
Alexander Theißen
2021-01-04 12:15:17 +01:00
committed by GitHub
parent e3e651f72c
commit 51c37ecc15
10 changed files with 768 additions and 37 deletions
@@ -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))
)
)