foundry icon indicating copy to clipboard operation
foundry copied to clipboard

bug(`forge`): deterministic address changed after updating forge version

Open Keref opened this issue 6 months ago • 6 comments

Component

Forge

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

  • [X] Foundry
  • [X] Foundryup

What version of Foundry are you on?

forge 0.2.0 (f2518c9 2024-08-06T00:20:17.084842600Z)

What command(s) is the bug in?

No response

Operating System

Windows

Describe the bug

I use forge to deploy deterministic contracts across several chains. Because of a bug that caused race conditions on low latency blocks like Arbitrum, I updated forge to the latest version. Now the contract addresses have changed, despite nothing else in the configuration having changed. In particular, I have a create2ownable contract that I use to deploy ownable contracts:

    address _c2o = getAddress(FORGE_DETERMINISTIC_DEPLOYER, type(Create2Ownable).creationCode, "Create2Ownable");

with

  function getAddress(address deployer, bytes memory bytecode, bytes32 _salt) public pure returns (address){
    bytes32 hash = keccak256(abi.encodePacked(bytes1(0xff), deployer, uint256(_salt), keccak256(bytecode)));
    return address(uint160(uint256(hash)));
  }

The contract has no parameter, and now is consistent across various chains, but with a different address from previously deployed contracts. Which makes it impossible to deploy with the same address now.

Code is using solc 0.8.19.

What has changed with forge or cast? Is there a chance to rollback forge version (and how do I know, forge doesnt keep logs after updating)

Keref avatar Aug 06 '24 03:08 Keref