Skip to content

Commit bf33be6

Browse files
committed
implemented requested changes
1 parent e2e5d56 commit bf33be6

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

service_contracts/foundry.lock

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,5 @@
1313
},
1414
"lib/pdp": {
1515
"rev": "61681392933926fbccb142ab7767e037680850b4"
16-
},
17-
"lib/session-key-registry": {
18-
"rev": "e472ca2b525fb2396832216182b64a0c165cb49c"
1916
}
2017
}

service_contracts/src/FilecoinWarmStorageService.sol

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,7 @@ contract FilecoinWarmStorageService is
15471547
uint256 provenEpochCount = 0;
15481548
uint256 lastProvenEpoch = fromEpoch;
15491549

1550-
(provenEpochCount, lastProvenEpoch) = findProvenEpochs(dataSetId, fromEpoch, toEpoch);
1550+
(provenEpochCount, lastProvenEpoch) = _findProvenEpochs(dataSetId, fromEpoch, toEpoch);
15511551

15521552
// If no epochs are proven, we can't settle anything
15531553
if (provenEpochCount == 0) {
@@ -1574,14 +1574,15 @@ contract FilecoinWarmStorageService is
15741574
});
15751575
}
15761576

1577-
function findProvenEpochs(uint256 dataSetId, uint256 fromEpoch, uint256 toEpoch)
1578-
public
1577+
function _findProvenEpochs(uint256 dataSetId, uint256 fromEpoch, uint256 toEpoch)
1578+
internal
15791579
view
15801580
returns (uint256, uint256)
15811581
{
15821582
uint256 provenEpochCount = 0;
15831583
uint256 lastProvenEpoch = fromEpoch;
15841584
uint256 activationEpoch = provingActivationEpoch[dataSetId];
1585+
uint256 currentPeriod = getProvingPeriodForEpoch(dataSetId, block.number);
15851586
if (toEpoch >= activationEpoch && toEpoch < block.number) {
15861587
// if `toEpoch` lies after activation, and `fromEpoch` lies before activation, then update the `fromEpoch`, as follows :
15871588
if (fromEpoch < activationEpoch) {
@@ -1596,25 +1597,25 @@ contract FilecoinWarmStorageService is
15961597

15971598
if (toEpoch < startingPeriod_deadline) {
15981599
// alternative way to check the same : `startingPeriod == endingPeriod`
1599-
if (_isPeriodProven(dataSetId, startingPeriod)) {
1600+
if (_isPeriodProven(dataSetId, startingPeriod, currentPeriod)) {
16001601
provenEpochCount = (toEpoch - fromEpoch);
16011602
lastProvenEpoch = toEpoch;
16021603
}
16031604
} else {
1604-
if (_isPeriodProven(dataSetId, startingPeriod)) {
1605+
if (_isPeriodProven(dataSetId, startingPeriod, currentPeriod)) {
16051606
provenEpochCount += (startingPeriod_deadline - fromEpoch);
16061607
}
16071608

16081609
// now loop through the proving periods between endingPeriod and startingPeriod.
16091610
for (uint256 period = startingPeriod + 1; period <= endingPeriod - 1; period++) {
1610-
if (_isPeriodProven(dataSetId, period)) {
1611+
if (_isPeriodProven(dataSetId, period, currentPeriod)) {
16111612
provenEpochCount += maxProvingPeriod;
16121613
lastProvenEpoch = _calcPeriodDeadline(dataSetId, period);
16131614
}
16141615
}
16151616

16161617
// now handle the last period separately
1617-
if (_isPeriodProven(dataSetId, endingPeriod)) {
1618+
if (_isPeriodProven(dataSetId, endingPeriod, currentPeriod)) {
16181619
// then the epochs to add = `endingPeriod_starting` to `toEpoch`. But since `endingPeriod_starting` is simply the ending of its previous period, so
16191620
provenEpochCount += (toEpoch - _calcPeriodDeadline(dataSetId, endingPeriod - 1));
16201621
lastProvenEpoch = toEpoch;
@@ -1625,8 +1626,7 @@ contract FilecoinWarmStorageService is
16251626
return (provenEpochCount, lastProvenEpoch);
16261627
}
16271628

1628-
function _isPeriodProven(uint256 dataSetId, uint256 periodId) private view returns (bool) {
1629-
uint256 currentPeriod = getProvingPeriodForEpoch(dataSetId, block.number);
1629+
function _isPeriodProven(uint256 dataSetId, uint256 periodId, uint256 currentPeriod) private view returns (bool) {
16301630
if (periodId == currentPeriod) {
16311631
return provenThisPeriod[dataSetId];
16321632
}

0 commit comments

Comments
 (0)