Near-One / rainbow-bridge

🌈🌈🌈 NEAR <> Ethereum Decentralized Bridge
GNU General Public License v3.0
327 stars 100 forks source link

`eth-types`: Fix `GasLimitExceeded` error #896

Closed karim-en closed 1 year ago

karim-en commented 1 year ago

The hash function near_sdk::env::keccak256 randomly panics HostError(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 avoid GasLimitExceeded error.

karim-en commented 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.