Skip to content

Commit

Permalink
Merge branch 'lee-migrator-changes' into chris-migrator-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PlasmaPower committed Jul 19, 2022
2 parents 82f8850 + 182574d commit 9d1dc6a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
24 changes: 20 additions & 4 deletions packages/arb-bridge-eth/contracts/bridge/NitroMigrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ interface INitroRollup {
function setInbox(IInbox newInbox) external;

function setOwner(address newOwner) external;

function pause() external;

function unpause() external;

function latestNodeCreated() external returns (uint64);

function createNitroMigrationGenesis(uint64 genesisBlockNumber, bytes32 genesisBlockHash)
external;
}

interface IArbOwner {
Expand Down Expand Up @@ -133,7 +142,7 @@ contract NitroMigrator is Ownable, IMessageProvider {
}
// this returns a different magic value so we can differentiate the user and admin facets
require(_rollup.isNitroReady() == uint8(0xa4b2), "ADMIN_ROLLUP_NOT_NITRO_READY");

require(_inbox.isNitroReady() == uint8(0xa4b1), "INBOX_NOT_UPGRADED");
require(_sequencerInbox.isNitroReady() == uint8(0xa4b1), "SEQINBOX_NOT_UPGRADED");

Expand All @@ -144,6 +153,9 @@ contract NitroMigrator is Ownable, IMessageProvider {
INitroInbox.IInbox oldNitroInbox = nitroRollup.inbox();
nitroBridge.setDelayedInbox(address(oldNitroInbox), false);

require(nitroRollup.latestNodeCreated() == 0, "NITRO_ROLLUP_HAS_NODES");
nitroRollup.pause();

latestCompleteStep = NitroMigrationSteps.Step0;
}

Expand Down Expand Up @@ -213,14 +225,17 @@ contract NitroMigrator is Ownable, IMessageProvider {
}

// CHRIS: TODO: remove skipCheck
function nitroStep3(bool skipCheck) external onlyOwner {
function nitroStep3(uint64 nitroGenesisBlockNumber, bytes32 nitroGenesisHash, bool skipCheck)
external
onlyOwner
{
require(latestCompleteStep == NitroMigrationSteps.Step2, "WRONG_STEP");
// CHRIS: TODO: destroying the node in the previous steps does not reset latestConfirmed/latestNodeCreated
require(
skipCheck || rollup.latestConfirmed() == rollup.latestNodeCreated(),
"ROLLUP_SHUTDOWN_NOT_COMPLETE"
);

bridge.setInbox(address(rollupEventBridge), false);

// Move the classic bridge funds to the nitro bridge
Expand All @@ -244,7 +259,8 @@ contract NitroMigrator is Ownable, IMessageProvider {
// we don't enable sequencer inbox and the rollup event bridge in nitro bridge as they are already configured in the deployment
nitroBridge.setDelayedInbox(address(inbox), true);

// TODO: set the genesis block hash of the nitro rollup
nitroRollup.unpause();
nitroRollup.createNitroMigrationGenesis(nitroGenesisBlockNumber, nitroGenesisHash);

// the migration is complete, relinquish ownership back to the
// nitro proxy admin owner
Expand Down
4 changes: 3 additions & 1 deletion packages/arb-upgrades/ethBridgeTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ task('migration-step-2', 'run nitro migration step 2')

task('migration-step-3', 'run nitro migration step 3')
.addParam('migrator', '')
.addParam('genesisnumber', 'The nitro genesis block number')
.addParam('genesishash', 'The nitro genesis block hash')

.setAction(async (args, hre) => {
let Migrator = (await hre.ethers.getContractFactory('NitroMigrator'))
Expand All @@ -270,7 +272,7 @@ task('migration-step-3', 'run nitro migration step 3')
Migrator = Migrator.connect(hre.ethers.provider.getSigner(owner))

console.log('Running migration step 3')
const receipt = await (await Migrator.nitroStep3(false)).wait()
const receipt = await (await Migrator.nitroStep3(args.genesisnumber, args.genesishash, false)).wait()
console.log('Ran migration step 3:', receipt)
})

Expand Down

0 comments on commit 9d1dc6a

Please sign in to comment.