ink icon indicating copy to clipboard operation
ink copied to clipboard

Pass large environmental ink! types by reference

Open Robbepop opened this issue 4 years ago • 1 comments

Below is a list of isolated actionable items that may reduce the Wasm file size of certain ink! smart contracts if applied correctly and thoroughly throughout the ink! codebase and codegen.

If you want to tackle one or multiple of these tasks please open a PR with a link to this issue and reply in this thread so that we can link back.

Todo List

  • [ ] Retire ToAccountId and replace with AsRef<AccountId>.
    • Returning a reference instead of a value type is important for AccountId types which are usually 256-bits in size and therefore too big to be efficiently computed by a Wasm VM.
  • [ ] Make EnvAccess API use references as inputs to big environmental types such as AccountId.
  • [ ] Make ink_env::CallBuilder API use references as inputs to big environmental types such as AccountId.
    • WIP: https://github.com/paritytech/ink/pull/970
  • [ ] Make it possible for collections such as ink_storage::HashMap<(K1, K2), V> to use the get method using a key of type (&K1, &K2) instead of &(K1, K2).
    • For this parity-scale-codec's EncodeLike trait might become very helpful to us: Documentation
    • First implemented in: https://github.com/paritytech/ink/pull/979
  • [ ] Make it possible to use references when emitting ink! events: https://github.com/paritytech/ink/issues/990
  • [ ] Make it possible to accept references as inputs to ink! constructors and messages: https://github.com/paritytech/ink/issues/989

Robbepop avatar Oct 06 '21 09:10 Robbepop

I began working on:

Make ink_env::CallBuilder API use references as inputs to big environmental types such as AccountId.

However, it is a bit unfortunate to work on it before #665 has been merged since most of the work for the ink! codegen has to be redone there. I am not done entirely but already see some improvements for the Delegator example contract.

Robbepop avatar Oct 19 '21 21:10 Robbepop