Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
eaefd33
feat(cleanup): add data set cleanup bond and cleanupPieces function
wjmelements May 16, 2026
60f6aab
refactor(fees): replace USDFC sybil fee with cleanup deposit and move…
wjmelements May 16, 2026
1bee1a3
refactor: non-public constants and do not set zero defaults during init
wjmelements May 18, 2026
f74971e
test(cleanup): verify piece storage slots are cleared after cleanupPi…
wjmelements May 18, 2026
1474952
perf: check before store
wjmelements May 18, 2026
c3782e2
test(cleanup): verify cleanupPieces rejects live and non-existent dat…
wjmelements May 18, 2026
0acf22f
refactor(cleanup): replace string errors with typed errors, saving 44…
wjmelements May 19, 2026
900a2d6
refactor(cleanup): use FVMPay.pay for deposit refunds instead of call…
wjmelements May 19, 2026
370d099
docs: document that FVMPay.pay cannot re-enter via SEND method
wjmelements May 19, 2026
82d058c
chore: update layout file
wjmelements May 19, 2026
168740f
test(cleanup): assert pieceCids dynamic data region is cleared
wjmelements May 19, 2026
5b77f60
test(fees): assert FIL_CLEANUP_DEPOSIT returns 0.1 FIL
wjmelements May 19, 2026
ab0f3e1
chore: simplify constant
wjmelements May 19, 2026
5cdb655
refactor(verifier): move challengeFinality from storage to immutable …
wjmelements May 20, 2026
d3590ac
fix: max finality should be less than inactivity period
wjmelements May 20, 2026
aa7e50d
fix(verifier): prevent immediate permissionless deletion on dataset c…
wjmelements May 20, 2026
c40b8e0
feat(tools): allow deprecated-prefix renames in storage layout check
wjmelements May 20, 2026
6ce12f4
chore(layout): regenerate layout files after challengeFinality rename
wjmelements May 21, 2026
ec6f8aa
chore(tools): remove stale USDFC/payments constructor args from deplo…
wjmelements May 21, 2026
9d43013
test(verifier): add test for challenge epoch before current block
wjmelements May 21, 2026
ee639ab
chore: typed error msg for misconfigured finality
wjmelements May 21, 2026
4b031fb
chore: swap error
wjmelements May 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/Fees.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ pragma solidity ^0.8.20;
/// @title PDPFees
/// @notice A library for calculating fees for the PDP.
library PDPFees {
uint256 constant ATTO_FIL = 1;
uint256 constant FIL_TO_ATTO_FIL = 1e18 * ATTO_FIL;

// 0.1 FIL
uint256 constant SYBIL_FEE = FIL_TO_ATTO_FIL / 10;
// 0.1 FIL cleanup bond held per data set, returned to whoever finalizes cleanup
uint256 constant CLEANUP_DEPOSIT = 0.1 ether;

// Default FIL-based proof fee: 0.00023 FIL per TiB (used for initialization)
// Based on: 0.00067 USD per TiB / 2.88 USD per FIL = 0.00023 FIL per TiB
Expand All @@ -29,9 +26,8 @@ library PDPFees {
return (feePerTiB * rawSize) >> 40;
}

// sybil fee adds cost to adding state to the pdp verifier contract to prevent
// wasteful state growth. 0.1 FIL
function sybilFee() internal pure returns (uint256) {
return SYBIL_FEE;
// cleanup deposit is held per data set and paid out to whoever completes cleanup. 0.1 FIL
function cleanupDeposit() internal pure returns (uint256) {
return CLEANUP_DEPOSIT;
}
}
269 changes: 168 additions & 101 deletions src/PDPVerifier.sol
Comment thread
wjmelements marked this conversation as resolved.

Large diffs are not rendered by default.

42 changes: 41 additions & 1 deletion src/PDPVerifierLayout.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"label": "challengeFinality",
"label": "deprecatedChallengeFinality",
"offset": 0,
"slot": "0",
"type": {
Expand Down Expand Up @@ -409,5 +409,45 @@
],
"numberOfBytes": "32"
}
},
{
"label": "cleanupDeposit",
"offset": 0,
"slot": "17",
"type": {
"encoding": "mapping",
"key": {
"encoding": "inplace",
"label": "uint256",
"numberOfBytes": "32"
},
"label": "mapping(uint256 => uint256)",
"numberOfBytes": "32",
"value": {
"encoding": "inplace",
"label": "uint256",
"numberOfBytes": "32"
}
}
},
{
"label": "cleanupModeEpoch",
"offset": 0,
"slot": "18",
"type": {
"encoding": "mapping",
"key": {
"encoding": "inplace",
"label": "uint256",
"numberOfBytes": "32"
},
"label": "mapping(uint256 => uint256)",
"numberOfBytes": "32",
"value": {
"encoding": "inplace",
"label": "uint256",
"numberOfBytes": "32"
}
}
}
]
4 changes: 3 additions & 1 deletion src/PDPVerifierLayout.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.8.20;
// This file is a generated binding and any changes will be lost.
// Generated with tools/generate_storage_layout.sh

bytes32 constant CHALLENGE_FINALITY_SLOT = bytes32(uint256(0));
bytes32 constant DEPRECATED_CHALLENGE_FINALITY_SLOT = bytes32(uint256(0));
bytes32 constant NEXT_DATA_SET_ID_SLOT = bytes32(uint256(1));
bytes32 constant PIECE_CIDS_SLOT = bytes32(uint256(2));
bytes32 constant PIECE_LEAF_COUNTS_SLOT = bytes32(uint256(3));
Expand All @@ -22,3 +22,5 @@ bytes32 constant DATA_SET_PROPOSED_STORAGE_PROVIDER_SLOT = bytes32(uint256(13));
bytes32 constant DATA_SET_LAST_PROVEN_EPOCH_SLOT = bytes32(uint256(14));
bytes32 constant FEE_STATUS_SLOT = bytes32(uint256(15));
bytes32 constant NEXT_UPGRADE_SLOT = bytes32(uint256(16));
bytes32 constant CLEANUP_DEPOSIT_SLOT = bytes32(uint256(17));
bytes32 constant CLEANUP_MODE_EPOCH_SLOT = bytes32(uint256(18));
8 changes: 3 additions & 5 deletions src/interfaces/IPDPVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface IPDPVerifier is IPDPEvents {
function claimDataSetStorageProvider(uint256 setId, bytes calldata extraData) external;
function createDataSet(address listenerAddr, bytes calldata extraData) external payable returns (uint256);
function deleteDataSet(uint256 setId, bytes calldata extraData) external;
function cleanupPieces(uint256 setId, uint256 maxPieces) external returns (bool done);
function addPieces(uint256 setId, address listenerAddr, Cids.Cid[] calldata pieceData, bytes calldata extraData)
external
payable
Expand All @@ -45,9 +46,6 @@ interface IPDPVerifier is IPDPEvents {
// Fee view: returns the current effective fee per TiB
function feePerTiB() external view returns (uint96);

// USDFC sybil fee amount
function USDFC_SYBIL_FEE() external view returns (uint256);

// FIL sybil fee amount
function FIL_SYBIL_FEE() external pure returns (uint256);
// FIL cleanup deposit amount held per data set
function FIL_CLEANUP_DEPOSIT() external pure returns (uint256);
}
Loading
Loading