Skip to content

Commit f2c8e16

Browse files
Use revert and add a proper error type in the interface
1 parent 974ce6a commit f2c8e16

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

contracts/src/core/AlignedProofAggregationService.sol

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ contract AlignedProofAggregationService is
7171
{
7272
(bytes32 merkleRoot) = abi.decode(sp1PublicValues, (bytes32));
7373

74-
require(programIds[programId] == uint8(IAlignedProofAggregationService.VerifierType.SP1), "Invalid program ID");
74+
if (programIds[programId] != uint8(IAlignedProofAggregationService.VerifierType.SP1)) {
75+
revert InvalidProgramId(programId, IAlignedProofAggregationService.VerifierType.SP1, programIds[programId]);
76+
}
7577

7678
// In dev mode, poofs are mocked, so we skip the verification part
7779
if (_isSP1VerificationEnabled()) {
@@ -88,7 +90,9 @@ contract AlignedProofAggregationService is
8890
{
8991
(bytes32 merkleRoot) = abi.decode(risc0JournalBytes, (bytes32));
9092

91-
require(programIds[programId] == uint8(IAlignedProofAggregationService.VerifierType.RISC0), "Invalid program ID");
93+
if (programIds[programId] != uint8(IAlignedProofAggregationService.VerifierType.RISC0)) {
94+
revert InvalidProgramId(programId, IAlignedProofAggregationService.VerifierType.RISC0, programIds[programId]);
95+
}
9296

9397
// In dev mode, poofs are mocked, so we skip the verification part
9498
if (_isRisc0VerificationEnabled()) {

contracts/src/core/IAlignedProofAggregationService.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ interface IAlignedProofAggregationService {
5454

5555
error OnlyAlignedAggregator(address sender);
5656

57+
error InvalidProgramId(bytes32 programId, VerifierType expected, uint8 actual);
58+
5759
enum VerifierType {
5860
INVALID, // If a given program does not exist in the `programId` map, it defaults to 0. This prevents non-existing keys to be considered valid in case SP1 or RISC0 were in this position
5961
SP1,

0 commit comments

Comments
 (0)