Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clever-news-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/contracts-bedrock': patch
---

Fixes a bug in the L2 Bedrock genesis script
32 changes: 22 additions & 10 deletions packages/contracts-bedrock/tasks/genesis-l2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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')
Expand Down