aurora-is-near / aurora-engine

⚙️ Aurora Engine implements an Ethereum Virtual Machine (EVM) on the NEAR Protocol.
https://doc.aurora.dev/develop/compat/evm
326 stars 78 forks source link

Fix(engine): More efficient modexp implementation #757

Closed birchmd closed 1 year ago

birchmd commented 1 year ago

Description

This PR replaces the modexp implementation with a more efficient one. This addresses a performance issue that has been raised to us.

Performance / NEAR gas cost considerations

The PR is all about performance. New benchmarks are added for modexp. We also see the gas cost go down for repro_Emufid2 because that transaction uses the modexp precompile.

Testing

New code includes unit tests. We also have the existing modexp tests.

How should this be reviewed

The code here is a little hard to read because it is implementing very low-level algorithms. Reviewers are welcome to read the papers referenced in the README to help get the overall idea of what is going on in the code. The correctness of this code has also been validated by comparing many cases against the results of other Rust libraries (ibig and num-bigint).