Pass large environmental ink! types by reference
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
ToAccountIdand replace withAsRef<AccountId>.- Returning a reference instead of a value type is important for
AccountIdtypes which are usually 256-bits in size and therefore too big to be efficiently computed by a Wasm VM.
- Returning a reference instead of a value type is important for
- [ ] Make
EnvAccessAPI use references as inputs to big environmental types such asAccountId. - [ ] Make
ink_env::CallBuilderAPI use references as inputs to big environmental types such asAccountId.- WIP: https://github.com/paritytech/ink/pull/970
- [ ] Make it possible for collections such as
ink_storage::HashMap<(K1, K2), V>to use thegetmethod using a key of type(&K1, &K2)instead of&(K1, K2).- For this
parity-scale-codec'sEncodeLiketrait might become very helpful to us: Documentation - First implemented in: https://github.com/paritytech/ink/pull/979
- For this
- [ ] 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
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.