Skip to content

Commit dd1c660

Browse files
committed
removes start publication from checkpoint
1 parent 6d08743 commit dd1c660

File tree

5 files changed

+14
-49
lines changed

5 files changed

+14
-49
lines changed

src/protocol/CheckpointTracker.sol

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,24 @@ contract CheckpointTracker is ICheckpointTracker {
3535
}
3636

3737
/// @inheritdoc ICheckpointTracker
38-
function proveTransition(
39-
Checkpoint calldata start,
40-
Checkpoint calldata end,
41-
uint256 numPublications,
42-
bytes calldata proof
43-
) external {
38+
function proveTransition(Checkpoint calldata end, uint256 numPublications, bytes calldata proof) external {
4439
require(
4540
proverManager == address(0) || msg.sender == proverManager, "Only the prover manager can call this function"
4641
);
4742

4843
require(end.commitment != 0, "Checkpoint commitment cannot be 0");
4944

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);
45+
bytes32 startPublicationHash = publicationFeed.getPublicationHash(_provenCheckpoint.publicationId);
5846
bytes32 endPublicationHash = publicationFeed.getPublicationHash(end.publicationId);
5947
require(endPublicationHash != 0, "End publication does not exist");
6048

6149
verifier.verifyProof(
62-
startPublicationHash, endPublicationHash, start.commitment, end.commitment, numPublications, proof
50+
startPublicationHash,
51+
endPublicationHash,
52+
_provenCheckpoint.commitment,
53+
end.commitment,
54+
numPublications,
55+
proof
6356
);
6457

6558
_provenCheckpoint = end;

src/protocol/ICheckpointTracker.sol

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,10 @@ interface ICheckpointTracker {
1515
function getProvenCheckpoint() external view returns (Checkpoint memory);
1616

1717
/// @notice Verifies a transition between two checkpoints. Update the latest `provenCheckpoint` if possible
18-
/// @param start The initial checkpoint before the transition
1918
/// @param end The final checkpoint after the transition
2019
/// @param numPublications The number of publications that need to be processed between the two checkpoints.
2120
/// Note that this is not necessarily (end.publicationId - start.publicationId) because there could be irrelevant
2221
/// publications.
2322
/// @param proof Arbitrary data passed to the `verifier` contract to confirm the transition validity
24-
function proveTransition(
25-
Checkpoint calldata start,
26-
Checkpoint calldata end,
27-
uint256 numPublications,
28-
bytes calldata proof
29-
) external;
23+
function proveTransition(Checkpoint calldata end, uint256 numPublications, bytes calldata proof) external;
3024
}

src/protocol/taiko_alethia/ProverManager.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ contract ProverManager is IProposerFees, IProverManager {
238238
require(start.publicationId + 1 == firstPub.id, "First publication not immediately after start checkpoint");
239239
require(firstPub.timestamp > previousPeriodEnd, "First publication is before the period");
240240

241-
checkpointTracker.proveTransition(start, end, numPublications, proof);
241+
checkpointTracker.proveTransition(end, numPublications, proof);
242242

243243
bool isPastDeadline = block.timestamp > period.deadline && period.deadline != 0;
244244
if (isPastDeadline) {

test/CheckpointTracker.t.sol

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,54 +59,37 @@ 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+
tracker.proveTransition(end, numRelevantPublications, proof);
7169

7270
ICheckpointTracker.Checkpoint memory provenCheckpoint = tracker.getProvenCheckpoint();
7371
assertEq(provenCheckpoint.publicationId, end.publicationId);
7472
assertEq(provenCheckpoint.commitment, end.commitment);
7573
}
7674

7775
function test_proveTransition_RevertWhenEndCommitmentIsZero() public {
78-
ICheckpointTracker.Checkpoint memory start =
79-
ICheckpointTracker.Checkpoint({publicationId: 0, commitment: keccak256(abi.encode("genesis"))});
8076
ICheckpointTracker.Checkpoint memory end =
8177
ICheckpointTracker.Checkpoint({publicationId: 3, commitment: bytes32(0)});
8278
uint256 numRelevantPublications = 2;
8379

8480
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);
81+
tracker.proveTransition(end, numRelevantPublications, proof);
9782
}
9883

9984
function test_proveTransition_RevertWhenEndPublicationNotAfterStart() public {
100-
ICheckpointTracker.Checkpoint memory start =
101-
ICheckpointTracker.Checkpoint({publicationId: 0, commitment: keccak256(abi.encode("genesis"))});
10285
ICheckpointTracker.Checkpoint memory end =
10386
ICheckpointTracker.Checkpoint({publicationId: 0, commitment: keccak256(abi.encode("end"))});
10487
// this is nonsensical, but we're testing the publicationId check so I think it makes sense for the other
10588
// parameters to match previous tests.
10689
uint256 numRelevantPublications = 2;
10790

10891
vm.expectRevert("End publication must be after the last proven publication");
109-
tracker.proveTransition(start, end, numRelevantPublications, proof);
92+
tracker.proveTransition(end, numRelevantPublications, proof);
11093
}
11194

11295
function createSampleFeed() private {

test/mocks/MockCheckpointTracker.sol

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ contract MockCheckpointTracker is ICheckpointTracker {
1313
}
1414

1515
/// @notice Do nothing. All checkpoints and proofs are accepted.
16-
function proveTransition(
17-
Checkpoint calldata start,
18-
Checkpoint calldata end,
19-
uint256 numPublications,
20-
bytes calldata proof
21-
) external {}
16+
function proveTransition(Checkpoint calldata end, uint256 numPublications, bytes calldata proof) external {}
2217

2318
/// @notice Helper to set the proven hash for easier testing
2419
/// @param checkpoint the checkpoint to set as proven, that will be hashed and stored as the proven hash

0 commit comments

Comments
 (0)