Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ee52a74
Added test sequencer inbox opt
yahgwai Oct 4, 2023
cb72410
Made state vars immutable
yahgwai Oct 4, 2023
2b17df0
Added commentson max time variation
yahgwai Oct 4, 2023
ad06124
Removed deprecated method
yahgwai Oct 4, 2023
a4c3800
Updated tests
yahgwai Oct 4, 2023
90de978
Updated comments
yahgwai Oct 4, 2023
b7414fb
Formatted files
yahgwai Oct 4, 2023
87aafcf
Test file lint
yahgwai Oct 4, 2023
5890bde
Merge from develop
yahgwai Oct 5, 2023
998fe16
Updated max time variation comments
yahgwai Oct 5, 2023
a60f7ff
Updated tests
yahgwai Oct 5, 2023
b7b2f49
Storage layout checks no longer required for sequencer inbox
yahgwai Oct 5, 2023
0b9ba23
Merge from develop
yahgwai Oct 25, 2023
cd0d302
Build updates
yahgwai Oct 25, 2023
75215ba
Updated tests and added bridge.rollup() initialization tests
yahgwai Oct 25, 2023
a3111c4
Formatting
yahgwai Oct 25, 2023
90f2262
Updated arbrollup tests
yahgwai Oct 25, 2023
fe97273
Removed test events
yahgwai Oct 25, 2023
f75a8fc
Moved delayed messages read and batch delivered event into the bridge
yahgwai Oct 26, 2023
887cc47
Removed tests for now
yahgwai Oct 26, 2023
d06f2a0
Added encoder v2
yahgwai Oct 26, 2023
ce8fb88
Updated bridge storage dot
yahgwai Oct 26, 2023
3609765
Merge branch 'develop' into seq-inbox-opt
gzeoneth Oct 27, 2023
275d75b
Merge remote-tracking branch 'origin/develop' into seq-inbox-opt
gzeoneth Oct 30, 2023
22c9c75
Merge remote-tracking branch 'origin/seq-inbox-opt' into seq-inbox-br…
gzeoneth Oct 31, 2023
a4337e1
Updates from CR
yahgwai Oct 31, 2023
f3b1ceb
Merge branch 'seq-inbox-bridge' of https://github.com/OffchainLabs/ni…
yahgwai Oct 31, 2023
285b6bf
Merge from remote
yahgwai Oct 31, 2023
085e0e9
Removed old dot files
yahgwai Oct 31, 2023
3646a78
Merge pull request #87 from OffchainLabs/seq-inbox-bridge
yahgwai Oct 31, 2023
31fd3c6
Added internal max time variation func
yahgwai Nov 17, 2023
05e311d
Updated max time variation to be u64
yahgwai Nov 17, 2023
773e1ec
Merge branch 'develop' into seq-inbox-opt
Tristan-Wilson Dec 7, 2023
f3cfc60
fix: backward compatible maxTimeVariation
gzeoneth Dec 28, 2023
1fd0958
Formatting
yahgwai Jan 9, 2024
ab6855c
Updated tests
yahgwai Jan 9, 2024
a8f206b
Merge pull request #106 from OffchainLabs/g-patch-1
yahgwai Jan 9, 2024
2dda137
Update src/bridge/ISequencerInbox.sol
yahgwai Jan 9, 2024
e728f1f
Updated gas refunder to account for proxy usage
yahgwai Jan 16, 2024
1c6a328
Formatting
yahgwai Jan 16, 2024
0b7dc82
Moved calldata words inside
yahgwai Jan 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 40 additions & 3 deletions src/bridge/AbsBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ import {
NotSequencerInbox,
NotOutbox,
InvalidOutboxSet,
BadSequencerMessageNumber
BadSequencerMessageNumber,
EmptyDelayedMessagesRead,
DelayedBackwards,
DelayedTooFar
} from "../libraries/Error.sol";
import "./IBridge.sol";
import "./Messages.sol";
import "../libraries/DelegateCallAware.sol";
import "./ISequencerInbox.sol";

import {L1MessageType_batchPostingReport} from "../libraries/MessageTypes.sol";

