diff --git a/.github/workflows/deploy-smart-contracts.yml b/.github/workflows/deploy-smart-contracts.yml index 71f4d22e5..3b05798b1 100644 --- a/.github/workflows/deploy-smart-contracts.yml +++ b/.github/workflows/deploy-smart-contracts.yml @@ -89,7 +89,7 @@ jobs: echo "Deploying to: ${{ inputs.network }} with ${{ inputs.environment }} environment" npm run deploy -- --network ${{ inputs.network }} - - name: Update config.json with ERC1538Proxy address + - name: Update config.json with Diamond proxy address if: inputs.network != 'hardhat' run: npx hardhat run scripts/tools/update-config.ts --network ${{ inputs.network }} diff --git a/config/config.json b/config/config.json index e64922f1d..1be835750 100644 --- a/config/config.json +++ b/config/config.json @@ -175,7 +175,7 @@ "v5": { "factory": "0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed", "factoryType": "createx", - "ERC1538Proxy": "0x14B465079537655E1662F012e99EBa3863c8B9E0", + "DiamondProxy": "0x14B465079537655E1662F012e99EBa3863c8B9E0", "salt": "0x0000000000000000000000000000000000000000000000000000000000000000" } }, diff --git a/deploy/0_deploy.ts b/deploy/0_deploy.ts index effa6ab6c..5798178b3 100644 --- a/deploy/0_deploy.ts +++ b/deploy/0_deploy.ts @@ -70,12 +70,12 @@ export default async function deploy() { .catch(() => { throw new Error('Failed to prepare transferOwnership data'); }); - const erc1538ProxyAddress = await deployDiamondProxyWithDefaultFacets( + const diamondProxyAddress = await deployDiamondProxyWithDefaultFacets( owner, // transferOwnershipCall, //TODO ); - const erc1538 = DiamondCutFacet__factory.connect(erc1538ProxyAddress, owner); - console.log(`IexecInstance found at address: ${await erc1538.getAddress()}`); + const diamond = DiamondCutFacet__factory.connect(diamondProxyAddress, owner); + console.log(`IexecInstance found at address: ${await diamond.getAddress()}`); // Deploy library & modules const iexecLibOrdersAddress = await factoryDeployer.deployContract( new IexecLibOrders_v5__factory(), @@ -103,21 +103,21 @@ export default async function deploy() { ]; for (const module of modules) { const address = await factoryDeployer.deployContract(module); - await linkContractToProxy(erc1538, address, module); + await linkContractToProxy(diamond, address, module); } - // Verify linking on ERC1538Proxy - const erc1538QueryInstance: DiamondLoupeFacet = DiamondLoupeFacet__factory.connect( - erc1538ProxyAddress, + // Verify linking on Diamond Proxy + const diamondLoupeFacetInstance: DiamondLoupeFacet = DiamondLoupeFacet__factory.connect( + diamondProxyAddress, owner, ); - const facets = await erc1538QueryInstance.facets(); + const facets = await diamondLoupeFacetInstance.facets(); const functionCount = facets .map((facet) => facet.functionSelectors.length) .reduce((acc, curr) => acc + curr, 0); - console.log(`The deployed ERC1538Proxy now supports ${functionCount} functions:`); + console.log(`The deployed Diamond Proxy now supports ${functionCount} functions:`); // TODO // for (let i = 0; i < Number(functionCount); i++) { - // const [method, , contract] = await erc1538QueryInstance.functionByIndex(i); + // const [method, , contract] = await diamondLoupeFacetInstance.functionByIndex(i); // console.log(`[${i}] ${contract} ${method}`); // } /** @@ -174,11 +174,11 @@ export default async function deploy() { } // Set main configuration - const iexecAccessorsInstance = IexecAccessors__factory.connect(erc1538ProxyAddress, owner); + const iexecAccessorsInstance = IexecAccessors__factory.connect(diamondProxyAddress, owner); const iexecInitialized = (await iexecAccessorsInstance.eip712domain_separator()) != ZeroHash; if (!iexecInitialized) { // TODO replace this with DiamondInit.init(). - await IexecMaintenanceDelegate__factory.connect(erc1538ProxyAddress, owner) + await IexecMaintenanceDelegate__factory.connect(diamondProxyAddress, owner) .configure( rlcInstanceAddress, 'Staked RLC', @@ -195,7 +195,7 @@ export default async function deploy() { const catCountBefore = await iexecAccessorsInstance.countCategory(); for (let i = Number(catCountBefore); i < config.categories.length; i++) { const category = config.categories[i]; - await IexecCategoryManager__factory.connect(erc1538ProxyAddress, owner) + await IexecCategoryManager__factory.connect(diamondProxyAddress, owner) .createCategory( category.name, JSON.stringify(category.description), diff --git a/scripts/boost/1_add-modules-to-proxy.ts b/scripts/boost/1_add-modules-to-proxy.ts index 98b8a02ed..ff3734354 100644 --- a/scripts/boost/1_add-modules-to-proxy.ts +++ b/scripts/boost/1_add-modules-to-proxy.ts @@ -21,16 +21,16 @@ import { const chainId = (await ethers.provider.getNetwork()).chainId; const deploymentOptions = config.getChainConfig(chainId).v5; console.log('Link Boost functions to proxy:'); - if (!deploymentOptions.ERC1538Proxy) { - throw new Error('ERC1538Proxy is required'); + if (!deploymentOptions.DiamondProxy) { + throw new Error('DiamondProxy is required'); } - const erc1538ProxyAddress = deploymentOptions.ERC1538Proxy; + const diamondProxyAddress = deploymentOptions.DiamondProxy; const iexecPocoBoostDelegateAddress = (await deployments.get('IexecPocoBoostDelegate')).address; // Bellecour: 0x8425229f979AB3b0dDDe00D475D762cA4d6a5eFc const iexecPocoBoostAccessorsDelegateAddress = ( await deployments.get('IexecPocoBoostAccessorsDelegate') ).address; // Bellecour: 0x56185a2b0dc8b556BBfBAFB702BC971Ed75e868C const [account] = await ethers.getSigners(); - const timelockAddress = await Ownable__factory.connect(erc1538ProxyAddress, account).owner(); // Bellecour: 0x4611B943AA1d656Fc669623b5DA08756A7e288E9 + const timelockAddress = await Ownable__factory.connect(diamondProxyAddress, account).owner(); // Bellecour: 0x4611B943AA1d656Fc669623b5DA08756A7e288E9 const iexecPocoBoostProxyUpdate = encodeModuleProxyUpdate( IexecPocoBoost__factory.createInterface(), iexecPocoBoostDelegateAddress, @@ -43,7 +43,7 @@ import { const operationSalt = '0x0be814a62c44af32241a2c964e5680d1b25c783473c6e7875cbc8071770d7ff0'; // Random const delay = BigInt(60 * 60 * 24 * 7); const updateProxyArgs = [ - Array(2).fill(erc1538ProxyAddress), + Array(2).fill(diamondProxyAddress), Array(2).fill(0), [iexecPocoBoostProxyUpdate, iexecPocoBoostAccessorsProxyUpdate], ZeroHash, @@ -68,7 +68,7 @@ import { await time.increase(delay); console.log('Time traveling..'); await printBlockTime(); - await printFunctions(erc1538ProxyAddress); + await printFunctions(diamondProxyAddress); console.log('Executing proxy update..'); await timelockInstance .connect(timelockAdminSigner) @@ -77,5 +77,5 @@ import { console.log(tx); tx.wait(); }); - await printFunctions(erc1538ProxyAddress); + await printFunctions(diamondProxyAddress); })(); diff --git a/scripts/set-callback-gas.ts b/scripts/set-callback-gas.ts index 2480c6941..e15a28e73 100644 --- a/scripts/set-callback-gas.ts +++ b/scripts/set-callback-gas.ts @@ -12,13 +12,13 @@ import { IexecAccessors__factory, IexecMaintenanceDelegate__factory } from '../t } console.log(`Setting callback-gas to ${requestedCallbackGas.toLocaleString()} ..`); const [owner] = await ethers.getSigners(); - const erc1538ProxyAddress = (await deployments.get('ERC1538Proxy')).address; + const diamondProxyAddress = (await deployments.get('Diamond')).address; const viewCallbackGas = async () => - (await IexecAccessors__factory.connect(erc1538ProxyAddress, owner).callbackgas()) + (await IexecAccessors__factory.connect(diamondProxyAddress, owner).callbackgas()) .toNumber() .toLocaleString(); const callbackGasBefore = await viewCallbackGas(); - await IexecMaintenanceDelegate__factory.connect(erc1538ProxyAddress, owner) + await IexecMaintenanceDelegate__factory.connect(diamondProxyAddress, owner) .setCallbackGas(requestedCallbackGas) .then((tx) => tx.wait()); console.log(`Changed callback-gas from ${callbackGasBefore} to ${await viewCallbackGas()}`); diff --git a/scripts/sponsoring/1_add-modules-to-proxy.ts b/scripts/sponsoring/1_add-modules-to-proxy.ts index 61d681e61..04f01a2cc 100644 --- a/scripts/sponsoring/1_add-modules-to-proxy.ts +++ b/scripts/sponsoring/1_add-modules-to-proxy.ts @@ -29,10 +29,10 @@ export async function addModulesToProxy() { const chainId = (await ethers.provider.getNetwork()).chainId; const deploymentOptions = config.getChainConfig(chainId).v5; console.log('Link functions to proxy:'); - if (!deploymentOptions.ERC1538Proxy) { - throw new Error('ERC1538Proxy is required'); + if (!deploymentOptions.DiamondProxy) { + throw new Error('DiamondProxy is required'); } - const erc1538ProxyAddress = deploymentOptions.ERC1538Proxy; + const diamondProxyAddress = deploymentOptions.DiamondProxy; const iexecOrderManagementAddress = (await hre.deployments.get('IexecOrderManagementDelegate')) .address; const iexecPoco1DelegateAddress = (await hre.deployments.get('IexecPoco1Delegate')).address; @@ -40,11 +40,11 @@ export async function addModulesToProxy() { const iexecPocoAccessorsDelegateAddress = ( await hre.deployments.get('IexecPocoAccessorsDelegate') ).address; - await printFunctions(erc1538ProxyAddress); + await printFunctions(diamondProxyAddress); console.log('Functions about to be added to proxy:'); const timelockAddress = await Ownable__factory.connect( - erc1538ProxyAddress, + diamondProxyAddress, ethers.provider, ).owner(); const iexecOrderManagementProxyUpdate = encodeModuleProxyUpdate( @@ -73,7 +73,7 @@ export async function addModulesToProxy() { iexecPocoAccessorsProxyUpdate, ]; const updateProxyArgs = [ - Array(updates.length).fill(erc1538ProxyAddress), + Array(updates.length).fill(diamondProxyAddress), Array(updates.length).fill(0), updates, ZeroHash, @@ -104,7 +104,7 @@ export async function addModulesToProxy() { console.log('Time traveling..'); await executeUpgrade(); - return erc1538ProxyAddress; + return diamondProxyAddress; async function scheduleUpgrade() { await timelockInstance @@ -118,7 +118,7 @@ export async function addModulesToProxy() { async function executeUpgrade() { await printBlockTime(); - await printFunctions(erc1538ProxyAddress); + await printFunctions(diamondProxyAddress); console.log('Executing proxy update..'); await timelockInstance .connect(timelockAdminSigner) @@ -127,6 +127,6 @@ export async function addModulesToProxy() { console.log(x); return x.wait(); }); - await printFunctions(erc1538ProxyAddress); + await printFunctions(diamondProxyAddress); } } diff --git a/scripts/tools/update-config.ts b/scripts/tools/update-config.ts index 0b0094ce6..26243371a 100644 --- a/scripts/tools/update-config.ts +++ b/scripts/tools/update-config.ts @@ -13,15 +13,15 @@ async function main(): Promise { const chainId = network.chainId.toString(); console.log(`Working with network: ${networkName} (Chain ID: ${chainId})`); - const deployment = await deployments.get('ERC1538Proxy'); + const deployment = await deployments.get('DiamondProxy'); const contractAddress = deployment.address; if (!contractAddress || contractAddress === 'null') { - console.error(`Failed to extract a valid ERC1538Proxy address from deployment file`); + console.error(`Failed to extract a valid DiamondProxy address from deployment file`); process.exit(1); } - console.log(`Found ERC1538Proxy address: ${contractAddress}`); + console.log(`Found DiamondProxy address: ${contractAddress}`); const localConfig = config; // Ensure the chain structure exists @@ -47,7 +47,7 @@ async function main(): Promise { localConfig.chains[chainId].v5 = {}; } - const contractKey = 'ERC1538Proxy'; + const contractKey = 'DiamondProxy'; const previousValue = localConfig.chains[chainId].v5[contractKey] || 'null'; localConfig.chains[chainId].v5[contractKey] = contractAddress; diff --git a/scripts/upgrades/upgrade-helper.ts b/scripts/upgrades/upgrade-helper.ts index 57b628d26..ac00159a0 100644 --- a/scripts/upgrades/upgrade-helper.ts +++ b/scripts/upgrades/upgrade-helper.ts @@ -29,15 +29,16 @@ async function printBlockTime() { } } -async function printFunctions(erc1538ProxyAddress: string) { - const erc1538QueryInstance: ERC1538Query = ERC1538Query__factory.connect( - erc1538ProxyAddress, +// TODO: update this function to use DiamonLoup +async function printFunctions(diamondProxyAddress: string) { + const diamondQueryInstance: ERC1538Query = ERC1538Query__factory.connect( + diamondProxyAddress, ethers.provider, ); - const functionCount = Number(await erc1538QueryInstance.totalFunctions()); - console.log(`ERC1538Proxy supports ${functionCount} functions:`); + const functionCount = Number(await diamondQueryInstance.totalFunctions()); + console.log(`DiamondProxy supports ${functionCount} functions:`); for (let i = 0; i < functionCount; i++) { - const [method, , contract] = await erc1538QueryInstance.functionByIndex(i); + const [method, , contract] = await diamondQueryInstance.functionByIndex(i); console.log(`[${i}] ${contract} ${method}`); } } diff --git a/test/utils/fixture-helpers.ts b/test/utils/fixture-helpers.ts index 360ae4670..964ce8fcd 100644 --- a/test/utils/fixture-helpers.ts +++ b/test/utils/fixture-helpers.ts @@ -50,9 +50,9 @@ export async function fundAccounts( * Transfers ownership of all contracts */ export async function transferAllOwnerships(chainConfig: any) { - if (chainConfig.v5.ERC1538Proxy) { + if (chainConfig.v5.DiamondProxy) { // Transfer proxy ownership from Timelock or current owner to a known EOA. - await transferProxyOwnership(chainConfig.v5.ERC1538Proxy); + await transferProxyOwnership(chainConfig.v5.DiamondProxy); } const registries = [ { name: 'AppRegistry', address: (await deployments.get('AppRegistry')).address }, diff --git a/test/utils/hardhat-fixture-deployer.ts b/test/utils/hardhat-fixture-deployer.ts index e20a4f3d8..d798ae242 100644 --- a/test/utils/hardhat-fixture-deployer.ts +++ b/test/utils/hardhat-fixture-deployer.ts @@ -23,9 +23,9 @@ async function deployAll() { */ async function setUpLocalForkInNativeMode() { const chainId = (await ethers.provider.getNetwork()).chainId; - const proxyAddress = config.getChainConfig(chainId).v5.ERC1538Proxy; + const proxyAddress = config.getChainConfig(chainId).v5.DiamondProxy; if (!proxyAddress) { - throw new Error('ERC1538Proxy is required'); + throw new Error('DiamondProxy is required'); } await fundAccounts(proxyAddress, proxyAddress, true); await transferAllOwnerships(config.getChainConfig(chainId)); @@ -48,16 +48,16 @@ async function setUpLocalForkInTokenMode() { } await transferAllOwnerships(chainConfig); - const proxyAddress = chainConfig.v5.ERC1538Proxy; + const proxyAddress = chainConfig.v5.DiamondProxy; if (proxyAddress) { - console.log(`Using existing ERC1538Proxy at ${proxyAddress}`); + console.log(`Using existing DiamondProxy at ${proxyAddress}`); return proxyAddress; } else { - console.log('No existing ERC1538Proxy found, deploying new contracts'); + console.log('No existing DiamondProxy found, deploying new contracts'); // Deploy all contracts await deploy(); - const newProxyAddress = (await deployments.get('ERC1538Proxy')).address; - console.log(`Deployed new ERC1538Proxy at ${newProxyAddress}`); + const newProxyAddress = (await deployments.get('Diamond')).address; + console.log(`Deployed new DiamondProxy at ${newProxyAddress}`); return newProxyAddress; } } diff --git a/utils/config.ts b/utils/config.ts index d7f7ffd68..b20f12d51 100644 --- a/utils/config.ts +++ b/utils/config.ts @@ -55,7 +55,8 @@ type ChainConfig = { AppRegistry?: string; DatasetRegistry?: string; WorkerpoolRegistry?: string; - ERC1538Proxy?: string; + ERC1538Proxy?: string; // Deprecated, use DiamondProxy instead TODO: to remove + DiamondProxy?: string; IexecLibOrders_v5?: string; }; }; diff --git a/utils/proxy-tools.ts b/utils/proxy-tools.ts index a34e65d3b..54304d1ce 100644 --- a/utils/proxy-tools.ts +++ b/utils/proxy-tools.ts @@ -13,8 +13,8 @@ interface AbiParameter { } /** - * Link a contract to an ERC1538 proxy. - * @param proxy contract to ERC1538 proxy. + * Link a contract to a Diamond proxy. + * @param proxy contract to Diamond proxy. * @param contractAddress The contract address to link to the proxy. * @param contractFactory The contract factory to link to the proxy. */