Sync with Substrate RC6 (#478)

* [core] remove get_runtime_storage and invoke_runtime

* [core] invalidate all implementations and usages of ext functions

* [core] adjust ext_ functions in

* [core] add ReturnFlags to public API

* [core] remove off-chain impls for get_runtime_storage and invoke_runtime

* [core] rename ext::ext_input -> ext::input

* [core] change return type of get_contract_storage

Previously returned Option<Result<R>> and now returns Result<Option<R>>.
This change is more pragmatic.

* [core] add conversion from ext::Error to EnvError

* [core] on-chain: add new utilities for static buffer modifications

- EncodeScope: for efficiently appending encoded values
- ScopedBuffer: for efficiently chunking buffers

* [core] add impls for on-chain property getters

* [core] remove no longer needed utiltiy function

* [core] on-chain: new impl for invoke_contract and eval_contract

* [core] on-chain: new impl for get_contract_storage

* [core] on-chain: new impl for decode_input

We should also rename this to simply "input" later.

* [core] on-chain: new impl for output

Now also uses the new ReturnFlags abstraction.

* [core] on-chain: new impl for instantiate_contract

* [core] on-chain: remove unused API

* [core] on-chain: move EncodeScope and ScopedBuffer to

* [core] on-chain: implement rest of the on-chain API

* [core] add ScopedBuffer::take_bytes

* [core] Add Env::call_chain_extension trait method

* [core] remove unused helper methods

* [core] on-chain: simplify static buffer

- No more length
- No more encodable
- Only full range access

* [core] add env::call_chain_extension public API

* [core] rename Env::output -> return_value

* [core] off-chain: adjust a bunch of off-chain methods to new interfaces

* [core] off-chain: adjust get_contract_storage return type

* [core] off-chain: remove RuntimeCallHandler and RuntimeStorage facilities

* [core] off-chain: adjust some tests

* [core] off-chain: remove OffCall utility type

* [core] off-chain: implement chain extension handler

* [core] adjust panic message

* [core] apply rustfmt

* [core] apply clippy suggestion

* [core] off-chain: re-export ChainExtension and ChainSpec types from test API

* [core] on-chain: retain panic messages

* [core] rename ext_ to seal_ for all on-chain functions

* [alloc] fix some warnings and add some minor comments

* [core] add wasm_import_module = "seal0"

* [core] introduce new Seal error codes

* [core] directly return ReturnCode from C-FII

* [core] make transfer return Result

* [core] improve some doc comments

* rename some old errors to their new names

* [core] remove unused env errors and rename some off-chain errors

* [core] fix bug in ReturnFlags::set_reverted (formerly known as set_trapped)

* [core] avoid From impl for () for OffChainError

* [lang] adjust lang layer for changes in core

- Remove invoke_runtime
- Remove get_runtime_storage
- Rename gas_price -> weight_to_fee
- Add ReturnFlags to return_value call

* [core] turn redundant asserts into debug_assert

* [core] be more strict when handling ext::get_storage error

* [core] implement clippy suggestion

* [examples] remove no longer useful runtime-storage contract

We no longer support the get_runtime_storage host function.
It will eventually be reintroduced at a later point through chain extensions.

* [core] disable chain extensions by default

Can be enabled by experimental crate feature:
- unstable_chain_extensions

* [lang] apply clippy suggestion to use matches! macro

* [core] fix docs for ext_return

Co-authored-by: Alexander Theißen <>

* [core] fix return type of api::return_value

Not sure why the compiler didn't mention this return type failure ...

Co-authored-by: Alexander Theißen <>

* [core] fix doc comment of Env::return_value

* [core] introduce RawReturnCode as a layer between Seal error codes and ink!

* [alloc] make #[alloc_error_handler] private

* [alloc, core] move alloc_handler from ink_alloc to ink_core

* [core] replace useless intermediate ReturnCode type

* [core] rename RawReturnCode -> ReturnCode

* [core] apply rustfmt

* [core] apply rustfmt

* [core] off-chain: rename invoke -> eval for chain extension calling

* [core] use Ptr32 and Ptr32Mut to encapsulate pointer -> u32 conversions

* [core] make new Ptr32 and Ptr32Mut abstractions more type safe

Co-authored-by: Alexander Theißen <>
71 jobs for master in 5 minutes and 42 seconds (queued for 3 seconds)