Implement keccak256 operator and softfork
Implements CHIP-36, using the implementation originally provided by @arvidn in https://github.com/Chia-Network/clvm_rs/pull/403 for CHIP-34.
New operators
There is 1 new operator enabled under softfork 1:
| operator | opcode |
|---|---|
keccak256 |
64 |
Cost
| operator | base cost | per argument | per byte |
|---|---|---|---|
keccak256 |
50 | 160 | 2 |
As always, there's also a cost of 10 per byte that's allocated for the return value.
Activation
Since this is a softfork, the extension will only be available when the ENABLE_KECCAK flag is set, which it will be after the softfork activates.
The operators will only be available for programs (<prg>) executing under (softfork <cost> 1 <prg> <arg>)
Hard fork
There's an option to hard-fork these operators out of the softfork-guard by specifying ENABLE_KECCAK_OPS_OUTSIDE_GUARD.
Tests
The test vectors are generated using the python wheel from eth_hash.auto import keccak.
Pull Request Test Coverage Report for Build 11730142584
Details
- 29 of 29 (100.0%) changed or added relevant lines in 3 files are covered.
- No unchanged relevant lines lost coverage.
- Overall coverage increased (+0.06%) to 93.406%
| Totals | |
|---|---|
| Change from base Build 11574796277: | 0.06% |
| Covered Lines: | 5595 |
| Relevant Lines: | 5990 |
💛 - Coveralls
did you generate the fuzzing corpus and run the fuzzer for a while?