Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 22 additions & 11 deletions service_contracts/src/FilecoinWarmStorageService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ contract FilecoinWarmStorageService is

// Proving period constants - set during initialization
uint64 private maxProvingPeriod;
uint256 private challengeWindowSize;
uint256 public challengeWindowSize;

// Commission rate
uint256 private serviceCommissionBps;
Expand Down Expand Up @@ -738,7 +738,10 @@ contract FilecoinWarmStorageService is
uint256 dataSetId,
uint256, // deletedLeafCount, - not used
bytes calldata // extraData, - not used
) external onlyPDPVerifier {
)
external
onlyPDPVerifier
{
// Verify the data set exists in our mapping
DataSetInfo storage info = dataSetInfo[dataSetId];
require(info.pdpRailId != 0, Errors.DataSetNotRegistered(dataSetId));
Expand Down Expand Up @@ -903,7 +906,10 @@ contract FilecoinWarmStorageService is
uint256, /*challengedLeafCount*/
uint256, /*seed*/
uint256 challengeCount
) external onlyPDPVerifier {
)
external
onlyPDPVerifier
{
requirePaymentNotBeyondEndEpoch(dataSetId);

if (provenThisPeriod[dataSetId]) {
Expand Down Expand Up @@ -1021,7 +1027,11 @@ contract FilecoinWarmStorageService is
address, // oldServiceProvider
address, // newServiceProvider
bytes calldata // extraData - not used
) external override onlyPDPVerifier {
)
external
override
onlyPDPVerifier
{
revert("Storage provider changes are not yet supported");
}

Expand Down Expand Up @@ -1535,7 +1545,12 @@ contract FilecoinWarmStorageService is
uint256 fromEpoch,
uint256 toEpoch,
uint256 /* rate */
) external view override returns (ValidationResult memory result) {
)
external
view
override
returns (ValidationResult memory result)
{
// Get the data set ID associated with this rail
uint256 dataSetId = railToDataSet[railId];
require(dataSetId != 0, Errors.RailNotAssociated(railId));
Expand All @@ -1548,9 +1563,7 @@ contract FilecoinWarmStorageService is
uint256 activationEpoch = provingActivationEpoch[dataSetId];
if (activationEpoch == 0) {
return ValidationResult({
modifiedAmount: 0,
settleUpto: fromEpoch,
note: "Proving never activated for this data set"
modifiedAmount: 0, settleUpto: fromEpoch, note: "Proving never activated for this data set"
});
}

Expand All @@ -1561,9 +1574,7 @@ contract FilecoinWarmStorageService is
// If no epochs are proven, we can't settle anything
if (provenEpochCount == 0) {
return ValidationResult({
modifiedAmount: 0,
settleUpto: settleUpTo,
note: "No proven epochs in the requested range"
modifiedAmount: 0, settleUpto: settleUpTo, note: "No proven epochs in the requested range"
});
}

Expand Down
4 changes: 0 additions & 4 deletions service_contracts/src/FilecoinWarmStorageServiceStateView.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ contract FilecoinWarmStorageServiceStateView is IPDPProvingSchedule {
service = _service;
}

function challengeWindow() external view returns (uint256) {
return service.challengeWindow();
}

function clientDataSets(address payer) external view returns (uint256[] memory dataSetIds) {
return service.clientDataSets(payer);
}
Expand Down
26 changes: 8 additions & 18 deletions service_contracts/src/ServiceProviderRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,7 @@ contract ServiceProviderRegistry is

// Store provider info
providers[providerId] = ServiceProviderInfo({
serviceProvider: msg.sender,
payee: payee,
name: name,
description: description,
isActive: true
serviceProvider: msg.sender, payee: payee, name: name, description: description, isActive: true
});

// Update address mapping
Expand Down Expand Up @@ -265,9 +261,11 @@ contract ServiceProviderRegistry is
/// @param productType The type of product to update
/// @param capabilityKeys Array of capability keys (max 32 chars each, max 10 keys)
/// @param capabilityValues Array of capability values (max 128 chars each, max 10 values)
function updateProduct(ProductType productType, string[] calldata capabilityKeys, bytes[] calldata capabilityValues)
external
{
function updateProduct(
ProductType productType,
string[] calldata capabilityKeys,
bytes[] calldata capabilityValues
) external {
// Only support PDP for now
require(productType == ProductType.PDP, "Only PDP product type currently supported");

Expand Down Expand Up @@ -537,11 +535,7 @@ contract ServiceProviderRegistry is
/// @notice Get provider info by address
/// @param providerAddress The address of the service provider
/// @return info The provider information (empty struct if not registered)
function getProviderByAddress(address providerAddress)
external
view
returns (ServiceProviderInfoView memory info)
{
function getProviderByAddress(address providerAddress) external view returns (ServiceProviderInfoView memory info) {
uint256 providerId = addressToProviderId[providerAddress];
if (providerId == 0) {
return _getEmptyProviderInfoView();
Expand Down Expand Up @@ -644,11 +638,7 @@ contract ServiceProviderRegistry is
return ServiceProviderInfoView({
providerId: 0,
info: ServiceProviderInfo({
serviceProvider: address(0),
payee: address(0),
name: "",
description: "",
isActive: false
serviceProvider: address(0), payee: address(0), name: "", description: "", isActive: false
})
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ bytes32 constant FIL_BEAM_CONTROLLER_ADDRESS_SLOT = bytes32(uint256(18));
bytes32 constant NEXT_UPGRADE_SLOT = bytes32(uint256(19));
bytes32 constant STORAGE_PRICE_PER_TIB_PER_MONTH_SLOT = bytes32(uint256(20));
bytes32 constant MINIMUM_STORAGE_RATE_PER_MONTH_SLOT = bytes32(uint256(21));

Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ library FilecoinWarmStorageServiceStateInternalLibrary {
returns (bool)
{
return uint256(
service.extsload(
service.extsload(
keccak256(
abi.encode(periodId >> 8, keccak256(abi.encode(dataSetId, StorageLayout.PROVEN_PERIODS_SLOT)))
)
abi.encode(periodId >> 8, keccak256(abi.encode(dataSetId, StorageLayout.PROVEN_PERIODS_SLOT)))
)
)
) & (1 << (periodId & 255)) != 0;
) & (1 << (periodId & 255)) != 0;
}

function provingActivationEpoch(FilecoinWarmStorageService service, uint256 dataSetId)
Expand All @@ -196,11 +196,11 @@ library FilecoinWarmStorageServiceStateInternalLibrary {
return uint64(uint256(service.extsload(StorageLayout.MAX_PROVING_PERIOD_SLOT)));
}

// Number of epochs at the end of a proving period during which a
// proof of possession can be submitted
function challengeWindow(FilecoinWarmStorageService service) internal view returns (uint256) {
return uint256(service.extsload(StorageLayout.CHALLENGE_WINDOW_SIZE_SLOT));
}
// // Number of epochs at the end of a proving period during which a
// // proof of possession can be submitted
// function challengeWindow(FilecoinWarmStorageService service) internal view returns (uint256) {
// return uint256(service.extsload(StorageLayout.CHALLENGE_WINDOW_SIZE_SLOT));
// }

/**
* @notice Returns PDP configuration values
Expand All @@ -221,7 +221,7 @@ library FilecoinWarmStorageServiceStateInternalLibrary {
)
{
maxProvingPeriod = getMaxProvingPeriod(service);
challengeWindowSize = challengeWindow(service);
challengeWindowSize = service.challengeWindowSize();
challengesPerProof = CHALLENGES_PER_PROOF;
initChallengeWindowStart = block.number + maxProvingPeriod - challengeWindowSize;
}
Expand Down Expand Up @@ -271,7 +271,7 @@ library FilecoinWarmStorageServiceStateInternalLibrary {
{
uint256 deadline = provingDeadline(service, setId);
uint64 maxProvingPeriod = getMaxProvingPeriod(service);
uint256 challengeWindowSize = challengeWindow(service);
uint256 challengeWindowSize = service.challengeWindowSize();

uint256 periodsSkipped;
// Proving period is open 0 skipped periods
Expand Down Expand Up @@ -398,11 +398,12 @@ library FilecoinWarmStorageServiceStateInternalLibrary {
* @return exists True if the key exists
* @return value The metadata value
*/
function getPieceMetadata(FilecoinWarmStorageService service, uint256 dataSetId, uint256 pieceId, string memory key)
internal
view
returns (bool exists, string memory value)
{
function getPieceMetadata(
FilecoinWarmStorageService service,
uint256 dataSetId,
uint256 pieceId,
string memory key
) internal view returns (bool exists, string memory value) {
// Check if key exists in the keys array
string[] memory keys = getStringArray(
service,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ library FilecoinWarmStorageServiceStateLibrary {
returns (bool)
{
return uint256(
service.extsload(
service.extsload(
keccak256(
abi.encode(periodId >> 8, keccak256(abi.encode(dataSetId, StorageLayout.PROVEN_PERIODS_SLOT)))
)
abi.encode(periodId >> 8, keccak256(abi.encode(dataSetId, StorageLayout.PROVEN_PERIODS_SLOT)))
)
)
) & (1 << (periodId & 255)) != 0;
) & (1 << (periodId & 255)) != 0;
}

function provingActivationEpoch(FilecoinWarmStorageService service, uint256 dataSetId)
Expand All @@ -192,11 +192,11 @@ library FilecoinWarmStorageServiceStateLibrary {
return uint64(uint256(service.extsload(StorageLayout.MAX_PROVING_PERIOD_SLOT)));
}

// Number of epochs at the end of a proving period during which a
// proof of possession can be submitted
function challengeWindow(FilecoinWarmStorageService service) public view returns (uint256) {
return uint256(service.extsload(StorageLayout.CHALLENGE_WINDOW_SIZE_SLOT));
}
// // Number of epochs at the end of a proving period during which a
// // proof of possession can be submitted
// function challengeWindow(FilecoinWarmStorageService service) public view returns (uint256) {
// return uint256(service.extsload(StorageLayout.CHALLENGE_WINDOW_SIZE_SLOT));
// }

/**
* @notice Returns PDP configuration values
Expand All @@ -217,7 +217,7 @@ library FilecoinWarmStorageServiceStateLibrary {
)
{
maxProvingPeriod = getMaxProvingPeriod(service);
challengeWindowSize = challengeWindow(service);
challengeWindowSize = service.challengeWindowSize();
challengesPerProof = CHALLENGES_PER_PROOF;
initChallengeWindowStart = block.number + maxProvingPeriod - challengeWindowSize;
}
Expand Down Expand Up @@ -267,7 +267,7 @@ library FilecoinWarmStorageServiceStateLibrary {
{
uint256 deadline = provingDeadline(service, setId);
uint64 maxProvingPeriod = getMaxProvingPeriod(service);
uint256 challengeWindowSize = challengeWindow(service);
uint256 challengeWindowSize = service.challengeWindowSize();

uint256 periodsSkipped;
// Proving period is open 0 skipped periods
Expand Down Expand Up @@ -394,11 +394,12 @@ library FilecoinWarmStorageServiceStateLibrary {
* @return exists True if the key exists
* @return value The metadata value
*/
function getPieceMetadata(FilecoinWarmStorageService service, uint256 dataSetId, uint256 pieceId, string memory key)
public
view
returns (bool exists, string memory value)
{
function getPieceMetadata(
FilecoinWarmStorageService service,
uint256 dataSetId,
uint256 pieceId,
string memory key
) public view returns (bool exists, string memory value) {
// Check if key exists in the keys array
string[] memory keys = getStringArray(
service,
Expand Down
5 changes: 3 additions & 2 deletions service_contracts/src/lib/SignatureVerificationLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ library SignatureVerificationLib {
string[] calldata keys,
string[] calldata values
) public pure returns (bytes32 structHash) {
return
keccak256(abi.encode(CREATE_DATA_SET_TYPEHASH, clientDataSetId, payee, hashMetadataEntries(keys, values)));
return keccak256(
abi.encode(CREATE_DATA_SET_TYPEHASH, clientDataSetId, payee, hashMetadataEntries(keys, values))
);
}

function hashAllCids(Cids.Cid[] calldata pieceDataArray) internal pure returns (bytes32 cidHashesHash) {
Expand Down
12 changes: 6 additions & 6 deletions service_contracts/test/FilecoinWarmStorageService.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -762,11 +762,7 @@ contract FilecoinWarmStorageServiceTest is MockFVMTest {
// Create dataset with metadataKeys/metadataValues
(string[] memory dsKeys, string[] memory dsValues) = _getSingleMetadataKV("label", "Test Data Set");
FilecoinWarmStorageService.DataSetCreateData memory createData = FilecoinWarmStorageService.DataSetCreateData({
payer: client,
clientDataSetId: 0,
metadataKeys: dsKeys,
metadataValues: dsValues,
signature: FAKE_SIGNATURE
payer: client, clientDataSetId: 0, metadataKeys: dsKeys, metadataValues: dsValues, signature: FAKE_SIGNATURE
});
bytes memory encodedCreateData = abi.encode(
createData.payer,
Expand Down Expand Up @@ -1629,7 +1625,11 @@ contract FilecoinWarmStorageServiceTest is MockFVMTest {
* @param clientAddress The client address
* @return The created data set ID
*/
function createDataSetForServiceProviderTest(address provider, address clientAddress, string memory /*metadata*/ )
function createDataSetForServiceProviderTest(
address provider,
address clientAddress,
string memory /*metadata*/
)
internal
returns (uint256)
{
Expand Down
6 changes: 2 additions & 4 deletions service_contracts/test/ProductTypes.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import {BloomSet16} from "../src/lib/BloomSet.sol";

contract ProductTypesTest is Test {
function testPDPKeys() public pure {
uint256 expected = (
BloomSet16.compressed("serviceURL") | BloomSet16.compressed("minPieceSizeInBytes")
uint256 expected = (BloomSet16.compressed("serviceURL") | BloomSet16.compressed("minPieceSizeInBytes")
| BloomSet16.compressed("maxPieceSizeInBytes") | BloomSet16.compressed("storagePricePerTibPerDay")
| BloomSet16.compressed("minProvingPeriodInEpochs") | BloomSet16.compressed("location")
| BloomSet16.compressed("paymentTokenAddress")
);
| BloomSet16.compressed("paymentTokenAddress"));
assertEq(expected, REQUIRED_PDP_KEYS);
}
}
5 changes: 2 additions & 3 deletions service_contracts/test/mocks/SharedMocks.sol
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,8 @@ contract MockPDPVerifier {

// Call the listener's storageProviderChanged function
if (listenerAddr != address(0)) {
PDPListener(listenerAddr).storageProviderChanged(
dataSetId, oldServiceProvider, newServiceProvider, extraData
);
PDPListener(listenerAddr)
.storageProviderChanged(dataSetId, oldServiceProvider, newServiceProvider, extraData);
}

emit DataSetServiceProviderChanged(dataSetId, oldServiceProvider, newServiceProvider);
Expand Down