Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Decrement storage buffer, add EigenDA delay proof entrypoint, & refactor EigenDA tests #43

118 changes: 59 additions & 59 deletions .github/workflows/contract-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,69 +183,69 @@ jobs:

# - name: Run e2e tests
# run: yarn test:e2e
test-e2e-custom-fee-token-eigenda:
name: Test e2e custom fee token
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
# test-e2e-custom-fee-token-eigenda:
# name: Test e2e custom fee token
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# with:
# submodules: recursive

- uses: Layr-Labs/arbitrum-actions/run-nitro-test-node@main
with:
l3-node: true
args: --l3-fee-token
no-token-bridge: true
no-l3-token-bridge: true
eigenda: true
nitro-contracts-branch: '${{ github.event.pull_request.head.sha || github.sha }}'
# - uses: Layr-Labs/arbitrum-actions/run-nitro-test-node@main
# with:
# l3-node: true
# args: --l3-fee-token
# no-token-bridge: true
# no-l3-token-bridge: true
# eigenda: true
# nitro-contracts-branch: '${{ github.event.pull_request.head.sha || github.sha }}'

- name: Setup node/yarn
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'
# - name: Setup node/yarn
# uses: actions/setup-node@v3
# with:
# node-version: 18
# cache: 'yarn'
# cache-dependency-path: '**/yarn.lock'

- name: Install packages
run: yarn
# - name: Install packages
# run: yarn

- name: Compile contracts
run: yarn build

- name: Run e2e tests
run: yarn test:e2e
# test-e2e-fee-token-6-decimals:
# name: Test e2e fee token with 6 decimals
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# with:
# submodules: recursive

# - uses: Layr-Labs/arbitrum-actions/run-nitro-test-node@main
# with:
# l3-node: true
# args: --l3-fee-token --l3-fee-token-decimals 6
# no-token-bridge: true
# no-l3-token-bridge: true
# nitro-contracts-branch: '${{ github.event.pull_request.head.sha || github.sha }}'

# - name: Setup node/yarn
# uses: actions/setup-node@v3
# with:
# node-version: 18
# cache: 'yarn'
# cache-dependency-path: '**/yarn.lock'

# - name: Install packages
# run: yarn

# - name: Compile contracts
# run: yarn build

# - name: Run e2e tests
# run: yarn test:e2e
# - name: Compile contracts
# run: yarn build

# - name: Run e2e tests
# run: yarn test:e2e
# test-e2e-fee-token-6-decimals:
# name: Test e2e fee token with 6 decimals
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# with:
# submodules: recursive

# - uses: Layr-Labs/arbitrum-actions/run-nitro-test-node@main
# with:
# l3-node: true
# args: --l3-fee-token --l3-fee-token-decimals 6
# no-token-bridge: true
# no-l3-token-bridge: true
# nitro-contracts-branch: '${{ github.event.pull_request.head.sha || github.sha }}'

# - name: Setup node/yarn
# uses: actions/setup-node@v3
# with:
# node-version: 18
# cache: 'yarn'
# cache-dependency-path: '**/yarn.lock'

# - name: Install packages
# run: yarn

# - name: Compile contracts
# run: yarn build

# - name: Run e2e tests
# run: yarn test:e2e

bold-upgrade:
name: BOLD upgrade test
Expand Down
12 changes: 12 additions & 0 deletions src/bridge/ISequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,18 @@ interface ISequencerInbox is IDelayedMessageProvider {
uint256 newMessageCount
) external;

/// @dev Proves message delays, updates delay buffers, verifies EigenDA certs, and posts them to the accumulator.
/// DelayProof proves the delay of the message and syncs the delay buffer.
function addSequencerL2BatchFromEigenDADelayProof(
uint256 sequenceNumber,
EigenDACert calldata cert,
IGasRefunder gasRefunder,
uint256 afterDelayedMessagesRead,
uint256 prevMessageCount,
uint256 newMessageCount,
DelayProof calldata delayProof
) external;

/// @dev Proves message delays, updates delay buffers, and posts an L2 batch with blob data.
/// DelayProof proves the delay of the message and syncs the delay buffer.
function addSequencerL2BatchFromBlobsDelayProof(
Expand Down
41 changes: 37 additions & 4 deletions src/bridge/SequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
AlreadyInit,
HadZeroInit,
BadPostUpgradeInit,
NotEOA,
NotOrigin,
DataTooLarge,
DelayedBackwards,
Expand Down Expand Up @@ -146,7 +145,7 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
// gap used to ensure forward compatiblity with newly introduced storage variables
// from upstream offchainlabs/nitro-contracts. Any newly introduced storage vars
// made in subsequent releases should result in decrementing the gap counter
uint256[38] internal __gap;
uint256[36] internal __gap;
IRollupManager public eigenDARollupManager;

constructor(
Expand Down Expand Up @@ -455,6 +454,39 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
}
}

