Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unimplemented precompiles on L2s are treated as implemented #6230

Closed
2 tasks done
zobront opened this issue Nov 6, 2023 · 1 comment
Closed
2 tasks done

Unimplemented precompiles on L2s are treated as implemented #6230

zobront opened this issue Nov 6, 2023 · 1 comment
Labels
T-bug Type: bug

Comments

@zobront
Copy link

zobront commented Nov 6, 2023

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (fd90b1d 2023-11-06T20:43:26.902623000Z)

What command(s) is the bug in?

forge test

Operating System

macOS (Apple Silicon)

Describe the bug

Since precompiles are implemented in revm, they're intercepted from forge test calls before reaching the network.

For L2s that don't implement certain precompiles (for example, Polygon zkEVM only implements ecRecover and identity - most other ZK rollups are similarly limited), this can lead to inaccurate behavior, where fork tests that call to precompiles will succeed when they should fail.

To reproduce:

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Test, console2} from "forge-std/Test.sol";

contract PrecompileTest is Test {
    function testPrecompiles() public {
        vm.createSelectFork("https://zkevm-rpc.com");
        bytes memory input = "hello";
        (bool s, bytes memory d) = address(2).call(input);
        console2.log(s);
        console2.logBytes(d);
    }
}
Logs:
  true
  0x2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824

Compare this to the cast call, which presumable pings the actual RPC node for a response:

zachobront@Zachs-MacBook-Pro prec % cast call 0x0000000000000000000000000000000000000002 --rpc-url "https://zkevm-rpc.com" 0x12345678
Error: 
(code: 3, message: execution reverted, data: Some(String("0x")))
@zobront zobront added the T-bug Type: bug label Nov 6, 2023
@gakonst gakonst added this to Foundry Nov 6, 2023
@github-project-automation github-project-automation bot moved this to Todo in Foundry Nov 6, 2023
@DaniPopes
Copy link
Member

DaniPopes commented Nov 7, 2023

This is known. We currently only support mainnet precompiles which are implemented in Revm, and there's no way to configure this in Foundry. See also #748.

@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
Archived in project
Development

No branches or pull requests

2 participants