Skip to content

Commit

Permalink
Merge pull request #2389 from OffchainLabs/nitro-migrator
Browse files Browse the repository at this point in the history
Nitro migratoooor
  • Loading branch information
hkalodner committed Aug 31, 2022
2 parents 0854f0b + 450c082 commit d40ac50
Show file tree
Hide file tree
Showing 64 changed files with 3,414 additions and 240 deletions.
2 changes: 1 addition & 1 deletion packages/MACHINEHASH
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0x3197f955bbd671d5074ea6de2e2b2172798b56fb3ac0a1ddb9a13f446aef14b7
0x1e9ccb390c15a084d695ad2fe83b27bc6212ca120213f2769fe39f6ba3899a17
2 changes: 1 addition & 1 deletion packages/arb-bridge-eth/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = {
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
project: './tsconfig.json',
},
extends: [
'eslint:recommended',
Expand Down
9 changes: 9 additions & 0 deletions packages/arb-bridge-eth/contracts/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

pragma solidity ^0.6.11;

import { NitroReadyMagicNums } from "./NitroMigratorUtil.sol";
import "./Inbox.sol";
import "./Outbox.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
Expand Down Expand Up @@ -153,4 +154,12 @@ contract Bridge is OwnableUpgradeable, IBridge {
function messageCount() external view override returns (uint256) {
return inboxAccs.length;
}

function allowedOutboxListLength() external view returns (uint256) {
return allowedOutboxList.length;
}

function isNitroReady() external view override returns (uint256) {
return NitroReadyMagicNums.BRIDGE;
}
}
16 changes: 16 additions & 0 deletions packages/arb-bridge-eth/contracts/bridge/Inbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import "./interfaces/IInbox.sol";
import "./interfaces/IBridge.sol";
import "../rollup/Rollup.sol";

import { NitroReadyMagicNums } from "./NitroMigratorUtil.sol";
import "./Messages.sol";
import "../libraries/Cloneable.sol";
import "../libraries/Whitelist.sol";
Expand All @@ -36,6 +37,8 @@ contract Inbox is IInbox, WhitelistConsumer, Cloneable {
uint8 internal constant L2_MSG = 3;
uint8 internal constant L1MessageType_L2FundedByL1 = 7;
uint8 internal constant L1MessageType_submitRetryableTx = 9;
uint8 internal constant L1MessageType_endOfBlock = 6;
uint8 internal constant L1MessageType_shutdownForNitro = 128;

uint8 internal constant L2MessageType_unsignedEOATx = 0;
uint8 internal constant L2MessageType_unsignedContractTx = 1;
Expand All @@ -51,6 +54,19 @@ contract Inbox is IInbox, WhitelistConsumer, Cloneable {
WhitelistConsumer.whitelist = _whitelist;
}

function isNitroReady() external pure returns (uint256) {
return NitroReadyMagicNums.DELAYED_INBOX;
}

function shutdownForNitro() external returns (uint256 msgNum) {
require(msg.sender == Bridge(address(bridge)).owner(), "ONLY_BRIDGE_OWNER");
// we deliver an end of block message followed by the shutdown message
msgNum = _deliverMessage(L1MessageType_endOfBlock, msg.sender, abi.encodePacked(""));
msgNum = _deliverMessage(L1MessageType_shutdownForNitro, msg.sender, abi.encodePacked(""));
// return the new message _count_ (one greater than the last _sequence number_)
return msgNum + 1;
}

/**
* @notice Send a generic L2 message to the chain
* @dev This method is an optimization to avoid having to emit the entirety of the messageData in a log. Instead validators are expected to be able to parse the data from the transaction's input
Expand Down
Loading

0 comments on commit d40ac50

Please sign in to comment.