Skip to content

Conversation

@DarkLord017
Copy link
Contributor

fixes #351

  • Added a new internal function validatePayerOperatorApprovalAndFundsForPieces to FilecoinWarmStorageService that checks payer/operator approvals, available funds, and allowance limits before allowing new pieces to be added.
  • Imported the IPDPVerifier interface to enable querying the current leaf count from the PDP verifier, which is used in the new validation logic.
  • Corrected mockpdpverifier to return leaf count

does the implementation loog good should i move to adding tests ?

@FilOzzy FilOzzy added this to FS Nov 14, 2025
@github-project-automation github-project-automation bot moved this to 📌 Triage in FS Nov 14, 2025
assertEq(dataSetId, 1, "Dataset should be created with above-minimum funds");
}

// function testInsufficientFunds_AddPieces() public {
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's going on here? why is it commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

like i made this PR for initial review like if the implementation sg than i can work on tests

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, feel free to proceed, I think you have a good handle on the task at hand, just look for opportunities to minimise duplication as I mentioned above

@DarkLord017 DarkLord017 requested a review from rvagg November 26, 2025 10:57
@DarkLord017
Copy link
Contributor Author

Also solves #350

dataSetPieceMetadataKeys[dataSetId][pieceId].push(key);
}
uint256 leaves = IPDPVerifier(pdpVerifierAddress).getDataSetLeafCount(dataSetId);
updatePaymentRates(dataSetId, leaves);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's not do this in here; the payment rate change from #350 is a much larger behavioural change than just validting funds. We ought not to mix the two up since they are different things and should be both considered and merged separately (perhaps we want to revert one but not the other, or stagger the order in which we deploy these, or maybe the behavioural change ends up creating new bugs and the mixing of these two things makes it harder to diagnose).

Copy link
Collaborator

Choose a reason for hiding this comment

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

if you just want to split this up into two separate PRs then that's fine by me; you can stack them if you like so the second one has both changes so that when we merge this one for validatePayerFunds it'll disappear from (or be rebased out of) the second one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK will split the prs

/// @notice Validate payer/operator approvals and funds for adding pieces
/// @dev Computes the new storage rate and corresponding 30-day lockup after adding `pieceData`
/// and validates the payer has sufficient available funds and operator allowances.
function validatePayerOperatorApprovalAndFundsForPieces(
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about instead of making a new function here, you just extend validatePayerOperatorApprovalAndFunds and allow it to take a leaf count - zero in the case of createDataSet and the actual count for the piecesAdded function - then we don't have so much code duplication.

Perhaps there's some nuance I'm missing between that case and this one but it seems to me that they are basically the same, just one has leaves and the other deals in minimums. In fact, there's some logic in validatePayerOperatorApprovalAndFunds that does minimum rate calculation that could be replaced with a call to _calculateStorageRate; so it may be that there's no need for special casing inside the function, it just needs to take a leafCount which may or may not be zero.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay

@rjan90 rjan90 moved this from 📌 Triage to 🔎 Awaiting review in FS Dec 4, 2025
@rvagg
Copy link
Collaborator

rvagg commented Dec 5, 2025

Aside from the changes above, we should take a critical look at what happens when we do #350 because maybe all of this nice work is unnecessary and would be a waste of gas. Since we're doing a rail modification in the call anyway we're going to be getting these checks by Filecoin Pay. My lingering question is over the UX of it—do we get what we want in terms of error information from Filecoin Pay because I think the only thing this might add after #350 is nicer sugar consistent with the CreateDataSet checks.

@DarkLord017
Copy link
Contributor Author

Aside from the changes above, we should take a critical look at what happens when we do #350 because maybe all of this nice work is unnecessary and would be a waste of gas. Since we're doing a rail modification in the call anyway we're going to be getting these checks by Filecoin Pay. My lingering question is over the UX of it—do we get what we want in terms of error information from Filecoin Pay because I think the only thing this might add after #350 is nicer sugar consistent with the CreateDataSet checks.

Please see #365

@DarkLord017 DarkLord017 requested a review from rvagg December 6, 2025 17:00
@DarkLord017
Copy link
Contributor Author

Also ig this pr will resolve the issue #351 completely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🔎 Awaiting review

Development

Successfully merging this pull request may close these issues.

validatePayerFunds for piecesAdded

2 participants