design
design copied to clipboard
Provide kecccak256 host function
EVM has an keccak instruction, webassembly does not. Because of this, https://github.com/hyperledger-labs/solang has to include a keccak implementation in any contract which does keccak hashing. Keccak hashing is used for mappings and storage arrays.
It would be much better if the EEI provided a keccak host function.
Note that Substrate wasm interface does provide this and another hashing functions too: https://github.com/paritytech/substrate/blob/master/frame/contracts/src/wasm/runtime.rs#L1199
This file is compiled to wasm by clang and linked into every ewasm contract: https://github.com/hyperledger-labs/solang/blob/master/stdlib/sha3.c
Please note there is a proposed precompile instead of a host function: https://github.com/ewasm/design/blob/master/system_contracts.md#keccak256
Ah I had missed that, thanks.
A host function is much better, this has much lower gas cost (no call overhead). This would help make ewasm competitive with evm.