Skip to content

Commit

Permalink
chore: Decrement storage buffer, add EigenDA delay proof entrypoint, …
Browse files Browse the repository at this point in the history
…& refactor EigenDA tests
  • Loading branch information
EthenNotEthan committed Jan 17, 2025
1 parent 1bc72c2 commit dc392f1
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 8 deletions.
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
40 changes: 37 additions & 3 deletions src/bridge/SequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,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[37] internal __gap;
IRollupManager public eigenDARollupManager;

constructor(
Expand Down Expand Up @@ -455,6 +455,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 +496,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
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

0 comments on commit dc392f1

Please sign in to comment.