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

Create2 revert, if done via SystemContractsCaller.systemCallWithReturndata #364

Open
2 tasks done
vladenysiuk opened this issue May 8, 2024 · 0 comments
Open
2 tasks done
Labels

Comments

@vladenysiuk
Copy link

vladenysiuk commented May 8, 2024

Component

Other (please describe)

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.0.2 (eda9078 2024-05-03T00:24:49.741164000Z)

What command(s) is the bug in?

forge test --is-system true --zksync

Operating System

macOS (Apple Silicon)

Describe the bug

When I try to execute low level system call to deployer system contract to execute create2 --- execution reverts:

contract TestDeploy is Test {
    
    
    function test_Deploy() public {
        address deployerWallet = makeAddr("deployer");
        vm.prank(deployerWallet);
        Auxiliary aux = new Auxiliary();
        aux.deploy(beaconProxyBytecodeHash, salt);
        
    }
}

deploy function (should be executed in zkEVM as external call):

contract Auxiliary{
    function deploy(bytes32 l2TokenProxyBytecodeHash,bytes32 salt) public {
        (bool success, bytes memory returndata) = SystemContractsCaller.systemCallWithReturndata(
            uint32(gasleft()),
            DEPLOYER_SYSTEM_CONTRACT,
            0,
            abi.encodeCall(
                IContractDeployer.create2,
                (salt, l2TokenProxyBytecodeHash, abi.encode(address(0), ""))
            )
        );
        if(!success) {
            assembly {
                returndatacopy(0,0,returndatasize())
                revert(0, returndatasize())
            }
        }
    }
Forge output:
Failing tests:
    Encountered 1 failing test in test/foundry/TestDeploy.t.sol:TestDeploy
    [FAIL. Reason: EvmError: Revert] test_Deploy() (gas: 37420)

foundry.toml:

[profile.default]
src = 'contracts'
out = 'out'
libs = ['node_modules', 'lib']
test = 'test/foundry'
cache_path = 'cache_forge'

[profile.zksync]
src = 'contracts'
libs = ['lib']
fallback_oz = true
test = 'test/foundry'
is_system = true
mode = "3"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant