Skip to content

Commit 9580511

Browse files
committed
fixed small errors in updated algo inside validatePayment
1 parent 8346892 commit 9580511

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

service_contracts/src/FilecoinWarmStorageService.sol

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,25 +1632,24 @@ contract FilecoinWarmStorageService is
16321632

16331633
// Count proven epochs and find the last proven epoch
16341634
uint256 provenEpochCount = 0;
1635-
uint256 lastProvenEpoch = 0;
1635+
uint256 lastProvenEpoch = fromEpoch;
16361636

16371637

16381638
// Updated algorithm
16391639
uint256 activationEpoch = provingActivationEpoch[dataSetId];
1640-
if(activationEpoch != 0 && toEpoch >= activationEpoch && toEpoch < block.number){
1641-
// now, starting epoch - fromEpoch + 1. find period corres to it. find out how long that period lasts and add that many epochs. then keep adding 2880 epochs till period end passes the endEpoch
1642-
1640+
if(toEpoch >= activationEpoch && toEpoch < block.number){
1641+
// if `toEpoch` lies after activation, and `fromEpoch` lies before activation, then update the `fromEpoch`, as follows :
16431642
if(fromEpoch < activationEpoch){
1644-
fromEpoch = activationEpoch;
1643+
fromEpoch = activationEpoch - 1; // we have done -1 because starting epoch is considered as `fromEpoch + 1`
16451644
}
16461645

16471646
uint256 startingPeriod = getProvingPeriodForEpoch(dataSetId, fromEpoch + 1);
16481647
uint256 endingPeriod = getProvingPeriodForEpoch(dataSetId, toEpoch);
16491648

1650-
// lets handle first period separately
1649+
// lets handle first period separately
16511650
uint256 startingPeriod_deadline = _calcPeriodDeadline(dataSetId, startingPeriod);
16521651

1653-
if(toEpoch < startingPeriod_deadline){
1652+
if(toEpoch < startingPeriod_deadline){ // alternative way to check the same : `startingPeriod == endingPeriod`
16541653
if(_isPeriodProven(dataSetId, startingPeriod)){
16551654
provenEpochCount = (toEpoch - fromEpoch);
16561655
lastProvenEpoch = toEpoch;
@@ -1662,7 +1661,7 @@ contract FilecoinWarmStorageService is
16621661

16631662
// now loop through the proving periods between endingPeriod and startingPeriod.
16641663
for(uint256 period = startingPeriod + 1; period <= endingPeriod - 1; period++){
1665-
if(provenPeriods[dataSetId][period]){ // here to check if period is proven, we can simply access the mapping since a period in between cannot be the current period
1664+
if(_isPeriodProven(dataSetId, period)){
16661665
provenEpochCount += maxProvingPeriod;
16671666
lastProvenEpoch = _calcPeriodDeadline(dataSetId, period);
16681667
}

0 commit comments

Comments
 (0)