Skip to content

Commit

Permalink
refactor: simplify BOLDUpgradeAction (#266)
Browse files Browse the repository at this point in the history
* chore: use 2.1.0 for OldRollup

* fix: wait for deployment

* feat: allow excessStakeReceiver to be eoa

* wip: print action calldata

* wip: show executor perform call data

* fix: testnode master rollup addr

* wip: add local testnode executor

* wip: testnode validator

* wip: testnode validator wallet

* fix: small range lookup

* chore: sample env for testnode

* feat: bold upgrade execute and improved logging

* fix: use nextInboxPosition at upgrade to verify

* Revert "fix: use nextInboxPosition at upgrade to verify"

This reverts commit 6948823.

* fix: getlog range

* fix: nextInboxPosition

* chore: print bold addresses

* chore: log more stuffs

* chore: use 1000 range when searching log

* fix: parse event to get nextInboxPosition and more logging

* feat: allow ROLLUP_ADDRESS override in bold upgrade

* refactor: remove rollup reader

* format: fix

* refactor: do not upgrade old rollup

* fix: format again

* fix: typo

* fix: min version required

* chore: warn if old rollup is old

* feat: make bold rollup address predictable easily

* fix: expectedRollupAddress

* feat: isRollupDeployedAtAddress

* feat: validateRollupDeployedAtAddress

* fix: squeeze within size limit

* chore: whitelist npm audit issue

* chore: remove excessStakeReceiver check

* chore: revert typo
  • Loading branch information
gzeoneth authored Nov 21, 2024
1 parent fdd5b15 commit 59d3cbd
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 192 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
},
"private": false,
"devDependencies": {
"@arbitrum/nitro-contracts-2.1.0": "npm:@arbitrum/[email protected]",
"@arbitrum/sdk": "^3.4.1",
"@ethersproject/providers": "^5.7.2",
"@nomicfoundation/hardhat-verify": "^2.0.9",
Expand Down
2 changes: 0 additions & 2 deletions scripts/boldUpgradeCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ export interface DeployedContracts {
rei: string
outbox: string
inbox: string
oldRollupUser: string
newRollupUser: string
newRollupAdmin: string
challengeManager: string
boldAction: string
rollupReader: string
preImageHashLookup: string
prover0: string
proverMem: string
Expand Down
42 changes: 7 additions & 35 deletions scripts/boldUpgradeFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,16 @@ import {
Outbox__factory,
RollupAdminLogic__factory,
RollupEventInbox__factory,
RollupReader__factory,
RollupUserLogic__factory,
SequencerInbox__factory,
Inbox__factory,
StateHashPreImageLookup__factory,
IReader4844__factory,
IOldRollup__factory,
} from '../build/types'
import { bytecode as Reader4844Bytecode } from '../out/yul/Reader4844.yul/Reader4844.json'
import { DeployedContracts, Config } from './boldUpgradeCommon'
import { AssertionStateStruct } from '../build/types/src/challengeV2/IAssertionChain'
// taken from https://github.com/OffchainLabs/nitro-contracts/blob/210e5b3bc96a513d276deaba90399130a60131d5/src/rollup/RollupUserLogic.sol
import {
abi as OldRollupAbi,
bytecode as OldRollupBytecode,
} from '@arbitrum/nitro-contracts-2.1.0/build/contracts/src/rollup/RollupUserLogic.sol/RollupUserLogic.json'
import { verifyContract } from './deploymentUtils'

export const deployDependencies = async (
Expand All @@ -35,9 +30,7 @@ export const deployDependencies = async (
isDelayBufferable: boolean,
log: boolean = false,
verify: boolean = true
): Promise<
Omit<DeployedContracts, 'boldAction' | 'preImageHashLookup' | 'rollupReader'>
> => {
): Promise<Omit<DeployedContracts, 'boldAction' | 'preImageHashLookup'>> => {
const bridgeFac = new Bridge__factory(signer)
const bridge = await bridgeFac.deploy()
await bridge.deployed()
Expand Down Expand Up @@ -119,21 +112,6 @@ export const deployDependencies = async (
await verifyContract('Inbox', inbox.address, [maxDataSize])
}

const oldRollupUserFac = new ContractFactory(
OldRollupAbi,
OldRollupBytecode,
signer
)
const oldRollupUser = await oldRollupUserFac.deploy()
await oldRollupUser.deployed()
if (log) {
console.log(`Old rollup user logic deployed at: ${oldRollupUser.address}`)
}
if (verify) {
await oldRollupUser.deployTransaction.wait(5)
await verifyContract('OldRollupUserLogic', oldRollupUser.address, [])
}

const newRollupUserFac = new RollupUserLogic__factory(signer)
const newRollupUser = await newRollupUserFac.deploy()
await newRollupUser.deployed()
Expand Down Expand Up @@ -238,7 +216,6 @@ export const deployDependencies = async (
rei: rei.address,
outbox: outbox.address,
inbox: inbox.address,
oldRollupUser: oldRollupUser.address,
newRollupUser: newRollupUser.address,
newRollupAdmin: newRollupAdmin.address,
challengeManager: challengeManager.address,
Expand Down Expand Up @@ -291,7 +268,6 @@ export const deployBoldUpgrade = async (
const deployedAndBold = {
...deployed,
boldAction: boldUpgradeAction.address,
rollupReader: await boldUpgradeAction.ROLLUP_READER(),
preImageHashLookup: await boldUpgradeAction.PREIMAGE_LOOKUP(),
}

Expand All @@ -301,12 +277,11 @@ export const deployBoldUpgrade = async (
export const populateLookup = async (
wallet: Signer,
rollupAddr: string,
preImageHashLookupAddr: string,
rollupReaderAddr: string
preImageHashLookupAddr: string
) => {
const oldRollup = new Contract(rollupAddr, OldRollupAbi, wallet.provider)
const latestConfirmed: number = await oldRollup.latestConfirmed()
const oldRollup = IOldRollup__factory.connect(rollupAddr, wallet)

const latestConfirmed = await oldRollup.latestConfirmed()
let latestConfirmedLog
let toBlock = await wallet.provider!.getBlockNumber()
for (let i = 0; i < 100; i++) {
Expand Down Expand Up @@ -343,11 +318,8 @@ export const populateLookup = async (
preImageHashLookupAddr,
wallet
)
const oldRollupReader = RollupReader__factory.connect(
rollupReaderAddr,
wallet
)
const node = await oldRollupReader.getNode(latestConfirmed)

const node = await oldRollup.getNode(latestConfirmed)
const stateHash = await lookup.stateHash(afterState, inboxCount)
if (node.stateHash != stateHash) {
throw new Error(`State hash mismatch ${node.stateHash} != ${stateHash}}`)
Expand Down
Loading

0 comments on commit 59d3cbd

Please sign in to comment.