Skip to content

[Fil 1232] updated validations for transfer method in Client SC#44

Open
RafalMagrys wants to merge 11 commits intomainfrom
FIL-1232-sla-client-sc-correctly-verify-beneficiary-expiration-when-creating-allocations
Open

[Fil 1232] updated validations for transfer method in Client SC#44
RafalMagrys wants to merge 11 commits intomainfrom
FIL-1232-sla-client-sc-correctly-verify-beneficiary-expiration-when-creating-allocations

Conversation

@RafalMagrys
Copy link
Copy Markdown
Collaborator

No description provided.

@RafalMagrys RafalMagrys self-assigned this Dec 12, 2025
@RafalMagrys RafalMagrys force-pushed the FIL-1232-sla-client-sc-correctly-verify-beneficiary-expiration-when-creating-allocations branch from ef5d82b to bf8ad5a Compare December 12, 2025 09:05
@RafalMagrys RafalMagrys requested review from Filip-L, Szooot and kacperzuk-neti and removed request for Filip-L and kacperzuk-neti December 12, 2025 11:20
src/Client.sol Outdated
);
int64 beneficiaryExpiration = CommonTypes.ChainEpoch.unwrap(beneficiary.active.term.expiration);

if (longestClaimExtension.termMax > beneficiaryExpiration + 250 weeks) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

termMax is relative to when the claim starts. so we should look at expiration + termMax instead of just termMax.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why is 250 weeks added here? Shouldn't it be 180 days?

Copy link
Copy Markdown
Collaborator Author

@RafalMagrys RafalMagrys Dec 23, 2025

Choose a reason for hiding this comment

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

but the claim doesn't have expiration decoded from params. it only has provider, claimId, termMax

@RafalMagrys RafalMagrys force-pushed the FIL-1232-sla-client-sc-correctly-verify-beneficiary-expiration-when-creating-allocations branch from 3aa7889 to ac7370c Compare December 23, 2025 14:46
@RafalMagrys RafalMagrys force-pushed the FIL-1232-sla-client-sc-correctly-verify-beneficiary-expiration-when-creating-allocations branch from ac7370c to 1b780d2 Compare January 2, 2026 10:10
uint256 operatorDataLength;
uint256 allocationRequestsLength;
uint256 claimExtensionRequestsLength;
uint256 resultLength;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why did you change the names of these variables? The previous ones were more readable. Was this due to Solhint or the compiler?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Minimizing number of local variables to fit in the 15 slot stack depth limit of EVM.

struct ProviderAllocation {
CommonTypes.FilActorId provider;
uint64 size;
int64 allocationTime;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we really need to store allocationTime for every allocation? I think this might be unnecessarily gas-consuming. Maybe we could move it to a separate struct or use a different approach.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I moved it to a new struct

function _verifyBeneficiaryExpiration(ProviderAllocation memory longestAllocation) internal view {
if (longestAllocation.allocationTime != 0) {
MinerTypes.GetBeneficiaryReturn memory beneficiary =
MinerUtils.getBeneficiaryWithChecks(longestAllocation.provider, beneficiaryFactory, true, true, true);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

getBeneficiaryWithChecks is used in _verifyAndRegisterAllocations, which might be the best place to validate the expiration. Within a single transfer, there can be more than one provider, each with a different beneficiary expiration time, but the check is only for one provider.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I can surely move it here, but why should I check everyone when in the task it is written to check only Miner’s beneficiary related to this longest allocation?

MinerUtils.getBeneficiaryWithChecks(longestAllocation.provider, beneficiaryFactory, true, true, true);
int64 beneficiaryExpiration = CommonTypes.ChainEpoch.unwrap(beneficiary.active.term.expiration);

if (longestAllocation.allocationTime > beneficiaryExpiration + 180 days) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The beneficiary must expire no earlier than 180 days after the allocation ends.
longestAllocation.allocationTime + 180 days > beneficiaryExpiration

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants