optimism icon indicating copy to clipboard operation
optimism copied to clipboard

deploy: get superchain proxy impls using zero address

Open qizhou opened this issue 4 months ago • 1 comments

Description

Deploy using the existing superchain config will fail because calling implementation() of the superchain proxies will be reverted. An example error is below:

[22332] Deploy::runWithSuperchain(0xDc82c0362A241Aa94d53546648EACe48C9773dAa, 0x856e75e9c0Da547F9753c17746D6cc139b668e5c, false)
    ├─ [2352] DeployConfig::l1ChainID() [staticcall]
    │   └─ ← [Return] 900
    ├─ [0] VM::chainId(900)
    │   └─ ← [Return] 
    ├─ [0] console::log("Deploying a fresh OP Stack with existing SuperchainConfig and ProtocolVersions") [staticcall]
    │   └─ ← [Stop] 
    ├─ [7333] 0xDc82c0362A241Aa94d53546648EACe48C9773dAa::implementation()
    │   ├─ [193] 0x238213078DbD09f2D15F4c14c02300FA1b2A81BB::implementation() [delegatecall]
    │   │   └─ ← [Revert] EvmError: Revert
    │   └─ ← [Revert] EvmError: Revert
    └─ ← [Revert] EvmError: Revert

The reason is that implementation() only returns when msg.sender is zero address or admin. If not, the proxy will forward the call to the implementation, which will revert the call.

The fix uses the zero address as msg.sender so that the proxy will return the implementation.

Tests

run ... forge script scripts/deploy/Deploy.s.sol:Deploy --sig 'runWithSuperchain(address,address,bool)' ..., got the following logs

Before

DeployConfig: reading file deploy-config/devnetL1.json
  Deploying a fresh OP Stack with existing SuperchainConfig and ProtocolVersions
Error: 
script failed: <empty revert data>

After

...
Deploying a fresh OP Stack with existing SuperchainConfig and ProtocolVersions
  Saving SuperchainConfig: 0x238213078DbD09f2D15F4c14c02300FA1b2A81BB
  Saving SuperchainConfigProxy: 0xDc82c0362A241Aa94d53546648EACe48C9773dAa
  Saving ProtocolVersions: 0xd85BdcdaE4db1FAEB8eF93331525FE68D7C8B3f0
  Saving ProtocolVersionsProxy: 0x856e75e9c0Da547F9753c17746D6cc139b668e5c
  start of L1 Deploy!
...

where the implementations are retrieved and printed. Additional context

Metadata

qizhou avatar Oct 14 '24 17:10 qizhou