Assessment reports>Proof of Data Possession>Discussion>Gas optimization

Gas optimization

Several functions in the PDPVerifier contract repeatedly access dynamically sized arrays within loops, leading to redundant storage and calldata reads, which increase gas costs. Specifically,

  • in provePossession(), proofs.length is accessed multiple times.

  • in nextProvingPeriod(), removals.length is accessed multiple times.

  • in addRoots(), rootData.length is accessed multiple times.

Since array lengths do not change during function execution, caching these values in local variables at the beginning of execution would optimize gas consumption.

Remediation

This issue has been acknowledged by Filecoin, and a fix was implemented in commit dc33146a.

Zellic © 2025Back to top ↑