Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Sneh1999 committed Nov 27, 2024
1 parent cc05e5d commit c308e83
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
5 changes: 0 additions & 5 deletions src/bridge/EspressoTEEVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ contract EspressoTEEVerifier is Ownable {
// This error is thrown when the reportDataHash doesn't match the hash signed by the TEE
error InvalidReportDataHash();

/// @dev a TEE attestation quote was verified
event TEEAttestationQuoteVerified(bytes32 reportDataHash);

// V3QuoteVerififer contract from automata to verify the quote
V3QuoteVerifier public quoteVerifier;
bytes32 public mrEnclave;
Expand Down Expand Up @@ -93,8 +90,6 @@ contract EspressoTEEVerifier is Ownable {
if (reportDataHash != bytes32(localReport.reportData.substring(0, 32))) {
revert InvalidReportDataHash();
}

emit TEEAttestationQuoteVerified(reportDataHash);
}

/*
Expand Down
3 changes: 3 additions & 0 deletions src/bridge/ISequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ interface ISequencerInbox is IDelayedMessageProvider {
/// @dev a keyset was invalidated
event InvalidateKeyset(bytes32 indexed keysetHash);

/// @dev a TEE attestation quote was verified
event TEEAttestationQuoteVerified(uint256 indexed seqMessageIndex);

function totalDelayedMessagesRead() external view returns (uint256);

function bridge() external view returns (IBridge);
Expand Down
5 changes: 4 additions & 1 deletion src/bridge/SequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,9 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
newMessageCount
)
);
// Verify the quote for the batch poster running in the TEE
// verify the quote for the batch poster running in the TEE
espressoTEEVerifier.verify(quote, reportDataHash);
emit TEEAttestationQuoteVerified(sequenceNumber);

(bytes32 dataHash, IBridge.TimeBounds memory timeBounds) = formCallDataHash(
data,
Expand Down Expand Up @@ -536,7 +537,9 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
newMessageCount
)
);
// verify the quote for the batch poster running in the TEE
espressoTEEVerifier.verify(quote, reportDataHash);
emit TEEAttestationQuoteVerified(sequenceNumber);
}
(bytes32 dataHash, IBridge.TimeBounds memory timeBounds) = formCallDataHash(
data,
Expand Down
4 changes: 0 additions & 4 deletions test/foundry/SequencerInbox.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ contract SequencerInboxTest is Test {
EspressoTEEVerifierMock espressoTEEVerifier;
V3QuoteVerifier quoteVerifier;
bytes sampleQuote;
bytes invalidQuote;

function setUp() public {
vm.startPrank(adminTEE);
Expand All @@ -80,9 +79,6 @@ contract SequencerInboxTest is Test {
string memory quotePath = "/test/foundry/configs/attestation.bin";
string memory inputFile = string.concat(vm.projectRoot(), quotePath);
sampleQuote = vm.readFileBinary(inputFile);
quotePath = "/test/foundry/configs/incorrect_attestation_quote.bin";
inputFile = string.concat(vm.projectRoot(), quotePath);
invalidQuote = vm.readFileBinary(inputFile);
vm.stopPrank();
}

Expand Down
10 changes: 7 additions & 3 deletions test/foundry/SequencerInboxTEE.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract RollupMock {
}

contract SequencerInboxTest is Test {
event TEEAttestationQuoteVerified(bytes32 reportDataHash);
event TEEAttestationQuoteVerified(uint256 indexed seqMessageIndex);
error InvalidReportDataHash();

address rollupOwner = address(137);
Expand Down Expand Up @@ -82,6 +82,10 @@ contract SequencerInboxTest is Test {
vm.prank(rollupOwner);
bridge.setDelayedInbox(dummyInbox, true);

seqInboxImpl = new SequencerInbox(maxDataSize, IReader4844(reader4844), false);
seqInbox = SequencerInbox(
address(new TransparentUpgradeableProxy(address(seqInboxImpl), proxyAdmin, ""))
);
seqInbox.initialize(bridge, maxTimeVariation, address(espressoTEEVerifier));

vm.prank(rollupOwner);
Expand Down Expand Up @@ -112,7 +116,7 @@ contract SequencerInboxTest is Test {

// We expect the TEE attestation quote to be validated
vm.expectEmit();
emit TEEAttestationQuoteVerified(reportDataHash);
emit TEEAttestationQuoteVerified(sequenceNumber);
seqInbox.addSequencerL2BatchFromOrigin(
sequenceNumber,
l2TEEData,
Expand Down Expand Up @@ -165,7 +169,7 @@ contract SequencerInboxTest is Test {

// We expect the TEE attestation quote to be validated
vm.expectEmit();
emit TEEAttestationQuoteVerified(reportDataHash);
emit TEEAttestationQuoteVerified(sequenceNumber);
seqInbox.addSequencerL2Batch(
sequenceNumber,
l2TEEData,
Expand Down

0 comments on commit c308e83

Please sign in to comment.