0xPolygonZero / plonky2

Apache License 2.0
757 stars 283 forks source link

Optimize `num_bytes` and `hex_prefix_rlp` #1384

Closed 4l0n50 closed 9 months ago

4l0n50 commented 9 months ago

We compute num_bytes by non-deterministically guessing the number of bits and checking that number >> number_of_bits - 1 == 1 (if number != 0). For hex_prefix_rlp, instead of writing the nibbles to the rlp segment one by one, we remove the first nibble (if necessary) directly on the packed nibbles and then write them using mstore_unpacking. For the ERC20 test, we get the following improvements on cpu and memory: CPU trace: 168206 -> 153563 Memory trace: 694042 -> 648593

sonarcloud[bot] commented 9 months ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information