Skip to content

Commit

Permalink
Merge pull request #208 from OffchainLabs/chris-migrator-changes
Browse files Browse the repository at this point in the history
Updated nitro migration manager to match recent changes
  • Loading branch information
PlasmaPower authored Jul 19, 2022
2 parents 182574d + 9d1dc6a commit 4de5b3f
Show file tree
Hide file tree
Showing 6 changed files with 438 additions and 477 deletions.
8 changes: 4 additions & 4 deletions packages/arb-bridge-eth/contracts/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ contract Bridge is OwnableUpgradeable, IBridge {
}

function allowedOutboxes(address outbox) external view override returns (bool) {
if (replacementBridge != address(0)) {
if (address(replacementBridge) != address(0)) {
return replacementBridge.allowedOutboxes(outbox);
}
return allowedOutboxesMap[outbox].allowed;
Expand Down Expand Up @@ -112,7 +112,7 @@ contract Bridge is OwnableUpgradeable, IBridge {
bytes calldata data
) external override returns (bool success, bytes memory returnData) {
require(allowedOutboxesMap[msg.sender].allowed, "NOT_FROM_OUTBOX");
if (replacementBridge != address(0)) {
if (address(replacementBridge) != address(0)) {
return replacementBridge.executeCall(destAddr, amount, data);
}
if (data.length > 0) require(destAddr.isContract(), "NO_CODE_AT_DEST");
Expand Down Expand Up @@ -165,14 +165,14 @@ contract Bridge is OwnableUpgradeable, IBridge {
}

function activeOutbox() external view override returns (address) {
if (replacementBridge == address(0)) {
if (address(replacementBridge) == address(0)) {
return localActiveOutbox;
} else {
return replacementBridge.activeOutbox();
}
}

function setReplacementBridge(address newReplacementBridge) external override onlyOwner {
replacementBridge = newReplacementBridge;
replacementBridge = IBridge(newReplacementBridge);
}
}
20 changes: 16 additions & 4 deletions packages/arb-bridge-eth/contracts/bridge/NitroMigrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import "./Bridge.sol";
import "./Outbox.sol";
import "./Inbox.sol";
import "./SequencerInbox.sol";
import "./NonDelegatingProxy.sol";
import "./Old_Outbox/OldOutbox.sol";
import "../rollup/facets/RollupAdmin.sol";
import "../rollup/RollupEventBridge.sol";
Expand All @@ -41,10 +40,14 @@ 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;
}
Expand Down Expand Up @@ -221,16 +224,18 @@ contract NitroMigrator is Ownable, IMessageProvider {
latestCompleteStep = NitroMigrationSteps.Step2;
}

function nitroStep3(uint64 nitroGenesisBlockNumber, bytes32 nitroGenesisHash)
// CHRIS: TODO: remove skipCheck
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(
rollup.latestConfirmed() == rollup.latestNodeCreated(),
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 @@ -249,14 +254,21 @@ contract NitroMigrator is Ownable, IMessageProvider {

// the bridge will proxy executeCall calls from the classic outboxes
nitroBridge.setOutbox(address(bridge), true);
bridge.setReplacementBridge(nitroBridge);
bridge.setReplacementBridge(address(nitroBridge));

// 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);

nitroRollup.unpause();
nitroRollup.createNitroMigrationGenesis(nitroGenesisBlockNumber, nitroGenesisHash);

// the migration is complete, relinquish ownership back to the
// nitro proxy admin owner
address nitroProxyAdminOwner = nitroProxyAdmin.owner();
rollup.setOwner(nitroProxyAdminOwner);
classicProxyAdmin.transferOwnership(nitroProxyAdminOwner);
nitroRollup.setOwner(address(nitroProxyAdmin));

latestCompleteStep = NitroMigrationSteps.Step3;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/arb-bridge-eth/contracts/test_only/BridgeMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import "../bridge/Bridge.sol";

contract BridgeMock is Bridge {
constructor() public {
activeOutbox = msg.sender;
localActiveOutbox = msg.sender;
}

function deliverMessageToInboxTest(
Expand Down
Loading

0 comments on commit 4de5b3f

Please sign in to comment.