/// @inheritdoc ISequencerInbox
function addSequencerL2BatchFromEigenDADelayProof(
uint256 sequenceNumber,
EigenDACert calldata cert,
IGasRefunder gasRefunder,
uint256 afterDelayedMessagesRead,
uint256 prevMessageCount,
uint256 newMessageCount,
DelayProof calldata delayProof
) external refundsGas(gasRefunder, IReader4844(address(0))) {
if (!CallerChecker.isCallerCodelessOrigin()) revert NotCodelessOrigin();
if (!isBatchPoster[msg.sender]) revert NotBatchPoster();
if (!isDelayBufferable) revert NotDelayBufferable();

delayProofImpl(afterDelayedMessagesRead, delayProof);

// Verify that the blob was actually included before continuing
eigenDARollupManager.verifyBlob(cert.blobHeader, cert.blobVerificationProof);
// Form the EigenDA data hash and get the time bounds
(bytes32 dataHash, IBridge.TimeBounds memory timeBounds) =
formEigenDADataHash(cert, afterDelayedMessagesRead);

ISequencerInbox.SequenceMetadata memory metadata = ISequencerInbox.SequenceMetadata({
sequenceNumber: sequenceNumber,
afterDelayedMessagesRead: afterDelayedMessagesRead,
prevMessageCount: prevMessageCount,
newMessageCount: newMessageCount
});

// Call a helper function to add the sequencer L2 batch
_addSequencerL2Batch(metadata, dataHash, timeBounds);
}

function addSequencerL2BatchFromEigenDA(
uint256 sequenceNumber,
EigenDACert calldata cert,
Expand All @@ -463,9 +495,10 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
uint256 prevMessageCount,
uint256 newMessageCount
) external refundsGas(gasRefunder, IReader4844(address(0))) {
if (msg.sender != tx.origin) revert NotOrigin();
if (!CallerChecker.isCallerCodelessOrigin()) revert NotCodelessOrigin();
if (!isBatchPoster[msg.sender]) revert NotBatchPoster();
if (address(msg.sender).code.length > 0) revert NotEOA();
if (isDelayProofRequired(afterDelayedMessagesRead)) revert DelayProofRequired();

// Verify that the blob was actually included before continuing
eigenDARollupManager.verifyBlob(cert.blobHeader, cert.blobVerificationProof);
// Form the EigenDA data hash and get the time bounds
Expand Down
3 changes: 0 additions & 3 deletions src/libraries/Error.sol
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ error IncorrectMessagePreimage();
/// @dev This can only be called by the batch poster
error NotBatchPoster();

/// @dev This can only be called by an EOA account without EIP-7702 enabled
error NotEOA();

/// @dev The sequence number provided to this message was inconsistent with the number of batches already included
error BadSequencerNumber(uint256 stored, uint256 received);

Expand Down
1 change: 1 addition & 0 deletions test/contract/sequencerInboxDelayBufferable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
forceIncludeMessages,
} from './testHelpers'

