Commit 5e113137 authored by smartcontracts's avatar smartcontracts Committed by GitHub

fix(ctb): bug in L2 genesis script (#3068)

Fixes a bug in the Bedrock L2 genesis script where storage slots were
being set in the implementation rather than the proxy, which (obviously)
broke various things that the SDK relies on.
Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent 987658bc
---
'@eth-optimism/contracts-bedrock': patch
---
Fixes a bug in the L2 Bedrock genesis script
......@@ -170,6 +170,28 @@ task('genesis-l2', 'create a genesis config')
}
if (predeployAddrs.has(ethers.utils.getAddress(addr))) {
const predeploy = Object.entries(predeploys).find(([, address]) => {
return ethers.utils.getAddress(address) === addr
})
// Really shouldn't happen, since predeployAddrs is a set generated from predeploys.
if (predeploy === undefined) {
throw new Error('could not find address')
}
const name = predeploy[0]
if (variables[name]) {
const storageLayout = await getStorageLayout(hre, name)
if (storageLayout === undefined) {
throw new Error(`cannot find storage layout for ${name}`)
}
const slots = computeStorageSlots(storageLayout, variables[name])
for (const slot of slots) {
alloc[addr].storage[slot.key] = slot.val
}
}
alloc[addr].storage[implementationSlot] = toCodeAddr(addr)
}
}
......@@ -247,16 +269,6 @@ task('genesis-l2', 'create a genesis config')
code: artifact.deployedBytecode,
storage: {},
}
const storageLayout = await getStorageLayout(hre, name)
if (storageLayout === undefined) {
throw new Error(`cannot find storage layout for ${name}`)
}
const slots = computeStorageSlots(storageLayout, variables[name])
for (const slot of slots) {
alloc[allocAddr].storage[slot.key] = slot.val
}
}
const portal = await hre.deployments.get('OptimismPortalProxy')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment