Skip to content

Commit 8b31e9e

Browse files
committed
make required changes
1 parent a9116db commit 8b31e9e

File tree

4 files changed

+14
-19
lines changed

4 files changed

+14
-19
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# VIM
22
*.swp
3-
foundry.lock
4-
my-changes.txt
3+
4+
# Foundry
5+
foundry.lock

service_contracts/.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ package-lock.json
1313
foundry.lock
1414

1515
# Ignore IDEs
16-
.idea
17-
new_changes.txt
16+
.idea

service_contracts/src/FilecoinWarmStorageService.sol

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@ contract FilecoinWarmStorageService is
14981498
if (toEpoch >= activationEpoch && toEpoch < block.number) {
14991499
// if `toEpoch` lies after activation, and `fromEpoch` lies before activation, then update the `fromEpoch`, as follows :
15001500
if (fromEpoch < activationEpoch - 1) {
1501-
fromEpoch = activationEpoch - 1;
1501+
fromEpoch = activationEpoch - 1;
15021502
}
15031503

15041504
uint256 startingPeriod = getProvingPeriodForEpoch(dataSetId, fromEpoch + 1);
@@ -1507,11 +1507,10 @@ contract FilecoinWarmStorageService is
15071507
// lets handle first period separately
15081508
uint256 startingPeriod_deadline = _calcPeriodDeadline(dataSetId, startingPeriod);
15091509

1510-
15111510
if (toEpoch < startingPeriod_deadline) {
15121511
// alternative way to check the same : `startingPeriod == endingPeriod`
15131512
if (_isPeriodProven(dataSetId, startingPeriod, currentPeriod)) {
1514-
provenEpochCount = (toEpoch - fromEpoch); // epochs : (`from + 1` -> `to`) (both inclusive)
1513+
provenEpochCount = (toEpoch - fromEpoch); // epochs : (`from + 1` -> `to`) (both inclusive)
15151514
lastProvenEpoch = toEpoch;
15161515
}
15171516
} else {
@@ -1530,7 +1529,7 @@ contract FilecoinWarmStorageService is
15301529
// now handle the last period separately
15311530
if (_isPeriodProven(dataSetId, endingPeriod, currentPeriod)) {
15321531
// then the epochs to add = `endingPeriod_starting` to `toEpoch`. But since `endingPeriod_starting` is simply the ending of its previous period + 1, so epochs : (`deadline + 1` -> `to`)
1533-
provenEpochCount += (toEpoch - _calcPeriodDeadline(dataSetId, endingPeriod - 1));
1532+
provenEpochCount += (toEpoch - _calcPeriodDeadline(dataSetId, endingPeriod - 1));
15341533
lastProvenEpoch = toEpoch;
15351534
}
15361535
}

service_contracts/test/FilecoinWarmStorageService.t.sol

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4261,8 +4261,6 @@ contract FilecoinWarmStorageServiceUpgradeTest is Test {
42614261
* @notice Tests for validatePayment function - ensures optimized implementation
42624262
* maintains same behavior as the original loop-based version
42634263
*/
4264-
4265-
42664264
contract ValidatePaymentTest is FilecoinWarmStorageServiceTest {
42674265
/**
42684266
* @notice Test: All epochs proven - should pay full amount
@@ -4273,10 +4271,8 @@ contract ValidatePaymentTest is FilecoinWarmStorageServiceTest {
42734271
// Start proving
42744272
(uint64 maxProvingPeriod, uint256 challengeWindow,,) = viewContract.getPDPConfig();
42754273

4276-
// Capture activation epoch BEFORE calling nextProvingPeriod
4277-
4278-
// uint256 _activationEpoch = block.number; // using this line is causing the activationEpoch variable to change every time we call vm.roll (some bug maybe) so better to do use the following line :
4279-
uint256 _activationEpoch = 1; // because in testing environment, starting block number is 1
4274+
// Capture activation epoch BEFORE calling nextProvingPeriod
4275+
uint256 _activationEpoch = vm.getBlockNumber();
42804276
uint256 firstChallengeEpoch = _activationEpoch + maxProvingPeriod - (challengeWindow / 2);
42814277

42824278
vm.prank(address(mockPDPVerifier));
@@ -4322,7 +4318,7 @@ contract ValidatePaymentTest is FilecoinWarmStorageServiceTest {
43224318
uint256 toEpoch = _activationEpoch + (maxProvingPeriod * 3) - 1; // inclusive end, all 3 periods
43234319
uint256 proposedAmount = 1000e6;
43244320

4325-
// Move past the periods we're validating, so that toEpoch becomes less than block.number
4321+
// Move past the periods we're validating, so that toEpoch becomes less than block.number
43264322
vm.roll(toEpoch + 1);
43274323
vm.prank(address(payments));
43284324
IValidator.ValidationResult memory result =
@@ -4346,7 +4342,7 @@ contract ValidatePaymentTest is FilecoinWarmStorageServiceTest {
43464342
vm.prank(address(mockPDPVerifier));
43474343
pdpServiceWithPayments.nextProvingPeriod(dataSetId, challengeEpoch, 100, "");
43484344

4349-
uint256 activationEpoch = 1; // same reason as the above test
4345+
uint256 activationEpoch = vm.getBlockNumber();
43504346

43514347
// Move forward 3 periods without submitting proofs
43524348
vm.roll(activationEpoch + (maxProvingPeriod * 3));
@@ -4380,7 +4376,7 @@ contract ValidatePaymentTest is FilecoinWarmStorageServiceTest {
43804376
vm.prank(address(mockPDPVerifier));
43814377
pdpServiceWithPayments.nextProvingPeriod(dataSetId, firstChallengeEpoch, 100, "");
43824378

4383-
uint256 activationEpoch = 1;
4379+
uint256 activationEpoch = vm.getBlockNumber();
43844380

43854381
// Submit proof for period 0
43864382
vm.roll(firstChallengeEpoch);
@@ -4465,7 +4461,7 @@ contract ValidatePaymentTest is FilecoinWarmStorageServiceTest {
44654461
vm.prank(address(mockPDPVerifier));
44664462
pdpServiceWithPayments.nextProvingPeriod(dataSetId, challengeEpoch, 100, "");
44674463

4468-
uint256 activationEpoch = block.number;
4464+
uint256 activationEpoch = vm.getBlockNumber();
44694465

44704466
// Try to validate for epochs before activation
44714467
FilecoinWarmStorageService.DataSetInfoView memory info = viewContract.getDataSet(dataSetId);
@@ -4494,7 +4490,7 @@ contract ValidatePaymentTest is FilecoinWarmStorageServiceTest {
44944490
vm.prank(address(mockPDPVerifier));
44954491
pdpServiceWithPayments.nextProvingPeriod(dataSetId, challengeEpoch, 100, "");
44964492

4497-
uint256 activationEpoch = 1;
4493+
uint256 activationEpoch = vm.getBlockNumber();
44984494

44994495
// Submit proof for period 0
45004496
vm.roll(challengeEpoch);

0 commit comments

Comments
 (0)