// TODO: Add delay proof tests for EigenDA entrypoint
describe('SequencerInboxDelayBufferable', async () => {
it('can deplete buffer', async () => {
const { bridge, sequencerInbox, batchPoster, delayConfig, maxDelay } =
Expand Down
42 changes: 37 additions & 5 deletions test/foundry/SequencerInbox.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,10 @@ contract SequencerInboxTest is Test {
subMessageCount,
subMessageCount + 1
);
}

// TODO: put these in jsons later
// create illegal commitment
function testAddSequencerL2BatchFromEigenDAFailsWithInvalidCert() public {
// TODO: put these in json files
BN254.G1Point memory illegalCommitment = BN254.G1Point({
X: 11151623676041303181597631684634074376466382703418354161831688442589830350329,
Y: 4222041728992406478862708226745479381252734858741080790666424175645694456140
Expand Down Expand Up @@ -479,6 +480,40 @@ contract SequencerInboxTest is Test {
inclusionProof: bytes(""),
quorumIndices: bytes("")
});

// finish filling out the illegalBlobHeader
illegalBlobHeader.commitment = illegalCommitment;
illegalBlobHeader.dataLength = 20;

ISequencerInbox.EigenDACert memory illegalCert = ISequencerInbox.EigenDACert({
blobHeader: illegalBlobHeader,
blobVerificationProof: illegalBlobVerificationProof
});

// change the eigenDAServiceManager to use the holesky testnet contract
(SequencerInbox seqInbox, Bridge bridge,) = deployRollup(false, false, bufferConfigDefault);
address delayedInboxSender = address(140);
uint8 delayedInboxKind = 3;
bytes32 messageDataHash = RAND.Bytes32();

vm.prank(dummyInbox);
bridge.enqueueDelayedMessage(delayedInboxKind, delayedInboxSender, messageDataHash);

uint256 subMessageCount = bridge.sequencerReportedSubMessageCount();
uint256 sequenceNumber = bridge.sequencerMessageCount();
uint256 delayedMessagesRead = bridge.delayedMessageCount();

vm.prank(tx.origin);

vm.expectRevert();
seqInbox.addSequencerL2BatchFromEigenDA(
sequenceNumber,
illegalCert,
IGasRefunder(address(0)),
delayedMessagesRead,
subMessageCount,
subMessageCount + 1
);
}

function testAddSequencerL2BatchFromOrigin_ArbitrumHosted(
Expand Down Expand Up @@ -862,9 +897,6 @@ contract SequencerInboxTest is Test {
blobHeader.dataLength =
uint32(uint256(vm.parseJsonInt(json, ".blob_info.blob_header.data_length")));

//bytes memory quorumParamsBytes = vm.parseJson(json, ".blob_info.blob_header.blob_quorum_params");

// TODO: Parse these from the array, for some reason parsing them reads in the wrong order
IEigenDAServiceManager.QuorumBlobParam[] memory quorumParams =
new IEigenDAServiceManager.QuorumBlobParam[](2);

Expand Down
1 change: 1 addition & 0 deletions test/signatures/SequencerInbox
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"addSequencerL2BatchFromBlobs(uint256,uint256,address,uint256,uint256)": "3e5aa082",
"addSequencerL2BatchFromBlobsDelayProof(uint256,uint256,address,uint256,uint256,(bytes32,(uint8,address,uint64,uint64,uint256,uint256,bytes32)))": "917cf8ac",
"addSequencerL2BatchFromEigenDA(uint256,((uint32,uint32,((bytes32,bytes,bytes,uint32),bytes32,uint32),bytes,bytes),((uint256,uint256),uint32,(uint8,uint8,uint8,uint32)[])),address,uint256,uint256,uint256)": "283d8225",
"addSequencerL2BatchFromEigenDADelayProof(uint256,((uint32,uint32,((bytes32,bytes,bytes,uint32),bytes32,uint32),bytes,bytes),((uint256,uint256),uint32,(uint8,uint8,uint8,uint32)[])),address,uint256,uint256,uint256,(bytes32,(uint8,address,uint64,uint64,uint256,uint256,bytes32)))": "883e4928",
"addSequencerL2BatchFromOrigin(uint256,bytes,uint256,address)": "6f12b0c9",
"addSequencerL2BatchFromOrigin(uint256,bytes,uint256,address,uint256,uint256)": "8f111f3c",
"addSequencerL2BatchFromOriginDelayProof(uint256,bytes,uint256,address,uint256,uint256,(bytes32,(uint8,address,uint64,uint64,uint256,uint256,bytes32)))": "69cacded",
Expand Down
4 changes: 2 additions & 2 deletions test/storage/SequencerInbox
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
|-----------------------------+----------------------------------------------------------+------+--------+-------+----------------------------------------------|
| buffer | struct BufferData | 12 | 0 | 64 | src/bridge/SequencerInbox.sol:SequencerInbox |
|-----------------------------+----------------------------------------------------------+------+--------+-------+----------------------------------------------|
| __gap | uint256[38] | 14 | 0 | 1216 | src/bridge/SequencerInbox.sol:SequencerInbox |
| __gap | uint256[36] | 14 | 0 | 1152 | src/bridge/SequencerInbox.sol:SequencerInbox |
|-----------------------------+----------------------------------------------------------+------+--------+-------+----------------------------------------------|
| eigenDARollupManager | contract IRollupManager | 52 | 0 | 20 | src/bridge/SequencerInbox.sol:SequencerInbox |
| eigenDARollupManager | contract IRollupManager | 50 | 0 | 20 | src/bridge/SequencerInbox.sol:SequencerInbox |
╰-----------------------------+----------------------------------------------------------+------+--------+-------+----------------------------------------------╯

Loading