Skip to content

bug: current contract deployments can't be replicated with current code #93

@fedgiac

Description

@fedgiac

Problem

It doesn't appear to be possible to deterministically redeploy the contracts with the code in this repo anymore, not even by checking out old commits.

Impact

Deterministic contract addresses are either not available or require bespoke procedures when deploying the contract on a new chain. Contract verification becomes in turn more difficult.

To reproduce

Execute the deployment command without broadcasting:

$ ETH_RPC_URL='https://eth.llamarpc.com'
$ forge script script/deploy_ProdStack.s.sol:DeployProdStack --rpc-url $ETH_RPC_URL -vvvv

Extract the expected deployment addresses:

$ cat ./broadcast/deploy_ProdStack.s.sol/1/dry-run/run-latest.json | jq --sort-keys '[ .transactions[] | select(.transactionType=="CREATE2") | { key: .contractName, 
value: .contractAddress} ] | from_entries' 
{
  "ComposableCoW": "0x3b69dfad2957ac71f8e1ee81f6901e6cb6695f1c",
  "CurrentBlockTimestampFactory": "0x302f261eb0b22dfb4a3d29f32503b1b6f7600f5b",
  "ExtensibleFallbackHandler": "0xa610bd67f02e84d5493ed002c3bb45d0415bf0df",
  "GoodAfterTime": "0x3b9122d50c0bbb81672c355187a05b301b00ce75",
  "PerpetualStableSwap": "0x963f411ac754055b611fe464fa4d50772e9b1f9c",
  "StopLoss": "0xab83e5bcce08b7c014c287cd07b6a0d4d9399746",
  "TWAP": "0xbf39aef05ca2f9c92b01088f90ebfc0715f02b75",
  "TradeAboveThreshold": "0x6e54d4d8f52a71cc6c6d95a6f06e696f69f99abf"
}

Compare with current addresses and observe that they all differ:

$ cat ./networks.json | jq --sort-keys '[. | to_entries[] | {key:.key, value: .value."1".address}] | from_entries'
{
  "ComposableCoW": "0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74",
  "CurrentBlockTimestampFactory": "0x52eD56Da04309Aca4c3FECC595298d80C2f16BAc",
  "ExtensibleFallbackHandler": "0x2f55e8b20D0B9FEFA187AA7d00B6Cbe563605bF5",
  "GoodAfterTime": "0xdaf33924925e03c9cc3a10d434016d6cfad0add5",
  "PerpetualStableSwap": "0x519BA24e959E33b3B6220CA98bd353d8c2D89920",
  "StopLoss": "0x412c36e5011cd2517016d243a2dfb37f73a242e7",
  "TWAP": "0x6cF1e9cA41f7611dEf408122793c358a3d11E5a5",
  "TradeAboveThreshold": "0x812308712a6d1367f437e1c1e4af85c854e1e9f6"
}

Expected behaviour

The addresses should be the same.

ComposableCoW version/commit hash

2ba71df3d5fdbfe8b92a540837262e164a0290ab

Additional context

We can also check the difference in the deployment bytecode, for example by comparing this and this. We can see that they only differ in the metadata bytes.

I suspect this issue has been introduced in 24d556b. However, the code needed to replicate the old behavior was in rndlabs/cowswap-contracts, which is a deleted repo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions