Skip to content

Commit 057d618

Browse files
authored
Merge c8cf416 into 6d08743
2 parents 6d08743 + c8cf416 commit 057d618

File tree

3 files changed

+19
-41
lines changed

3 files changed

+19
-41
lines changed

src/protocol/CheckpointTracker.sol

+9-10
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ contract CheckpointTracker is ICheckpointTracker {
3535
}
3636

3737
/// @inheritdoc ICheckpointTracker
38+
/// @dev This function does not use the `start` checkpoint since we don't support parallel transitions.
3839
function proveTransition(
39-
Checkpoint calldata start,
40+
Checkpoint calldata,
4041
Checkpoint calldata end,
4142
uint256 numPublications,
4243
bytes calldata proof
@@ -47,19 +48,17 @@ contract CheckpointTracker is ICheckpointTracker {
4748

4849
require(end.commitment != 0, "Checkpoint commitment cannot be 0");
4950

50-
require(
51-
start.publicationId == _provenCheckpoint.publicationId && start.commitment == _provenCheckpoint.commitment,
52-
"Start checkpoint must be the latest proven checkpoint"
53-
);
54-
55-
require(start.publicationId < end.publicationId, "End publication must be after the last proven publication");
56-
57-
bytes32 startPublicationHash = publicationFeed.getPublicationHash(start.publicationId);
51+
bytes32 startPublicationHash = publicationFeed.getPublicationHash(_provenCheckpoint.publicationId);
5852
bytes32 endPublicationHash = publicationFeed.getPublicationHash(end.publicationId);
5953
require(endPublicationHash != 0, "End publication does not exist");
6054

6155
verifier.verifyProof(
62-
startPublicationHash, endPublicationHash, start.commitment, end.commitment, numPublications, proof
56+
startPublicationHash,
57+
endPublicationHash,
58+
_provenCheckpoint.commitment,
59+
end.commitment,
60+
numPublications,
61+
proof
6362
);
6463

6564
_provenCheckpoint = end;

test/CheckpointTracker.t.sol

+9-30
Original file line numberDiff line numberDiff line change
@@ -59,54 +59,33 @@ contract CheckpointTrackerTest is Test {
5959
}
6060

6161
function test_proveTransition_SuccessfulTransition() public {
62-
ICheckpointTracker.Checkpoint memory start =
63-
ICheckpointTracker.Checkpoint({publicationId: 0, commitment: keccak256(abi.encode("genesis"))});
6462
ICheckpointTracker.Checkpoint memory end =
6563
ICheckpointTracker.Checkpoint({publicationId: 3, commitment: keccak256(abi.encode("end"))});
6664
uint256 numRelevantPublications = 2;
6765

6866
vm.expectEmit();
6967
emit ICheckpointTracker.CheckpointUpdated(end);
70-
tracker.proveTransition(start, end, numRelevantPublications, proof);
68+
69+
// Empty checkpoint needed to comply with the interface, but not used in `CheckpointTracker`
70+
ICheckpointTracker.Checkpoint memory emptyCheckpoint =
71+
ICheckpointTracker.Checkpoint({publicationId: 0, commitment: bytes32(0)});
72+
tracker.proveTransition(emptyCheckpoint, end, numRelevantPublications, proof);
7173

7274
ICheckpointTracker.Checkpoint memory provenCheckpoint = tracker.getProvenCheckpoint();
7375
assertEq(provenCheckpoint.publicationId, end.publicationId);
7476
assertEq(provenCheckpoint.commitment, end.commitment);
7577
}
7678

7779
function test_proveTransition_RevertWhenEndCommitmentIsZero() public {
78-
ICheckpointTracker.Checkpoint memory start =
79-
ICheckpointTracker.Checkpoint({publicationId: 0, commitment: keccak256(abi.encode("genesis"))});
8080
ICheckpointTracker.Checkpoint memory end =
8181
ICheckpointTracker.Checkpoint({publicationId: 3, commitment: bytes32(0)});
8282
uint256 numRelevantPublications = 2;
8383

8484
vm.expectRevert("Checkpoint commitment cannot be 0");
85-
tracker.proveTransition(start, end, numRelevantPublications, proof);
86-
}
87-
88-
function test_proveTransition_RevertWhenStartCheckpointNotLatestProven() public {
89-
ICheckpointTracker.Checkpoint memory start =
90-
ICheckpointTracker.Checkpoint({publicationId: 1, commitment: keccak256(abi.encode("wrong"))});
91-
ICheckpointTracker.Checkpoint memory end =
92-
ICheckpointTracker.Checkpoint({publicationId: 3, commitment: keccak256(abi.encode("end"))});
93-
uint256 numRelevantPublications = 2;
94-
95-
vm.expectRevert("Start checkpoint must be the latest proven checkpoint");
96-
tracker.proveTransition(start, end, numRelevantPublications, proof);
97-
}
98-
99-
function test_proveTransition_RevertWhenEndPublicationNotAfterStart() public {
100-
ICheckpointTracker.Checkpoint memory start =
101-
ICheckpointTracker.Checkpoint({publicationId: 0, commitment: keccak256(abi.encode("genesis"))});
102-
ICheckpointTracker.Checkpoint memory end =
103-
ICheckpointTracker.Checkpoint({publicationId: 0, commitment: keccak256(abi.encode("end"))});
104-
// this is nonsensical, but we're testing the publicationId check so I think it makes sense for the other
105-
// parameters to match previous tests.
106-
uint256 numRelevantPublications = 2;
107-
108-
vm.expectRevert("End publication must be after the last proven publication");
109-
tracker.proveTransition(start, end, numRelevantPublications, proof);
85+
// Empty checkpoint needed to comply with the interface, but not used in `CheckpointTracker`
86+
ICheckpointTracker.Checkpoint memory emptyCheckpoint =
87+
ICheckpointTracker.Checkpoint({publicationId: 0, commitment: bytes32(0)});
88+
tracker.proveTransition(emptyCheckpoint, end, numRelevantPublications, proof);
11089
}
11190

11291
function createSampleFeed() private {

test/mocks/MockCheckpointTracker.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ contract MockCheckpointTracker is ICheckpointTracker {
1414

1515
/// @notice Do nothing. All checkpoints and proofs are accepted.
1616
function proveTransition(
17-
Checkpoint calldata start,
17+
Checkpoint calldata,
1818
Checkpoint calldata end,
1919
uint256 numPublications,
2020
bytes calldata proof

0 commit comments

Comments
 (0)