Expand Down Expand Up @@ -55,8 +59,25 @@ abstract contract AbsBridge is Initializable, DelegateCallAware, IBridge {

uint256 public override sequencerReportedSubMessageCount;

uint256 public totalDelayedMessagesRead;

address internal constant EMPTY_ACTIVEOUTBOX = address(type(uint160).max);

event SequencerBatchDelivered(
uint256 indexed batchSequenceNumber,
bytes32 indexed beforeAcc,
bytes32 indexed afterAcc,
bytes32 delayedAcc,
uint256 afterDelayedMessagesRead,
ICommon.TimeBounds timeBounds,
ICommon.BatchDataLocation dataLocation
);

function postUpgradeInit() external onlyDelegated onlyProxyOwner {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we include setSequencerInbox in here too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh, I thinkn that makes sense, will update.

totalDelayedMessagesRead = ISequencerInbox(sequencerInbox).totalDelayedMessagesRead();
if (totalDelayedMessagesRead == 0) revert EmptyDelayedMessagesRead();
}

modifier onlyRollupOrOwner() {
if (msg.sender != address(rollup)) {
address rollupOwner = rollup.owner();
Expand Down Expand Up @@ -101,7 +122,9 @@ abstract contract AbsBridge is Initializable, DelegateCallAware, IBridge {
bytes32 dataHash,
uint256 afterDelayedMessagesRead,
uint256 prevMessageCount,
uint256 newMessageCount
uint256 newMessageCount,
ICommon.TimeBounds memory timeBounds,
ICommon.BatchDataLocation batchDataLocation
)
external
onlySequencerInbox
Expand All @@ -119,6 +142,9 @@ abstract contract AbsBridge is Initializable, DelegateCallAware, IBridge {
) {
revert BadSequencerMessageNumber(sequencerReportedSubMessageCount, prevMessageCount);
}
if (afterDelayedMessagesRead > delayedInboxAccs.length) revert DelayedTooFar();
if (afterDelayedMessagesRead < totalDelayedMessagesRead) revert DelayedBackwards();

sequencerReportedSubMessageCount = newMessageCount;
seqMessageIndex = sequencerInboxAccs.length;
if (sequencerInboxAccs.length > 0) {
Expand All @@ -129,6 +155,17 @@ abstract contract AbsBridge is Initializable, DelegateCallAware, IBridge {
}
acc = keccak256(abi.encodePacked(beforeAcc, dataHash, delayedAcc));
sequencerInboxAccs.push(acc);
totalDelayedMessagesRead = afterDelayedMessagesRead;

emit SequencerBatchDelivered(
seqMessageIndex,
beforeAcc,
acc,
delayedAcc,
afterDelayedMessagesRead,
timeBounds,
batchDataLocation
);
}

/// @inheritdoc IBridge
Expand Down Expand Up @@ -304,5 +341,5 @@ abstract contract AbsBridge is Initializable, DelegateCallAware, IBridge {
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[40] private __gap;
uint256[39] private __gap;
}
7 changes: 6 additions & 1 deletion src/bridge/IBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
pragma solidity >=0.6.9 <0.9.0;

import "./IOwnable.sol";
import "./ICommon.sol";

interface IBridge {
event MessageDelivered(
Expand Down Expand Up @@ -66,13 +67,17 @@ interface IBridge {

function sequencerMessageCount() external view returns (uint256);

function totalDelayedMessagesRead() external view returns (uint256);

// ---------- onlySequencerInbox functions ----------

function enqueueSequencerMessage(
bytes32 dataHash,
uint256 afterDelayedMessagesRead,
uint256 prevMessageCount,
uint256 newMessageCount
uint256 newMessageCount,
ICommon.TimeBounds memory timeBounds,
ICommon.BatchDataLocation dataLocation
)
external
returns (
Expand Down
21 changes: 21 additions & 0 deletions src/bridge/ICommon.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

// solhint-disable-next-line compiler-version
pragma solidity >=0.6.9 <0.9.0;

interface ICommon {
enum BatchDataLocation {
TxInput,
SeparateBatchEvent,
NoData
}

struct TimeBounds {
uint64 minTimestamp;
uint64 maxTimestamp;
uint64 minBlockNumber;
uint64 maxBlockNumber;
}
}
26 changes: 3 additions & 23 deletions src/bridge/ISequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pragma experimental ABIEncoderV2;
import "../libraries/IGasRefunder.sol";
import "./IDelayedMessageProvider.sol";
import "./IBridge.sol";
import "./ICommon.sol";

interface ISequencerInbox is IDelayedMessageProvider {
/// @notice The maximum amount of time variatin between a message being posted on the L1 and being executed on the L2
Expand All @@ -23,29 +24,6 @@ interface ISequencerInbox is IDelayedMessageProvider {
uint256 futureSeconds;
}

struct TimeBounds {
uint64 minTimestamp;
uint64 maxTimestamp;
uint64 minBlockNumber;
uint64 maxBlockNumber;
}

enum BatchDataLocation {
TxInput,
SeparateBatchEvent,
NoData
}

event SequencerBatchDelivered(
uint256 indexed batchSequenceNumber,
bytes32 indexed beforeAcc,
bytes32 indexed afterAcc,
bytes32 delayedAcc,
uint256 afterDelayedMessagesRead,
TimeBounds timeBounds,
BatchDataLocation dataLocation
);

event OwnerFunctionCalled(uint256 indexed id);

/// @dev a separate event that emits batch data when this isn't easily accessible in the tx.input
Expand All @@ -57,6 +35,8 @@ interface ISequencerInbox is IDelayedMessageProvider {
/// @dev a keyset was invalidated
event InvalidateKeyset(bytes32 indexed keysetHash);

/// @notice The total number of delated messages read in the bridge
/// @dev We surface this here for backwards compatibility
function totalDelayedMessagesRead() external view returns (uint256);

function bridge() external view returns (IBridge);
Expand Down
Loading