From f34d07153aa99765b0c38086687c69f2fcf698db Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Thu, 18 Sep 2025 17:27:17 +0200 Subject: [PATCH 01/39] feat: Update IexecPocoAccessorsFacet and related scripts for enhanced functionality and proxy updates --- contracts/facets/IexecPocoAccessorsFacet.sol | 161 ++++++++++++++- contracts/interfaces/IexecPocoAccessors.sol | 48 +++++ deploy/0_deploy.ts | 3 +- hardhat.config.ts | 17 ++ .../0_deploy-updated-accessor-facet.ts | 41 ++++ .../1_update-proxy-with-new-facet.ts | 191 ++++++++++++++++++ scripts/updateProxy/update-diamond-proxy.ts | 33 +++ .../IexecCategoryManager.test.ts | 2 +- 8 files changed, 492 insertions(+), 4 deletions(-) create mode 100644 scripts/updateProxy/0_deploy-updated-accessor-facet.ts create mode 100644 scripts/updateProxy/1_update-proxy-with-new-facet.ts create mode 100644 scripts/updateProxy/update-diamond-proxy.ts diff --git a/contracts/facets/IexecPocoAccessorsFacet.sol b/contracts/facets/IexecPocoAccessorsFacet.sol index 9678f2b82..266db5b7e 100644 --- a/contracts/facets/IexecPocoAccessorsFacet.sol +++ b/contracts/facets/IexecPocoAccessorsFacet.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.0; -import {PocoStorageLib} from "../libs/PocoStorageLib.v8.sol"; +import {PocoStorageLib, IRegistry} from "../libs/PocoStorageLib.v8.sol"; import {FacetBase} from "./FacetBase.v8.sol"; import {IexecLibCore_v5} from "../libs/IexecLibCore_v5.sol"; import {IexecLibOrders_v5} from "../libs/IexecLibOrders_v5.sol"; @@ -73,4 +73,163 @@ contract IexecPocoAccessorsFacet is _toTypedDataHash(requestOrder.hash()) ); } + + // ========= Token and Account Accessors ========= + + function name() external view returns (string memory) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_name; + } + + function symbol() external view returns (string memory) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_symbol; + } + + function decimals() external view returns (uint8) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_decimals; + } + + function totalSupply() external view returns (uint256) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_totalSupply; + } + + function balanceOf(address account) external view returns (uint256) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_balances[account]; + } + + function frozenOf(address account) external view returns (uint256) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_frozens[account]; + } + + function allowance(address account, address spender) external view returns (uint256) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_allowances[account][spender]; + } + + function viewAccount(address account) external view returns (IexecLibCore_v5.Account memory) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return IexecLibCore_v5.Account($.m_balances[account], $.m_frozens[account]); + } + + function token() external view returns (address) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return address($.m_baseToken); + } + + // ========= Deal and Task Accessors ========= + + function viewConsumed(bytes32 _id) external view returns (uint256 consumed) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_consumed[_id]; + } + + function viewPresigned(bytes32 _id) external view returns (address signer) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_presigned[_id]; + } + + function viewContribution( + bytes32 _taskid, + address _worker + ) external view returns (IexecLibCore_v5.Contribution memory) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_contributions[_taskid][_worker]; + } + + function viewScore(address _worker) external view returns (uint256) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_workerScores[_worker]; + } + + function resultFor(bytes32 id) external view returns (bytes memory) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + IexecLibCore_v5.Task storage task = $.m_tasks[id]; + require(task.status == IexecLibCore_v5.TaskStatusEnum.COMPLETED, "task-pending"); + return task.resultsCallback; // Expansion - result separation + } + + // ========= Category Accessors ========= + + function viewCategory( + uint256 _catid + ) external view returns (IexecLibCore_v5.Category memory category) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_categories[_catid]; + } + + function countCategory() external view returns (uint256 count) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_categories.length; + } + + // ========= Registry Accessors ========= + + function appregistry() external view returns (IRegistry) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_appregistry; + } + + function datasetregistry() external view returns (IRegistry) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_datasetregistry; + } + + function workerpoolregistry() external view returns (IRegistry) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_workerpoolregistry; + } + + function teebroker() external view returns (address) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_teebroker; + } + + function callbackgas() external view returns (uint256) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_callbackgas; + } + + // ========= Constants Accessors ========= + + function contribution_deadline_ratio() external view returns (uint256) { + return CONTRIBUTION_DEADLINE_RATIO; + } + + function reveal_deadline_ratio() external view returns (uint256) { + return REVEAL_DEADLINE_RATIO; + } + + function final_deadline_ratio() external view returns (uint256) { + return FINAL_DEADLINE_RATIO; + } + + function workerpool_stake_ratio() external view returns (uint256) { + return WORKERPOOL_STAKE_RATIO; + } + + function kitty_ratio() external view returns (uint256) { + return KITTY_RATIO; + } + + function kitty_min() external view returns (uint256) { + return KITTY_MIN; + } + + function kitty_address() external view returns (address) { + return KITTY_ADDRESS; + } + + function groupmember_purpose() external view returns (uint256) { + return GROUPMEMBER_PURPOSE; + } + + function eip712domain_separator() external view returns (bytes32) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_eip712DomainSeparator; + } } diff --git a/contracts/interfaces/IexecPocoAccessors.sol b/contracts/interfaces/IexecPocoAccessors.sol index 4e4ddd276..ffdc55360 100644 --- a/contracts/interfaces/IexecPocoAccessors.sol +++ b/contracts/interfaces/IexecPocoAccessors.sol @@ -5,8 +5,10 @@ pragma solidity ^0.8.0; import {IexecLibCore_v5} from "../libs/IexecLibCore_v5.sol"; import {IexecLibOrders_v5} from "../libs/IexecLibOrders_v5.sol"; +import {IRegistry} from "../libs/PocoStorageLib.v8.sol"; interface IexecPocoAccessors { + // ========= Deal and Task Accessors ========= function viewDeal(bytes32 id) external view returns (IexecLibCore_v5.Deal memory); function viewTask(bytes32 id) external view returns (IexecLibCore_v5.Task memory); @@ -17,4 +19,50 @@ interface IexecPocoAccessors { IexecLibOrders_v5.WorkerpoolOrder calldata workerpoolOrder, IexecLibOrders_v5.RequestOrder calldata requestOrder ) external view returns (uint256); + + function viewConsumed(bytes32 _id) external view returns (uint256 consumed); + + function viewPresigned(bytes32 _id) external view returns (address signer); + + function viewContribution( + bytes32 _taskid, + address _worker + ) external view returns (IexecLibCore_v5.Contribution memory); + + function viewScore(address _worker) external view returns (uint256); + + function resultFor(bytes32 id) external view returns (bytes memory); + + // ========= Token and Account Accessors ========= + function name() external view returns (string memory); + function symbol() external view returns (string memory); + function decimals() external view returns (uint8); + function totalSupply() external view returns (uint256); + function balanceOf(address account) external view returns (uint256); + function frozenOf(address account) external view returns (uint256); + function allowance(address account, address spender) external view returns (uint256); + function viewAccount(address account) external view returns (IexecLibCore_v5.Account memory); + function token() external view returns (address); + + // ========= Category Accessors ========= + function viewCategory(uint256 _catid) external view returns (IexecLibCore_v5.Category memory); + function countCategory() external view returns (uint256); + + // ========= Registry Accessors ========= + function appregistry() external view returns (IRegistry); + function datasetregistry() external view returns (IRegistry); + function workerpoolregistry() external view returns (IRegistry); + function teebroker() external view returns (address); + function callbackgas() external view returns (uint256); + + // ========= Constants Accessors ========= + function contribution_deadline_ratio() external view returns (uint256); + function reveal_deadline_ratio() external view returns (uint256); + function final_deadline_ratio() external view returns (uint256); + function workerpool_stake_ratio() external view returns (uint256); + function kitty_ratio() external view returns (uint256); + function kitty_min() external view returns (uint256); + function kitty_address() external view returns (address); + function groupmember_purpose() external view returns (uint256); + function eip712domain_separator() external view returns (bytes32); } diff --git a/deploy/0_deploy.ts b/deploy/0_deploy.ts index 70d2e3047..6f5d39bcb 100644 --- a/deploy/0_deploy.ts +++ b/deploy/0_deploy.ts @@ -14,7 +14,6 @@ import { DiamondLoupeFacet__factory, Diamond__factory, IexecAccessorsABILegacyFacet__factory, - IexecAccessorsFacet__factory, IexecAccessors__factory, IexecCategoryManagerFacet__factory, IexecCategoryManager__factory, @@ -93,7 +92,7 @@ export default async function deploy() { const isArbitrumMainnet = (await ethers.provider.getNetwork()).chainId === 42161n; const facets = [ new IexecAccessorsABILegacyFacet__factory(), - new IexecAccessorsFacet__factory(), + // new IexecAccessorsFacet__factory(), to test the updated IexecPocoAccessorsFacet new IexecCategoryManagerFacet__factory(), new IexecConfigurationExtraFacet__factory(), new IexecConfigurationFacet__factory(iexecLibOrders), diff --git a/hardhat.config.ts b/hardhat.config.ts index 557dca560..da9192a52 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -17,6 +17,7 @@ const isNativeChainType = chainConfig.isNativeChain(); const isLocalFork = process.env.LOCAL_FORK == 'true'; const isFujiFork = process.env.FUJI_FORK == 'true'; const isArbitrumSepoliaFork = process.env.ARBITRUM_SEPOLIA_FORK == 'true'; +const isArbitrumFork = process.env.ARBITRUM_FORK == 'true'; const bellecourBlockscoutUrl = 'https://blockscout.bellecour.iex.ec'; /** @@ -119,6 +120,18 @@ const config: HardhatUserConfig = { }, ...arbitrumSepoliaBaseConfig, }), + + ...(isArbitrumFork && { + forking: { + url: + process.env.ARBITRUM_RPC_URL || + 'https://lb.drpc.org/arbitrum/AhEPbH3buE5zjj_dDMs3E2hIUihFGTAR8J88ThukG97E', + blockNumber: process.env.ARBITRUM_BLOCK_NUMBER + ? parseInt(process.env.ARBITRUM_BLOCK_NUMBER) + : undefined, + }, + ...arbitrumBaseConfig, + }), }, 'external-hardhat': { ...defaultHardhatNetworkParams, @@ -139,6 +152,10 @@ const config: HardhatUserConfig = { accounts: 'remote', // Override defaults accounts for impersonation ...arbitrumSepoliaBaseConfig, }), + ...(isArbitrumFork && { + accounts: 'remote', // Override defaults accounts for impersonation + ...arbitrumBaseConfig, + }), }, 'dev-native': { chainId: 65535, diff --git a/scripts/updateProxy/0_deploy-updated-accessor-facet.ts b/scripts/updateProxy/0_deploy-updated-accessor-facet.ts new file mode 100644 index 000000000..3f6fa9395 --- /dev/null +++ b/scripts/updateProxy/0_deploy-updated-accessor-facet.ts @@ -0,0 +1,41 @@ +// SPDX-FileCopyrightText: 2025 IEXEC BLOCKCHAIN TECH +// SPDX-License-Identifier: Apache-2.0 + +import { deployments, ethers } from 'hardhat'; +import { IexecPocoAccessorsFacet__factory } from '../../typechain'; +import { FactoryDeployer } from '../../utils/FactoryDeployer'; +import config from '../../utils/config'; +import { mineBlockIfOnLocalFork } from '../../utils/mine'; + +(async () => { + console.log('Deploying updated IexecPocoAccessorsFacet...'); + await mineBlockIfOnLocalFork(); + + const [owner] = await ethers.getSigners(); + const chainId = (await ethers.provider.getNetwork()).chainId; + const deploymentOptions = config.getChainConfig(chainId).v5; + + if (!deploymentOptions.IexecLibOrders_v5) { + throw new Error('IexecLibOrders_v5 is required'); + } + + const factoryDeployer = new FactoryDeployer(owner, chainId); + const iexecLibOrders = { + ['contracts/libs/IexecLibOrders_v5.sol:IexecLibOrders_v5']: + deploymentOptions.IexecLibOrders_v5, + }; + + const factory = new IexecPocoAccessorsFacet__factory(iexecLibOrders); + const facetAddress = await factoryDeployer.deployContract(factory); + + console.log(`IexecPocoAccessorsFacet deployed at: ${facetAddress}`); + + // Save deployment for later use + await deployments.save('IexecPocoAccessorsFacet', { + abi: factory.interface.fragments as any, + address: facetAddress, + bytecode: factory.bytecode, + }); + + console.log('Deployment saved as IexecPocoAccessorsFacet'); +})(); diff --git a/scripts/updateProxy/1_update-proxy-with-new-facet.ts b/scripts/updateProxy/1_update-proxy-with-new-facet.ts new file mode 100644 index 000000000..48a47c197 --- /dev/null +++ b/scripts/updateProxy/1_update-proxy-with-new-facet.ts @@ -0,0 +1,191 @@ +// SPDX-FileCopyrightText: 2025 IEXEC BLOCKCHAIN TECH +// SPDX-License-Identifier: Apache-2.0 + +import { ZeroAddress } from 'ethers'; +import { deployments, ethers } from 'hardhat'; +import { FacetCutAction } from 'hardhat-deploy/dist/types'; +import type { IDiamond } from '../../typechain'; +import { + DiamondCutFacet__factory, + DiamondLoupeFacet__factory, + IexecPocoAccessorsFacet__factory, +} from '../../typechain'; +import { Ownable__factory } from '../../typechain/factories/rlc-faucet-contract/contracts'; +import config from '../../utils/config'; +import { getFunctionSelectors } from '../../utils/proxy-tools'; +import { printFunctions } from '../upgrades/upgrade-helper'; + +(async () => { + const chainId = (await ethers.provider.getNetwork()).chainId; + const deploymentOptions = config.getChainConfig(chainId).v5; + + console.log('Updating diamond proxy with new IexecPocoAccessorsFacet...'); + console.log(`Network: ${chainId}`); + + if (!deploymentOptions.DiamondProxy) { + throw new Error('DiamondProxy is required'); + } + if (!deploymentOptions.IexecLibOrders_v5) { + throw new Error('IexecLibOrders_v5 is required'); + } + + const diamondProxyAddress = deploymentOptions.DiamondProxy; + console.log(`Diamond proxy address: ${diamondProxyAddress}`); + + const [account] = await ethers.getSigners(); + + const updatedFacetAddress = (await deployments.get('IexecPocoAccessorsFacet')).address; //C + console.log(`Updated facet address: ${updatedFacetAddress}`); + + const diamondLoupe = DiamondLoupeFacet__factory.connect(diamondProxyAddress, account); + const facets = await diamondLoupe.facets(); + + console.log('\nCurrent facets in diamond:'); + facets.forEach((facet) => { + console.log(` ${facet.facetAddress}: ${facet.functionSelectors.length} functions`); + }); + + const iexecLibOrders = { + ['contracts/libs/IexecLibOrders_v5.sol:IexecLibOrders_v5']: + deploymentOptions.IexecLibOrders_v5, + }; + + // Find the specific old accessor facets to remove completely + const oldAccessorFacets = new Set(); + + const accessorFunctionSignatures = [ + '0x70a08231', // balanceOf() + '0x06fdde03', // name() + '0x95d89b41', // symbol() + '0x313ce567', // decimals() + '0x18160ddd', // totalSupply() + '0xdd62ed3e', // allowance() + '0x9910fd72', // workerpoolByIndex() + '0xdb8aaa26', // appByIndex() + '0x1bf6e00d', // datasetByIndex() + ]; + + const specificFunctionSignature = '0x66517ca6'; // ComputeDealVolume + + // Find the current accessor facet in the diamond (the one with 32 functions) + for (const facet of facets) { + const hasAccessorFunctions = facet.functionSelectors.some((selector) => + accessorFunctionSignatures.includes(selector), + ); + if (hasAccessorFunctions) { + oldAccessorFacets.add(facet.facetAddress); + } + + const hasSpecificFunction = facet.functionSelectors.includes(specificFunctionSignature); + if (hasSpecificFunction) { + oldAccessorFacets.add(facet.facetAddress); + } + } + + // Find functions that need to be removed - ALL functions from old accessor facets + const functionsToRemove: string[] = []; + const functionsToRemoveByFacet = new Map(); + + // Remove ALL functions from the old accessor facets + for (const facet of facets) { + if (oldAccessorFacets.has(facet.facetAddress)) { + console.log( + `Found old accessor facet ${facet.facetAddress} with ${facet.functionSelectors.length} functions - will remove ALL`, + ); + functionsToRemove.push(...facet.functionSelectors); + functionsToRemoveByFacet.set(facet.facetAddress, [...facet.functionSelectors]); + } + } + + // Functions to add - ALL functions from the new facet, but exclude any that exist in other (non-accessor) facets + const newFacetFactory = new IexecPocoAccessorsFacet__factory(iexecLibOrders); //C + const allNewFunctionSelectors = getFunctionSelectors(newFacetFactory); + + const functionsInOtherFacets = new Set(); + for (const facet of facets) { + // Skip old accessor facets (we're removing them) and the updated facet (if it already exists) + if ( + !oldAccessorFacets.has(facet.facetAddress) && + facet.facetAddress !== updatedFacetAddress + ) { + facet.functionSelectors.forEach((selector) => { + if (allNewFunctionSelectors.includes(selector)) { + functionsInOtherFacets.add(selector); + console.log( + ` Function ${selector} already exists in other facet ${facet.facetAddress} - will not add`, + ); + } + }); + } + } + + const newFunctionSelectors = allNewFunctionSelectors.filter( + (selector) => !functionsInOtherFacets.has(selector), + ); + + console.log(`Total functions to remove from old accessor facets: ${functionsToRemove.length}`); + console.log(`Functions skipped (exist in other facets): ${functionsInOtherFacets.size}`); + console.log(`Functions to add to new facet: ${newFunctionSelectors.length}`); + + const facetCuts: IDiamond.FacetCutStruct[] = []; + // Remove all functions from old accessor facets + for (const [, selectors] of functionsToRemoveByFacet) { + if (selectors.length > 0) { + facetCuts.push({ + facetAddress: ZeroAddress, + action: FacetCutAction.Remove, + functionSelectors: [...selectors], + }); + } + } + + // Add new functions + if (newFunctionSelectors.length > 0) { + console.log( + `Preparing to add ${newFunctionSelectors.length} functions to new facet ${updatedFacetAddress}`, + ); + facetCuts.push({ + facetAddress: updatedFacetAddress, + action: FacetCutAction.Add, + functionSelectors: [...newFunctionSelectors], + }); + } + + console.log('Functions before upgrade:'); + await printFunctions(diamondProxyAddress); + + const proxyOwnerAddress = await Ownable__factory.connect(diamondProxyAddress, account).owner(); + console.log(`Diamond proxy owner: ${proxyOwnerAddress}`); + const proxyOwnerSigner = await ethers.getImpersonatedSigner(proxyOwnerAddress); + const diamondProxyWithOwner = DiamondCutFacet__factory.connect( + diamondProxyAddress, + proxyOwnerSigner, + ); + + console.log('Executing diamond cut...'); + console.log(`Facet cuts: ${facetCuts.length}`); + facetCuts.forEach((cut, index) => { + console.log(` Cut ${index + 1}: ${cut.action} ${cut.functionSelectors.length} functions`); + console.log(` Facet: ${cut.facetAddress}`); + }); + + const tx = await diamondProxyWithOwner.diamondCut(facetCuts, ZeroAddress, '0x'); + await tx.wait(); + console.log('Diamond cut executed successfully'); + console.log(`Transaction hash: ${tx.hash}`); + + // Print functions after upgrade + console.log('Functions after upgrade:'); + await printFunctions(diamondProxyAddress); + + // Update the deployment record to point to the new facet + const newFacetFactoryForSave = new IexecPocoAccessorsFacet__factory(iexecLibOrders); + await deployments.save('IexecPocoAccessorsFacet', { + abi: newFacetFactoryForSave.interface.fragments as any, + address: updatedFacetAddress, + bytecode: newFacetFactoryForSave.bytecode, + }); + + console.log('Proxy update completed successfully!'); + console.log(`New IexecPocoAccessorsFacet is now active at: ${updatedFacetAddress}`); +})(); diff --git a/scripts/updateProxy/update-diamond-proxy.ts b/scripts/updateProxy/update-diamond-proxy.ts new file mode 100644 index 000000000..a2102f24b --- /dev/null +++ b/scripts/updateProxy/update-diamond-proxy.ts @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: 2024-2025 IEXEC BLOCKCHAIN TECH +// SPDX-License-Identifier: Apache-2.0 + +import { execSync } from 'child_process'; +import { ethers } from 'hardhat'; + +(async () => { + const chainId = (await ethers.provider.getNetwork()).chainId; + const networkName = process.env.HARDHAT_NETWORK || 'hardhat'; + console.log('Starting Diamond Proxy Update Process...'); + console.log(`Network: ${networkName} (Chain ID: ${chainId})`); + console.log('='.repeat(60)); + + try { + console.log('Step 1: Deploying updated IexecPocoAccessorsFacet...'); + execSync( + `npx hardhat run scripts/updateProxy/0_deploy-updated-accessor-facet.ts --network ${networkName}`, + { stdio: 'inherit' }, + ); + + console.log('Step 2: Updating diamond proxy...'); + execSync( + `npx hardhat run scripts/updateProxy/1_update-proxy-with-new-facet.ts --network ${networkName}`, + { stdio: 'inherit' }, + ); + + console.log('\\n' + '='.repeat(60)); + } catch (error) { + console.error('Error during proxy update:'); + console.error(error); + process.exit(1); + } +})(); diff --git a/test/byContract/IexecCategoryManager/IexecCategoryManager.test.ts b/test/byContract/IexecCategoryManager/IexecCategoryManager.test.ts index 8d1c2c41f..14f44b85e 100644 --- a/test/byContract/IexecCategoryManager/IexecCategoryManager.test.ts +++ b/test/byContract/IexecCategoryManager/IexecCategoryManager.test.ts @@ -47,7 +47,7 @@ describe('CategoryManager', async () => { const lastCategoryIndex = (await iexecPocoAsAnyone.countCategory()) - 1n; await expect( iexecPocoAsAnyone.viewCategory(lastCategoryIndex + 1n), - ).to.be.revertedWithoutReason(); + ).to.be.revertedWithPanic(0x32); }); it('Should create category', async () => { From 4a44957ac8d36432430e9fce04c03f19a6f50b4c Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 08:14:07 +0200 Subject: [PATCH 02/39] feat: Remove useless file --- scripts/updateProxy/update-diamond-proxy.ts | 33 --------------------- 1 file changed, 33 deletions(-) delete mode 100644 scripts/updateProxy/update-diamond-proxy.ts diff --git a/scripts/updateProxy/update-diamond-proxy.ts b/scripts/updateProxy/update-diamond-proxy.ts deleted file mode 100644 index a2102f24b..000000000 --- a/scripts/updateProxy/update-diamond-proxy.ts +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-FileCopyrightText: 2024-2025 IEXEC BLOCKCHAIN TECH -// SPDX-License-Identifier: Apache-2.0 - -import { execSync } from 'child_process'; -import { ethers } from 'hardhat'; - -(async () => { - const chainId = (await ethers.provider.getNetwork()).chainId; - const networkName = process.env.HARDHAT_NETWORK || 'hardhat'; - console.log('Starting Diamond Proxy Update Process...'); - console.log(`Network: ${networkName} (Chain ID: ${chainId})`); - console.log('='.repeat(60)); - - try { - console.log('Step 1: Deploying updated IexecPocoAccessorsFacet...'); - execSync( - `npx hardhat run scripts/updateProxy/0_deploy-updated-accessor-facet.ts --network ${networkName}`, - { stdio: 'inherit' }, - ); - - console.log('Step 2: Updating diamond proxy...'); - execSync( - `npx hardhat run scripts/updateProxy/1_update-proxy-with-new-facet.ts --network ${networkName}`, - { stdio: 'inherit' }, - ); - - console.log('\\n' + '='.repeat(60)); - } catch (error) { - console.error('Error during proxy update:'); - console.error(error); - process.exit(1); - } -})(); From 99b1b47212f494592f321ef94a24c0193b7473bd Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 08:54:15 +0200 Subject: [PATCH 03/39] feat: Refactor deal and task accessors in IexecPocoAccessorsFacet --- contracts/facets/IexecPocoAccessorsFacet.sol | 63 ++++++++++---------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/contracts/facets/IexecPocoAccessorsFacet.sol b/contracts/facets/IexecPocoAccessorsFacet.sol index 266db5b7e..9ce51221c 100644 --- a/contracts/facets/IexecPocoAccessorsFacet.sol +++ b/contracts/facets/IexecPocoAccessorsFacet.sol @@ -25,6 +25,7 @@ contract IexecPocoAccessorsFacet is using IexecLibOrders_v5 for IexecLibOrders_v5.WorkerpoolOrder; using IexecLibOrders_v5 for IexecLibOrders_v5.RequestOrder; + // ========= Deal and Task Accessors ========= /** * Get a deal created by PoCo classic facet. * @param id The ID of the deal. @@ -74,6 +75,36 @@ contract IexecPocoAccessorsFacet is ); } + function viewConsumed(bytes32 _id) external view returns (uint256 consumed) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_consumed[_id]; + } + + function viewPresigned(bytes32 _id) external view returns (address signer) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_presigned[_id]; + } + + function viewContribution( + bytes32 _taskid, + address _worker + ) external view returns (IexecLibCore_v5.Contribution memory) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_contributions[_taskid][_worker]; + } + + function viewScore(address _worker) external view returns (uint256) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return $.m_workerScores[_worker]; + } + + function resultFor(bytes32 id) external view returns (bytes memory) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + IexecLibCore_v5.Task storage task = $.m_tasks[id]; + require(task.status == IexecLibCore_v5.TaskStatusEnum.COMPLETED, "task-pending"); + return task.resultsCallback; // Expansion - result separation + } + // ========= Token and Account Accessors ========= function name() external view returns (string memory) { @@ -121,38 +152,6 @@ contract IexecPocoAccessorsFacet is return address($.m_baseToken); } - // ========= Deal and Task Accessors ========= - - function viewConsumed(bytes32 _id) external view returns (uint256 consumed) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_consumed[_id]; - } - - function viewPresigned(bytes32 _id) external view returns (address signer) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_presigned[_id]; - } - - function viewContribution( - bytes32 _taskid, - address _worker - ) external view returns (IexecLibCore_v5.Contribution memory) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_contributions[_taskid][_worker]; - } - - function viewScore(address _worker) external view returns (uint256) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_workerScores[_worker]; - } - - function resultFor(bytes32 id) external view returns (bytes memory) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - IexecLibCore_v5.Task storage task = $.m_tasks[id]; - require(task.status == IexecLibCore_v5.TaskStatusEnum.COMPLETED, "task-pending"); - return task.resultsCallback; // Expansion - result separation - } - // ========= Category Accessors ========= function viewCategory( From be36a3a8809ebc0216a032bd2fa560f246af1e30 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 08:55:55 +0200 Subject: [PATCH 04/39] feat: Update Arbitrum RPC URL in Hardhat configuration --- hardhat.config.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hardhat.config.ts b/hardhat.config.ts index da9192a52..1630a6eca 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -123,9 +123,7 @@ const config: HardhatUserConfig = { ...(isArbitrumFork && { forking: { - url: - process.env.ARBITRUM_RPC_URL || - 'https://lb.drpc.org/arbitrum/AhEPbH3buE5zjj_dDMs3E2hIUihFGTAR8J88ThukG97E', + url: process.env.ARBITRUM_RPC_URL || 'https://arbitrum.gateway.tenderly.co', blockNumber: process.env.ARBITRUM_BLOCK_NUMBER ? parseInt(process.env.ARBITRUM_BLOCK_NUMBER) : undefined, From 7c7fe077621828e41bfd039770b25a7e11c9050e Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 09:02:50 +0200 Subject: [PATCH 05/39] feat: move new upgrades scripts in accessors subfolder --- .../accessors}/0_deploy-updated-accessor-facet.ts | 8 ++++---- .../accessors}/1_update-proxy-with-new-facet.ts | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) rename scripts/{updateProxy => upgrades/accessors}/0_deploy-updated-accessor-facet.ts (84%) rename scripts/{updateProxy => upgrades/accessors}/1_update-proxy-with-new-facet.ts (95%) diff --git a/scripts/updateProxy/0_deploy-updated-accessor-facet.ts b/scripts/upgrades/accessors/0_deploy-updated-accessor-facet.ts similarity index 84% rename from scripts/updateProxy/0_deploy-updated-accessor-facet.ts rename to scripts/upgrades/accessors/0_deploy-updated-accessor-facet.ts index 3f6fa9395..a1102c75b 100644 --- a/scripts/updateProxy/0_deploy-updated-accessor-facet.ts +++ b/scripts/upgrades/accessors/0_deploy-updated-accessor-facet.ts @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 import { deployments, ethers } from 'hardhat'; -import { IexecPocoAccessorsFacet__factory } from '../../typechain'; -import { FactoryDeployer } from '../../utils/FactoryDeployer'; -import config from '../../utils/config'; -import { mineBlockIfOnLocalFork } from '../../utils/mine'; +import { IexecPocoAccessorsFacet__factory } from '../../../typechain'; +import { FactoryDeployer } from '../../../utils/FactoryDeployer'; +import config from '../../../utils/config'; +import { mineBlockIfOnLocalFork } from '../../../utils/mine'; (async () => { console.log('Deploying updated IexecPocoAccessorsFacet...'); diff --git a/scripts/updateProxy/1_update-proxy-with-new-facet.ts b/scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts similarity index 95% rename from scripts/updateProxy/1_update-proxy-with-new-facet.ts rename to scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts index 48a47c197..362b68377 100644 --- a/scripts/updateProxy/1_update-proxy-with-new-facet.ts +++ b/scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts @@ -4,16 +4,16 @@ import { ZeroAddress } from 'ethers'; import { deployments, ethers } from 'hardhat'; import { FacetCutAction } from 'hardhat-deploy/dist/types'; -import type { IDiamond } from '../../typechain'; +import type { IDiamond } from '../../../typechain'; import { DiamondCutFacet__factory, DiamondLoupeFacet__factory, IexecPocoAccessorsFacet__factory, -} from '../../typechain'; -import { Ownable__factory } from '../../typechain/factories/rlc-faucet-contract/contracts'; -import config from '../../utils/config'; -import { getFunctionSelectors } from '../../utils/proxy-tools'; -import { printFunctions } from '../upgrades/upgrade-helper'; +} from '../../../typechain'; +import { Ownable__factory } from '../../../typechain/factories/rlc-faucet-contract/contracts'; +import config from '../../../utils/config'; +import { getFunctionSelectors } from '../../../utils/proxy-tools'; +import { printFunctions } from '../upgrade-helper'; (async () => { const chainId = (await ethers.provider.getNetwork()).chainId; From 8b261fd42e4eec4e60e1e9f5f939fb44673b8281 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 09:03:45 +0200 Subject: [PATCH 06/39] feat: refactor deployment script for IexecPocoAccessorsFacet --- .../accessors/0_deploy-updated-accessor-facet.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/scripts/upgrades/accessors/0_deploy-updated-accessor-facet.ts b/scripts/upgrades/accessors/0_deploy-updated-accessor-facet.ts index a1102c75b..95368a2f0 100644 --- a/scripts/upgrades/accessors/0_deploy-updated-accessor-facet.ts +++ b/scripts/upgrades/accessors/0_deploy-updated-accessor-facet.ts @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: 2025 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 -import { deployments, ethers } from 'hardhat'; +import { ethers } from 'hardhat'; import { IexecPocoAccessorsFacet__factory } from '../../../typechain'; import { FactoryDeployer } from '../../../utils/FactoryDeployer'; import config from '../../../utils/config'; @@ -25,17 +25,8 @@ import { mineBlockIfOnLocalFork } from '../../../utils/mine'; deploymentOptions.IexecLibOrders_v5, }; - const factory = new IexecPocoAccessorsFacet__factory(iexecLibOrders); - const facetAddress = await factoryDeployer.deployContract(factory); + const facetFactory = new IexecPocoAccessorsFacet__factory(iexecLibOrders); + const facetAddress = await factoryDeployer.deployContract(facetFactory); console.log(`IexecPocoAccessorsFacet deployed at: ${facetAddress}`); - - // Save deployment for later use - await deployments.save('IexecPocoAccessorsFacet', { - abi: factory.interface.fragments as any, - address: facetAddress, - bytecode: factory.bytecode, - }); - - console.log('Deployment saved as IexecPocoAccessorsFacet'); })(); From b27b1166d9f1e97e539b53ae73f914c89b6fa008 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 09:47:29 +0200 Subject: [PATCH 07/39] feat: change to pure instead of view --- contracts/facets/IexecPocoAccessorsFacet.sol | 18 +++++++++--------- contracts/interfaces/IexecPocoAccessors.sol | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/contracts/facets/IexecPocoAccessorsFacet.sol b/contracts/facets/IexecPocoAccessorsFacet.sol index 9ce51221c..8e7dd03f3 100644 --- a/contracts/facets/IexecPocoAccessorsFacet.sol +++ b/contracts/facets/IexecPocoAccessorsFacet.sol @@ -105,7 +105,7 @@ contract IexecPocoAccessorsFacet is return task.resultsCallback; // Expansion - result separation } - // ========= Token and Account Accessors ========= + // ========= SRLC Token and Account Accessors ========= function name() external view returns (string memory) { PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); @@ -195,35 +195,35 @@ contract IexecPocoAccessorsFacet is // ========= Constants Accessors ========= - function contribution_deadline_ratio() external view returns (uint256) { + function contribution_deadline_ratio() external pure returns (uint256) { return CONTRIBUTION_DEADLINE_RATIO; } - function reveal_deadline_ratio() external view returns (uint256) { + function reveal_deadline_ratio() external pure returns (uint256) { return REVEAL_DEADLINE_RATIO; } - function final_deadline_ratio() external view returns (uint256) { + function final_deadline_ratio() external pure returns (uint256) { return FINAL_DEADLINE_RATIO; } - function workerpool_stake_ratio() external view returns (uint256) { + function workerpool_stake_ratio() external pure returns (uint256) { return WORKERPOOL_STAKE_RATIO; } - function kitty_ratio() external view returns (uint256) { + function kitty_ratio() external pure returns (uint256) { return KITTY_RATIO; } - function kitty_min() external view returns (uint256) { + function kitty_min() external pure returns (uint256) { return KITTY_MIN; } - function kitty_address() external view returns (address) { + function kitty_address() external pure returns (address) { return KITTY_ADDRESS; } - function groupmember_purpose() external view returns (uint256) { + function groupmember_purpose() external pure returns (uint256) { return GROUPMEMBER_PURPOSE; } diff --git a/contracts/interfaces/IexecPocoAccessors.sol b/contracts/interfaces/IexecPocoAccessors.sol index ffdc55360..09593f881 100644 --- a/contracts/interfaces/IexecPocoAccessors.sol +++ b/contracts/interfaces/IexecPocoAccessors.sol @@ -33,7 +33,7 @@ interface IexecPocoAccessors { function resultFor(bytes32 id) external view returns (bytes memory); - // ========= Token and Account Accessors ========= + // ========= SRLC Token and Account Accessors ========= function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); From 9e1d7eb336553e843548f68c8170bfb7642a7e27 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 09:47:51 +0200 Subject: [PATCH 08/39] feat: remove commented code for IexecAccessorsFacet in deploy script --- deploy/0_deploy.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/deploy/0_deploy.ts b/deploy/0_deploy.ts index 6f5d39bcb..dcd9467d7 100644 --- a/deploy/0_deploy.ts +++ b/deploy/0_deploy.ts @@ -92,7 +92,6 @@ export default async function deploy() { const isArbitrumMainnet = (await ethers.provider.getNetwork()).chainId === 42161n; const facets = [ new IexecAccessorsABILegacyFacet__factory(), - // new IexecAccessorsFacet__factory(), to test the updated IexecPocoAccessorsFacet new IexecCategoryManagerFacet__factory(), new IexecConfigurationExtraFacet__factory(), new IexecConfigurationFacet__factory(iexecLibOrders), From 2939683da399aaf8e034f0453681d2fef63cdc0b Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 11:53:19 +0200 Subject: [PATCH 09/39] feat: remove blockNumber configuration for Arbitrum forking --- hardhat.config.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/hardhat.config.ts b/hardhat.config.ts index f7160fb16..ad9d02b2c 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -124,9 +124,6 @@ const config: HardhatUserConfig = { ...(isArbitrumFork && { forking: { url: process.env.ARBITRUM_RPC_URL || 'https://arbitrum.gateway.tenderly.co', - blockNumber: process.env.ARBITRUM_BLOCK_NUMBER - ? parseInt(process.env.ARBITRUM_BLOCK_NUMBER) - : undefined, }, ...arbitrumBaseConfig, }), From 99acad352398cf63a1624925af679fdefc3f20fa Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 11:53:55 +0200 Subject: [PATCH 10/39] fix: remove commented code in update proxy script for IexecPocoAccessorsFacet --- scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts b/scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts index 362b68377..15fa6e054 100644 --- a/scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts +++ b/scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts @@ -34,7 +34,7 @@ import { printFunctions } from '../upgrade-helper'; const [account] = await ethers.getSigners(); - const updatedFacetAddress = (await deployments.get('IexecPocoAccessorsFacet')).address; //C + const updatedFacetAddress = (await deployments.get('IexecPocoAccessorsFacet')).address; console.log(`Updated facet address: ${updatedFacetAddress}`); const diamondLoupe = DiamondLoupeFacet__factory.connect(diamondProxyAddress, account); @@ -98,7 +98,7 @@ import { printFunctions } from '../upgrade-helper'; } // Functions to add - ALL functions from the new facet, but exclude any that exist in other (non-accessor) facets - const newFacetFactory = new IexecPocoAccessorsFacet__factory(iexecLibOrders); //C + const newFacetFactory = new IexecPocoAccessorsFacet__factory(iexecLibOrders); const allNewFunctionSelectors = getFunctionSelectors(newFacetFactory); const functionsInOtherFacets = new Set(); From 359d32c108a05736cfbed89c21c69d9d79faa308 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 12:01:26 +0200 Subject: [PATCH 11/39] refactor: remove unused functionsToRemove array in update proxy script --- scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts b/scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts index 15fa6e054..974bbc0ab 100644 --- a/scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts +++ b/scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts @@ -83,7 +83,6 @@ import { printFunctions } from '../upgrade-helper'; } // Find functions that need to be removed - ALL functions from old accessor facets - const functionsToRemove: string[] = []; const functionsToRemoveByFacet = new Map(); // Remove ALL functions from the old accessor facets @@ -92,7 +91,6 @@ import { printFunctions } from '../upgrade-helper'; console.log( `Found old accessor facet ${facet.facetAddress} with ${facet.functionSelectors.length} functions - will remove ALL`, ); - functionsToRemove.push(...facet.functionSelectors); functionsToRemoveByFacet.set(facet.facetAddress, [...facet.functionSelectors]); } } @@ -123,7 +121,6 @@ import { printFunctions } from '../upgrade-helper'; (selector) => !functionsInOtherFacets.has(selector), ); - console.log(`Total functions to remove from old accessor facets: ${functionsToRemove.length}`); console.log(`Functions skipped (exist in other facets): ${functionsInOtherFacets.size}`); console.log(`Functions to add to new facet: ${newFunctionSelectors.length}`); From aa5d0e12f5ae36a2de4a6dcef1e9811773c36785 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 12:02:03 +0200 Subject: [PATCH 12/39] refactor: remove deployment record update for IexecPocoAccessorsFacet in proxy upgrade script --- .../upgrades/accessors/1_update-proxy-with-new-facet.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts b/scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts index 974bbc0ab..fea6a3a7f 100644 --- a/scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts +++ b/scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts @@ -175,14 +175,5 @@ import { printFunctions } from '../upgrade-helper'; console.log('Functions after upgrade:'); await printFunctions(diamondProxyAddress); - // Update the deployment record to point to the new facet - const newFacetFactoryForSave = new IexecPocoAccessorsFacet__factory(iexecLibOrders); - await deployments.save('IexecPocoAccessorsFacet', { - abi: newFacetFactoryForSave.interface.fragments as any, - address: updatedFacetAddress, - bytecode: newFacetFactoryForSave.bytecode, - }); - console.log('Proxy update completed successfully!'); - console.log(`New IexecPocoAccessorsFacet is now active at: ${updatedFacetAddress}`); })(); From cc99fa1ec3598f295987471c22f29a530f06baaf Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 12:28:16 +0200 Subject: [PATCH 13/39] feat: implement deployment and update logic for IexecPocoAccessorsFacet in new script --- .../0_deploy-updated-accessor-facet.ts | 32 -------------- ...ts => deploy-and-update-accessor-facet.ts} | 42 +++++++++++-------- 2 files changed, 25 insertions(+), 49 deletions(-) delete mode 100644 scripts/upgrades/accessors/0_deploy-updated-accessor-facet.ts rename scripts/upgrades/accessors/{1_update-proxy-with-new-facet.ts => deploy-and-update-accessor-facet.ts} (87%) diff --git a/scripts/upgrades/accessors/0_deploy-updated-accessor-facet.ts b/scripts/upgrades/accessors/0_deploy-updated-accessor-facet.ts deleted file mode 100644 index 95368a2f0..000000000 --- a/scripts/upgrades/accessors/0_deploy-updated-accessor-facet.ts +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-FileCopyrightText: 2025 IEXEC BLOCKCHAIN TECH -// SPDX-License-Identifier: Apache-2.0 - -import { ethers } from 'hardhat'; -import { IexecPocoAccessorsFacet__factory } from '../../../typechain'; -import { FactoryDeployer } from '../../../utils/FactoryDeployer'; -import config from '../../../utils/config'; -import { mineBlockIfOnLocalFork } from '../../../utils/mine'; - -(async () => { - console.log('Deploying updated IexecPocoAccessorsFacet...'); - await mineBlockIfOnLocalFork(); - - const [owner] = await ethers.getSigners(); - const chainId = (await ethers.provider.getNetwork()).chainId; - const deploymentOptions = config.getChainConfig(chainId).v5; - - if (!deploymentOptions.IexecLibOrders_v5) { - throw new Error('IexecLibOrders_v5 is required'); - } - - const factoryDeployer = new FactoryDeployer(owner, chainId); - const iexecLibOrders = { - ['contracts/libs/IexecLibOrders_v5.sol:IexecLibOrders_v5']: - deploymentOptions.IexecLibOrders_v5, - }; - - const facetFactory = new IexecPocoAccessorsFacet__factory(iexecLibOrders); - const facetAddress = await factoryDeployer.deployContract(facetFactory); - - console.log(`IexecPocoAccessorsFacet deployed at: ${facetAddress}`); -})(); diff --git a/scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts similarity index 87% rename from scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts rename to scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts index fea6a3a7f..873390fd6 100644 --- a/scripts/upgrades/accessors/1_update-proxy-with-new-facet.ts +++ b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import { ZeroAddress } from 'ethers'; -import { deployments, ethers } from 'hardhat'; +import { ethers } from 'hardhat'; import { FacetCutAction } from 'hardhat-deploy/dist/types'; import type { IDiamond } from '../../../typechain'; import { @@ -11,31 +11,43 @@ import { IexecPocoAccessorsFacet__factory, } from '../../../typechain'; import { Ownable__factory } from '../../../typechain/factories/rlc-faucet-contract/contracts'; +import { FactoryDeployer } from '../../../utils/FactoryDeployer'; import config from '../../../utils/config'; +import { mineBlockIfOnLocalFork } from '../../../utils/mine'; import { getFunctionSelectors } from '../../../utils/proxy-tools'; import { printFunctions } from '../upgrade-helper'; (async () => { + console.log('Deploying and updating IexecPocoAccessorsFacet...'); + await mineBlockIfOnLocalFork(); + + const [account] = await ethers.getSigners(); const chainId = (await ethers.provider.getNetwork()).chainId; const deploymentOptions = config.getChainConfig(chainId).v5; - console.log('Updating diamond proxy with new IexecPocoAccessorsFacet...'); - console.log(`Network: ${chainId}`); - - if (!deploymentOptions.DiamondProxy) { - throw new Error('DiamondProxy is required'); - } if (!deploymentOptions.IexecLibOrders_v5) { throw new Error('IexecLibOrders_v5 is required'); } + if (!deploymentOptions.DiamondProxy) { + throw new Error('DiamondProxy is required'); + } const diamondProxyAddress = deploymentOptions.DiamondProxy; + console.log(`Network: ${chainId}`); console.log(`Diamond proxy address: ${diamondProxyAddress}`); - const [account] = await ethers.getSigners(); + console.log('\n=== Step 1: Deploying new IexecPocoAccessorsFacet ==='); + const factoryDeployer = new FactoryDeployer(account, chainId); + const iexecLibOrders = { + ['contracts/libs/IexecLibOrders_v5.sol:IexecLibOrders_v5']: + deploymentOptions.IexecLibOrders_v5, + }; + + const facetFactory = new IexecPocoAccessorsFacet__factory(iexecLibOrders); + const updatedFacetAddress = await factoryDeployer.deployContract(facetFactory); + console.log(`IexecPocoAccessorsFacet deployed at: ${updatedFacetAddress}`); - const updatedFacetAddress = (await deployments.get('IexecPocoAccessorsFacet')).address; - console.log(`Updated facet address: ${updatedFacetAddress}`); + console.log('\n=== Step 2: Updating diamond proxy with new facet ==='); const diamondLoupe = DiamondLoupeFacet__factory.connect(diamondProxyAddress, account); const facets = await diamondLoupe.facets(); @@ -45,11 +57,6 @@ import { printFunctions } from '../upgrade-helper'; console.log(` ${facet.facetAddress}: ${facet.functionSelectors.length} functions`); }); - const iexecLibOrders = { - ['contracts/libs/IexecLibOrders_v5.sol:IexecLibOrders_v5']: - deploymentOptions.IexecLibOrders_v5, - }; - // Find the specific old accessor facets to remove completely const oldAccessorFacets = new Set(); @@ -171,9 +178,10 @@ import { printFunctions } from '../upgrade-helper'; console.log('Diamond cut executed successfully'); console.log(`Transaction hash: ${tx.hash}`); - // Print functions after upgrade console.log('Functions after upgrade:'); await printFunctions(diamondProxyAddress); - console.log('Proxy update completed successfully!'); + console.log('\nUpgrade completed successfully!'); + console.log(`New IexecPocoAccessorsFacet deployed at: ${updatedFacetAddress}`); + console.log('Diamond proxy updated with new facet'); })(); From ce727e7ff491ef2e53fbb16b226a09fb16263dbc Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 13:57:36 +0200 Subject: [PATCH 14/39] refactor: simplify old accessor facets identification in deploy script --- .../deploy-and-update-accessor-facet.ts | 34 +++---------------- 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts index 873390fd6..24192756c 100644 --- a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts +++ b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts @@ -58,36 +58,10 @@ import { printFunctions } from '../upgrade-helper'; }); // Find the specific old accessor facets to remove completely - const oldAccessorFacets = new Set(); - - const accessorFunctionSignatures = [ - '0x70a08231', // balanceOf() - '0x06fdde03', // name() - '0x95d89b41', // symbol() - '0x313ce567', // decimals() - '0x18160ddd', // totalSupply() - '0xdd62ed3e', // allowance() - '0x9910fd72', // workerpoolByIndex() - '0xdb8aaa26', // appByIndex() - '0x1bf6e00d', // datasetByIndex() - ]; - - const specificFunctionSignature = '0x66517ca6'; // ComputeDealVolume - - // Find the current accessor facet in the diamond (the one with 32 functions) - for (const facet of facets) { - const hasAccessorFunctions = facet.functionSelectors.some((selector) => - accessorFunctionSignatures.includes(selector), - ); - if (hasAccessorFunctions) { - oldAccessorFacets.add(facet.facetAddress); - } - - const hasSpecificFunction = facet.functionSelectors.includes(specificFunctionSignature); - if (hasSpecificFunction) { - oldAccessorFacets.add(facet.facetAddress); - } - } + const oldAccessorFacets = new Set([ + '0xEa232be31ab0112916505Aeb7A2a94b5571DCc6b', //IexecAccessorsFacet + '0xeb40697b275413241d9b31dE568C98B3EA12FFF0', //IexecPocoAccessorsFacet + ]); // Find functions that need to be removed - ALL functions from old accessor facets const functionsToRemoveByFacet = new Map(); From a74abf21e859fb39a1bbc9dd118f9644e56bccb4 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 14:54:44 +0200 Subject: [PATCH 15/39] refactor: remove IexecAccessorsFacet contract as part of code cleanup --- contracts/facets/IexecAccessorsFacet.sol | 176 ----------------------- 1 file changed, 176 deletions(-) delete mode 100644 contracts/facets/IexecAccessorsFacet.sol diff --git a/contracts/facets/IexecAccessorsFacet.sol b/contracts/facets/IexecAccessorsFacet.sol deleted file mode 100644 index f81003632..000000000 --- a/contracts/facets/IexecAccessorsFacet.sol +++ /dev/null @@ -1,176 +0,0 @@ -// SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH -// SPDX-License-Identifier: Apache-2.0 - -pragma solidity ^0.6.0; -pragma experimental ABIEncoderV2; - -import "./FacetBase.sol"; -import "../interfaces/IexecAccessors.sol"; -import {PocoStorageLib} from "../libs/PocoStorageLib.sol"; - -contract IexecAccessorsFacet is IexecAccessors, FacetBase { - function name() external view override returns (string memory) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_name; - } - - function symbol() external view override returns (string memory) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_symbol; - } - - function decimals() external view override returns (uint8) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_decimals; - } - - function totalSupply() external view override returns (uint256) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_totalSupply; - } - - function balanceOf(address account) external view override returns (uint256) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_balances[account]; - } - - function frozenOf(address account) external view override returns (uint256) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_frozens[account]; - } - - function allowance(address account, address spender) external view override returns (uint256) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_allowances[account][spender]; - } - - function viewAccount( - address account - ) external view override returns (IexecLibCore_v5.Account memory) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return IexecLibCore_v5.Account($.m_balances[account], $.m_frozens[account]); - } - - function token() external view override returns (address) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return address($.m_baseToken); - } - - function viewDeal( - bytes32 _id - ) external view override returns (IexecLibCore_v5.Deal memory deal) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_deals[_id]; - } - - function viewConsumed(bytes32 _id) external view override returns (uint256 consumed) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_consumed[_id]; - } - - function viewPresigned(bytes32 _id) external view override returns (address signer) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_presigned[_id]; - } - - function viewTask( - bytes32 _taskid - ) external view override returns (IexecLibCore_v5.Task memory) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_tasks[_taskid]; - } - - function viewContribution( - bytes32 _taskid, - address _worker - ) external view override returns (IexecLibCore_v5.Contribution memory) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_contributions[_taskid][_worker]; - } - - function viewScore(address _worker) external view override returns (uint256) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_workerScores[_worker]; - } - - function resultFor(bytes32 id) external view override returns (bytes memory) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - IexecLibCore_v5.Task storage task = $.m_tasks[id]; - require(task.status == IexecLibCore_v5.TaskStatusEnum.COMPLETED, "task-pending"); - return task.resultsCallback; // Expansion - result separation - } - - function viewCategory( - uint256 _catid - ) external view override returns (IexecLibCore_v5.Category memory category) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_categories[_catid]; - } - - function countCategory() external view override returns (uint256 count) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_categories.length; - } - - function appregistry() external view override returns (IRegistry) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_appregistry; - } - - function datasetregistry() external view override returns (IRegistry) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_datasetregistry; - } - - function workerpoolregistry() external view override returns (IRegistry) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_workerpoolregistry; - } - - function teebroker() external view override returns (address) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_teebroker; - } - - function callbackgas() external view override returns (uint256) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_callbackgas; - } - - function contribution_deadline_ratio() external view override returns (uint256) { - return CONTRIBUTION_DEADLINE_RATIO; - } - - function reveal_deadline_ratio() external view override returns (uint256) { - return REVEAL_DEADLINE_RATIO; - } - - function final_deadline_ratio() external view override returns (uint256) { - return FINAL_DEADLINE_RATIO; - } - - function workerpool_stake_ratio() external view override returns (uint256) { - return WORKERPOOL_STAKE_RATIO; - } - - function kitty_ratio() external view override returns (uint256) { - return KITTY_RATIO; - } - - function kitty_min() external view override returns (uint256) { - return KITTY_MIN; - } - - function kitty_address() external view override returns (address) { - return KITTY_ADDRESS; - } - - function groupmember_purpose() external view override returns (uint256) { - return GROUPMEMBER_PURPOSE; - } - - function eip712domain_separator() external view override returns (bytes32) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return $.m_eip712DomainSeparator; - } -} From 2aefd8e54d7012b55d7b263126c39f6c07f62c25 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 14:55:02 +0200 Subject: [PATCH 16/39] refactor: change public constants to internal in FacetBase contract --- contracts/facets/FacetBase.sol | 16 ++++++++-------- contracts/facets/FacetBase.v8.sol | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/contracts/facets/FacetBase.sol b/contracts/facets/FacetBase.sol index 8466f0cc7..73ef9b06d 100644 --- a/contracts/facets/FacetBase.sol +++ b/contracts/facets/FacetBase.sol @@ -14,20 +14,20 @@ import "../interfaces/IOwnable.sol"; */ abstract contract FacetBase { // Poco - Constants - uint256 public constant CONTRIBUTION_DEADLINE_RATIO = 7; - uint256 public constant REVEAL_DEADLINE_RATIO = 2; - uint256 public constant FINAL_DEADLINE_RATIO = 10; - uint256 public constant WORKERPOOL_STAKE_RATIO = 30; - uint256 public constant KITTY_RATIO = 10; - uint256 public constant KITTY_MIN = 1e9; // ADJUSTEMENT VARIABLE + uint256 internal constant CONTRIBUTION_DEADLINE_RATIO = 7; + uint256 internal constant REVEAL_DEADLINE_RATIO = 2; + uint256 internal constant FINAL_DEADLINE_RATIO = 10; + uint256 internal constant WORKERPOOL_STAKE_RATIO = 30; + uint256 internal constant KITTY_RATIO = 10; + uint256 internal constant KITTY_MIN = 1e9; // ADJUSTEMENT VARIABLE // Seized funds of workerpools that do not honor their deals are sent // out to this kitty address. // It is determined with address(uint256(keccak256(bytes('iExecKitty'))) - 1). - address public constant KITTY_ADDRESS = 0x99c2268479b93fDe36232351229815DF80837e23; + address internal constant KITTY_ADDRESS = 0x99c2268479b93fDe36232351229815DF80837e23; // Used with ERC-734 Key Manager identity contract for authorization management. - uint256 public constant GROUPMEMBER_PURPOSE = 4; + uint256 internal constant GROUPMEMBER_PURPOSE = 4; modifier onlyOwner() { require(_msgSender() == owner(), "Ownable: caller is not the owner"); diff --git a/contracts/facets/FacetBase.v8.sol b/contracts/facets/FacetBase.v8.sol index b85ffb550..c3fcacc54 100644 --- a/contracts/facets/FacetBase.v8.sol +++ b/contracts/facets/FacetBase.v8.sol @@ -14,20 +14,20 @@ import {PocoStorageLib} from "../libs/PocoStorageLib.v8.sol"; */ abstract contract FacetBase { // Poco - Constants - uint256 public constant CONTRIBUTION_DEADLINE_RATIO = 7; - uint256 public constant REVEAL_DEADLINE_RATIO = 2; - uint256 public constant FINAL_DEADLINE_RATIO = 10; - uint256 public constant WORKERPOOL_STAKE_RATIO = 30; - uint256 public constant KITTY_RATIO = 10; - uint256 public constant KITTY_MIN = 1e9; // ADJUSTEMENT VARIABLE + uint256 internal constant CONTRIBUTION_DEADLINE_RATIO = 7; + uint256 internal constant REVEAL_DEADLINE_RATIO = 2; + uint256 internal constant FINAL_DEADLINE_RATIO = 10; + uint256 internal constant WORKERPOOL_STAKE_RATIO = 30; + uint256 internal constant KITTY_RATIO = 10; + uint256 internal constant KITTY_MIN = 1e9; // ADJUSTEMENT VARIABLE // Seized funds of workerpools that do not honor their deals are sent // out to this kitty address. // It is determined with address(uint256(keccak256(bytes('iExecKitty'))) - 1). - address public constant KITTY_ADDRESS = 0x99c2268479b93fDe36232351229815DF80837e23; + address internal constant KITTY_ADDRESS = 0x99c2268479b93fDe36232351229815DF80837e23; // Used with ERC-734 Key Manager identity contract for authorization management. - uint256 public constant GROUPMEMBER_PURPOSE = 4; + uint256 internal constant GROUPMEMBER_PURPOSE = 4; modifier onlyOwner() { require(_msgSender() == owner(), "Ownable: caller is not the owner"); From 552b7ad397e4d7bed5f44205ec60efedbff754bf Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 15:01:27 +0200 Subject: [PATCH 17/39] refactor: enhance removal logic for specific constant functions in IexecPocoAccessorsFacet --- .../deploy-and-update-accessor-facet.ts | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts index 24192756c..b75bf89c6 100644 --- a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts +++ b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts @@ -63,7 +63,20 @@ import { printFunctions } from '../upgrade-helper'; '0xeb40697b275413241d9b31dE568C98B3EA12FFF0', //IexecPocoAccessorsFacet ]); - // Find functions that need to be removed - ALL functions from old accessor facets + // Specific constant getter functions to remove from facet + const constantFacetAddress = '0x56CDC32332648b1220a89172191798852706EB35'; // IexecAccessorsABILegacyFacet + const constantFunctionsToRemove = [ + '0x7b244832', // CONTRIBUTION_DEADLINE_RATIO() + '0x90fc26b1', // FINAL_DEADLINE_RATIO() + '0x68a9ef1c', // GROUPMEMBER_PURPOSE() + '0x9e986e81', // KITTY_ADDRESS() + '0xe2e7a8c1', // KITTY_MIN() + '0x51152de1', // KITTY_RATIO() + '0x5fde601d', // REVEAL_DEADLINE_RATIO() + '0x4ec3b9e3', // WORKERPOOL_STAKE_RATIO() + ]; + + // Find functions that need to be removed - ALL functions from old accessor facets + specific constants const functionsToRemoveByFacet = new Map(); // Remove ALL functions from the old accessor facets @@ -76,15 +89,32 @@ import { printFunctions } from '../upgrade-helper'; } } + // Remove specific constant functions from the constants facet + for (const facet of facets) { + if (facet.facetAddress === constantFacetAddress) { + const functionsToRemove = facet.functionSelectors.filter((selector) => + constantFunctionsToRemove.includes(selector), + ); + if (functionsToRemove.length > 0) { + console.log( + `Found constants facet ${facet.facetAddress} - will remove ${functionsToRemove.length} specific constant functions`, + ); + functionsToRemoveByFacet.set(facet.facetAddress, functionsToRemove); + } + break; + } + } + // Functions to add - ALL functions from the new facet, but exclude any that exist in other (non-accessor) facets const newFacetFactory = new IexecPocoAccessorsFacet__factory(iexecLibOrders); const allNewFunctionSelectors = getFunctionSelectors(newFacetFactory); const functionsInOtherFacets = new Set(); for (const facet of facets) { - // Skip old accessor facets (we're removing them) and the updated facet (if it already exists) + // Skip old accessor facets (we're removing them), the constants facet (we're removing specific functions), and the updated facet (if it already exists) if ( !oldAccessorFacets.has(facet.facetAddress) && + facet.facetAddress !== constantFacetAddress && facet.facetAddress !== updatedFacetAddress ) { facet.functionSelectors.forEach((selector) => { @@ -106,7 +136,7 @@ import { printFunctions } from '../upgrade-helper'; console.log(`Functions to add to new facet: ${newFunctionSelectors.length}`); const facetCuts: IDiamond.FacetCutStruct[] = []; - // Remove all functions from old accessor facets + // Remove functions from facets (both old accessor facets and specific constants) for (const [, selectors] of functionsToRemoveByFacet) { if (selectors.length > 0) { facetCuts.push({ From 342f64d9340aa24f7e991975bc8004cc0041a337 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 15:15:17 +0200 Subject: [PATCH 18/39] refactor: replace hardcoded constant function signatures with dynamic mapping in deploy script --- .../deploy-and-update-accessor-facet.ts | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts index b75bf89c6..de29fab1e 100644 --- a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts +++ b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts @@ -65,16 +65,19 @@ import { printFunctions } from '../upgrade-helper'; // Specific constant getter functions to remove from facet const constantFacetAddress = '0x56CDC32332648b1220a89172191798852706EB35'; // IexecAccessorsABILegacyFacet - const constantFunctionsToRemove = [ - '0x7b244832', // CONTRIBUTION_DEADLINE_RATIO() - '0x90fc26b1', // FINAL_DEADLINE_RATIO() - '0x68a9ef1c', // GROUPMEMBER_PURPOSE() - '0x9e986e81', // KITTY_ADDRESS() - '0xe2e7a8c1', // KITTY_MIN() - '0x51152de1', // KITTY_RATIO() - '0x5fde601d', // REVEAL_DEADLINE_RATIO() - '0x4ec3b9e3', // WORKERPOOL_STAKE_RATIO() + const constantFunctionSignatures = [ + 'CONTRIBUTION_DEADLINE_RATIO()', + 'FINAL_DEADLINE_RATIO()', + 'GROUPMEMBER_PURPOSE()', + 'KITTY_ADDRESS()', + 'KITTY_MIN()', + 'KITTY_RATIO()', + 'REVEAL_DEADLINE_RATIO()', + 'WORKERPOOL_STAKE_RATIO()', ]; + const constantFunctionsToRemove = constantFunctionSignatures.map((sig) => + ethers.id(sig).slice(0, 10), + ); // Find functions that need to be removed - ALL functions from old accessor facets + specific constants const functionsToRemoveByFacet = new Map(); From 101ef27a1d7ba1ef483acc39670f9ce354567bdb Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 15:22:24 +0200 Subject: [PATCH 19/39] refactor: clarify comment for constant facet address in deploy script --- scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts index de29fab1e..304784547 100644 --- a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts +++ b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts @@ -63,8 +63,7 @@ import { printFunctions } from '../upgrade-helper'; '0xeb40697b275413241d9b31dE568C98B3EA12FFF0', //IexecPocoAccessorsFacet ]); - // Specific constant getter functions to remove from facet - const constantFacetAddress = '0x56CDC32332648b1220a89172191798852706EB35'; // IexecAccessorsABILegacyFacet + const constantFacetAddress = '0x56CDC32332648b1220a89172191798852706EB35'; // Facet providing constant getters (IexecAccessorsABILegacyFacet) const constantFunctionSignatures = [ 'CONTRIBUTION_DEADLINE_RATIO()', 'FINAL_DEADLINE_RATIO()', From 22b517e60156bc22d1d720089ca0fe38d2bade57 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 17:12:48 +0200 Subject: [PATCH 20/39] refactor: update variable names for clarity in deploy and update script for IexecPocoAccessorsFacet --- .../deploy-and-update-accessor-facet.ts | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts index 24192756c..eb9cbc48c 100644 --- a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts +++ b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts @@ -43,17 +43,17 @@ import { printFunctions } from '../upgrade-helper'; deploymentOptions.IexecLibOrders_v5, }; - const facetFactory = new IexecPocoAccessorsFacet__factory(iexecLibOrders); - const updatedFacetAddress = await factoryDeployer.deployContract(facetFactory); - console.log(`IexecPocoAccessorsFacet deployed at: ${updatedFacetAddress}`); + const newFacetFactory = new IexecPocoAccessorsFacet__factory(iexecLibOrders); + const newFacetAddress = await factoryDeployer.deployContract(newFacetFactory); + console.log(`IexecPocoAccessorsFacet deployed at: ${newFacetAddress}`); console.log('\n=== Step 2: Updating diamond proxy with new facet ==='); const diamondLoupe = DiamondLoupeFacet__factory.connect(diamondProxyAddress, account); - const facets = await diamondLoupe.facets(); + const currentFacets = await diamondLoupe.facets(); console.log('\nCurrent facets in diamond:'); - facets.forEach((facet) => { + currentFacets.forEach((facet) => { console.log(` ${facet.facetAddress}: ${facet.functionSelectors.length} functions`); }); @@ -67,7 +67,7 @@ import { printFunctions } from '../upgrade-helper'; const functionsToRemoveByFacet = new Map(); // Remove ALL functions from the old accessor facets - for (const facet of facets) { + for (const facet of currentFacets) { if (oldAccessorFacets.has(facet.facetAddress)) { console.log( `Found old accessor facet ${facet.facetAddress} with ${facet.functionSelectors.length} functions - will remove ALL`, @@ -77,16 +77,12 @@ import { printFunctions } from '../upgrade-helper'; } // Functions to add - ALL functions from the new facet, but exclude any that exist in other (non-accessor) facets - const newFacetFactory = new IexecPocoAccessorsFacet__factory(iexecLibOrders); const allNewFunctionSelectors = getFunctionSelectors(newFacetFactory); const functionsInOtherFacets = new Set(); - for (const facet of facets) { + for (const facet of currentFacets) { // Skip old accessor facets (we're removing them) and the updated facet (if it already exists) - if ( - !oldAccessorFacets.has(facet.facetAddress) && - facet.facetAddress !== updatedFacetAddress - ) { + if (!oldAccessorFacets.has(facet.facetAddress) && facet.facetAddress !== newFacetAddress) { facet.functionSelectors.forEach((selector) => { if (allNewFunctionSelectors.includes(selector)) { functionsInOtherFacets.add(selector); @@ -120,10 +116,10 @@ import { printFunctions } from '../upgrade-helper'; // Add new functions if (newFunctionSelectors.length > 0) { console.log( - `Preparing to add ${newFunctionSelectors.length} functions to new facet ${updatedFacetAddress}`, + `Preparing to add ${newFunctionSelectors.length} functions to new facet ${newFacetAddress}`, ); facetCuts.push({ - facetAddress: updatedFacetAddress, + facetAddress: newFacetAddress, action: FacetCutAction.Add, functionSelectors: [...newFunctionSelectors], }); @@ -156,6 +152,6 @@ import { printFunctions } from '../upgrade-helper'; await printFunctions(diamondProxyAddress); console.log('\nUpgrade completed successfully!'); - console.log(`New IexecPocoAccessorsFacet deployed at: ${updatedFacetAddress}`); + console.log(`New IexecPocoAccessorsFacet deployed at: ${newFacetAddress}`); console.log('Diamond proxy updated with new facet'); })(); From 78d8a97fbb4ffb233fe5bbc8570a616b78b77fc9 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 22 Sep 2025 17:27:56 +0200 Subject: [PATCH 21/39] refactor: replace function selector retrieval with linkContractToProxy for new facet integration --- .../deploy-and-update-accessor-facet.ts | 84 ++++++------------- 1 file changed, 25 insertions(+), 59 deletions(-) diff --git a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts index eb9cbc48c..b9f3aee73 100644 --- a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts +++ b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts @@ -14,7 +14,7 @@ import { Ownable__factory } from '../../../typechain/factories/rlc-faucet-contra import { FactoryDeployer } from '../../../utils/FactoryDeployer'; import config from '../../../utils/config'; import { mineBlockIfOnLocalFork } from '../../../utils/mine'; -import { getFunctionSelectors } from '../../../utils/proxy-tools'; +import { linkContractToProxy } from '../../../utils/proxy-tools'; import { printFunctions } from '../upgrade-helper'; (async () => { @@ -63,7 +63,7 @@ import { printFunctions } from '../upgrade-helper'; '0xeb40697b275413241d9b31dE568C98B3EA12FFF0', //IexecPocoAccessorsFacet ]); - // Find functions that need to be removed - ALL functions from old accessor facets + // Functions to remove - ALL functions from the old accessor facets const functionsToRemoveByFacet = new Map(); // Remove ALL functions from the old accessor facets @@ -76,36 +76,21 @@ import { printFunctions } from '../upgrade-helper'; } } - // Functions to add - ALL functions from the new facet, but exclude any that exist in other (non-accessor) facets - const allNewFunctionSelectors = getFunctionSelectors(newFacetFactory); - - const functionsInOtherFacets = new Set(); - for (const facet of currentFacets) { - // Skip old accessor facets (we're removing them) and the updated facet (if it already exists) - if (!oldAccessorFacets.has(facet.facetAddress) && facet.facetAddress !== newFacetAddress) { - facet.functionSelectors.forEach((selector) => { - if (allNewFunctionSelectors.includes(selector)) { - functionsInOtherFacets.add(selector); - console.log( - ` Function ${selector} already exists in other facet ${facet.facetAddress} - will not add`, - ); - } - }); - } - } + console.log('Functions before upgrade:'); + await printFunctions(diamondProxyAddress); - const newFunctionSelectors = allNewFunctionSelectors.filter( - (selector) => !functionsInOtherFacets.has(selector), + const proxyOwnerAddress = await Ownable__factory.connect(diamondProxyAddress, account).owner(); + console.log(`Diamond proxy owner: ${proxyOwnerAddress}`); + const proxyOwnerSigner = await ethers.getImpersonatedSigner(proxyOwnerAddress); + const diamondProxyWithOwner = DiamondCutFacet__factory.connect( + diamondProxyAddress, + proxyOwnerSigner, ); - console.log(`Functions skipped (exist in other facets): ${functionsInOtherFacets.size}`); - console.log(`Functions to add to new facet: ${newFunctionSelectors.length}`); - - const facetCuts: IDiamond.FacetCutStruct[] = []; - // Remove all functions from old accessor facets + const removalCuts: IDiamond.FacetCutStruct[] = []; for (const [, selectors] of functionsToRemoveByFacet) { if (selectors.length > 0) { - facetCuts.push({ + removalCuts.push({ facetAddress: ZeroAddress, action: FacetCutAction.Remove, functionSelectors: [...selectors], @@ -113,40 +98,21 @@ import { printFunctions } from '../upgrade-helper'; } } - // Add new functions - if (newFunctionSelectors.length > 0) { - console.log( - `Preparing to add ${newFunctionSelectors.length} functions to new facet ${newFacetAddress}`, - ); - facetCuts.push({ - facetAddress: newFacetAddress, - action: FacetCutAction.Add, - functionSelectors: [...newFunctionSelectors], + if (removalCuts.length > 0) { + console.log('Executing diamond cut to remove old functions...'); + console.log(`Removal cuts: ${removalCuts.length}`); + removalCuts.forEach((cut, index) => { + console.log(` Cut ${index + 1}: Remove ${cut.functionSelectors.length} functions`); }); - } - console.log('Functions before upgrade:'); - await printFunctions(diamondProxyAddress); - - const proxyOwnerAddress = await Ownable__factory.connect(diamondProxyAddress, account).owner(); - console.log(`Diamond proxy owner: ${proxyOwnerAddress}`); - const proxyOwnerSigner = await ethers.getImpersonatedSigner(proxyOwnerAddress); - const diamondProxyWithOwner = DiamondCutFacet__factory.connect( - diamondProxyAddress, - proxyOwnerSigner, - ); - - console.log('Executing diamond cut...'); - console.log(`Facet cuts: ${facetCuts.length}`); - facetCuts.forEach((cut, index) => { - console.log(` Cut ${index + 1}: ${cut.action} ${cut.functionSelectors.length} functions`); - console.log(` Facet: ${cut.facetAddress}`); - }); - - const tx = await diamondProxyWithOwner.diamondCut(facetCuts, ZeroAddress, '0x'); - await tx.wait(); - console.log('Diamond cut executed successfully'); - console.log(`Transaction hash: ${tx.hash}`); + const removeTx = await diamondProxyWithOwner.diamondCut(removalCuts, ZeroAddress, '0x'); + await removeTx.wait(); + console.log('Old functions removed successfully'); + console.log(`Transaction hash: ${removeTx.hash}`); + } + console.log('Adding new functions using linkContractToProxy...'); + await linkContractToProxy(diamondProxyWithOwner, newFacetAddress, newFacetFactory); + console.log('New functions added successfully'); console.log('Functions after upgrade:'); await printFunctions(diamondProxyAddress); From 7bd8bef30b09b54bb77efeb97a0765d63938436c Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Tue, 23 Sep 2025 10:08:39 +0200 Subject: [PATCH 22/39] refactor: streamline upgrade process by removing redundant logs and enhancing clarity --- .../upgrades/accessors/deploy-and-update-accessor-facet.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts index 45968897d..f92b004e0 100644 --- a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts +++ b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts @@ -132,17 +132,12 @@ import { printFunctions } from '../upgrade-helper'; const removeTx = await diamondProxyWithOwner.diamondCut(removalCuts, ZeroAddress, '0x'); await removeTx.wait(); - console.log('Old functions removed successfully'); console.log(`Transaction hash: ${removeTx.hash}`); } - console.log('Adding new functions using linkContractToProxy...'); await linkContractToProxy(diamondProxyWithOwner, newFacetAddress, newFacetFactory); console.log('New functions added successfully'); console.log('Functions after upgrade:'); await printFunctions(diamondProxyAddress); - - console.log('\nUpgrade completed successfully!'); - console.log(`New IexecPocoAccessorsFacet deployed at: ${newFacetAddress}`); console.log('Diamond proxy updated with new facet'); })(); From 871d1f20402f4930e690bbb3be86409f8b988406 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Tue, 23 Sep 2025 14:47:10 +0200 Subject: [PATCH 23/39] refactor: update error handling in viewCategory test to use revertedWithoutReason --- .../IexecCategoryManager/IexecCategoryManager.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/byContract/IexecCategoryManager/IexecCategoryManager.test.ts b/test/byContract/IexecCategoryManager/IexecCategoryManager.test.ts index 14f44b85e..8d1c2c41f 100644 --- a/test/byContract/IexecCategoryManager/IexecCategoryManager.test.ts +++ b/test/byContract/IexecCategoryManager/IexecCategoryManager.test.ts @@ -47,7 +47,7 @@ describe('CategoryManager', async () => { const lastCategoryIndex = (await iexecPocoAsAnyone.countCategory()) - 1n; await expect( iexecPocoAsAnyone.viewCategory(lastCategoryIndex + 1n), - ).to.be.revertedWithPanic(0x32); + ).to.be.revertedWithoutReason(); }); it('Should create category', async () => { From 99ed6a4d10835b9280da8cba7a70710a354a9a55 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Tue, 23 Sep 2025 16:29:54 +0200 Subject: [PATCH 24/39] fix: update bigintToAddress function to specify byte length for hex conversion --- test/byContract/registries/registries.test.ts | 5 +++++ utils/tools.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/test/byContract/registries/registries.test.ts b/test/byContract/registries/registries.test.ts index 96f4837d5..0c11ae4e8 100644 --- a/test/byContract/registries/registries.test.ts +++ b/test/byContract/registries/registries.test.ts @@ -250,6 +250,11 @@ describe('Registries', () => { expect(await appRegistry.ownerOf(predictedAddress)).to.equal(appProvider.address); const tokenAtIndex = await appRegistry.tokenOfOwnerByIndex(appProvider.address, 0); + console.log('tokenAtIndex', tokenAtIndex); + console.log('BEFORE', ethers.getAddress(ethers.toBeHex(tokenAtIndex))); + + console.log('ethers.getAddress(predictedAddress)', ethers.getAddress(predictedAddress)); + console.log('bigintToAddress(tokenAtIndex)', bigintToAddress(tokenAtIndex)); expect(bigintToAddress(tokenAtIndex)).to.equal(ethers.getAddress(predictedAddress)); const tokenURI = await appRegistry.tokenURI(predictedAddress); diff --git a/utils/tools.ts b/utils/tools.ts index 3d3ba3eef..d3033fbe8 100644 --- a/utils/tools.ts +++ b/utils/tools.ts @@ -11,7 +11,7 @@ export function compactSignature(signature: string): string { } export function bigintToAddress(bigint: bigint) { - return ethers.getAddress(ethers.toBeHex(bigint)); + return ethers.getAddress(ethers.toBeHex(bigint, 20)); } export function minBigInt(a: bigint, b: bigint) { From 45ea533af56e1181d2df3098907941ab0597e4de Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Tue, 23 Sep 2025 16:38:18 +0200 Subject: [PATCH 25/39] refactor: reorder console logs for clarity in appRegistry token retrieval test --- test/byContract/registries/registries.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/byContract/registries/registries.test.ts b/test/byContract/registries/registries.test.ts index 0c11ae4e8..9b69d8e3f 100644 --- a/test/byContract/registries/registries.test.ts +++ b/test/byContract/registries/registries.test.ts @@ -251,11 +251,11 @@ describe('Registries', () => { const tokenAtIndex = await appRegistry.tokenOfOwnerByIndex(appProvider.address, 0); console.log('tokenAtIndex', tokenAtIndex); - console.log('BEFORE', ethers.getAddress(ethers.toBeHex(tokenAtIndex))); console.log('ethers.getAddress(predictedAddress)', ethers.getAddress(predictedAddress)); console.log('bigintToAddress(tokenAtIndex)', bigintToAddress(tokenAtIndex)); expect(bigintToAddress(tokenAtIndex)).to.equal(ethers.getAddress(predictedAddress)); + console.log('BEFORE', ethers.getAddress(ethers.toBeHex(tokenAtIndex))); const tokenURI = await appRegistry.tokenURI(predictedAddress); const baseURI = await appRegistry.baseURI(); From cf0c3feca3622ad55f275b9f5b0115824c9942c1 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Tue, 23 Sep 2025 16:46:46 +0200 Subject: [PATCH 26/39] refactor: remove unnecessary console logs in appRegistry token retrieval test --- test/byContract/registries/registries.test.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/byContract/registries/registries.test.ts b/test/byContract/registries/registries.test.ts index 9b69d8e3f..96f4837d5 100644 --- a/test/byContract/registries/registries.test.ts +++ b/test/byContract/registries/registries.test.ts @@ -250,12 +250,7 @@ describe('Registries', () => { expect(await appRegistry.ownerOf(predictedAddress)).to.equal(appProvider.address); const tokenAtIndex = await appRegistry.tokenOfOwnerByIndex(appProvider.address, 0); - console.log('tokenAtIndex', tokenAtIndex); - - console.log('ethers.getAddress(predictedAddress)', ethers.getAddress(predictedAddress)); - console.log('bigintToAddress(tokenAtIndex)', bigintToAddress(tokenAtIndex)); expect(bigintToAddress(tokenAtIndex)).to.equal(ethers.getAddress(predictedAddress)); - console.log('BEFORE', ethers.getAddress(ethers.toBeHex(tokenAtIndex))); const tokenURI = await appRegistry.tokenURI(predictedAddress); const baseURI = await appRegistry.baseURI(); From 6eddbd531bd61e8b66e8cb6cd1d58252e3dfc794 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Tue, 23 Sep 2025 17:38:49 +0200 Subject: [PATCH 27/39] feat: add dataset, app, and workerpool accessors with corresponding view functions --- contracts/facets/IexecPocoAccessorsFacet.sol | 68 +++++++++++++++++++ contracts/interfaces/IexecAccessors.sol | 8 +++ contracts/interfaces/IexecPocoAccessors.sol | 13 ++++ contracts/libs/IexecLibCore_v5.sol | 22 ++++++ .../IexecAccessors/IexecAccessors.test.ts | 26 +++++++ 5 files changed, 137 insertions(+) diff --git a/contracts/facets/IexecPocoAccessorsFacet.sol b/contracts/facets/IexecPocoAccessorsFacet.sol index 4c3426c94..9da6233af 100644 --- a/contracts/facets/IexecPocoAccessorsFacet.sol +++ b/contracts/facets/IexecPocoAccessorsFacet.sol @@ -11,6 +11,29 @@ import {IexecPocoAccessors} from "../interfaces/IexecPocoAccessors.sol"; import {IexecPocoCommon} from "./IexecPocoCommon.sol"; import {SignatureVerifier} from "./SignatureVerifier.v8.sol"; +interface DatasetInterface { + function owner() external view returns (address); + function m_datasetName() external view returns (string memory); + function m_datasetMultiaddr() external view returns (bytes memory); + function m_datasetChecksum() external view returns (bytes32); +} + +interface AppInterface { + function owner() external view returns (address); + function m_appName() external view returns (string memory); + function m_appType() external view returns (string memory); + function m_appMultiaddr() external view returns (bytes memory); + function m_appChecksum() external view returns (bytes32); + function m_appMREnclave() external view returns (bytes memory); +} + +interface WorkerpoolInterface { + function owner() external view returns (address); + function m_workerpoolDescription() external view returns (string memory); + function m_workerStakeRatioPolicy() external view returns (uint256); + function m_schedulerRewardRatioPolicy() external view returns (uint256); +} + /** * @title Getters contract for PoCo facets. */ @@ -196,6 +219,51 @@ contract IexecPocoAccessorsFacet is return $.m_callbackgas; } + // ========= Dataset Accessors ========= + + function viewDataset( + address dataset + ) external view returns (IexecLibCore_v5.DatasetInfo memory) { + DatasetInterface datasetContract = DatasetInterface(dataset); + return + IexecLibCore_v5.DatasetInfo({ + owner: datasetContract.owner(), + m_datasetName: datasetContract.m_datasetName(), + m_datasetMultiaddr: datasetContract.m_datasetMultiaddr(), + m_datasetChecksum: datasetContract.m_datasetChecksum() + }); + } + + // ========= App Accessors ========= + + function viewApp(address app) external view returns (IexecLibCore_v5.AppInfo memory) { + AppInterface appContract = AppInterface(app); + return + IexecLibCore_v5.AppInfo({ + owner: appContract.owner(), + m_appName: appContract.m_appName(), + m_appType: appContract.m_appType(), + m_appMultiaddr: appContract.m_appMultiaddr(), + m_appChecksum: appContract.m_appChecksum(), + m_appMREnclave: appContract.m_appMREnclave() + }); + } + + // ========= Workerpool Accessors ========= + + function viewWorkerpool( + address workerpool + ) external view returns (IexecLibCore_v5.WorkerpoolInfo memory) { + WorkerpoolInterface workerpoolContract = WorkerpoolInterface(workerpool); + return + IexecLibCore_v5.WorkerpoolInfo({ + owner: workerpoolContract.owner(), + m_workerpoolDescription: workerpoolContract.m_workerpoolDescription(), + m_workerStakeRatioPolicy: workerpoolContract.m_workerStakeRatioPolicy(), + m_schedulerRewardRatioPolicy: workerpoolContract.m_schedulerRewardRatioPolicy() + }); + } + // ========= Constants Accessors ========= function contribution_deadline_ratio() external pure returns (uint256) { diff --git a/contracts/interfaces/IexecAccessors.sol b/contracts/interfaces/IexecAccessors.sol index 337e2406d..70a2e8471 100644 --- a/contracts/interfaces/IexecAccessors.sol +++ b/contracts/interfaces/IexecAccessors.sol @@ -37,6 +37,14 @@ interface IexecAccessors is IOracle { function teebroker() external view returns (address); function callbackgas() external view returns (uint256); + function viewDataset( + address dataset + ) external view returns (IexecLibCore_v5.DatasetInfo memory); + function viewApp(address app) external view returns (IexecLibCore_v5.AppInfo memory); + function viewWorkerpool( + address workerpool + ) external view returns (IexecLibCore_v5.WorkerpoolInfo memory); + function contribution_deadline_ratio() external view returns (uint256); function reveal_deadline_ratio() external view returns (uint256); function final_deadline_ratio() external view returns (uint256); diff --git a/contracts/interfaces/IexecPocoAccessors.sol b/contracts/interfaces/IexecPocoAccessors.sol index 09593f881..01dd4c61d 100644 --- a/contracts/interfaces/IexecPocoAccessors.sol +++ b/contracts/interfaces/IexecPocoAccessors.sol @@ -55,6 +55,19 @@ interface IexecPocoAccessors { function teebroker() external view returns (address); function callbackgas() external view returns (uint256); + // ========= Dataset Accessors ========= + function viewDataset( + address dataset + ) external view returns (IexecLibCore_v5.DatasetInfo memory); + + // ========= App Accessors ========= + function viewApp(address app) external view returns (IexecLibCore_v5.AppInfo memory); + + // ========= Workerpool Accessors ========= + function viewWorkerpool( + address workerpool + ) external view returns (IexecLibCore_v5.WorkerpoolInfo memory); + // ========= Constants Accessors ========= function contribution_deadline_ratio() external view returns (uint256); function reveal_deadline_ratio() external view returns (uint256); diff --git a/contracts/libs/IexecLibCore_v5.sol b/contracts/libs/IexecLibCore_v5.sol index edf566315..a32c551c0 100644 --- a/contracts/libs/IexecLibCore_v5.sol +++ b/contracts/libs/IexecLibCore_v5.sol @@ -16,6 +16,28 @@ library IexecLibCore_v5 { string description; uint256 workClockTimeRef; } + struct DatasetInfo { + address owner; + string m_datasetName; + bytes m_datasetMultiaddr; + bytes32 m_datasetChecksum; + } + + struct AppInfo { + address owner; + string m_appName; + string m_appType; + bytes m_appMultiaddr; + bytes32 m_appChecksum; + bytes m_appMREnclave; + } + + struct WorkerpoolInfo { + address owner; + string m_workerpoolDescription; + uint256 m_workerStakeRatioPolicy; + uint256 m_schedulerRewardRatioPolicy; + } /** * Clerk - Deals diff --git a/test/byContract/IexecAccessors/IexecAccessors.test.ts b/test/byContract/IexecAccessors/IexecAccessors.test.ts index c65f79ff4..094accba4 100644 --- a/test/byContract/IexecAccessors/IexecAccessors.test.ts +++ b/test/byContract/IexecAccessors/IexecAccessors.test.ts @@ -243,6 +243,32 @@ describe('IexecAccessors', async () => { expect(await iexecPoco.callbackgas()).to.equal(100_000n); }); + it('viewDataset', async function () { + const datasetInfo = await iexecPoco.viewDataset(datasetAddress); + expect(datasetInfo.owner).to.equal(datasetProvider.address); + expect(datasetInfo.m_datasetName).to.equal('my-dataset'); + expect(datasetInfo.m_datasetMultiaddr).to.equal(ZeroHash); + expect(datasetInfo.m_datasetChecksum).to.equal(ZeroHash); + }); + + it('viewApp', async function () { + const appInfo = await iexecPoco.viewApp(appAddress); + expect(appInfo.owner).to.equal(appProvider.address); + expect(appInfo.m_appName).to.equal('my-app'); + expect(appInfo.m_appType).to.equal('APP_TYPE_0'); + expect(appInfo.m_appMultiaddr).to.equal(ZeroHash); + expect(appInfo.m_appChecksum).to.equal(ZeroHash); + expect(appInfo.m_appMREnclave).to.equal(ZeroHash); + }); + + it('viewWorkerpool', async function () { + const workerpoolInfo = await iexecPoco.viewWorkerpool(workerpoolAddress); + expect(workerpoolInfo.owner).to.equal(scheduler.address); + expect(workerpoolInfo.m_workerpoolDescription).to.equal('my-workerpool'); + expect(workerpoolInfo.m_workerStakeRatioPolicy).to.equal(30n); + expect(workerpoolInfo.m_schedulerRewardRatioPolicy).to.equal(1n); + }); + it('contributionDeadlineRatio', async function () { expect(await iexecPoco.contribution_deadline_ratio()).to.equal(7); }); From 83d732cbd0c01f3697e58f9bea4cf07ebc47eaa1 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Tue, 23 Sep 2025 17:40:46 +0200 Subject: [PATCH 28/39] refactor: change owner function visibility to internal and update TODO comment for migration --- contracts/facets/FacetBase.sol | 3 ++- contracts/facets/FacetBase.v8.sol | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/contracts/facets/FacetBase.sol b/contracts/facets/FacetBase.sol index 73ef9b06d..f42f01523 100644 --- a/contracts/facets/FacetBase.sol +++ b/contracts/facets/FacetBase.sol @@ -34,7 +34,8 @@ abstract contract FacetBase { _; } - function owner() public view returns (address) { + function owner() internal view returns (address) { + // TODO use LibDiamond.contractOwner() instead of an external call when migrating all contracts to v8. return IOwnable(address(this)).owner(); } diff --git a/contracts/facets/FacetBase.v8.sol b/contracts/facets/FacetBase.v8.sol index c3fcacc54..56af0c7fc 100644 --- a/contracts/facets/FacetBase.v8.sol +++ b/contracts/facets/FacetBase.v8.sol @@ -34,7 +34,8 @@ abstract contract FacetBase { _; } - function owner() public view returns (address) { + function owner() internal view returns (address) { + // TODO use LibDiamond.contractOwner() instead of an external call when migrating all contracts to v8. // Make an external call to delegatecall the OwnershipFacet. return IERC5313(address(this)).owner(); } From a5e6e9060759a13b1d23b4f63ccd39d65fdedbaf Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Tue, 23 Sep 2025 17:42:32 +0200 Subject: [PATCH 29/39] refactor: improve logging for diamond functions before upgrade in deploy-and-update-accessor-facet script --- .../upgrades/accessors/deploy-and-update-accessor-facet.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts index 31a7b332b..99d219282 100644 --- a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts +++ b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts @@ -69,6 +69,9 @@ import { printFunctions } from '../upgrade-helper'; console.log(` ${facet.facetAddress}: ${facet.functionSelectors.length} functions`); }); + console.log('Diamond functions before upgrade:'); + await printFunctions(diamondProxyAddress); + const constantFacetAddress = '0x56CDC32332648b1220a89172191798852706EB35'; // Facet providing constant getters (IexecAccessorsABILegacyFacet) const oldAccessorFacets = [ '0xEa232be31ab0112916505Aeb7A2a94b5571DCc6b', //IexecAccessorsFacet @@ -89,10 +92,6 @@ import { printFunctions } from '../upgrade-helper'; const constantFunctionsToRemove = constantFunctionSignatures.map((sig) => ethers.id(sig).slice(0, 10), ); - - console.log('Diamond functions before upgrade:'); - await printFunctions(diamondProxyAddress); - const removalCuts: IDiamond.FacetCutStruct[] = []; // Remove ALL functions from the old accessor facets using diamondLoupe.facetFunctionSelectors() except of constant founctions From 9410bfab37b2bf2e811c5f13e27081be4a92b3dc Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Tue, 23 Sep 2025 17:44:30 +0200 Subject: [PATCH 30/39] refactor: streamline removal of old accessor facets and constant functions in deploy-and-update-accessor-facet script --- .../deploy-and-update-accessor-facet.ts | 50 +++++++------------ 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts index 99d219282..fa2625bfe 100644 --- a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts +++ b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts @@ -72,13 +72,7 @@ import { printFunctions } from '../upgrade-helper'; console.log('Diamond functions before upgrade:'); await printFunctions(diamondProxyAddress); - const constantFacetAddress = '0x56CDC32332648b1220a89172191798852706EB35'; // Facet providing constant getters (IexecAccessorsABILegacyFacet) - const oldAccessorFacets = [ - '0xEa232be31ab0112916505Aeb7A2a94b5571DCc6b', //IexecAccessorsFacet - '0xeb40697b275413241d9b31dE568C98B3EA12FFF0', //IexecPocoAccessorsFacet - constantFacetAddress, - ]; - + const removalCuts: IDiamond.FacetCutStruct[] = []; const constantFunctionSignatures = [ 'CONTRIBUTION_DEADLINE_RATIO()', 'FINAL_DEADLINE_RATIO()', @@ -92,36 +86,28 @@ import { printFunctions } from '../upgrade-helper'; const constantFunctionsToRemove = constantFunctionSignatures.map((sig) => ethers.id(sig).slice(0, 10), ); - const removalCuts: IDiamond.FacetCutStruct[] = []; + removalCuts.push({ + facetAddress: ZeroAddress, + action: FacetCutAction.Remove, + functionSelectors: constantFunctionsToRemove, + }); + const oldAccessorFacets = [ + '0xEa232be31ab0112916505Aeb7A2a94b5571DCc6b', //IexecAccessorsFacet + '0xeb40697b275413241d9b31dE568C98B3EA12FFF0', //IexecPocoAccessorsFacet + ]; // Remove ALL functions from the old accessor facets using diamondLoupe.facetFunctionSelectors() except of constant founctions for (const facetAddress of oldAccessorFacets) { const selectors = await diamondLoupe.facetFunctionSelectors(facetAddress); if (selectors.length > 0) { - if (facetAddress === constantFacetAddress) { - const functionsToRemove = selectors.filter((selector) => - constantFunctionsToRemove.includes(selector), - ); - if (functionsToRemove.length > 0) { - console.log( - `Found constants facet ${facetAddress} - will remove ${functionsToRemove.length} specific constant functions`, - ); - removalCuts.push({ - facetAddress: ZeroAddress, - action: FacetCutAction.Remove, - functionSelectors: [...functionsToRemove], - }); - } - } else { - console.log( - `Removing old accessor facet ${facetAddress} with ${selectors.length} functions - will remove ALL`, - ); - removalCuts.push({ - facetAddress: ZeroAddress, - action: FacetCutAction.Remove, - functionSelectors: [...selectors], - }); - } + console.log( + `Removing old accessor facet ${facetAddress} with ${selectors.length} functions - will remove ALL`, + ); + removalCuts.push({ + facetAddress: ZeroAddress, + action: FacetCutAction.Remove, + functionSelectors: [...selectors], + }); } } From 01107ef514021c16413d2a2aff8b99a2adbf68de Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Wed, 24 Sep 2025 15:25:16 +0200 Subject: [PATCH 31/39] refactor: remove owner function and onlyOwner modifier in FacetBase contract --- contracts/facets/FacetBase.v8.sol | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/contracts/facets/FacetBase.v8.sol b/contracts/facets/FacetBase.v8.sol index 56af0c7fc..ed5a74cdb 100644 --- a/contracts/facets/FacetBase.v8.sol +++ b/contracts/facets/FacetBase.v8.sol @@ -29,17 +29,6 @@ abstract contract FacetBase { // Used with ERC-734 Key Manager identity contract for authorization management. uint256 internal constant GROUPMEMBER_PURPOSE = 4; - modifier onlyOwner() { - require(_msgSender() == owner(), "Ownable: caller is not the owner"); - _; - } - - function owner() internal view returns (address) { - // TODO use LibDiamond.contractOwner() instead of an external call when migrating all contracts to v8. - // Make an external call to delegatecall the OwnershipFacet. - return IERC5313(address(this)).owner(); - } - function _msgSender() internal view returns (address) { return msg.sender; } From db8005a3bd6630d0c2bf68dd27b7f2068196b723 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Wed, 24 Sep 2025 16:20:00 +0200 Subject: [PATCH 32/39] refactor: add logging for constant functions scheduled for removal in deploy-and-update-accessor-facet script --- scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts index fa2625bfe..bb21614aa 100644 --- a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts +++ b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts @@ -86,6 +86,9 @@ import { printFunctions } from '../upgrade-helper'; const constantFunctionsToRemove = constantFunctionSignatures.map((sig) => ethers.id(sig).slice(0, 10), ); + console.log( + `Removing specific constant functions from diamond Proxy - will remove ${constantFunctionsToRemove.length} specific constant functions`, + ); removalCuts.push({ facetAddress: ZeroAddress, action: FacetCutAction.Remove, From 7fb43fd7438cbe4b856d09826fbc897667ba2035 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Wed, 24 Sep 2025 16:44:06 +0200 Subject: [PATCH 33/39] test: move from IexecAccessors to IexecPocoAccessors test file --- .../IexecPocoAccessors.test.ts} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename test/byContract/{IexecAccessors/IexecAccessors.test.ts => iexecPocoAccessors/IexecPocoAccessors.test.ts} (99%) diff --git a/test/byContract/IexecAccessors/IexecAccessors.test.ts b/test/byContract/iexecPocoAccessors/IexecPocoAccessors.test.ts similarity index 99% rename from test/byContract/IexecAccessors/IexecAccessors.test.ts rename to test/byContract/iexecPocoAccessors/IexecPocoAccessors.test.ts index c65f79ff4..a6238244c 100644 --- a/test/byContract/IexecAccessors/IexecAccessors.test.ts +++ b/test/byContract/iexecPocoAccessors/IexecPocoAccessors.test.ts @@ -48,7 +48,7 @@ let [requester, appProvider, datasetProvider, scheduler, worker1, anyone]: Signe let ordersAssets: OrdersAssets; let ordersPrices: OrdersPrices; -describe('IexecAccessors', async () => { +describe('IexecPocoAccessors', async () => { beforeEach('Deploy', async () => { // Deploy all contracts proxyAddress = await loadHardhatFixtureDeployment(); From 446ccac3bd422fd7e61ff4ba988012cd2a5acbee Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Wed, 24 Sep 2025 17:39:32 +0200 Subject: [PATCH 34/39] refactor: reorganize dataset, app, and workerpool accessors in IexecAccessors interface --- contracts/interfaces/IexecAccessors.sol | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/contracts/interfaces/IexecAccessors.sol b/contracts/interfaces/IexecAccessors.sol index 70a2e8471..1c0bf0045 100644 --- a/contracts/interfaces/IexecAccessors.sol +++ b/contracts/interfaces/IexecAccessors.sol @@ -37,14 +37,6 @@ interface IexecAccessors is IOracle { function teebroker() external view returns (address); function callbackgas() external view returns (uint256); - function viewDataset( - address dataset - ) external view returns (IexecLibCore_v5.DatasetInfo memory); - function viewApp(address app) external view returns (IexecLibCore_v5.AppInfo memory); - function viewWorkerpool( - address workerpool - ) external view returns (IexecLibCore_v5.WorkerpoolInfo memory); - function contribution_deadline_ratio() external view returns (uint256); function reveal_deadline_ratio() external view returns (uint256); function final_deadline_ratio() external view returns (uint256); @@ -54,4 +46,17 @@ interface IexecAccessors is IOracle { function kitty_address() external view returns (address); function groupmember_purpose() external view returns (uint256); function eip712domain_separator() external view returns (bytes32); + + // ========= Dataset Accessors ========= + function viewDataset( + address dataset + ) external view returns (IexecLibCore_v5.DatasetInfo memory); + + // ========= App Accessors ========= + function viewApp(address app) external view returns (IexecLibCore_v5.AppInfo memory); + + // ========= Workerpool Accessors ========= + function viewWorkerpool( + address workerpool + ) external view returns (IexecLibCore_v5.WorkerpoolInfo memory); } From 5fabe28230e5dac848b3e3e0f0f5a85a8ed618f9 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Wed, 24 Sep 2025 17:39:53 +0200 Subject: [PATCH 35/39] refactor: update accessors to use interfaces for Dataset, App, and Workerpool --- contracts/facets/IexecPocoAccessorsFacet.sol | 33 ++++--------------- contracts/registries/apps/IApp.v8.sol | 12 +++++++ contracts/registries/datasets/IDataset.v8.sol | 10 ++++++ .../registries/workerpools/IWorkerpool.v8.sol | 8 +++-- 4 files changed, 34 insertions(+), 29 deletions(-) create mode 100644 contracts/registries/apps/IApp.v8.sol create mode 100644 contracts/registries/datasets/IDataset.v8.sol diff --git a/contracts/facets/IexecPocoAccessorsFacet.sol b/contracts/facets/IexecPocoAccessorsFacet.sol index 9da6233af..166011db0 100644 --- a/contracts/facets/IexecPocoAccessorsFacet.sol +++ b/contracts/facets/IexecPocoAccessorsFacet.sol @@ -7,33 +7,12 @@ import {PocoStorageLib, IRegistry} from "../libs/PocoStorageLib.v8.sol"; import {FacetBase} from "./FacetBase.v8.sol"; import {IexecLibCore_v5} from "../libs/IexecLibCore_v5.sol"; import {IexecLibOrders_v5} from "../libs/IexecLibOrders_v5.sol"; +import {IDataset} from "../registries/datasets/IDataset.v8.sol"; +import {IApp} from "../registries/apps/IApp.v8.sol"; +import {IWorkerpool} from "../registries/workerpools/IWorkerpool.v8.sol"; import {IexecPocoAccessors} from "../interfaces/IexecPocoAccessors.sol"; import {IexecPocoCommon} from "./IexecPocoCommon.sol"; import {SignatureVerifier} from "./SignatureVerifier.v8.sol"; - -interface DatasetInterface { - function owner() external view returns (address); - function m_datasetName() external view returns (string memory); - function m_datasetMultiaddr() external view returns (bytes memory); - function m_datasetChecksum() external view returns (bytes32); -} - -interface AppInterface { - function owner() external view returns (address); - function m_appName() external view returns (string memory); - function m_appType() external view returns (string memory); - function m_appMultiaddr() external view returns (bytes memory); - function m_appChecksum() external view returns (bytes32); - function m_appMREnclave() external view returns (bytes memory); -} - -interface WorkerpoolInterface { - function owner() external view returns (address); - function m_workerpoolDescription() external view returns (string memory); - function m_workerStakeRatioPolicy() external view returns (uint256); - function m_schedulerRewardRatioPolicy() external view returns (uint256); -} - /** * @title Getters contract for PoCo facets. */ @@ -224,7 +203,7 @@ contract IexecPocoAccessorsFacet is function viewDataset( address dataset ) external view returns (IexecLibCore_v5.DatasetInfo memory) { - DatasetInterface datasetContract = DatasetInterface(dataset); + IDataset datasetContract = IDataset(dataset); return IexecLibCore_v5.DatasetInfo({ owner: datasetContract.owner(), @@ -237,7 +216,7 @@ contract IexecPocoAccessorsFacet is // ========= App Accessors ========= function viewApp(address app) external view returns (IexecLibCore_v5.AppInfo memory) { - AppInterface appContract = AppInterface(app); + IApp appContract = IApp(app); return IexecLibCore_v5.AppInfo({ owner: appContract.owner(), @@ -254,7 +233,7 @@ contract IexecPocoAccessorsFacet is function viewWorkerpool( address workerpool ) external view returns (IexecLibCore_v5.WorkerpoolInfo memory) { - WorkerpoolInterface workerpoolContract = WorkerpoolInterface(workerpool); + IWorkerpool workerpoolContract = IWorkerpool(workerpool); return IexecLibCore_v5.WorkerpoolInfo({ owner: workerpoolContract.owner(), diff --git a/contracts/registries/apps/IApp.v8.sol b/contracts/registries/apps/IApp.v8.sol new file mode 100644 index 000000000..2be83f8fb --- /dev/null +++ b/contracts/registries/apps/IApp.v8.sol @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: 2023-2025 IEXEC BLOCKCHAIN TECH +// SPDX-License-Identifier: Apache-2.0 + +pragma solidity ^0.8.0; +interface IApp { + function owner() external view returns (address); + function m_appName() external view returns (string memory); + function m_appType() external view returns (string memory); + function m_appMultiaddr() external view returns (bytes memory); + function m_appChecksum() external view returns (bytes32); + function m_appMREnclave() external view returns (bytes memory); +} diff --git a/contracts/registries/datasets/IDataset.v8.sol b/contracts/registries/datasets/IDataset.v8.sol new file mode 100644 index 000000000..d6ede1f9e --- /dev/null +++ b/contracts/registries/datasets/IDataset.v8.sol @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2023-2025 IEXEC BLOCKCHAIN TECH +// SPDX-License-Identifier: Apache-2.0 + +pragma solidity ^0.8.0; +interface IDataset { + function owner() external view returns (address); + function m_datasetName() external view returns (string memory); + function m_datasetMultiaddr() external view returns (bytes memory); + function m_datasetChecksum() external view returns (bytes32); +} diff --git a/contracts/registries/workerpools/IWorkerpool.v8.sol b/contracts/registries/workerpools/IWorkerpool.v8.sol index 4d428a550..ba29d0486 100644 --- a/contracts/registries/workerpools/IWorkerpool.v8.sol +++ b/contracts/registries/workerpools/IWorkerpool.v8.sol @@ -4,7 +4,11 @@ pragma solidity ^0.8.0; interface IWorkerpool { - function m_schedulerRewardRatioPolicy() external returns (uint256); + function owner() external view returns (address); - function m_workerStakeRatioPolicy() external returns (uint256); + function m_workerpoolDescription() external view returns (string memory); + + function m_schedulerRewardRatioPolicy() external view returns (uint256); + + function m_workerStakeRatioPolicy() external view returns (uint256); } From a0a68cb20049a426502d764587435534f29fda91 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Wed, 24 Sep 2025 17:45:41 +0200 Subject: [PATCH 36/39] fix: add missing newline in IexecPocoAccessorsFacet.sol imports --- contracts/facets/IexecPocoAccessorsFacet.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/facets/IexecPocoAccessorsFacet.sol b/contracts/facets/IexecPocoAccessorsFacet.sol index 166011db0..9377ecf13 100644 --- a/contracts/facets/IexecPocoAccessorsFacet.sol +++ b/contracts/facets/IexecPocoAccessorsFacet.sol @@ -13,6 +13,7 @@ import {IWorkerpool} from "../registries/workerpools/IWorkerpool.v8.sol"; import {IexecPocoAccessors} from "../interfaces/IexecPocoAccessors.sol"; import {IexecPocoCommon} from "./IexecPocoCommon.sol"; import {SignatureVerifier} from "./SignatureVerifier.v8.sol"; + /** * @title Getters contract for PoCo facets. */ From ab33303af62ee422be099cfb423fc7adff7e0abf Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Wed, 24 Sep 2025 17:46:06 +0200 Subject: [PATCH 37/39] refactor: remove unnecessary line breaks in IWorkerpool interface --- contracts/registries/workerpools/IWorkerpool.v8.sol | 3 --- 1 file changed, 3 deletions(-) diff --git a/contracts/registries/workerpools/IWorkerpool.v8.sol b/contracts/registries/workerpools/IWorkerpool.v8.sol index ba29d0486..b86f452fd 100644 --- a/contracts/registries/workerpools/IWorkerpool.v8.sol +++ b/contracts/registries/workerpools/IWorkerpool.v8.sol @@ -5,10 +5,7 @@ pragma solidity ^0.8.0; interface IWorkerpool { function owner() external view returns (address); - function m_workerpoolDescription() external view returns (string memory); - function m_schedulerRewardRatioPolicy() external view returns (uint256); - function m_workerStakeRatioPolicy() external view returns (uint256); } From 406c10bebd5f4bbaf88e2f8def2a5d8069518990 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Wed, 24 Sep 2025 18:29:18 +0200 Subject: [PATCH 38/39] refactor: sepolia arbitrum enhance proxy owner signer logic and encapsulate constant function removal for --- .../deploy-and-update-accessor-facet.ts | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts index bb21614aa..f94e2c435 100644 --- a/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts +++ b/scripts/upgrades/accessors/deploy-and-update-accessor-facet.ts @@ -39,7 +39,7 @@ import { printFunctions } from '../upgrade-helper'; // Use impersonated signer only for fork testing, otherwise use account signer const proxyOwnerSigner = - process.env.ARBITRUM_FORK === 'true' + process.env.ARBITRUM_FORK === 'true' || process.env.ARBITRUM_SEPOLIA_FORK === 'true' ? await ethers.getImpersonatedSigner(proxyOwnerAddress) : account; const diamondProxyAsOwner = DiamondCutFacet__factory.connect( @@ -73,27 +73,31 @@ import { printFunctions } from '../upgrade-helper'; await printFunctions(diamondProxyAddress); const removalCuts: IDiamond.FacetCutStruct[] = []; - const constantFunctionSignatures = [ - 'CONTRIBUTION_DEADLINE_RATIO()', - 'FINAL_DEADLINE_RATIO()', - 'GROUPMEMBER_PURPOSE()', - 'KITTY_ADDRESS()', - 'KITTY_MIN()', - 'KITTY_RATIO()', - 'REVEAL_DEADLINE_RATIO()', - 'WORKERPOOL_STAKE_RATIO()', - ]; - const constantFunctionsToRemove = constantFunctionSignatures.map((sig) => - ethers.id(sig).slice(0, 10), - ); - console.log( - `Removing specific constant functions from diamond Proxy - will remove ${constantFunctionsToRemove.length} specific constant functions`, - ); - removalCuts.push({ - facetAddress: ZeroAddress, - action: FacetCutAction.Remove, - functionSelectors: constantFunctionsToRemove, - }); + + // constant functions are deployed within IexecAccessorsFacet on arbitrum sepolia + if (process.env.ARBITRUM_FORK === 'true' || chainId == 42161n) { + const constantFunctionSignatures = [ + 'CONTRIBUTION_DEADLINE_RATIO()', + 'FINAL_DEADLINE_RATIO()', + 'GROUPMEMBER_PURPOSE()', + 'KITTY_ADDRESS()', + 'KITTY_MIN()', + 'KITTY_RATIO()', + 'REVEAL_DEADLINE_RATIO()', + 'WORKERPOOL_STAKE_RATIO()', + ]; + const constantFunctionsToRemove = constantFunctionSignatures.map((sig) => + ethers.id(sig).slice(0, 10), + ); + console.log( + `Removing specific constant functions from diamond Proxy - will remove ${constantFunctionsToRemove.length} specific constant functions`, + ); + removalCuts.push({ + facetAddress: ZeroAddress, + action: FacetCutAction.Remove, + functionSelectors: constantFunctionsToRemove, + }); + } const oldAccessorFacets = [ '0xEa232be31ab0112916505Aeb7A2a94b5571DCc6b', //IexecAccessorsFacet From 03a17d80b633f99bf19a9bdcb6584a0e8d46b030 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Wed, 24 Sep 2025 20:13:12 +0200 Subject: [PATCH 39/39] refactor: replace IexecAccessors with IexecPocoAccessors across deployment, scripts, and tests --- deploy/0_deploy.ts | 7 +- scripts/set-callback-gas.ts | 4 +- test/000_fullchain-boost.test.ts | 8 +- .../IexecPocoBoost/IexecPocoBoost.test.ts | 76 +++++++++------- .../IexecPocoAccessors.test.ts | 86 ++++++++++--------- test/utils/IexecWrapper.ts | 20 +++-- 6 files changed, 113 insertions(+), 88 deletions(-) diff --git a/deploy/0_deploy.ts b/deploy/0_deploy.ts index dcd9467d7..1d877b7e6 100644 --- a/deploy/0_deploy.ts +++ b/deploy/0_deploy.ts @@ -14,7 +14,6 @@ import { DiamondLoupeFacet__factory, Diamond__factory, IexecAccessorsABILegacyFacet__factory, - IexecAccessors__factory, IexecCategoryManagerFacet__factory, IexecCategoryManager__factory, IexecConfigurationExtraFacet__factory, @@ -27,6 +26,7 @@ import { IexecPoco1Facet__factory, IexecPoco2Facet__factory, IexecPocoAccessorsFacet__factory, + IexecPocoAccessors__factory, IexecPocoBoostAccessorsFacet__factory, IexecPocoBoostFacet__factory, IexecRelayFacet__factory, @@ -186,7 +186,10 @@ export default async function deploy() { } // Set main configuration - const iexecAccessorsInstance = IexecAccessors__factory.connect(diamondProxyAddress, deployer); + const iexecAccessorsInstance = IexecPocoAccessors__factory.connect( + diamondProxyAddress, + deployer, + ); const iexecInitialized = (await iexecAccessorsInstance.eip712domain_separator()) != ZeroHash; if (!iexecInitialized) { // TODO replace this with DiamondInit.init(). diff --git a/scripts/set-callback-gas.ts b/scripts/set-callback-gas.ts index 6ef0d5a07..f840e96df 100644 --- a/scripts/set-callback-gas.ts +++ b/scripts/set-callback-gas.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import { deployments, ethers } from 'hardhat'; -import { IexecAccessors__factory, IexecConfigurationFacet__factory } from '../typechain'; +import { IexecConfigurationFacet__factory, IexecPocoAccessors__factory } from '../typechain'; (async () => { const requestedCallbackGas = Number(process.env.CALLBACK_GAS); @@ -14,7 +14,7 @@ import { IexecAccessors__factory, IexecConfigurationFacet__factory } from '../ty const [owner] = await ethers.getSigners(); const diamondProxyAddress = (await deployments.get('Diamond')).address; const viewCallbackGas = async () => - (await IexecAccessors__factory.connect(diamondProxyAddress, owner).callbackgas()) + (await IexecPocoAccessors__factory.connect(diamondProxyAddress, owner).callbackgas()) .toNumber() .toLocaleString(); const callbackGasBefore = await viewCallbackGas(); diff --git a/test/000_fullchain-boost.test.ts b/test/000_fullchain-boost.test.ts index 3e006017e..d45d0bccc 100644 --- a/test/000_fullchain-boost.test.ts +++ b/test/000_fullchain-boost.test.ts @@ -7,9 +7,9 @@ import { expect } from 'chai'; import { TypedDataDomain } from 'ethers'; import hre from 'hardhat'; import { - IexecAccessors, - IexecAccessors__factory, IexecOrderManagement__factory, + IexecPocoAccessors, + IexecPocoAccessors__factory, IexecPocoBoostAccessorsFacet__factory, IexecPocoBoostFacet, IexecPocoBoostFacet__factory, @@ -50,7 +50,7 @@ const workerpoolPrice = 1_000_000_000n; describe('IexecPocoBoostFacet (IT)', function () { let domain: TypedDataDomain; let proxyAddress: string; - let iexecInstance: IexecAccessors; + let iexecInstance: IexecPocoAccessors; let iexecPocoBoostInstance: IexecPocoBoostFacet; let iexecWrapper: IexecWrapper; let appAddress = ''; @@ -88,7 +88,7 @@ describe('IexecPocoBoostFacet (IT)', function () { requester: requester, }; iexecPocoBoostInstance = IexecPocoBoostFacet__factory.connect(proxyAddress, owner); - iexecInstance = IexecAccessors__factory.connect(proxyAddress, anyone); + iexecInstance = IexecPocoAccessors__factory.connect(proxyAddress, anyone); domain = { name: 'iExecODB', version: '5.0.0', diff --git a/test/byContract/IexecPocoBoost/IexecPocoBoost.test.ts b/test/byContract/IexecPocoBoost/IexecPocoBoost.test.ts index a21a415f8..cd99577c4 100644 --- a/test/byContract/IexecPocoBoost/IexecPocoBoost.test.ts +++ b/test/byContract/IexecPocoBoost/IexecPocoBoost.test.ts @@ -14,12 +14,11 @@ import { GasWasterClient__factory, IERC721__factory, IOracleConsumer__factory, - IexecAccessors, - IexecAccessors__factory, IexecConfiguration, IexecConfiguration__factory, IexecOrderManagement__factory, IexecPoco2__factory, + IexecPocoAccessors, IexecPocoAccessors__factory, IexecPocoBoostAccessorsFacet__factory, IexecPocoBoostFacet, @@ -75,7 +74,7 @@ const randomEOAAddress = randomAddress(); let proxyAddress: string; let iexecPocoBoostInstance: IexecPocoBoostFacet; let iexecConfigurationAsAdmin: IexecConfiguration; -let iexecAccessor: IexecAccessors; +let iexecPocoAccessor: IexecPocoAccessors; let oracleConsumerInstance: TestClient; let gasWasterClientInstance: GasWasterClient; let gasWasterClientAddress: string; @@ -130,7 +129,7 @@ describe('IexecPocoBoost', function () { proxyAddress, accounts.iexecAdmin, ); - iexecAccessor = IexecAccessors__factory.connect(proxyAddress, ethers.provider); + iexecPocoAccessor = IexecPocoAccessors__factory.connect(proxyAddress, ethers.provider); ordersActors = { appOwner: appProvider, datasetOwner: datasetProvider, @@ -161,9 +160,9 @@ describe('IexecPocoBoost', function () { dataset: datasetPrice, workerpool: workerpoolPrice, }; - workerpoolStakeRatio = await iexecAccessor.workerpool_stake_ratio(); - kittyAddress = await iexecAccessor.kitty_address(); - categoryTime = (await iexecAccessor.viewCategory(category)).workClockTimeRef; + workerpoolStakeRatio = await iexecPocoAccessor.workerpool_stake_ratio(); + kittyAddress = await iexecPocoAccessor.kitty_address(); + categoryTime = (await iexecPocoAccessor.viewCategory(category)).workClockTimeRef; } describe('Match orders Boost', function () { @@ -286,7 +285,7 @@ describe('IexecPocoBoost', function () { // Check balances and frozens await expect(matchOrdersBoostTx).to.changeTokenBalances( - iexecAccessor, + iexecPocoAccessor, [proxyAddress, requester.address, scheduler.address], [ dealPrice + schedulerStake, // Poco proxy @@ -413,7 +412,7 @@ describe('IexecPocoBoost', function () { // Check balances and frozens await expect(sponsorMatchOrdersBoostTx).to.changeTokenBalances( - iexecAccessor, + iexecPocoAccessor, [proxyAddress, requester.address, sponsor.address, scheduler.address], [ dealPrice + schedulerStake, // Poco proxy @@ -526,13 +525,16 @@ describe('IexecPocoBoost', function () { requester: requester.address, }).toObject(); const erc1271Address = await deployErc1271MockContract(); - await IERC721__factory.connect(await iexecAccessor.appregistry(), appProvider) + await IERC721__factory.connect(await iexecPocoAccessor.appregistry(), appProvider) .transferFrom(appProvider.address, erc1271Address, appAddress) .then((tx) => tx.wait()); - await IERC721__factory.connect(await iexecAccessor.datasetregistry(), datasetProvider) + await IERC721__factory.connect( + await iexecPocoAccessor.datasetregistry(), + datasetProvider, + ) .transferFrom(datasetProvider.address, erc1271Address, datasetAddress) .then((tx) => tx.wait()); - await IERC721__factory.connect(await iexecAccessor.workerpoolregistry(), scheduler) + await IERC721__factory.connect(await iexecPocoAccessor.workerpoolregistry(), scheduler) .transferFrom(scheduler.address, erc1271Address, workerpoolAddress) .then((tx) => tx.wait()); requestOrder.requester = erc1271Address; @@ -1105,7 +1107,7 @@ describe('IexecPocoBoost', function () { it('Should fail when invalid app order signature from contract', async function () { const erc1271Address = await deployErc1271MockContract(); - await IERC721__factory.connect(await iexecAccessor.appregistry(), appProvider) + await IERC721__factory.connect(await iexecPocoAccessor.appregistry(), appProvider) .transferFrom(appProvider.address, erc1271Address, appAddress) .then((tx) => tx.wait()); const orders = buildOrders({ @@ -1150,7 +1152,10 @@ describe('IexecPocoBoost', function () { it('Should fail when invalid dataset order signature from contract', async function () { const erc1271Address = await deployErc1271MockContract(); - await IERC721__factory.connect(await iexecAccessor.datasetregistry(), datasetProvider) + await IERC721__factory.connect( + await iexecPocoAccessor.datasetregistry(), + datasetProvider, + ) .transferFrom(datasetProvider.address, erc1271Address, datasetAddress) .then((tx) => tx.wait()); const orders = buildOrders({ @@ -1197,7 +1202,7 @@ describe('IexecPocoBoost', function () { it('Should fail when invalid workerpool order signature from contract', async function () { const erc1271Address = await deployErc1271MockContract(); - await IERC721__factory.connect(await iexecAccessor.workerpoolregistry(), scheduler) + await IERC721__factory.connect(await iexecPocoAccessor.workerpoolregistry(), scheduler) .transferFrom(scheduler.address, erc1271Address, workerpoolAddress) .then((tx) => tx.wait()); const orders = buildOrders({ @@ -1268,7 +1273,7 @@ describe('IexecPocoBoost', function () { const initialRequesterBalance = 2n; await iexecWrapper.depositInIexecAccount(requester, initialRequesterBalance); - expect(await iexecAccessor.balanceOf(requester.address)).to.be.lessThan(dealPrice); + expect(await iexecPocoAccessor.balanceOf(requester.address)).to.be.lessThan(dealPrice); await signOrders(domain, orders, ordersActors); await expect( @@ -1293,9 +1298,13 @@ describe('IexecPocoBoost', function () { ); await iexecWrapper.depositInIexecAccount(scheduler, initialSchedulerBalance); // Make sure the tx does not fail because of requester's balance. - expect(await iexecAccessor.balanceOf(requester.address)).to.be.greaterThan(dealPrice); + expect(await iexecPocoAccessor.balanceOf(requester.address)).to.be.greaterThan( + dealPrice, + ); // Make sure the scheduler does not have enough to stake. - expect(await iexecAccessor.balanceOf(scheduler.address)).to.be.lessThan(schedulerStake); + expect(await iexecPocoAccessor.balanceOf(scheduler.address)).to.be.lessThan( + schedulerStake, + ); await signOrders(domain, orders, ordersActors); await expect( @@ -1312,7 +1321,7 @@ describe('IexecPocoBoost', function () { const initialSponsorBalance = 2n; await iexecWrapper.depositInIexecAccount(sponsor, initialSponsorBalance); - expect(await iexecAccessor.balanceOf(sponsor.address)).to.be.lessThan(dealPrice); + expect(await iexecPocoAccessor.balanceOf(sponsor.address)).to.be.lessThan(dealPrice); await signOrders(domain, orders, ordersActors); await expect( @@ -1350,7 +1359,7 @@ describe('IexecPocoBoost', function () { }).toArray(), ); await time.setNextBlockTimestamp( - (await iexecAccessor.viewDeal(kittyFillingDeal.dealId)).startTime + + (await iexecPocoAccessor.viewDeal(kittyFillingDeal.dealId)).startTime + 10n * categoryTime, ); await IexecPoco2__factory.connect(proxyAddress, anyone) @@ -1444,7 +1453,7 @@ describe('IexecPocoBoost', function () { .to.emit(iexecPocoBoostInstance, 'ResultPushedBoost') .withArgs(dealId, taskIndex, results); // Check task status - const task = await iexecAccessor.viewTask(taskId); + const task = await iexecPocoAccessor.viewTask(taskId); expect(task.status).to.equal(TaskStatusEnum.COMPLETED); expect(task.dealid).to.equal(HashZero); expect(task.idx).to.equal(0); @@ -1462,7 +1471,7 @@ describe('IexecPocoBoost', function () { expect(task.resultsCallback).to.equal('0x'); // Check balances and frozens await expect(pushResultBoostTx).to.changeTokenBalances( - iexecAccessor, + iexecPocoAccessor, [ proxyAddress, requester.address, @@ -2041,7 +2050,7 @@ describe('IexecPocoBoost', function () { .connect(worker) .pushResultBoost.estimateGas(...pushResultArgs); const failingTxGaslimit = - successfulTxGasLimit - (await iexecAccessor.callbackgas()) / 63n; + successfulTxGasLimit - (await iexecPocoAccessor.callbackgas()) / 63n; // Forward to consumer contract less gas than it has the right to consume const pushResultBoost = iexecPocoBoostInstance @@ -2102,7 +2111,7 @@ describe('IexecPocoBoost', function () { .to.emit(iexecPocoBoostInstance, 'TaskClaimed') .withArgs(taskId); // Check task status - const task = await iexecAccessor.viewTask(taskId); + const task = await iexecPocoAccessor.viewTask(taskId); expect(task.status).to.equal(TaskStatusEnum.FAILED); expect(task.dealid).to.equal(HashZero); expect(task.idx).to.equal(0); @@ -2120,7 +2129,7 @@ describe('IexecPocoBoost', function () { expect(task.resultsCallback).to.equal('0x'); // Check balances and frozens await expect(claimBoostTx).to.changeTokenBalances( - iexecAccessor, + iexecPocoAccessor, [proxyAddress, requester.address, scheduler.address], [ -taskPrice, // PoCo proxy @@ -2169,7 +2178,7 @@ describe('IexecPocoBoost', function () { // Verifications after claiming "claimedTasks" tasks. // Check balances and frozens await expect(claimBoostTx).to.changeTokenBalances( - iexecAccessor, + iexecPocoAccessor, [proxyAddress, requester.address, scheduler.address], [ -taskPrice, // PoCo proxy @@ -2238,10 +2247,12 @@ describe('IexecPocoBoost', function () { .withArgs(taskId); // Check task status - expect((await iexecAccessor.viewTask(taskId)).status).to.equal(TaskStatusEnum.FAILED); + expect((await iexecPocoAccessor.viewTask(taskId)).status).to.equal( + TaskStatusEnum.FAILED, + ); // Check balances and frozens await expect(claimBoostTx).to.changeTokenBalances( - iexecAccessor, + iexecPocoAccessor, [proxyAddress, requester.address, sponsor.address, scheduler.address], [ -taskPrice, // PoCo proxy @@ -2392,7 +2403,10 @@ async function whenIdentityContractCalledForCandidateInGroupThenReturnTrue( candidate: string, ) { await erc734IdentityContractInstance - .setKeyHasPurpose(addressToBytes32(candidate), await iexecAccessor.groupmember_purpose()) + .setKeyHasPurpose( + addressToBytes32(candidate), + await iexecPocoAccessor.groupmember_purpose(), + ) .then((tx) => tx.wait()); } @@ -2431,11 +2445,11 @@ function computeSchedulerDealStake(workerpoolPrice: bigint, volume: bigint) { } async function expectOrderConsumed(orderHash: string, expectedConsumedVolume: bigint) { - expect(await iexecAccessor.viewConsumed(orderHash)).to.equal(expectedConsumedVolume); + expect(await iexecPocoAccessor.viewConsumed(orderHash)).to.equal(expectedConsumedVolume); } async function frozenOf(account: string) { - return await iexecAccessor.frozenOf(account); + return await iexecPocoAccessor.frozenOf(account); } async function expectFrozen(account: string, expectedFrozenValue: bigint) { diff --git a/test/byContract/iexecPocoAccessors/IexecPocoAccessors.test.ts b/test/byContract/iexecPocoAccessors/IexecPocoAccessors.test.ts index 7628058e2..e8db4ff97 100644 --- a/test/byContract/iexecPocoAccessors/IexecPocoAccessors.test.ts +++ b/test/byContract/iexecPocoAccessors/IexecPocoAccessors.test.ts @@ -10,6 +10,8 @@ import { IexecInterfaceNative, IexecInterfaceNative__factory, IexecLibOrders_v5, + IexecPocoAccessors, + IexecPocoAccessors__factory, } from '../../../typechain'; import { OrdersAssets, @@ -42,6 +44,7 @@ const { resultsCallback, callbackResultDigest } = buildResultCallbackAndDigest(1 let proxyAddress: string; let iexecPoco: IexecInterfaceNative; +let iexecPocoAccessors: IexecPocoAccessors; let iexecWrapper: IexecWrapper; let [appAddress, datasetAddress, workerpoolAddress]: string[] = []; let [requester, appProvider, datasetProvider, scheduler, worker1, anyone]: SignerWithAddress[] = []; @@ -62,6 +65,7 @@ describe('IexecPocoAccessors', async () => { iexecWrapper = new IexecWrapper(proxyAddress, accounts); ({ appAddress, datasetAddress, workerpoolAddress } = await iexecWrapper.createAssets()); iexecPoco = IexecInterfaceNative__factory.connect(proxyAddress, ethers.provider); + iexecPocoAccessors = IexecPocoAccessors__factory.connect(proxyAddress, ethers.provider); ordersAssets = { app: appAddress, dataset: datasetAddress, @@ -75,31 +79,31 @@ describe('IexecPocoAccessors', async () => { } it('name', async function () { - expect(await iexecPoco.name()).to.equal('Staked RLC'); + expect(await iexecPocoAccessors.name()).to.equal('Staked RLC'); }); it('symbol', async function () { - expect(await iexecPoco.symbol()).to.equal('SRLC'); + expect(await iexecPocoAccessors.symbol()).to.equal('SRLC'); }); it('decimals', async function () { - expect(await iexecPoco.decimals()).to.equal(9n); + expect(await iexecPocoAccessors.decimals()).to.equal(9n); }); it('totalSupply', async function () { - expect(await iexecPoco.totalSupply()).to.equal(0n); + expect(await iexecPocoAccessors.totalSupply()).to.equal(0n); }); it('balanceOf', async function () { const amount = 3n; await iexecWrapper.depositInIexecAccount(anyone, amount); - expect(await iexecPoco.balanceOf(anyone.address)).to.equal(amount); + expect(await iexecPocoAccessors.balanceOf(anyone.address)).to.equal(amount); }); it('frozenOf', async function () { await createDeal(); // Lock some requester funds. const dealPrice = appPrice + datasetPrice + workerpoolPrice; // volume == 1 - expect(await iexecPoco.frozenOf(requester.address)).to.equal(dealPrice); + expect(await iexecPocoAccessors.frozenOf(requester.address)).to.equal(dealPrice); }); it('allowance', async function () { @@ -107,7 +111,7 @@ describe('IexecPocoAccessors', async () => { const spender = randomAddress(); await iexecWrapper.depositInIexecAccount(anyone, amount); await iexecPoco.connect(anyone).approve(spender, amount); - expect(await iexecPoco.allowance(anyone.address, spender)).to.equal(amount); + expect(await iexecPocoAccessors.allowance(anyone.address, spender)).to.equal(amount); }); it('viewAccount', async function () { @@ -117,19 +121,19 @@ describe('IexecPocoAccessors', async () => { const stakedBalance = 3n; await iexecWrapper.depositInIexecAccount(requester, stakedBalance); // Check staked and locked amounts. - const account = await iexecPoco.viewAccount(requester.address); + const account = await iexecPocoAccessors.viewAccount(requester.address); expect(account.stake).to.equal(stakedBalance); expect(account.locked).to.equal(dealPrice); }); // TODO test the case where token() == 0x0 in native mode. it('token', async function () { - expect(await iexecPoco.token()).to.equal((await deployments.get('RLC')).address); + expect(await iexecPocoAccessors.token()).to.equal((await deployments.get('RLC')).address); }); it('viewDeal', async function () { const { dealId } = await createDeal(); - const deal = await iexecPoco.viewDeal(dealId); + const deal = await iexecPocoAccessors.viewDeal(dealId); expect(deal.app.pointer).to.equal(appAddress); expect(deal.app.owner).to.equal(appProvider.address); expect(deal.app.price).to.equal(appPrice); @@ -156,7 +160,9 @@ describe('IexecPocoAccessors', async () => { it('viewConsumed', async function () { const { orders } = await createDeal(); - expect(await iexecPoco.viewConsumed(iexecWrapper.hashOrder(orders.app))).to.equal(1); + expect(await iexecPocoAccessors.viewConsumed(iexecWrapper.hashOrder(orders.app))).to.equal( + 1, + ); }); it('viewPresigned', async function () { @@ -167,7 +173,7 @@ describe('IexecPocoAccessors', async () => { .connect(appProvider) .manageAppOrder(orderOperation) .then((tx) => tx.wait()); - expect(await iexecPoco.viewPresigned(iexecWrapper.hashOrder(appOrder))).equal( + expect(await iexecPocoAccessors.viewPresigned(iexecWrapper.hashOrder(appOrder))).equal( appProvider.address, ); }); @@ -176,10 +182,10 @@ describe('IexecPocoAccessors', async () => { const { dealId, taskId, taskIndex, startTime, timeRef } = await createDeal(); await iexecWrapper.initializeTask(dealId, taskIndex); - const contributionDeadlineRatio = await iexecPoco.contribution_deadline_ratio(); - const finalDeadlineRatio = await iexecPoco.final_deadline_ratio(); + const contributionDeadlineRatio = await iexecPocoAccessors.contribution_deadline_ratio(); + const finalDeadlineRatio = await iexecPocoAccessors.final_deadline_ratio(); - const task = await iexecPoco.viewTask(taskId); + const task = await iexecPocoAccessors.viewTask(taskId); expect(task.status).to.equal(TaskStatusEnum.ACTIVE); expect(task.dealid).to.equal(dealId); expect(task.idx).to.equal(taskIndex); @@ -201,7 +207,7 @@ describe('IexecPocoAccessors', async () => { const { dealId, taskIndex, taskId } = await createDeal(); await iexecWrapper.initializeTask(dealId, taskIndex); await iexecWrapper.contributeToTask(dealId, taskIndex, resultDigest, worker1); - const contribution = await iexecPoco.viewContribution(taskId, worker1.address); + const contribution = await iexecPocoAccessors.viewContribution(taskId, worker1.address); expect(contribution.status).to.equal(ContributionStatusEnum.CONTRIBUTED); expect(contribution.resultHash.length).to.equal(66); expect(contribution.resultSeal.length).to.equal(66); @@ -210,41 +216,41 @@ describe('IexecPocoAccessors', async () => { }); it.skip('[TODO] viewScore', async function () { - expect(await iexecPoco.viewScore(worker1.address)).to.equal(0); + expect(await iexecPocoAccessors.viewScore(worker1.address)).to.equal(0); }); it('countCategory', async function () { - expect(await iexecPoco.countCategory()).to.equal(5); + expect(await iexecPocoAccessors.countCategory()).to.equal(5); }); it('appRegistry', async function () { - expect(await iexecPoco.appregistry()).to.equal( + expect(await iexecPocoAccessors.appregistry()).to.equal( (await deployments.get('AppRegistry')).address, ); }); it('datasetRegistry', async function () { - expect(await iexecPoco.datasetregistry()).to.equal( + expect(await iexecPocoAccessors.datasetregistry()).to.equal( (await deployments.get('DatasetRegistry')).address, ); }); it('workerpoolRegistry', async function () { - expect(await iexecPoco.workerpoolregistry()).to.equal( + expect(await iexecPocoAccessors.workerpoolregistry()).to.equal( (await deployments.get('WorkerpoolRegistry')).address, ); }); it('teeBroker', async function () { - expect(await iexecPoco.teebroker()).to.equal(ZeroAddress); + expect(await iexecPocoAccessors.teebroker()).to.equal(ZeroAddress); }); it('callbackGas', async function () { - expect(await iexecPoco.callbackgas()).to.equal(100_000n); + expect(await iexecPocoAccessors.callbackgas()).to.equal(100_000n); }); it('viewDataset', async function () { - const datasetInfo = await iexecPoco.viewDataset(datasetAddress); + const datasetInfo = await iexecPocoAccessors.viewDataset(datasetAddress); expect(datasetInfo.owner).to.equal(datasetProvider.address); expect(datasetInfo.m_datasetName).to.equal('my-dataset'); expect(datasetInfo.m_datasetMultiaddr).to.equal(ZeroHash); @@ -252,7 +258,7 @@ describe('IexecPocoAccessors', async () => { }); it('viewApp', async function () { - const appInfo = await iexecPoco.viewApp(appAddress); + const appInfo = await iexecPocoAccessors.viewApp(appAddress); expect(appInfo.owner).to.equal(appProvider.address); expect(appInfo.m_appName).to.equal('my-app'); expect(appInfo.m_appType).to.equal('APP_TYPE_0'); @@ -262,7 +268,7 @@ describe('IexecPocoAccessors', async () => { }); it('viewWorkerpool', async function () { - const workerpoolInfo = await iexecPoco.viewWorkerpool(workerpoolAddress); + const workerpoolInfo = await iexecPocoAccessors.viewWorkerpool(workerpoolAddress); expect(workerpoolInfo.owner).to.equal(scheduler.address); expect(workerpoolInfo.m_workerpoolDescription).to.equal('my-workerpool'); expect(workerpoolInfo.m_workerStakeRatioPolicy).to.equal(30n); @@ -270,41 +276,41 @@ describe('IexecPocoAccessors', async () => { }); it('contributionDeadlineRatio', async function () { - expect(await iexecPoco.contribution_deadline_ratio()).to.equal(7); + expect(await iexecPocoAccessors.contribution_deadline_ratio()).to.equal(7); }); it('revealDeadlineRatio', async function () { - expect(await iexecPoco.reveal_deadline_ratio()).to.equal(2n); + expect(await iexecPocoAccessors.reveal_deadline_ratio()).to.equal(2n); }); it('finalDeadlineRatio', async function () { - expect(await iexecPoco.final_deadline_ratio()).to.equal(10n); + expect(await iexecPocoAccessors.final_deadline_ratio()).to.equal(10n); }); it('workerpoolStakeRatio', async function () { - expect(await iexecPoco.workerpool_stake_ratio()).to.equal(30n); + expect(await iexecPocoAccessors.workerpool_stake_ratio()).to.equal(30n); }); it('kittyRatio', async function () { - expect(await iexecPoco.kitty_ratio()).to.equal(10n); + expect(await iexecPocoAccessors.kitty_ratio()).to.equal(10n); }); it('kittyMin', async function () { - expect(await iexecPoco.kitty_min()).to.equal(1_000_000_000n); + expect(await iexecPocoAccessors.kitty_min()).to.equal(1_000_000_000n); }); it('kittyAddress', async function () { - expect(await iexecPoco.kitty_address()).to.equal( + expect(await iexecPocoAccessors.kitty_address()).to.equal( '0x99c2268479b93fDe36232351229815DF80837e23', ); }); it('groupMemberPurpose', async function () { - expect(await iexecPoco.groupmember_purpose()).to.equal(4n); + expect(await iexecPocoAccessors.groupmember_purpose()).to.equal(4n); }); it('eip712domainSeparator', async function () { - expect(await iexecPoco.eip712domain_separator()).equal( + expect(await iexecPocoAccessors.eip712domain_separator()).equal( await hashDomain({ // TODO use IexecWrapper.getDomain() (with some modifications). name: 'iExecODB', @@ -335,7 +341,7 @@ describe('IexecPocoAccessors', async () => { .then((tx) => tx.wait()); const task = await iexecPoco.viewTask(taskId); expect(task.status).to.equal(TaskStatusEnum.COMPLETED); - expect(await iexecPoco.resultFor(taskId)).to.equal(resultsCallback); + expect(await iexecPocoAccessors.resultFor(taskId)).to.equal(resultsCallback); }); it('Should not get result when task is not completed', async function () { @@ -367,13 +373,13 @@ async function createDeal(volume: bigint = 1n) { const { dealId, taskId, taskIndex, startTime } = await iexecWrapper.signAndMatchOrders( ...orders.toArray(), ); - const dealCategory = (await iexecPoco.viewDeal(dealId)).category; - const timeRef = (await iexecPoco.viewCategory(dealCategory)).workClockTimeRef; + const dealCategory = (await iexecPocoAccessors.viewDeal(dealId)).category; + const timeRef = (await iexecPocoAccessors.viewCategory(dealCategory)).workClockTimeRef; return { dealId, taskId, taskIndex, startTime, timeRef, orders }; } async function verifyTaskStatusAndResult(taskId: string, expectedStatus: number) { - const task = await iexecPoco.viewTask(taskId); + const task = await iexecPocoAccessors.viewTask(taskId); expect(task.status).to.equal(expectedStatus); - await expect(iexecPoco.resultFor(taskId)).to.be.revertedWith('task-pending'); + await expect(iexecPocoAccessors.resultFor(taskId)).to.be.revertedWith('task-pending'); } diff --git a/test/utils/IexecWrapper.ts b/test/utils/IexecWrapper.ts index 5370fdeeb..9775b529c 100644 --- a/test/utils/IexecWrapper.ts +++ b/test/utils/IexecWrapper.ts @@ -18,7 +18,6 @@ import { AppRegistry__factory, DatasetRegistry, DatasetRegistry__factory, - IexecAccessors__factory, IexecConfigurationFacet__factory, IexecInterfaceNative__factory, IexecLibOrders_v5, @@ -91,7 +90,10 @@ export class IexecWrapper { return; } const rlc = RLC__factory.connect( - await IexecAccessors__factory.connect(this.proxyAddress, this.accounts.anyone).token(), + await IexecPocoAccessors__factory.connect( + this.proxyAddress, + this.accounts.anyone, + ).token(), this.accounts.iexecAdmin, ); // Transfer RLC from owner to recipient @@ -114,7 +116,7 @@ export class IexecWrapper { * @returns total amount to stake by the scheduler */ async computeSchedulerDealStake(workerpoolPrice: bigint, volume: bigint): Promise { - const stakeRatio = await IexecAccessors__factory.connect( + const stakeRatio = await IexecPocoAccessors__factory.connect( this.proxyAddress, this.accounts.anyone, ).workerpool_stake_ratio(); @@ -166,7 +168,7 @@ export class IexecWrapper { ).workerReward; } // CLASSIC mode. - const deal = await IexecAccessors__factory.connect( + const deal = await IexecPocoAccessors__factory.connect( this.proxyAddress, ethers.provider, ).viewDeal(dealId); @@ -251,7 +253,7 @@ export class IexecWrapper { const datasetOrder = orders.dataset; const workerpoolOrder = orders.workerpool; const requestOrder = orders.requester; - const taskIndex = await IexecAccessors__factory.connect( + const taskIndex = await IexecPocoAccessors__factory.connect( this.proxyAddress, ethers.provider, ).viewConsumed(this.hashOrder(requestOrder)); @@ -292,7 +294,7 @@ export class IexecWrapper { } async createApp() { - const iexec = IexecAccessors__factory.connect(this.proxyAddress, this.accounts.anyone); + const iexec = IexecPocoAccessors__factory.connect(this.proxyAddress, this.accounts.anyone); const appRegistry: AppRegistry = AppRegistry__factory.connect( await iexec.appregistry(), this.accounts.appProvider, @@ -311,7 +313,7 @@ export class IexecWrapper { } async createDataset() { - const iexec = IexecAccessors__factory.connect(this.proxyAddress, this.accounts.anyone); + const iexec = IexecPocoAccessors__factory.connect(this.proxyAddress, this.accounts.anyone); const datasetRegistry: DatasetRegistry = DatasetRegistry__factory.connect( await iexec.datasetregistry(), this.accounts.datasetProvider, @@ -406,7 +408,7 @@ export class IexecWrapper { useEnclave: Boolean, ) { const taskId = getTaskId(dealId, taskIndex); - const workerStakePerTask = await IexecAccessors__factory.connect( + const workerStakePerTask = await IexecPocoAccessors__factory.connect( this.proxyAddress, ethers.provider, ) @@ -446,7 +448,7 @@ export class IexecWrapper { } async createWorkerpool() { - const iexec = IexecAccessors__factory.connect(this.proxyAddress, this.accounts.anyone); + const iexec = IexecPocoAccessors__factory.connect(this.proxyAddress, this.accounts.anyone); const workerpoolRegistry: WorkerpoolRegistry = WorkerpoolRegistry__factory.connect( await iexec.workerpoolregistry(), this.accounts.scheduler,