foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.27k stars 1.74k forks source link

Add new precompiled contract for SECP256R1 signature verification #7637

Closed EWCunha closed 1 month ago

EWCunha commented 6 months ago

Component

Forge

Describe the feature you would like

There is a new precompiled contract for SECP256R1 signature verifications on Polygon networks. The precompiled address is 0x0000000000000000000000000000000000000100.

Additional context

While testing, I tried forking Mumbai and Polygon networks to test the new precompiled contract and verify a SECP256R1 signature, but the test was not working. I realized that maybe forge is not aware of this new precompiled address.

For more context: https://forum.polygon.technology/t/pip-27-precompiled-for-secp256r1-curve-support/13049/5?u=manuechanove https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md

mattsse commented 6 months ago

this will be possible very shortly

zerosnacks commented 3 months ago

@mattsse is the current recommended way of handling this via vm.etch?

https://book.getfoundry.sh/cheatcodes/etch#using-vmetch-for-enabling-custom-precompiles

grandizzy commented 1 month ago

@EWCunha this should be available in latest forge build, please retest and reopen if issues. thank you!

preston4896 commented 4 days ago

hey @grandizzy , i just updated Foundry with the version:

forge 0.2.0 (a428ba6 2024-10-29T00:21:52.576754000Z)

But it still seems that Foundry isn't able to locate the P256 precompile when running cast call, this is what I am getting from my call trace:

    │   ├─ [0] 0x0000000000000000000000000000000000000100::1b9195f8(67e494c27ec1e6cc1d58139dc82effad48936cb8e8bb872aadedee03dc78b64ceb56213ee8a004be5b49f758325ba9558ea549057c8a1c5ca3e3f9d7e778a3246dc745091f5b05a4479c626bf1e9e9c20affd6cd04bdf8b220dfec5335207feeddb595748ed82bb3a71c3be1e241ef61320c6816e6b5c2b71dad5532eaea12a4eb3f948916429ea47ba6c3af82a15e4b19664e52657939a2d96633de) [staticcall]
    │   │   └─ ← [Stop] 
    │   └─ ← [Revert] EvmError: Revert