From 2c064664548f999c5901b5c3555da06edd959f64 Mon Sep 17 00:00:00 2001 From: William Morriss Date: Thu, 16 Oct 2025 20:25:57 -0500 Subject: [PATCH 1/2] burn with FVMPay --- service_contracts/foundry.toml | 1 + service_contracts/src/ServiceProviderRegistry.sol | 7 ++----- .../test/FilecoinWarmStorageService.t.sol | 8 +++++--- .../test/FilecoinWarmStorageServiceOwner.t.sol | 8 +++++--- service_contracts/test/ProviderValidation.t.sol | 7 ++++--- service_contracts/test/ServiceProviderRegistry.t.sol | 7 ++++--- .../test/ServiceProviderRegistryFull.t.sol | 12 +++++++----- .../test/ServiceProviderRegistryPagination.t.sol | 7 ++++--- 8 files changed, 32 insertions(+), 25 deletions(-) diff --git a/service_contracts/foundry.toml b/service_contracts/foundry.toml index ee83fb78..93a816ac 100644 --- a/service_contracts/foundry.toml +++ b/service_contracts/foundry.toml @@ -18,6 +18,7 @@ remappings = [ '@fws-payments/=lib/fws-payments/src/', '@pdp/=lib/pdp/src/', '@session-key-registry/=lib/session-key-registry/src/', + '@fvm-solidity/=lib/pdp/lib/fvm-solidity/src/', '@pythnetwork/pyth-sdk-solidity/=lib/pdp/lib/pyth-sdk-solidity/', ] diff --git a/service_contracts/src/ServiceProviderRegistry.sol b/service_contracts/src/ServiceProviderRegistry.sol index 9f9b0c12..2144a0e0 100644 --- a/service_contracts/src/ServiceProviderRegistry.sol +++ b/service_contracts/src/ServiceProviderRegistry.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT pragma solidity ^0.8.20; +import {FVMPay} from "@fvm-solidity/FVMPay.sol"; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; @@ -47,9 +48,6 @@ contract ServiceProviderRegistry is /// @notice Maximum length for location field uint256 private constant MAX_LOCATION_LENGTH = 128; - /// @notice Burn actor address for burning FIL - address public constant BURN_ACTOR = 0xff00000000000000000000000000000000000063; - /// @notice Registration fee in attoFIL (5 FIL = 5 * 10^18 attoFIL) uint256 public constant REGISTRATION_FEE = 5e18; @@ -193,8 +191,7 @@ contract ServiceProviderRegistry is ); // Burn the registration fee - (bool burnSuccess,) = BURN_ACTOR.call{value: REGISTRATION_FEE}(""); - require(burnSuccess, "Burn failed"); + require(FVMPay.burn(REGISTRATION_FEE), "Burn failed"); } /// @notice Add a new product to an existing provider diff --git a/service_contracts/test/FilecoinWarmStorageService.t.sol b/service_contracts/test/FilecoinWarmStorageService.t.sol index 90dfd2e2..1d656eb9 100644 --- a/service_contracts/test/FilecoinWarmStorageService.t.sol +++ b/service_contracts/test/FilecoinWarmStorageService.t.sol @@ -1,7 +1,8 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; -import {Test, console, Vm} from "forge-std/Test.sol"; +import {MockFVMTest} from "@fvm-solidity/mocks/MockFVMTest.sol"; +import {console, Test, Vm} from "forge-std/Test.sol"; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; @@ -21,7 +22,7 @@ import {Errors} from "../src/Errors.sol"; import {ServiceProviderRegistryStorage} from "../src/ServiceProviderRegistryStorage.sol"; import {ServiceProviderRegistry} from "../src/ServiceProviderRegistry.sol"; -contract FilecoinWarmStorageServiceTest is Test { +contract FilecoinWarmStorageServiceTest is MockFVMTest { using SafeERC20 for MockERC20; using FilecoinWarmStorageServiceStateLibrary for FilecoinWarmStorageService; // Testing Constants @@ -92,7 +93,8 @@ contract FilecoinWarmStorageServiceTest is Test { bytes extraData; } - function setUp() public { + function setUp() public override { + super.setUp(); // Setup test accounts deployer = address(this); client = address(0xf1); diff --git a/service_contracts/test/FilecoinWarmStorageServiceOwner.t.sol b/service_contracts/test/FilecoinWarmStorageServiceOwner.t.sol index 85c21c0f..40149dda 100644 --- a/service_contracts/test/FilecoinWarmStorageServiceOwner.t.sol +++ b/service_contracts/test/FilecoinWarmStorageServiceOwner.t.sol @@ -1,7 +1,8 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; -import {Test, console} from "forge-std/Test.sol"; +import {MockFVMTest} from "@fvm-solidity/mocks/MockFVMTest.sol"; +import {console} from "forge-std/Test.sol"; import {FilecoinWarmStorageService} from "../src/FilecoinWarmStorageService.sol"; import {FilecoinWarmStorageServiceStateView} from "../src/FilecoinWarmStorageServiceStateView.sol"; import {ServiceProviderRegistry} from "../src/ServiceProviderRegistry.sol"; @@ -15,7 +16,7 @@ import {Errors} from "../src/Errors.sol"; import {MockERC20, MockPDPVerifier} from "./mocks/SharedMocks.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -contract FilecoinWarmStorageServiceOwnerTest is Test { +contract FilecoinWarmStorageServiceOwnerTest is MockFVMTest { using SafeERC20 for MockERC20; // Constants @@ -49,7 +50,8 @@ contract FilecoinWarmStorageServiceOwnerTest is Test { uint256 indexed dataSetId, address indexed oldServiceProvider, address indexed newServiceProvider ); - function setUp() public { + function setUp() public override { + super.setUp(); // Setup accounts owner = address(this); client = address(0x1); diff --git a/service_contracts/test/ProviderValidation.t.sol b/service_contracts/test/ProviderValidation.t.sol index e0f2d2e0..d1910207 100644 --- a/service_contracts/test/ProviderValidation.t.sol +++ b/service_contracts/test/ProviderValidation.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; -import {Test} from "forge-std/Test.sol"; +import {MockFVMTest} from "@fvm-solidity/mocks/MockFVMTest.sol"; import {FilecoinPayV1} from "@fws-payments/FilecoinPayV1.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; @@ -16,7 +16,7 @@ import {ServiceProviderRegistryStorage} from "../src/ServiceProviderRegistryStor import {MockERC20, MockPDPVerifier} from "./mocks/SharedMocks.sol"; import {Errors} from "../src/Errors.sol"; -contract ProviderValidationTest is Test { +contract ProviderValidationTest is MockFVMTest { using SafeERC20 for MockERC20; FilecoinWarmStorageService public warmStorage; @@ -40,7 +40,8 @@ contract ProviderValidationTest is Test { uint8(27) ); - function setUp() public { + function setUp() public override { + super.setUp(); owner = address(this); provider1 = address(0x1); provider2 = address(0x2); diff --git a/service_contracts/test/ServiceProviderRegistry.t.sol b/service_contracts/test/ServiceProviderRegistry.t.sol index a96ad6a7..38918afa 100644 --- a/service_contracts/test/ServiceProviderRegistry.t.sol +++ b/service_contracts/test/ServiceProviderRegistry.t.sol @@ -1,21 +1,22 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; -import {Test} from "forge-std/Test.sol"; +import {MockFVMTest} from "@fvm-solidity/mocks/MockFVMTest.sol"; import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {ServiceProviderRegistry} from "../src/ServiceProviderRegistry.sol"; import {ServiceProviderRegistryStorage} from "../src/ServiceProviderRegistryStorage.sol"; -contract ServiceProviderRegistryTest is Test { +contract ServiceProviderRegistryTest is MockFVMTest { ServiceProviderRegistry public implementation; ServiceProviderRegistry public registry; address public owner; address public user1; address public user2; - function setUp() public { + function setUp() public override { + super.setUp(); owner = address(this); user1 = address(0x1); user2 = address(0x2); diff --git a/service_contracts/test/ServiceProviderRegistryFull.t.sol b/service_contracts/test/ServiceProviderRegistryFull.t.sol index 50cb3acc..4b5e10e8 100644 --- a/service_contracts/test/ServiceProviderRegistryFull.t.sol +++ b/service_contracts/test/ServiceProviderRegistryFull.t.sol @@ -1,13 +1,14 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; -import {Test} from "forge-std/Test.sol"; +import {BURN_ADDRESS} from "@fvm-solidity/FVMActors.sol"; +import {MockFVMTest} from "@fvm-solidity/mocks/MockFVMTest.sol"; import {ServiceProviderRegistry} from "../src/ServiceProviderRegistry.sol"; import {ServiceProviderRegistryStorage} from "../src/ServiceProviderRegistryStorage.sol"; import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -contract ServiceProviderRegistryFullTest is Test { +contract ServiceProviderRegistryFullTest is MockFVMTest { ServiceProviderRegistry public implementation; ServiceProviderRegistry public registry; @@ -49,7 +50,8 @@ contract ServiceProviderRegistryFullTest is Test { event ProviderRemoved(uint256 indexed providerId); event ProviderInfoUpdated(uint256 indexed providerId); - function setUp() public { + function setUp() public override { + super.setUp(); owner = address(this); provider1 = address(0x1); provider2 = address(0x2); @@ -123,7 +125,7 @@ contract ServiceProviderRegistryFullTest is Test { function testRegisterProvider() public { // Check burn actor balance before - uint256 burnActorBalanceBefore = registry.BURN_ACTOR().balance; + uint256 burnActorBalanceBefore = BURN_ADDRESS.balance; vm.startPrank(provider1); @@ -233,7 +235,7 @@ contract ServiceProviderRegistryFullTest is Test { assertEq(datacenterValue, "EU-WEST", "Product first value should be EU-WEST"); // Verify fee was burned - uint256 burnActorBalanceAfter = registry.BURN_ACTOR().balance; + uint256 burnActorBalanceAfter = BURN_ADDRESS.balance; assertEq(burnActorBalanceAfter - burnActorBalanceBefore, REGISTRATION_FEE, "Fee should be burned"); } diff --git a/service_contracts/test/ServiceProviderRegistryPagination.t.sol b/service_contracts/test/ServiceProviderRegistryPagination.t.sol index 645e0ad2..cbdd6ae1 100644 --- a/service_contracts/test/ServiceProviderRegistryPagination.t.sol +++ b/service_contracts/test/ServiceProviderRegistryPagination.t.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT pragma solidity ^0.8.20; -import {Test} from "forge-std/Test.sol"; +import {MockFVMTest} from "@fvm-solidity/mocks/MockFVMTest.sol"; import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {ServiceProviderRegistry} from "../src/ServiceProviderRegistry.sol"; import {ServiceProviderRegistryStorage} from "../src/ServiceProviderRegistryStorage.sol"; -contract ServiceProviderRegistryPaginationTest is Test { +contract ServiceProviderRegistryPaginationTest is MockFVMTest { ServiceProviderRegistry public registry; address public owner = address(0x1); @@ -24,7 +24,8 @@ contract ServiceProviderRegistryPaginationTest is Test { ServiceProviderRegistryStorage.PDPOffering public defaultPDPData; bytes public encodedDefaultPDPData; - function setUp() public { + function setUp() public override { + super.setUp(); vm.startPrank(owner); // Deploy implementation From 930a082cd3468c02209dd3763a357018612eaf58 Mon Sep 17 00:00:00 2001 From: William Morriss Date: Thu, 16 Oct 2025 20:27:43 -0500 Subject: [PATCH 2/2] make update-abi --- .../abi/ServiceProviderRegistry.abi.json | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/service_contracts/abi/ServiceProviderRegistry.abi.json b/service_contracts/abi/ServiceProviderRegistry.abi.json index f3ffa682..454d9a9b 100644 --- a/service_contracts/abi/ServiceProviderRegistry.abi.json +++ b/service_contracts/abi/ServiceProviderRegistry.abi.json @@ -4,19 +4,6 @@ "inputs": [], "stateMutability": "nonpayable" }, - { - "type": "function", - "name": "BURN_ACTOR", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, { "type": "function", "name": "MAX_CAPABILITIES",