Skip to content

Conversation

@wjmelements
Copy link
Contributor

@wjmelements wjmelements commented Oct 22, 2025

Reviewer @rvagg
It is only important to block forward progress through the current proving period.
Currently we don't allow forward progress through unsettled periods without proofs.
This could be a problem if there was a rail unproven for a long time but proofs were later resumed.
Though much less likely after #258 and #267, we would not want it to be possible for the gap to exceed the block gas limit.

Also important to recall that the fromEpoch is an exclusive index while toEpoch is an inclusive index.

Changes

  • allow to settleUpTo previous period when unproven
  • define settledUpTo in previously irrelevant case

@wjmelements wjmelements requested a review from rvagg October 22, 2025 20:02
@FilOzzy FilOzzy added this to FS Oct 22, 2025
@github-project-automation github-project-automation bot moved this to 📌 Triage in FS Oct 22, 2025
@wjmelements wjmelements added the enhancement New feature or request label Oct 22, 2025

// Count proven epochs and find the last proven epoch
(uint256 provenEpochCount, uint256 lastProvenEpoch) =
(uint256 provenEpochCount, uint256 settledUpTo) =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like "settled" isn't the right language for (and in) _findProvenEpochs, maybe "settleUpTo" as an instruction would be more accurate? Or even "provenUpTo" as a description—although that's tricky because it's not necessarily all proven, it's more like "this is the last historical epoch within which you can make a settlement". The event itself has "settle" so I think it's just this internal usage that's making me trip over what on earth _findProvenEpochs is trying to do for us.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think settle is the right word based on how it's used in settleRail. Once the period is faulted it's not going to become unfaulted, so we should mark progress, and that does settle it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k, well let's remove the "d" from here and in _findProvenEpochs, it's odd

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert Errors.InvalidChallengeEpoch(dataSetId, minWindow, maxWindow, challengeEpoch);
}
provingDeadlines[dataSetId] = firstDeadline;
provenThisPeriod[dataSetId] = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can expect this to already be false when this data set's proving deadline is not initialized

uint256 completedPeriodId = getProvingPeriodForEpoch(dataSetId, provingDeadlines[dataSetId] - 1);

// Record whether this period was proven
provenPeriods[dataSetId][completedPeriodId >> 8] |= 1 << (completedPeriodId & 255);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already set by possessionProven

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hah, odd, any idea why it's in here too? hopefully just an oversight and not some functionality I'm not seeing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code has changed over time. Before it was a bitmap, this could set both true and false. Since I also see things initialized to false elsewhere, perhaps the original author did not know that false was the default.


function _isPeriodProven(uint256 dataSetId, uint256 periodId, uint256 currentPeriod) private view returns (bool) {
if (periodId == currentPeriod) {
return provenThisPeriod[dataSetId];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because this is set by possessionProven, we do not need to also check it here. in fact it might be a bug to do so

settledUpTo = _calcPeriodDeadline(activationEpoch, endingPeriod - 1);
settleUpTo = _calcPeriodDeadline(activationEpoch, endingPeriod - 1);

// handle the last period separately
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// handle the last period separately
// handle the last period separately to account for partial epoch count (toEpoch < deadline)

Copy link
Collaborator

@rvagg rvagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks correct, I'm just not clear on what the fix is, settleUpTo seems to be 0 coming out of this currently if you choose a range shorter than one period and that period isn't proven

@github-project-automation github-project-automation bot moved this from 📌 Triage to ✔️ Approved by reviewer in FS Oct 24, 2025
@wjmelements
Copy link
Contributor Author

wjmelements commented Oct 24, 2025

looks correct, I'm just not clear on what the fix is, settleUpTo seems to be 0 coming out of this currently if you choose a range shorter than one period and that period isn't proven

Before this change, settleUpTo is ignored in the case where no epochs are proven. After this change it is not.

@wjmelements wjmelements merged commit e7c609e into main Oct 24, 2025
6 checks passed
@wjmelements wjmelements deleted the allow-unsettled-forward-progress branch October 24, 2025 18:50
@github-project-automation github-project-automation bot moved this from ✔️ Approved by reviewer to 🎉 Done in FS Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

3 participants