Skip to content

Commit 9a100a8

Browse files
committed
add disableMessageFromOriginEvent constructor parameter
1 parent c32af12 commit 9a100a8

File tree

15 files changed

+63
-38
lines changed

15 files changed

+63
-38
lines changed

scripts/deployment.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ethers } from 'hardhat'
22
import '@nomiclabs/hardhat-ethers'
33
import { deployAllContracts, _isRunningOnArbitrum } from './deploymentUtils'
4-
import { maxDataSize } from './config'
4+
import { maxDataSize, disableMessageFromOriginEvent } from './config'
55

66
import { ArbSys__factory } from '../build/types'
77

@@ -26,10 +26,12 @@ async function main() {
2626

2727
try {
2828
// Deploying all contracts
29+
const verify = false;
2930
const contracts = await deployAllContracts(
3031
signer,
3132
ethers.BigNumber.from(maxDataSize),
32-
true
33+
disableMessageFromOriginEvent,
34+
verify
3335
)
3436

3537
// Call setTemplates with the deployed contract addresses

scripts/deploymentUtils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export async function deployUpgradeExecutor(signer: any): Promise<Contract> {
117117
export async function deployAllContracts(
118118
signer: any,
119119
maxDataSize: BigNumber,
120+
disableMessageFromOriginEvent: boolean,
120121
verify: boolean = true
121122
): Promise<Record<string, Contract>> {
122123
const isOnArb = await _isRunningOnArbitrum(signer)
@@ -139,7 +140,7 @@ export async function deployAllContracts(
139140
verify
140141
)
141142

142-
const ethInbox = await deployContract('Inbox', signer, [maxDataSize], verify)
143+
const ethInbox = await deployContract('Inbox', signer, [maxDataSize, disableMessageFromOriginEvent], verify)
143144
const ethRollupEventInbox = await deployContract(
144145
'RollupEventInbox',
145146
signer,
@@ -164,7 +165,7 @@ export async function deployAllContracts(
164165
const erc20Inbox = await deployContract(
165166
'ERC20Inbox',
166167
signer,
167-
[maxDataSize],
168+
[maxDataSize, disableMessageFromOriginEvent],
168169
verify
169170
)
170171
const erc20RollupEventInbox = await deployContract(

scripts/local-deployment/deployCreatorAndCreateRollup.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ async function main() {
3636
? ethers.BigNumber.from(process.env.MAX_DATA_SIZE)
3737
: ethers.BigNumber.from(117964)
3838

39+
const disableMessageFromOriginEvent =
40+
process.env.DISABLE_MESSAGE_FROM_ORIGIN_EVENT !== undefined
41+
? process.env.DISABLE_MESSAGE_FROM_ORIGIN_EVENT === 'true'
42+
: false
43+
3944
/// get fee token address, if undefined use address(0) to have ETH as fee token
4045
let feeToken = process.env.FEE_TOKEN_ADDRESS as string
4146
if (!feeToken) {
@@ -62,7 +67,8 @@ async function main() {
6267

6368
/// deploy templates and rollup creator
6469
console.log('Deploy RollupCreator')
65-
const contracts = await deployAllContracts(deployerWallet, maxDataSize, false)
70+
const verify = false;
71+
const contracts = await deployAllContracts(deployerWallet, maxDataSize, disableMessageFromOriginEvent, verify)
6672

6773
console.log('Set templates on the Rollup Creator')
6874
await (

src/bridge/AbsInbox.sol

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,16 @@ abstract contract AbsInbox is DelegateCallAware, PausableUpgradeable, IInboxBase
102102

103103
// On L1 this should be set to 117964: 90% of Geth's 128KB tx size limit, leaving ~13KB for proving
104104
uint256 public immutable maxDataSize;
105+
// If disableMessageFromOriginEvent is true, an InboxMessageDelivered event will be emitted instead of InboxMessageDeliveredFromOrigin
106+
bool public immutable disableMessageFromOriginEvent;
105107
uint256 internal immutable deployTimeChainId = block.chainid;
106108

107109
constructor(
108-
uint256 _maxDataSize
110+
uint256 _maxDataSize,
111+
bool _disableMessageFromOriginEvent
109112
) {
110113
maxDataSize = _maxDataSize;
114+
disableMessageFromOriginEvent = _disableMessageFromOriginEvent;
111115
}
112116

113117
function _chainIdChanged() internal view returns (bool) {
@@ -143,6 +147,10 @@ abstract contract AbsInbox is DelegateCallAware, PausableUpgradeable, IInboxBase
143147
if (!CallerChecker.isCallerCodelessOrigin()) revert NotCodelessOrigin();
144148
if (messageData.length > maxDataSize) revert DataTooLarge(messageData.length, maxDataSize);
145149
uint256 msgNum = _deliverToBridge(L2_MSG, msg.sender, keccak256(messageData), 0);
150+
if (disableMessageFromOriginEvent) {
151+
emit InboxMessageDelivered(msgNum, messageData);
152+
return msgNum;
153+
}
146154
emit InboxMessageDeliveredFromOrigin(msgNum);
147155
return msgNum;
148156
}

src/bridge/ERC20Inbox.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ contract ERC20Inbox is AbsInbox, IERC20Inbox {
2727
using SafeERC20 for IERC20;
2828

2929
constructor(
30-
uint256 _maxDataSize
31-
) AbsInbox(_maxDataSize) {}
30+
uint256 _maxDataSize,
31+
bool _disableMessageFromOriginEvent
32+
) AbsInbox(_maxDataSize, _disableMessageFromOriginEvent) {}
3233

3334
/// @inheritdoc IInboxBase
3435
function initialize(

src/bridge/Inbox.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
2828
*/
2929
contract Inbox is AbsInbox, IInbox {
3030
constructor(
31-
uint256 _maxDataSize
32-
) AbsInbox(_maxDataSize) {}
31+
uint256 _maxDataSize,
32+
bool _disableMessageFromOriginEvent
33+
) AbsInbox(_maxDataSize, _disableMessageFromOriginEvent) {}
3334

3435
/// @inheritdoc IInboxBase
3536
function initialize(

test/Rollup.t.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ contract RollupTest is Test {
4747
uint256 constant MINI_STAKE_VALUE = 2;
4848
uint64 constant CONFIRM_PERIOD_BLOCKS = 100;
4949
uint256 constant MAX_DATA_SIZE = 117964;
50+
bool constant DISABLE_MESSAGE_FROM_ORIGIN_EVENT = false;
5051
uint64 constant CHALLENGE_GRACE_PERIOD_BLOCKS = 10;
5152

5253
bytes32 constant FIRST_ASSERTION_BLOCKHASH = keccak256("FIRST_ASSERTION_BLOCKHASH");
@@ -94,15 +95,15 @@ contract RollupTest is Test {
9495
bridge: new Bridge(),
9596
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, false, false),
9697
delayBufferableSequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, false, true),
97-
inbox: new Inbox(MAX_DATA_SIZE),
98+
inbox: new Inbox(MAX_DATA_SIZE, DISABLE_MESSAGE_FROM_ORIGIN_EVENT),
9899
rollupEventInbox: new RollupEventInbox(),
99100
outbox: new Outbox()
100101
});
101102
BridgeCreator.BridgeTemplates erc20BasedTemplates = BridgeCreator.BridgeTemplates({
102103
bridge: new ERC20Bridge(),
103104
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, true, false),
104105
delayBufferableSequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, true, true),
105-
inbox: new ERC20Inbox(MAX_DATA_SIZE),
106+
inbox: new ERC20Inbox(MAX_DATA_SIZE, DISABLE_MESSAGE_FROM_ORIGIN_EVENT),
106107
rollupEventInbox: new ERC20RollupEventInbox(),
107108
outbox: new ERC20Outbox()
108109
});

test/foundry/AbsInbox.t.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ abstract contract AbsInboxTest is Test {
1616
IBridge public bridge;
1717

1818
uint256 public constant MAX_DATA_SIZE = 117_964;
19+
bool public constant DISABLE_MESSAGE_FROM_ORIGIN_EVENT = false;
1920

2021
address public user = address(100);
2122
address public rollup = address(1000);
@@ -168,7 +169,7 @@ abstract contract AbsInboxTest is Test {
168169
}
169170

170171
function test_initialize_revert_NonDelegated() public {
171-
ERC20Inbox inb = new ERC20Inbox(MAX_DATA_SIZE);
172+
ERC20Inbox inb = new ERC20Inbox(MAX_DATA_SIZE, DISABLE_MESSAGE_FROM_ORIGIN_EVENT);
172173
vm.expectRevert("Function must be called through delegatecall");
173174
inb.initialize(bridge, ISequencerInbox(seqInbox));
174175
}

test/foundry/BridgeCreator.t.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@ contract BridgeCreatorTest is Test {
1313
BridgeCreator public creator;
1414
address public owner = address(100);
1515
uint256 public constant MAX_DATA_SIZE = 117_964;
16+
bool public constant DISABLE_MESSAGE_FROM_ORIGIN_EVENT = false;
1617
IReader4844 dummyReader4844 = IReader4844(address(137));
1718

1819
BridgeCreator.BridgeTemplates ethBasedTemplates = BridgeCreator.BridgeTemplates({
1920
bridge: new Bridge(),
2021
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, false, false),
2122
delayBufferableSequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, false, true),
22-
inbox: new Inbox(MAX_DATA_SIZE),
23+
inbox: new Inbox(MAX_DATA_SIZE, DISABLE_MESSAGE_FROM_ORIGIN_EVENT),
2324
rollupEventInbox: new RollupEventInbox(),
2425
outbox: new Outbox()
2526
});
2627
BridgeCreator.BridgeTemplates erc20BasedTemplates = BridgeCreator.BridgeTemplates({
2728
bridge: new ERC20Bridge(),
2829
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, true, false),
2930
delayBufferableSequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, true, true),
30-
inbox: new ERC20Inbox(MAX_DATA_SIZE),
31+
inbox: new ERC20Inbox(MAX_DATA_SIZE, DISABLE_MESSAGE_FROM_ORIGIN_EVENT),
3132
rollupEventInbox: new ERC20RollupEventInbox(),
3233
outbox: new ERC20Outbox()
3334
});

test/foundry/ERC20Bridge.t.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ contract ERC20BridgeTest is AbsBridgeTest {
1818
IERC20 public nativeToken;
1919

2020
uint256 public constant MAX_DATA_SIZE = 117_964;
21+
bool public constant DISABLE_MESSAGE_FROM_ORIGIN_EVENT = false;
2122

2223
// msg details
2324
uint8 public kind = 7;
@@ -34,7 +35,7 @@ contract ERC20BridgeTest is AbsBridgeTest {
3435
erc20Bridge.initialize(IOwnable(rollup), address(nativeToken));
3536

3637
// deploy inbox
37-
inbox = address(TestUtil.deployProxy(address(new ERC20Inbox(MAX_DATA_SIZE))));
38+
inbox = address(TestUtil.deployProxy(address(new ERC20Inbox(MAX_DATA_SIZE, DISABLE_MESSAGE_FROM_ORIGIN_EVENT))));
3839
IERC20Inbox(address(inbox)).initialize(bridge, ISequencerInbox(seqInbox));
3940
}
4041

0 commit comments

Comments
 (0)