From c308e832739e01a86b1a1f18ee3f64dd780dd0bd Mon Sep 17 00:00:00 2001 From: Sneh Koul Date: Wed, 27 Nov 2024 14:32:25 -0500 Subject: [PATCH] address comments --- src/bridge/EspressoTEEVerifier.sol | 5 ----- src/bridge/ISequencerInbox.sol | 3 +++ src/bridge/SequencerInbox.sol | 5 ++++- test/foundry/SequencerInbox.t.sol | 4 ---- test/foundry/SequencerInboxTEE.t.sol | 10 +++++++--- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/bridge/EspressoTEEVerifier.sol b/src/bridge/EspressoTEEVerifier.sol index 693e8f3f..fa9f23c0 100644 --- a/src/bridge/EspressoTEEVerifier.sol +++ b/src/bridge/EspressoTEEVerifier.sol @@ -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; @@ -93,8 +90,6 @@ contract EspressoTEEVerifier is Ownable { if (reportDataHash != bytes32(localReport.reportData.substring(0, 32))) { revert InvalidReportDataHash(); } - - emit TEEAttestationQuoteVerified(reportDataHash); } /* diff --git a/src/bridge/ISequencerInbox.sol b/src/bridge/ISequencerInbox.sol index ef43bc69..de05fde2 100644 --- a/src/bridge/ISequencerInbox.sol +++ b/src/bridge/ISequencerInbox.sol @@ -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); diff --git a/src/bridge/SequencerInbox.sol b/src/bridge/SequencerInbox.sol index c7837528..db841887 100644 --- a/src/bridge/SequencerInbox.sol +++ b/src/bridge/SequencerInbox.sol @@ -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, @@ -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, diff --git a/test/foundry/SequencerInbox.t.sol b/test/foundry/SequencerInbox.t.sol index ea2f78b9..aebe30f3 100644 --- a/test/foundry/SequencerInbox.t.sol +++ b/test/foundry/SequencerInbox.t.sol @@ -70,7 +70,6 @@ contract SequencerInboxTest is Test { EspressoTEEVerifierMock espressoTEEVerifier; V3QuoteVerifier quoteVerifier; bytes sampleQuote; - bytes invalidQuote; function setUp() public { vm.startPrank(adminTEE); @@ -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(); } diff --git a/test/foundry/SequencerInboxTEE.t.sol b/test/foundry/SequencerInboxTEE.t.sol index af168104..7139f6e7 100644 --- a/test/foundry/SequencerInboxTEE.t.sol +++ b/test/foundry/SequencerInboxTEE.t.sol @@ -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); @@ -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); @@ -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, @@ -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,