@@ -13,9 +13,9 @@ contract AlignedProofAggregationService is
1313 OwnableUpgradeable ,
1414 UUPSUpgradeable
1515{
16- /// @notice Maps the aggregated verification merkle root with the blob transaction hash that contains the leaves
17- uint64 public currentAggregatedProofNumber;
18- mapping (uint64 => AggregatedProof ) public aggregatedProofs;
16+
17+ /// @notice Map the merkle root to a boolean to indicate it was verified
18+ mapping (bytes32 => bool ) public aggregatedProofs;
1919
2020 /// @notice The address of the SP1 verifier contract.
2121 /// @dev This can either be a specific SP1Verifier for a specific version, or the
@@ -24,6 +24,7 @@ contract AlignedProofAggregationService is
2424 /// https://docs.succinct.xyz/onchain-verification/contract-addresses
2525 address public sp1VerifierAddress;
2626
27+ /// @notice The address of the Wallet that is allowed to call the verify function.
2728 address public alignedAggregatorAddress;
2829
2930 /// @notice whether we are in dev mode or not
@@ -51,43 +52,19 @@ contract AlignedProofAggregationService is
5152 bytes calldata sp1PublicValues ,
5253 bytes calldata sp1ProofBytes
5354 ) public onlyAlignedAggregator {
54- // In dev mode, poofs are mocked, so we skip the verification part
55- if (sp1VerifierAddress == VERIFIER_MOCK_ADDRESS) {
56- (bytes32 merkleRoot ) = abi.decode (sp1PublicValues, (bytes32 ));
57- _newAggregatedProof (merkleRoot, blobVersionedHash);
58- return ;
59- }
55+ (bytes32 merkleRoot ) = abi.decode (sp1PublicValues, (bytes32 ));
6056
61- try ISP1Verifier (sp1VerifierAddress).verifyProof (sp1ProgramVKey, sp1PublicValues, sp1ProofBytes) {
62- (bytes32 merkleRoot ) = abi.decode (sp1PublicValues, (bytes32 ));
63- _newAggregatedProof (merkleRoot, blobVersionedHash);
64- } catch {
65- AggregatedProof storage proof = aggregatedProofs[currentAggregatedProofNumber];
66- proof.status = AggregatedProofStatus.Failed;
67- emit NewAggregatedProof (currentAggregatedProofNumber, AggregatedProofStatus.Failed, 0x0 , 0x0 );
68- currentAggregatedProofNumber += 1 ;
57+ // In dev mode, poofs are mocked, so we skip the verification part
58+ if (_isVerificationEnabled ()) {
59+ ISP1Verifier (sp1VerifierAddress).verifyProof (sp1ProgramVKey, sp1PublicValues, sp1ProofBytes);
6960 }
70- }
71-
72- function markCurrentAggregatedProofAsMissed () public onlyAlignedAggregator {
73- AggregatedProof storage proof = aggregatedProofs[currentAggregatedProofNumber];
74- proof.status = AggregatedProofStatus.Missed;
75- emit NewAggregatedProof (currentAggregatedProofNumber, AggregatedProofStatus.Missed, 0x0 , 0x0 );
76- currentAggregatedProofNumber += 1 ;
77- }
7861
79- function _newAggregatedProof (bytes32 merkleRoot , bytes32 blobHash ) internal {
80- AggregatedProof storage proof = aggregatedProofs[currentAggregatedProofNumber];
81- proof.merkleRoot = merkleRoot;
82- proof.blobHash = blobHash;
83- proof.status = AggregatedProofStatus.Verified;
84- emit NewAggregatedProof (currentAggregatedProofNumber, AggregatedProofStatus.Verified, merkleRoot, blobHash);
85- currentAggregatedProofNumber += 1 ;
62+ aggregatedProofs[merkleRoot] = true ;
63+ emit AggregatedProofVerified (merkleRoot, blobVersionedHash);
8664 }
8765
88- function getAggregatedProof (uint64 proofNumber ) public view returns (uint8 , bytes32 blobHash , bytes32 merkleRoot ) {
89- AggregatedProof storage proof = aggregatedProofs[proofNumber];
90- return (uint8 (proof.status), proof.blobHash, proof.merkleRoot);
66+ function _isVerificationEnabled () internal view returns (bool ) {
67+ return sp1VerifierAddress != VERIFIER_MOCK_ADDRESS;
9168 }
9269
9370 function _authorizeUpgrade (address newImplementation )
0 commit comments