Closed karim-en closed 1 year ago
Why can't we use
sha3
package only for both scenarios?
The gas usage will be increased in this case, because the near_sdk::env::keccak256
is a precompile call, the target node calculates the hash in its native environment.
The hash function
near_sdk::env::keccak256
randomly panicsHostError(GasLimitExceeded)
when calling it not in a near contract because it executes the code in the VM environment. This code is used by other apps and services that running in the ARM/X86 environments to calculate the block hash, so native sha3 should be used instead of the one from near SDK to improve the performance and to avoidGasLimitExceeded
error.