Skip to content

Conversation

@Robbepop
Copy link
Collaborator

Closes #474

Robbepop added 26 commits July 23, 2020 22:36
Previously returned Option<Result<R>> and now returns Result<Option<R>>.
This change is more pragmatic.
- EncodeScope: for efficiently appending encoded values
- ScopedBuffer: for efficiently chunking buffers
We should also rename this to simply "input" later.
Now also uses the new ReturnFlags abstraction.
- No more length
- No more encodable
- Only full range access
@Robbepop
Copy link
Collaborator Author

Robbepop commented Aug 25, 2020

Upcoming API changes to ext_transfer, ext_instantiate, ext_call: paritytech/substrate#6773
But I guess this PR only targets RC5, right?

This PR mainly targets to fully sync with Substrate's latest changes. So we will include those as well so that we are in sync again (finally).

Changes have been implemented and I have been able to build the Flipper contract using cargo-contract again:

2020-08-25-105809_627x163_scrot

Generated Wasm file header for the Flipper smart contract:

(module
  (type (;0;) (func))
  (type (;1;) (func (param i32)))
  (type (;2;) (func (param i32 i32)))
  (type (;3;) (func (param i32 i32 i32)))
  (type (;4;) (func (result i32)))
  (type (;5;) (func (param i32) (result i32)))
  (type (;6;) (func (param i32 i32 i32) (result i32)))
  (import "seal0" "seal_input" (func (;0;) (type 2)))
  (import "seal0" "seal_get_storage" (func (;1;) (type 6)))
  (import "seal0" "seal_set_storage" (func (;2;) (type 3)))
  (import "seal0" "seal_clear_storage" (func (;3;) (type 1)))
  (import "seal0" "seal_return" (func (;4;) (type 3)))
  (import "env" "memory" (memory (;0;) 2 16))
  ...
)

We no longer support the get_runtime_storage host function.
It will eventually be reintroduced at a later point through chain extensions.
Can be enabled by experimental crate feature:
- unstable_chain_extensions
@codecov-commenter
Copy link

codecov-commenter commented Aug 25, 2020

Codecov Report

Merging #478 into master will decrease coverage by 0.37%.
The diff coverage is 67.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #478      +/-   ##
==========================================
- Coverage   85.36%   84.99%   -0.38%     
==========================================
  Files         127      127              
  Lines        5501     5497       -4     
==========================================
- Hits         4696     4672      -24     
- Misses        805      825      +20     
Impacted Files Coverage Δ
core/src/env/backend.rs 0.00% <0.00%> (ø)
core/src/env/engine/off_chain/test_api.rs 67.85% <ø> (ø)
core/src/storage2/traits/mod.rs 100.00% <ø> (ø)
lang/macro/src/ir/data.rs 93.18% <0.00%> (+2.07%) ⬆️
core/src/env/api.rs 87.50% <100.00%> (ø)
core/src/env/engine/off_chain/chain_extension.rs 100.00% <100.00%> (ø)
core/src/env/engine/off_chain/db/accounts.rs 81.69% <100.00%> (ø)
core/src/env/engine/off_chain/impls.rs 93.33% <100.00%> (ø)
core/src/env/engine/off_chain/mod.rs 89.47% <100.00%> (-0.27%) ⬇️
core/src/storage2/traits/optspec.rs 89.28% <100.00%> (-0.37%) ⬇️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eeb6bc0...402728d. Read the comment docs.

Copy link
Contributor

@athei athei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only complaint is the ReturnCode casting which seems unsound.

}

/// Invokes the chain extension with the given parameters.
pub fn invoke<I, O>(&mut self, func_id: FuncId, input: &I) -> Result<O>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You rename it or keep it as invoke?

@Robbepop Robbepop changed the title Sync with substrate rc5 Sync with substrate rc6 Aug 25, 2020
@Robbepop Robbepop changed the title Sync with substrate rc6 Sync with Substrate RC6 Aug 25, 2020
@Robbepop Robbepop merged commit ba5aed1 into master Aug 25, 2020
@Robbepop Robbepop deleted the sync-substrate-rc5 branch August 25, 2020 18:44
cmichi pushed a commit that referenced this pull request Sep 2, 2020
* [core] remove get_runtime_storage and invoke_runtime

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

* [core] adjust ext_ functions in ext.rs

* [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 buffer.rs

* [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 <[email protected]>

* [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 <[email protected]>

* [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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sync with most recent Substrate changes

6 participants