-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(levm): modexp pass only first 32 bytes to gas_cost, fix get_slice…
…_or_default (#1572) **Motivation** The modexp precompile was failing in some cases because get_slice_or_default was returning None when not enough calldata was passed, there was a bug in the gas_cost calculation, we need to pass to the gas_cost function the first 32 bytes of the exponent we were passing the whole exponent. **Description** - `get_slice_or_default` creates a vec initialized with zeroes with size:`size_to_expand`, then copies byte by byte the calldata until `upper_limit` or `calldata.len()` whichever is lower, - we return an empty vector (this translates to the value 0 when converted to UINT) if the range is invalid. - the gas_cost function now gets the first 32 bytes of the exponent, if `e_size < 32` we pass the whole exponent, the name of the variable in the gas_cost function was changed to reflect this change.
- Loading branch information
Showing
2 changed files
with
23 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters