From 56ca9344380f53803654592823719b5047eb863b Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 6 May 2025 10:58:41 +0200 Subject: [PATCH 01/42] Remove result proxy address from sharing contract --- .../contracts/DataProtectorSharing.sol | 6 ++---- .../sharing-smart-contract/contracts/ManageOrders.sol | 5 +++-- packages/sharing-smart-contract/scripts/updateEnv.js | 11 +++++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/sharing-smart-contract/contracts/DataProtectorSharing.sol b/packages/sharing-smart-contract/contracts/DataProtectorSharing.sol index 877bd1800..5c03d46fa 100644 --- a/packages/sharing-smart-contract/contracts/DataProtectorSharing.sol +++ b/packages/sharing-smart-contract/contracts/DataProtectorSharing.sol @@ -72,7 +72,7 @@ contract DataProtectorSharing is __AccessControl_init(); _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); - updateEnv("ipfs", "https://result.v8-bellecour.iex.ec"); + updateEnv("ipfs"); } /*************************************************************************** @@ -261,11 +261,9 @@ contract DataProtectorSharing is * Admin * **************************************************************************/ function updateEnv( - string memory iexecResultStorageProvider_, - string memory iexecResultStorageProxy_ + string memory iexecResultStorageProvider_ ) public onlyRole(DEFAULT_ADMIN_ROLE) { _iexecResultStorageProvider = iexecResultStorageProvider_; - _iexecResultStorageProxy = iexecResultStorageProxy_; } /*************************************************************************** diff --git a/packages/sharing-smart-contract/contracts/ManageOrders.sol b/packages/sharing-smart-contract/contracts/ManageOrders.sol index 74debf956..1733eb468 100644 --- a/packages/sharing-smart-contract/contracts/ManageOrders.sol +++ b/packages/sharing-smart-contract/contracts/ManageOrders.sol @@ -38,6 +38,9 @@ abstract contract ManageOrders { 0x0000000000000000000000000000000000000000000000000000000000000003; // [tee,scone] uint256 internal constant TRUST = 0; // No replication string internal _iexecResultStorageProvider; + // This value is not used anymore but it is kept + // as a placeholder to not break storage of the proxy + // deployed on Bellecour. string internal _iexecResultStorageProxy; uint256 private _salt; @@ -166,8 +169,6 @@ abstract contract ManageOrders { '{"iexec_result_encryption":true', // solhint-disable-line quotes ',"iexec_result_storage_provider":"', // solhint-disable-line quotes _iexecResultStorageProvider, - '","iexec_result_storage_proxy":"', // solhint-disable-line quotes - _iexecResultStorageProxy, '"}' // solhint-disable-line quotes ); } diff --git a/packages/sharing-smart-contract/scripts/updateEnv.js b/packages/sharing-smart-contract/scripts/updateEnv.js index eb7be8f2f..71d368b11 100644 --- a/packages/sharing-smart-contract/scripts/updateEnv.js +++ b/packages/sharing-smart-contract/scripts/updateEnv.js @@ -7,11 +7,14 @@ const { ethers } = pkg; async function main() { const { ENV } = env; console.log(`using ENV: ${ENV}`); - const { dataprotectorSharingContractAddress, resultProxyUrl } = getEnvironment(ENV); + const { dataprotectorSharingContractAddress } = getEnvironment(ENV); - const newEnv = ['ipfs', resultProxyUrl]; + const newResultStorageProvider = 'ipfs'; - console.log(`UpdateEnv Contract at ${dataprotectorSharingContractAddress} with [${newEnv}]`); + console.log( + `UpdateEnv contract at ${dataprotectorSharingContractAddress} ` + + `[newResultStorageProvider=${newResultStorageProvider}]`, + ); const [admin] = await ethers.getSigners(); console.log(`using wallet ${admin.address}`); @@ -20,7 +23,7 @@ async function main() { dataprotectorSharingContractAddress, ); - const updateEnvTx = await dataProtectorSharingContract.updateEnv(...newEnv); + const updateEnvTx = await dataProtectorSharingContract.updateEnv(newResultStorageProvider); console.log(`tx: ${updateEnvTx.hash}`); await updateEnvTx.wait(); From e1de79bd0efe09b0fc6d2002c192754869c024f8 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 6 May 2025 10:58:57 +0200 Subject: [PATCH 02/42] Add cleanup todos --- environments/README.md | 2 +- environments/common/utils.js | 2 +- environments/types/index.d.ts | 2 +- packages/sdk/tests/test-utils.ts | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/environments/README.md b/environments/README.md index 9e5cf92ac..8011313cf 100644 --- a/environments/README.md +++ b/environments/README.md @@ -24,7 +24,7 @@ import { getEnvironment } from "@iexec/dataprotector-environments"; const { smsUrl, iexecGatewayUrl, - resultProxyUrl, + resultProxyUrl, // TODO remove ipfsGatewayUrl, ipfsNodeUrl, workerpoolProdAddress, diff --git a/environments/common/utils.js b/environments/common/utils.js index 927bdd2f5..2ff506c4e 100644 --- a/environments/common/utils.js +++ b/environments/common/utils.js @@ -6,7 +6,7 @@ export const KNOWN_KEYS = [ // iexec protocol config "smsUrl", "iexecGatewayUrl", - "resultProxyUrl", + "resultProxyUrl", // TODO remove "ipfsGatewayUrl", "ipfsNodeUrl", "workerpoolProdAddress", diff --git a/environments/types/index.d.ts b/environments/types/index.d.ts index 437e8341e..b5e38889b 100644 --- a/environments/types/index.d.ts +++ b/environments/types/index.d.ts @@ -2,7 +2,7 @@ export declare type KnownEnv = "prod" | "staging"; export declare type EnvKey = | "smsUrl" | "iexecGatewayUrl" - | "resultProxyUrl" + | "resultProxyUrl" // TODO remove | "ipfsGatewayUrl" | "ipfsNodeUrl" /** diff --git a/packages/sdk/tests/test-utils.ts b/packages/sdk/tests/test-utils.ts index 25d3fc288..7cb8344ad 100644 --- a/packages/sdk/tests/test-utils.ts +++ b/packages/sdk/tests/test-utils.ts @@ -17,7 +17,7 @@ const TEST_CHAIN = { smsDebugURL: DRONE ? 'http://sms-debug:13300' : 'http://127.0.0.1:13301', resultProxyURL: DRONE ? 'http://result-proxy:13200' - : 'http://127.0.0.1:13200', + : 'http://127.0.0.1:13200', // TODO remove iexecGatewayURL: DRONE ? 'http://market-api:3000' : 'http://127.0.0.1:3000', provider: new JsonRpcProvider( DRONE ? 'http://bellecour-fork:8545' : 'http://localhost:8545' @@ -34,7 +34,7 @@ export const getTestRpcProvider = () => new JsonRpcProvider(TEST_CHAIN.rpcURL); export const getTestIExecOption = () => ({ smsURL: TEST_CHAIN.smsURL, smsDebugURL: TEST_CHAIN.smsDebugURL, - resultProxyURL: TEST_CHAIN.resultProxyURL, + resultProxyURL: TEST_CHAIN.resultProxyURL, // TODO remove iexecGatewayURL: TEST_CHAIN.iexecGatewayURL, }); From 6696d428abd19e3b4023357b7dd449da9a6d8ef6 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 6 May 2025 11:00:43 +0200 Subject: [PATCH 03/42] Update changelog --- packages/sharing-smart-contract/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/sharing-smart-contract/CHANGELOG.md b/packages/sharing-smart-contract/CHANGELOG.md index 8a9f1d845..a6b40a3a9 100644 --- a/packages/sharing-smart-contract/CHANGELOG.md +++ b/packages/sharing-smart-contract/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. ### Changed +- [BREAKING] Remove result proxy url from contract config and deal params. - Fix Sharing contract constructor arguments order (#433) - Update blockscout url From ca5bd50749bce416cc577be72bdb8f3b49acc88c Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 6 May 2025 11:05:33 +0200 Subject: [PATCH 04/42] Update abis --- .../DataProtectorSharing.sol/DataProtectorSharing.json | 5 ----- .../abis/DataProtectorSharing.sol/DataProtectorSharing.json | 5 ----- packages/subgraph/abis/DataProtectorSharingABI.json | 5 ----- 3 files changed, 15 deletions(-) diff --git a/packages/sdk/abis/sharing/DataProtectorSharing.sol/DataProtectorSharing.json b/packages/sdk/abis/sharing/DataProtectorSharing.sol/DataProtectorSharing.json index 8ea079bb1..9f61f3582 100644 --- a/packages/sdk/abis/sharing/DataProtectorSharing.sol/DataProtectorSharing.json +++ b/packages/sdk/abis/sharing/DataProtectorSharing.sol/DataProtectorSharing.json @@ -2007,11 +2007,6 @@ "internalType": "string", "name": "iexecResultStorageProvider_", "type": "string" - }, - { - "internalType": "string", - "name": "iexecResultStorageProxy_", - "type": "string" } ], "name": "updateEnv", diff --git a/packages/sharing-smart-contract/abis/DataProtectorSharing.sol/DataProtectorSharing.json b/packages/sharing-smart-contract/abis/DataProtectorSharing.sol/DataProtectorSharing.json index 8ea079bb1..9f61f3582 100644 --- a/packages/sharing-smart-contract/abis/DataProtectorSharing.sol/DataProtectorSharing.json +++ b/packages/sharing-smart-contract/abis/DataProtectorSharing.sol/DataProtectorSharing.json @@ -2007,11 +2007,6 @@ "internalType": "string", "name": "iexecResultStorageProvider_", "type": "string" - }, - { - "internalType": "string", - "name": "iexecResultStorageProxy_", - "type": "string" } ], "name": "updateEnv", diff --git a/packages/subgraph/abis/DataProtectorSharingABI.json b/packages/subgraph/abis/DataProtectorSharingABI.json index 8ea079bb1..9f61f3582 100644 --- a/packages/subgraph/abis/DataProtectorSharingABI.json +++ b/packages/subgraph/abis/DataProtectorSharingABI.json @@ -2007,11 +2007,6 @@ "internalType": "string", "name": "iexecResultStorageProvider_", "type": "string" - }, - { - "internalType": "string", - "name": "iexecResultStorageProxy_", - "type": "string" } ], "name": "updateEnv", From 08a92ddb73b6caa1e0b9137ba5385d3f9abda1a0 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 6 May 2025 15:04:15 +0200 Subject: [PATCH 05/42] Add upgrade unit test --- .../__test/DataProtectorSharingV2Mock.sol | 50 +++++++++++++++++++ .../sharing-smart-contract/hardhat.config.cjs | 1 + .../test/e2e/upgrade.test.js | 50 +++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 packages/sharing-smart-contract/contracts/__test/DataProtectorSharingV2Mock.sol create mode 100644 packages/sharing-smart-contract/test/e2e/upgrade.test.js diff --git a/packages/sharing-smart-contract/contracts/__test/DataProtectorSharingV2Mock.sol b/packages/sharing-smart-contract/contracts/__test/DataProtectorSharingV2Mock.sol new file mode 100644 index 000000000..8b734ea60 --- /dev/null +++ b/packages/sharing-smart-contract/contracts/__test/DataProtectorSharingV2Mock.sol @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: Apache-2.0 + +/****************************************************************************** + * Copyright 2024-2025 IEXEC BLOCKCHAIN TECH * + * * + * Licensed under the Apache License, Version 2.0 (the "License"); * + * you may not use this file except in compliance with the License. * + * You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, software * + * distributed under the License is distributed on an "AS IS" BASIS, * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * See the License for the specific language governing permissions and * + * limitations under the License. * + ******************************************************************************/ + +pragma solidity ^0.8.24; + +import {ERC721BurnableUpgradeable, ERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol"; +import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; +import {MulticallUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol"; +import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol"; +import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; +import {DataProtectorSharing} from "../DataProtectorSharing.sol"; +import {AddOnlyAppWhitelistRegistry, IAddOnlyAppWhitelist} from "../registry/AddOnlyAppWhitelistRegistry.sol"; +import {IRegistry} from "../interfaces/IRegistry.sol"; +import {ManageOrders} from "../ManageOrders.sol"; + +/** + * @notice This contract is for upgradeability testing purposes only. + */ + +contract DataProtectorSharingV2Mock is DataProtectorSharing { + + string public newStorage; + + /// @custom:oz-upgrades-unsafe-allow constructor + constructor() DataProtectorSharing( + address(0), + IRegistry(address(0)), + AddOnlyAppWhitelistRegistry(address(0)) + ) {} + + function initializeV2(string calldata foo) public reinitializer(2) { + newStorage = foo; + } +} diff --git a/packages/sharing-smart-contract/hardhat.config.cjs b/packages/sharing-smart-contract/hardhat.config.cjs index 2788665e2..0fe931a68 100644 --- a/packages/sharing-smart-contract/hardhat.config.cjs +++ b/packages/sharing-smart-contract/hardhat.config.cjs @@ -2,6 +2,7 @@ require('@nomicfoundation/hardhat-foundry'); require('@nomicfoundation/hardhat-toolbox'); require('@openzeppelin/hardhat-upgrades'); require('hardhat-contract-sizer'); +require('@openzeppelin/hardhat-upgrades'); require('dotenv').config(); const { WALLET_PRIVATE_KEY } = process.env; diff --git a/packages/sharing-smart-contract/test/e2e/upgrade.test.js b/packages/sharing-smart-contract/test/e2e/upgrade.test.js new file mode 100644 index 000000000..95152750e --- /dev/null +++ b/packages/sharing-smart-contract/test/e2e/upgrade.test.js @@ -0,0 +1,50 @@ +import { loadFixture } from '@nomicfoundation/hardhat-toolbox/network-helpers.js'; +import { expect } from 'chai'; +import hardhat from 'hardhat'; +const { ethers, upgrades } = hardhat; +import { createCollection, deploySCFixture } from './utils/loadFixture.test.js'; + +// TODO convert to ts. +// TODO use typechain for factories. + +let dataProtectorSharingContract; +let contractAddress; +let owner, addr1; + +describe('DataProtectorSharing', function () { + beforeEach('Deploy fixture', async function () { + ({ dataProtectorSharingContract, owner, addr1 } = await loadFixture(deploySCFixture)); + contractAddress = await dataProtectorSharingContract.getAddress(); + await dataProtectorSharingContract.createCollection(owner).then((tx) => tx.wait()); + }); + + describe('Upgrade', function () { + it('Should upgrade', async function () { + // Update the state of the original proxy. + const { collectionTokenId } = await createCollection(); + // Upgrade the proxy. + const newImplementationFactory = await ethers.getContractFactory( + 'DataProtectorSharingV2Mock', + owner, + ); + await upgrades + .upgradeProxy(contractAddress, newImplementationFactory) + .then((contract) => contract.waitForDeployment()); + const dataProtectorSharingContractV2 = await ethers.getContractAt( + 'DataProtectorSharingV2Mock', + contractAddress, + ); + await dataProtectorSharingContractV2.initializeV2('bar'); + // Check V1 storage. + expect(await dataProtectorSharingContractV2.ownerOf(collectionTokenId)).to.equal( + addr1.address, + ); + // Check V2 storage. + expect(await dataProtectorSharingContractV2.newStorage()).to.equal('bar'); + // Check address. + expect(await dataProtectorSharingContractV2.getAddress()).to.equal(contractAddress); + }); + + it('TODO - Should not upgrade when storage is broken', async function () {}); + }); +}); From 519e9c0c9c67ed4c07a67cabb608c3dcf7462877 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 6 May 2025 15:08:11 +0200 Subject: [PATCH 06/42] Format --- .../contracts/__test/DataProtectorSharingV2Mock.sol | 13 +++++++------ .../sharing-smart-contract/test/e2e/upgrade.test.js | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/sharing-smart-contract/contracts/__test/DataProtectorSharingV2Mock.sol b/packages/sharing-smart-contract/contracts/__test/DataProtectorSharingV2Mock.sol index 8b734ea60..3f1ba7582 100644 --- a/packages/sharing-smart-contract/contracts/__test/DataProtectorSharingV2Mock.sol +++ b/packages/sharing-smart-contract/contracts/__test/DataProtectorSharingV2Mock.sol @@ -34,15 +34,16 @@ import {ManageOrders} from "../ManageOrders.sol"; */ contract DataProtectorSharingV2Mock is DataProtectorSharing { - string public newStorage; /// @custom:oz-upgrades-unsafe-allow constructor - constructor() DataProtectorSharing( - address(0), - IRegistry(address(0)), - AddOnlyAppWhitelistRegistry(address(0)) - ) {} + constructor() + DataProtectorSharing( + address(0), + IRegistry(address(0)), + AddOnlyAppWhitelistRegistry(address(0)) + ) + {} function initializeV2(string calldata foo) public reinitializer(2) { newStorage = foo; diff --git a/packages/sharing-smart-contract/test/e2e/upgrade.test.js b/packages/sharing-smart-contract/test/e2e/upgrade.test.js index 95152750e..c314d8441 100644 --- a/packages/sharing-smart-contract/test/e2e/upgrade.test.js +++ b/packages/sharing-smart-contract/test/e2e/upgrade.test.js @@ -1,8 +1,8 @@ import { loadFixture } from '@nomicfoundation/hardhat-toolbox/network-helpers.js'; import { expect } from 'chai'; import hardhat from 'hardhat'; -const { ethers, upgrades } = hardhat; import { createCollection, deploySCFixture } from './utils/loadFixture.test.js'; +const { ethers, upgrades } = hardhat; // TODO convert to ts. // TODO use typechain for factories. From 32028df5a276f6b8b6e8e806ebb4f795a47d8a05 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 6 May 2025 15:14:12 +0200 Subject: [PATCH 07/42] Fix linting error --- packages/sharing-smart-contract/test/e2e/upgrade.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/sharing-smart-contract/test/e2e/upgrade.test.js b/packages/sharing-smart-contract/test/e2e/upgrade.test.js index c314d8441..cc7adafa9 100644 --- a/packages/sharing-smart-contract/test/e2e/upgrade.test.js +++ b/packages/sharing-smart-contract/test/e2e/upgrade.test.js @@ -2,6 +2,7 @@ import { loadFixture } from '@nomicfoundation/hardhat-toolbox/network-helpers.js import { expect } from 'chai'; import hardhat from 'hardhat'; import { createCollection, deploySCFixture } from './utils/loadFixture.test.js'; +import {beforeEach} from 'mocha'; const { ethers, upgrades } = hardhat; // TODO convert to ts. From 2813cc8ce827f0d1d6fec36277793dcafe6212bd Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 6 May 2025 15:16:48 +0200 Subject: [PATCH 08/42] Clean --- packages/sharing-smart-contract/test/e2e/upgrade.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sharing-smart-contract/test/e2e/upgrade.test.js b/packages/sharing-smart-contract/test/e2e/upgrade.test.js index cc7adafa9..932d46697 100644 --- a/packages/sharing-smart-contract/test/e2e/upgrade.test.js +++ b/packages/sharing-smart-contract/test/e2e/upgrade.test.js @@ -1,8 +1,8 @@ import { loadFixture } from '@nomicfoundation/hardhat-toolbox/network-helpers.js'; import { expect } from 'chai'; import hardhat from 'hardhat'; +import { beforeEach } from 'mocha'; import { createCollection, deploySCFixture } from './utils/loadFixture.test.js'; -import {beforeEach} from 'mocha'; const { ethers, upgrades } = hardhat; // TODO convert to ts. From 826b1cd855c4ae61587a8ecbeb019e60209bae65 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 6 May 2025 15:38:56 +0200 Subject: [PATCH 09/42] Clean --- packages/sharing-smart-contract/contracts/ManageOrders.sol | 5 ++--- packages/sharing-smart-contract/test/e2e/upgrade.test.js | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/sharing-smart-contract/contracts/ManageOrders.sol b/packages/sharing-smart-contract/contracts/ManageOrders.sol index 1733eb468..9b25bf245 100644 --- a/packages/sharing-smart-contract/contracts/ManageOrders.sol +++ b/packages/sharing-smart-contract/contracts/ManageOrders.sol @@ -38,9 +38,8 @@ abstract contract ManageOrders { 0x0000000000000000000000000000000000000000000000000000000000000003; // [tee,scone] uint256 internal constant TRUST = 0; // No replication string internal _iexecResultStorageProvider; - // This value is not used anymore but it is kept - // as a placeholder to not break storage of the proxy - // deployed on Bellecour. + // This value is not used anymore but it must be kept + // to not break deployed proxies when upgrading them. string internal _iexecResultStorageProxy; uint256 private _salt; diff --git a/packages/sharing-smart-contract/test/e2e/upgrade.test.js b/packages/sharing-smart-contract/test/e2e/upgrade.test.js index 932d46697..d63efe599 100644 --- a/packages/sharing-smart-contract/test/e2e/upgrade.test.js +++ b/packages/sharing-smart-contract/test/e2e/upgrade.test.js @@ -29,7 +29,9 @@ describe('DataProtectorSharing', function () { owner, ); await upgrades - .upgradeProxy(contractAddress, newImplementationFactory) + .upgradeProxy(contractAddress, newImplementationFactory, { + kind: 'transparent', + }) .then((contract) => contract.waitForDeployment()); const dataProtectorSharingContractV2 = await ethers.getContractAt( 'DataProtectorSharingV2Mock', From c501af82de335deb65320fb25c208243a44a7d75 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 6 May 2025 17:19:43 +0200 Subject: [PATCH 10/42] Include review --- packages/sdk/tests/test-utils.ts | 2 +- packages/sharing-smart-contract/contracts/ManageOrders.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sdk/tests/test-utils.ts b/packages/sdk/tests/test-utils.ts index 7cb8344ad..ddfaccfd1 100644 --- a/packages/sdk/tests/test-utils.ts +++ b/packages/sdk/tests/test-utils.ts @@ -34,7 +34,7 @@ export const getTestRpcProvider = () => new JsonRpcProvider(TEST_CHAIN.rpcURL); export const getTestIExecOption = () => ({ smsURL: TEST_CHAIN.smsURL, smsDebugURL: TEST_CHAIN.smsDebugURL, - resultProxyURL: TEST_CHAIN.resultProxyURL, // TODO remove + resultProxyURL: TEST_CHAIN.resultProxyURL, iexecGatewayURL: TEST_CHAIN.iexecGatewayURL, }); diff --git a/packages/sharing-smart-contract/contracts/ManageOrders.sol b/packages/sharing-smart-contract/contracts/ManageOrders.sol index 9b25bf245..3f3c2a2c1 100644 --- a/packages/sharing-smart-contract/contracts/ManageOrders.sol +++ b/packages/sharing-smart-contract/contracts/ManageOrders.sol @@ -38,7 +38,7 @@ abstract contract ManageOrders { 0x0000000000000000000000000000000000000000000000000000000000000003; // [tee,scone] uint256 internal constant TRUST = 0; // No replication string internal _iexecResultStorageProvider; - // This value is not used anymore but it must be kept + // [WARNING] This value is not used anymore but it must be kept // to not break deployed proxies when upgrading them. string internal _iexecResultStorageProxy; uint256 private _salt; From 8dac743a34141a381ec0ed3221096b5c3e421d18 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 6 May 2025 17:26:49 +0200 Subject: [PATCH 11/42] Add PR number to changelog --- packages/sharing-smart-contract/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sharing-smart-contract/CHANGELOG.md b/packages/sharing-smart-contract/CHANGELOG.md index a6b40a3a9..ee59bd8ba 100644 --- a/packages/sharing-smart-contract/CHANGELOG.md +++ b/packages/sharing-smart-contract/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file. ### Changed -- [BREAKING] Remove result proxy url from contract config and deal params. +- [BREAKING] Remove result proxy url from contract config and deal params (#438). - Fix Sharing contract constructor arguments order (#433) - Update blockscout url From 0c2f2e7868d6d95d2ed2e2d97d1d2f5dcd7a998f Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 6 May 2025 18:05:20 +0200 Subject: [PATCH 12/42] Fix tests on the CI --- .github/workflows/sharing-smart-contract-test.yml | 3 +++ packages/sharing-smart-contract/hardhat.config.cjs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index ea7cf3922..975590f36 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -83,8 +83,11 @@ jobs: echo "Error: Anvil did not start within the timeout period." exit 1 + # TODO check why the CI does not fail when the following error occurs: + # 1) Uncaught error outside test suite - name: Hardhat Tests working-directory: packages/sharing-smart-contract + # TODO run tests on hardhat forked network without using anvil. run: npm run test -- --network ci-bellecour-fork - name: Upgrade Test diff --git a/packages/sharing-smart-contract/hardhat.config.cjs b/packages/sharing-smart-contract/hardhat.config.cjs index 0fe931a68..7e162ec5d 100644 --- a/packages/sharing-smart-contract/hardhat.config.cjs +++ b/packages/sharing-smart-contract/hardhat.config.cjs @@ -34,7 +34,7 @@ module.exports = { }, 'ci-bellecour-fork': { ...bellecourBase, - url: 'http://bellecour-fork:8545', + url: 'http://localhost:8545', }, bellecour: { ...bellecourBase, From 32fd0e54910e7d98844c5a0214b2b3c70342bc6f Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 6 May 2025 18:17:45 +0200 Subject: [PATCH 13/42] Run tests on hardhat network (forked) --- .../workflows/sharing-smart-contract-test.yml | 25 ++----------------- .../sharing-smart-contract/hardhat.config.cjs | 4 --- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index 975590f36..c3b03e830 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -63,36 +63,15 @@ jobs: fail-on: none target: 'packages/sharing-smart-contract/' - - name: Start Anvil - run: | - anvil --host 0.0.0.0 --port 8545 --hardfork berlin --fork-url https://bellecour.iex.ec --chain-id 134 --gas-limit 6700000 --gas-price 0 & - - - name: Wait for Anvil to start - run: | - timeout=30 - interval=1 - echo "Waiting for Anvil to start..." - for ((i=0; i Date: Mon, 12 May 2025 12:44:45 +0200 Subject: [PATCH 14/42] Fix CI --- .../workflows/sharing-smart-contract-test.yml | 23 +++++++++++++++++-- .../sharing-smart-contract/hardhat.config.cjs | 5 ++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index c3b03e830..2d3f41690 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -63,15 +63,34 @@ jobs: fail-on: none target: 'packages/sharing-smart-contract/' + - name: Start Anvil + run: | + anvil --host 0.0.0.0 --port 8545 --hardfork berlin --fork-url https://bellecour.iex.ec --chain-id 134 --gas-limit 6700000 --gas-price 0 & + - name: Wait for Anvil to start + run: | + timeout=30 + interval=1 + echo "Waiting for Anvil to start..." + for ((i=0; i Date: Mon, 12 May 2025 12:50:21 +0200 Subject: [PATCH 15/42] Debug CI --- .github/workflows/sharing-smart-contract-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index 2d3f41690..73f21a3f9 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -86,7 +86,7 @@ jobs: # 1) Uncaught error outside test suite - name: Hardhat Tests working-directory: packages/sharing-smart-contract - run: npm run test -- --network bellecour-fork # runs on local forked hardhat network + run: nc -z localhost 8545; npm run test -- --network bellecour-fork # runs on local forked hardhat network - name: Upgrade Test working-directory: packages/sharing-smart-contract From 14c94f1843b234a8a276b37b8fe6c2d8b7336dd2 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Mon, 12 May 2025 12:56:03 +0200 Subject: [PATCH 16/42] Debug CI --- .github/workflows/sharing-smart-contract-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index 73f21a3f9..988a1e375 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -86,7 +86,7 @@ jobs: # 1) Uncaught error outside test suite - name: Hardhat Tests working-directory: packages/sharing-smart-contract - run: nc -z localhost 8545; npm run test -- --network bellecour-fork # runs on local forked hardhat network + run: nc -z localhost 8545; DEBUG=* npm run test -- --network bellecour-fork # runs on local forked hardhat network - name: Upgrade Test working-directory: packages/sharing-smart-contract From 62f0d1e16c13e799018236792e8f436a685d469c Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Mon, 12 May 2025 13:05:13 +0200 Subject: [PATCH 17/42] Debug CI --- .github/workflows/sharing-smart-contract-test.yml | 2 +- packages/sharing-smart-contract/hardhat.config.cjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index 988a1e375..9456b9250 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -86,7 +86,7 @@ jobs: # 1) Uncaught error outside test suite - name: Hardhat Tests working-directory: packages/sharing-smart-contract - run: nc -z localhost 8545; DEBUG=* npm run test -- --network bellecour-fork # runs on local forked hardhat network + run: curl -v http://127.0.0.1:8545; echo '#######'; nc -z localhost 8545; DEBUG=* npm run test -- --network bellecour-fork # runs on local forked hardhat network - name: Upgrade Test working-directory: packages/sharing-smart-contract diff --git a/packages/sharing-smart-contract/hardhat.config.cjs b/packages/sharing-smart-contract/hardhat.config.cjs index 579cd2cef..906ed7df4 100644 --- a/packages/sharing-smart-contract/hardhat.config.cjs +++ b/packages/sharing-smart-contract/hardhat.config.cjs @@ -29,7 +29,7 @@ module.exports = { }, 'bellecour-fork': { ...bellecourBase, - url: 'http://localhost:8545', + url: 'http://127.0.0.1:8545', }, bellecour: { ...bellecourBase, From 25f7d1f16e9c4651c48d8f9ccda95b19d0746d71 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Mon, 12 May 2025 14:57:07 +0200 Subject: [PATCH 18/42] Remove debugging flags --- .github/workflows/sharing-smart-contract-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index 9456b9250..2d3f41690 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -86,7 +86,7 @@ jobs: # 1) Uncaught error outside test suite - name: Hardhat Tests working-directory: packages/sharing-smart-contract - run: curl -v http://127.0.0.1:8545; echo '#######'; nc -z localhost 8545; DEBUG=* npm run test -- --network bellecour-fork # runs on local forked hardhat network + run: npm run test -- --network bellecour-fork # runs on local forked hardhat network - name: Upgrade Test working-directory: packages/sharing-smart-contract From 74e1c9162c39c2b55d2aaf8148db958553ecfe9d Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Mon, 12 May 2025 14:57:41 +0200 Subject: [PATCH 19/42] Clean --- .github/workflows/sharing-smart-contract-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index 2d3f41690..26cedd6c7 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -82,8 +82,8 @@ jobs: echo "Error: Anvil did not start within the timeout period." exit 1 - # TODO check why the CI does not fail when the following error occurs: - # 1) Uncaught error outside test suite + # TODO check why the CI does not fail when the following error occurs: + # 1) Uncaught error outside test suite - name: Hardhat Tests working-directory: packages/sharing-smart-contract run: npm run test -- --network bellecour-fork # runs on local forked hardhat network From 65e07fee19183a5e09af4e164bfb6642e0a20e3c Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Mon, 12 May 2025 15:05:24 +0200 Subject: [PATCH 20/42] Debug upgrade tests on CI --- .github/workflows/sharing-smart-contract-test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index 26cedd6c7..54b7af9d6 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -84,13 +84,13 @@ jobs: # TODO check why the CI does not fail when the following error occurs: # 1) Uncaught error outside test suite - - name: Hardhat Tests - working-directory: packages/sharing-smart-contract - run: npm run test -- --network bellecour-fork # runs on local forked hardhat network + # - name: Hardhat Tests + # working-directory: packages/sharing-smart-contract + # run: npm run test -- --network bellecour-fork # runs on local forked hardhat network - name: Upgrade Test working-directory: packages/sharing-smart-contract - run: npm run upgrade-local-fork -- --network bellecour-fork + run: ls -al; npm run upgrade-local-fork -- --network bellecour-fork - name: Set Directory Permissions working-directory: packages/sharing-smart-contract From 7afc0aff7ff021a2ef8e933e852d268b45890909 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Mon, 12 May 2025 15:08:18 +0200 Subject: [PATCH 21/42] Debug upgrade tests on CI --- .github/workflows/sharing-smart-contract-test.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index 54b7af9d6..43c9d9b5d 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -55,13 +55,13 @@ jobs: working-directory: packages/sharing-smart-contract run: npm run uml - - name: Static Analyzer - uses: crytic/slither-action@v0.4.0 - id: slither - with: - sarif: result.sarif - fail-on: none - target: 'packages/sharing-smart-contract/' + # - name: Static Analyzer + # uses: crytic/slither-action@v0.4.0 + # id: slither + # with: + # sarif: result.sarif + # fail-on: none + # target: 'packages/sharing-smart-contract/' - name: Start Anvil run: | From ae4f26ee3af93dd99c8aa407f1282fcfa516d69c Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Mon, 12 May 2025 15:39:09 +0200 Subject: [PATCH 22/42] Remove upgrade tests as it interferes with local-fork script --- .../workflows/sharing-smart-contract-test.yml | 23 ++++---- .../__test/DataProtectorSharingV2Mock.sol | 51 ------------------ .../test/e2e/upgrade.test.js | 53 ------------------- 3 files changed, 12 insertions(+), 115 deletions(-) delete mode 100644 packages/sharing-smart-contract/contracts/__test/DataProtectorSharingV2Mock.sol delete mode 100644 packages/sharing-smart-contract/test/e2e/upgrade.test.js diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index 43c9d9b5d..25e2c2b5a 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -55,17 +55,18 @@ jobs: working-directory: packages/sharing-smart-contract run: npm run uml - # - name: Static Analyzer - # uses: crytic/slither-action@v0.4.0 - # id: slither - # with: - # sarif: result.sarif - # fail-on: none - # target: 'packages/sharing-smart-contract/' + - name: Static Analyzer + uses: crytic/slither-action@v0.4.0 + id: slither + with: + sarif: result.sarif + fail-on: none + target: 'packages/sharing-smart-contract/' - name: Start Anvil run: | anvil --host 0.0.0.0 --port 8545 --hardfork berlin --fork-url https://bellecour.iex.ec --chain-id 134 --gas-limit 6700000 --gas-price 0 & + - name: Wait for Anvil to start run: | timeout=30 @@ -84,13 +85,13 @@ jobs: # TODO check why the CI does not fail when the following error occurs: # 1) Uncaught error outside test suite - # - name: Hardhat Tests - # working-directory: packages/sharing-smart-contract - # run: npm run test -- --network bellecour-fork # runs on local forked hardhat network + - name: Hardhat Tests + working-directory: packages/sharing-smart-contract + run: npm run test -- --network bellecour-fork # runs on local forked hardhat network - name: Upgrade Test working-directory: packages/sharing-smart-contract - run: ls -al; npm run upgrade-local-fork -- --network bellecour-fork + run: npm run upgrade-local-fork -- --network bellecour-fork - name: Set Directory Permissions working-directory: packages/sharing-smart-contract diff --git a/packages/sharing-smart-contract/contracts/__test/DataProtectorSharingV2Mock.sol b/packages/sharing-smart-contract/contracts/__test/DataProtectorSharingV2Mock.sol deleted file mode 100644 index 3f1ba7582..000000000 --- a/packages/sharing-smart-contract/contracts/__test/DataProtectorSharingV2Mock.sol +++ /dev/null @@ -1,51 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 - -/****************************************************************************** - * Copyright 2024-2025 IEXEC BLOCKCHAIN TECH * - * * - * Licensed under the Apache License, Version 2.0 (the "License"); * - * you may not use this file except in compliance with the License. * - * You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, software * - * distributed under the License is distributed on an "AS IS" BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * - * See the License for the specific language governing permissions and * - * limitations under the License. * - ******************************************************************************/ - -pragma solidity ^0.8.24; - -import {ERC721BurnableUpgradeable, ERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol"; -import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; -import {MulticallUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol"; -import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol"; -import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; -import {DataProtectorSharing} from "../DataProtectorSharing.sol"; -import {AddOnlyAppWhitelistRegistry, IAddOnlyAppWhitelist} from "../registry/AddOnlyAppWhitelistRegistry.sol"; -import {IRegistry} from "../interfaces/IRegistry.sol"; -import {ManageOrders} from "../ManageOrders.sol"; - -/** - * @notice This contract is for upgradeability testing purposes only. - */ - -contract DataProtectorSharingV2Mock is DataProtectorSharing { - string public newStorage; - - /// @custom:oz-upgrades-unsafe-allow constructor - constructor() - DataProtectorSharing( - address(0), - IRegistry(address(0)), - AddOnlyAppWhitelistRegistry(address(0)) - ) - {} - - function initializeV2(string calldata foo) public reinitializer(2) { - newStorage = foo; - } -} diff --git a/packages/sharing-smart-contract/test/e2e/upgrade.test.js b/packages/sharing-smart-contract/test/e2e/upgrade.test.js deleted file mode 100644 index d63efe599..000000000 --- a/packages/sharing-smart-contract/test/e2e/upgrade.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import { loadFixture } from '@nomicfoundation/hardhat-toolbox/network-helpers.js'; -import { expect } from 'chai'; -import hardhat from 'hardhat'; -import { beforeEach } from 'mocha'; -import { createCollection, deploySCFixture } from './utils/loadFixture.test.js'; -const { ethers, upgrades } = hardhat; - -// TODO convert to ts. -// TODO use typechain for factories. - -let dataProtectorSharingContract; -let contractAddress; -let owner, addr1; - -describe('DataProtectorSharing', function () { - beforeEach('Deploy fixture', async function () { - ({ dataProtectorSharingContract, owner, addr1 } = await loadFixture(deploySCFixture)); - contractAddress = await dataProtectorSharingContract.getAddress(); - await dataProtectorSharingContract.createCollection(owner).then((tx) => tx.wait()); - }); - - describe('Upgrade', function () { - it('Should upgrade', async function () { - // Update the state of the original proxy. - const { collectionTokenId } = await createCollection(); - // Upgrade the proxy. - const newImplementationFactory = await ethers.getContractFactory( - 'DataProtectorSharingV2Mock', - owner, - ); - await upgrades - .upgradeProxy(contractAddress, newImplementationFactory, { - kind: 'transparent', - }) - .then((contract) => contract.waitForDeployment()); - const dataProtectorSharingContractV2 = await ethers.getContractAt( - 'DataProtectorSharingV2Mock', - contractAddress, - ); - await dataProtectorSharingContractV2.initializeV2('bar'); - // Check V1 storage. - expect(await dataProtectorSharingContractV2.ownerOf(collectionTokenId)).to.equal( - addr1.address, - ); - // Check V2 storage. - expect(await dataProtectorSharingContractV2.newStorage()).to.equal('bar'); - // Check address. - expect(await dataProtectorSharingContractV2.getAddress()).to.equal(contractAddress); - }); - - it('TODO - Should not upgrade when storage is broken', async function () {}); - }); -}); From e330b351da83dc31c3efdc09f72af3dcdabce924 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Mon, 12 May 2025 15:46:24 +0200 Subject: [PATCH 23/42] Revert naming changes --- .github/workflows/sharing-smart-contract-test.yml | 7 ++++--- packages/sharing-smart-contract/hardhat.config.cjs | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index 25e2c2b5a..5e5f9589a 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -83,15 +83,16 @@ jobs: echo "Error: Anvil did not start within the timeout period." exit 1 - # TODO check why the CI does not fail when the following error occurs: + # TODO check why the CI does not fail when the following error occurs + # (when the RPC node is not available): # 1) Uncaught error outside test suite - name: Hardhat Tests working-directory: packages/sharing-smart-contract - run: npm run test -- --network bellecour-fork # runs on local forked hardhat network + run: npm run test -- --network local-bellecour-fork - name: Upgrade Test working-directory: packages/sharing-smart-contract - run: npm run upgrade-local-fork -- --network bellecour-fork + run: npm run upgrade-local-fork -- --network local-bellecour-fork - name: Set Directory Permissions working-directory: packages/sharing-smart-contract diff --git a/packages/sharing-smart-contract/hardhat.config.cjs b/packages/sharing-smart-contract/hardhat.config.cjs index 906ed7df4..d89e22a48 100644 --- a/packages/sharing-smart-contract/hardhat.config.cjs +++ b/packages/sharing-smart-contract/hardhat.config.cjs @@ -17,7 +17,7 @@ const bellecourBase = { * @type import('hardhat/config').HardhatUserConfig */ module.exports = { - // run `npx hardhat node` to start the forked bellecour node "bellecour-fork" + // run `npx hardhat node` to start the forked bellecour node "local-bellecour-fork" networks: { hardhat: { ...bellecourBase, @@ -27,7 +27,7 @@ module.exports = { url: 'https://bellecour.iex.ec', }, }, - 'bellecour-fork': { + 'local-bellecour-fork': { ...bellecourBase, url: 'http://127.0.0.1:8545', }, From af797bd99bd76874424d1f02cb29b4b258c934aa Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Mon, 12 May 2025 17:19:59 +0200 Subject: [PATCH 24/42] Run tests on hardhat fork --- .../workflows/sharing-smart-contract-test.yml | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index 5e5f9589a..61d1f9512 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -63,6 +63,17 @@ jobs: fail-on: none target: 'packages/sharing-smart-contract/' + # TODO check why the CI does not fail when the following error occurs + # (when the RPC node is not available): + # 1) Uncaught error outside test suite + - name: Hardhat tests + working-directory: packages/sharing-smart-contract + run: npm run test # Runs on local hardhat fork. + + - name: Upgrade test + working-directory: packages/sharing-smart-contract + run: npm run upgrade-local-fork + - name: Start Anvil run: | anvil --host 0.0.0.0 --port 8545 --hardfork berlin --fork-url https://bellecour.iex.ec --chain-id 134 --gas-limit 6700000 --gas-price 0 & @@ -83,17 +94,6 @@ jobs: echo "Error: Anvil did not start within the timeout period." exit 1 - # TODO check why the CI does not fail when the following error occurs - # (when the RPC node is not available): - # 1) Uncaught error outside test suite - - name: Hardhat Tests - working-directory: packages/sharing-smart-contract - run: npm run test -- --network local-bellecour-fork - - - name: Upgrade Test - working-directory: packages/sharing-smart-contract - run: npm run upgrade-local-fork -- --network local-bellecour-fork - - name: Set Directory Permissions working-directory: packages/sharing-smart-contract run: sudo chmod -R 777 . From 2760952c2a2e710f992188e8edc9d043e47818a6 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Mon, 12 May 2025 17:36:55 +0200 Subject: [PATCH 25/42] Debug upgrade tests on CI --- .../workflows/sharing-smart-contract-test.yml | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index 61d1f9512..e15403958 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -63,17 +63,6 @@ jobs: fail-on: none target: 'packages/sharing-smart-contract/' - # TODO check why the CI does not fail when the following error occurs - # (when the RPC node is not available): - # 1) Uncaught error outside test suite - - name: Hardhat tests - working-directory: packages/sharing-smart-contract - run: npm run test # Runs on local hardhat fork. - - - name: Upgrade test - working-directory: packages/sharing-smart-contract - run: npm run upgrade-local-fork - - name: Start Anvil run: | anvil --host 0.0.0.0 --port 8545 --hardfork berlin --fork-url https://bellecour.iex.ec --chain-id 134 --gas-limit 6700000 --gas-price 0 & @@ -94,6 +83,17 @@ jobs: echo "Error: Anvil did not start within the timeout period." exit 1 + - name: Upgrade test + working-directory: packages/sharing-smart-contract + run: npm run upgrade-local-fork -- --network local-bellecour-fork + + # TODO check why the CI does not fail when the following error occurs + # (when the RPC node is not available): + # 1) Uncaught error outside test suite + - name: Hardhat tests + working-directory: packages/sharing-smart-contract + run: npm run test -- --network local-bellecour-fork + - name: Set Directory Permissions working-directory: packages/sharing-smart-contract run: sudo chmod -R 777 . From df06547a219b8c51e57845288bfdf0367b9d53a7 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 13 May 2025 16:22:46 +0200 Subject: [PATCH 26/42] Install HH dep compiler --- packages/sharing-smart-contract/package-lock.json | 14 ++++++++++++++ packages/sharing-smart-contract/package.json | 1 + 2 files changed, 15 insertions(+) diff --git a/packages/sharing-smart-contract/package-lock.json b/packages/sharing-smart-contract/package-lock.json index e42065b35..0480243e7 100644 --- a/packages/sharing-smart-contract/package-lock.json +++ b/packages/sharing-smart-contract/package-lock.json @@ -26,6 +26,7 @@ "eslint-plugin-import": "^2.31.0", "hardhat": "^2.23.0", "hardhat-contract-sizer": "^2.10.0", + "hardhat-dependency-compiler": "^1.2.1", "prettier": "^3.3.3", "prettier-plugin-organize-imports": "^4.0.0", "prettier-plugin-solidity": "^1.4.1", @@ -8618,6 +8619,19 @@ "hardhat": "^2.0.0" } }, + "node_modules/hardhat-dependency-compiler": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/hardhat-dependency-compiler/-/hardhat-dependency-compiler-1.2.1.tgz", + "integrity": "sha512-xG5iwbspTtxOEiP5UsPngEYQ1Hg+fjTjliapIjdTQmwGkCPofrsDhQDV2O/dopcYzcR68nTx2X8xTewYHgA2rQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.14.0" + }, + "peerDependencies": { + "hardhat": "^2.0.0" + } + }, "node_modules/hardhat-gas-reporter": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/hardhat-gas-reporter/-/hardhat-gas-reporter-1.0.10.tgz", diff --git a/packages/sharing-smart-contract/package.json b/packages/sharing-smart-contract/package.json index 546c88191..d579e2b7c 100644 --- a/packages/sharing-smart-contract/package.json +++ b/packages/sharing-smart-contract/package.json @@ -41,6 +41,7 @@ "eslint-plugin-import": "^2.31.0", "hardhat": "^2.23.0", "hardhat-contract-sizer": "^2.10.0", + "hardhat-dependency-compiler": "^1.2.1", "prettier": "^3.3.3", "prettier-plugin-organize-imports": "^4.0.0", "prettier-plugin-solidity": "^1.4.1", From 64e5c1ed9b7601aa7685d8759e26e4ad49f6ff30 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 13 May 2025 16:23:21 +0200 Subject: [PATCH 27/42] Compile transparent proxy to create artifact --- packages/sharing-smart-contract/hardhat.config.cjs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/sharing-smart-contract/hardhat.config.cjs b/packages/sharing-smart-contract/hardhat.config.cjs index d89e22a48..b48647fa0 100644 --- a/packages/sharing-smart-contract/hardhat.config.cjs +++ b/packages/sharing-smart-contract/hardhat.config.cjs @@ -3,8 +3,11 @@ require('@nomicfoundation/hardhat-toolbox'); require('@openzeppelin/hardhat-upgrades'); require('hardhat-contract-sizer'); require('@openzeppelin/hardhat-upgrades'); +require('hardhat-dependency-compiler'); require('dotenv').config(); +// TODO format + const { WALLET_PRIVATE_KEY } = process.env; const bellecourBase = { @@ -87,4 +90,9 @@ module.exports = { }, }, }, + dependencyCompiler: { + paths: [ + '@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol', + ], + }, }; From 64822c9a07100a0d01bf3534bd37c6bc9d0fa5f7 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 13 May 2025 16:24:34 +0200 Subject: [PATCH 28/42] Create ESM and Commonjs flavor of config and env files --- .../sharing-smart-contract/config/config.cjs | 8 ++++ .../sharing-smart-contract/config/config.js | 9 ++-- .../sharing-smart-contract/config/env.cjs | 44 +++++++++++++++++++ packages/sharing-smart-contract/config/env.js | 40 +---------------- 4 files changed, 59 insertions(+), 42 deletions(-) create mode 100644 packages/sharing-smart-contract/config/config.cjs create mode 100644 packages/sharing-smart-contract/config/env.cjs diff --git a/packages/sharing-smart-contract/config/config.cjs b/packages/sharing-smart-contract/config/config.cjs new file mode 100644 index 000000000..7f69c1d50 --- /dev/null +++ b/packages/sharing-smart-contract/config/config.cjs @@ -0,0 +1,8 @@ +// Hardhat Ignition does not support ESM modules, so we use CommonJS syntax. +// TODO refactor this to use ESM syntax when Hardhat Ignition supports it. + +module.exports = { + POCO_ADDRESS: '0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f', + DATASET_REGISTRY_ADDRESS: '0x799DAa22654128d0C64d5b79eac9283008158730', + APP_REGISTRY_ADDRESS: '0xB1C52075b276f87b1834919167312221d50c9D16', +}; diff --git a/packages/sharing-smart-contract/config/config.js b/packages/sharing-smart-contract/config/config.js index 57689eb0b..635eb0e86 100644 --- a/packages/sharing-smart-contract/config/config.js +++ b/packages/sharing-smart-contract/config/config.js @@ -1,4 +1,5 @@ -export const SMART_CONTRACT_ADDRESS_FILE = '.smart-contract-address'; -export const POCO_ADDRESS = '0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f'; -export const DATASET_REGISTRY_ADDRESS = '0x799DAa22654128d0C64d5b79eac9283008158730'; -export const APP_REGISTRY_ADDRESS = '0xB1C52075b276f87b1834919167312221d50c9D16'; +import config from './config.cjs'; + +export const POCO_ADDRESS = config.POCO_ADDRESS; +export const DATASET_REGISTRY_ADDRESS = config.DATASET_REGISTRY_ADDRESS; +export const APP_REGISTRY_ADDRESS = config.APP_REGISTRY_ADDRESS; diff --git a/packages/sharing-smart-contract/config/env.cjs b/packages/sharing-smart-contract/config/env.cjs new file mode 100644 index 000000000..988151ca5 --- /dev/null +++ b/packages/sharing-smart-contract/config/env.cjs @@ -0,0 +1,44 @@ +// Hardhat Ignition does not support ESM modules, so we use CommonJS syntax. +// TODO refactor this to use ESM syntax when Hardhat Ignition supports it. + +require('dotenv/config.js'); +const { z } = require('zod'); + +const addressRegex = /(^|\b)(0x)?[0-9a-fA-F]{64}(\b|$)/; +const privateKeyRegex = /(^|\b)(0x)?[0-9a-fA-F]{64}(\b|$)/; + +const envSchema = z.object({ + // Private key of the wallet used for transactions + WALLET_PRIVATE_KEY: z + .string() + .regex(privateKeyRegex, 'Invalid private key format') + .optional() + .or(z.literal('')), + + // environment to use for configuration (prod/staging) + ENV: z.enum(['prod', 'staging'], 'ENV must be either "prod" or "staging"').default('prod'), + + // Address of the PoCo contract + POCO_ADDRESS: z + .string() + .regex(addressRegex, 'Invalid Ethereum address format') + .optional() + .or(z.literal('')), + + // Address of the DatasetRegistry + DATASET_REGISTRY_ADDRESS: z + .string() + .regex(addressRegex, 'Invalid Ethereum address format') + .optional() + .or(z.literal('')), + + // URL of the RPC used for network connection + RPC_URL: z.string().url('RPC_URL must be a valid URL').optional().or(z.literal('')), + + // Mnemonic for deployment or network interaction + MNEMONIC: z.string().min(1, 'MNEMONIC cannot be empty').optional().or(z.literal('')), +}); + +module.exports = { + env: envSchema.parse(process.env), +}; diff --git a/packages/sharing-smart-contract/config/env.js b/packages/sharing-smart-contract/config/env.js index 3ede68f29..f9510c15d 100644 --- a/packages/sharing-smart-contract/config/env.js +++ b/packages/sharing-smart-contract/config/env.js @@ -1,39 +1,3 @@ -import 'dotenv/config.js'; -import { z } from 'zod'; +import env from './env.cjs'; -const addressRegex = /(^|\b)(0x)?[0-9a-fA-F]{64}(\b|$)/; -const privateKeyRegex = /(^|\b)(0x)?[0-9a-fA-F]{64}(\b|$)/; - -const envSchema = z.object({ - // Private key of the wallet used for transactions - WALLET_PRIVATE_KEY: z - .string() - .regex(privateKeyRegex, 'Invalid private key format') - .optional() - .or(z.literal('')), - - // environment to use for configuration (prod/staging) - ENV: z.enum(['prod', 'staging'], 'ENV must be either "prod" or "staging"').default('prod'), - - // Address of the PoCo contract - POCO_ADDRESS: z - .string() - .regex(addressRegex, 'Invalid Ethereum address format') - .optional() - .or(z.literal('')), - - // Address of the DatasetRegistry - DATASET_REGISTRY_ADDRESS: z - .string() - .regex(addressRegex, 'Invalid Ethereum address format') - .optional() - .or(z.literal('')), - - // URL of the RPC used for network connection - RPC_URL: z.string().url('RPC_URL must be a valid URL').optional().or(z.literal('')), - - // Mnemonic for deployment or network interaction - MNEMONIC: z.string().min(1, 'MNEMONIC cannot be empty').optional().or(z.literal('')), -}); - -export const env = envSchema.parse(process.env); +export const env = env.env; From d9f50e3eb6d46fe25e92b2799e289b7cd28d86cb Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 13 May 2025 16:32:06 +0200 Subject: [PATCH 29/42] Add ignition module to deploy contracts --- .../modules/DataProtectorSharingModule.cts | 62 +++++++++++++++++++ packages/sharing-smart-contract/tsconfig.json | 10 +++ 2 files changed, 72 insertions(+) create mode 100644 packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cts create mode 100644 packages/sharing-smart-contract/tsconfig.json diff --git a/packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cts b/packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cts new file mode 100644 index 000000000..2b7287ad3 --- /dev/null +++ b/packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cts @@ -0,0 +1,62 @@ +// import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'; +const { buildModule } = require('@nomicfoundation/hardhat-ignition/modules'); + +const { + DATASET_REGISTRY_ADDRESS: defaultDatasetRegistryAddress, + POCO_ADDRESS: defaultPocoAddress, +} = require('../../config/config.cjs'); +const { env } = require('../../config/env.cjs'); + +// Hardhat Ignition does not support ESM yet. + +// @ts-ignore +module.exports = buildModule('DataProtectorSharingModule', (m) => { + const proxyAdminOwner = m.getAccount(0); + const pocoAddress = env.POCO_ADDRESS || defaultPocoAddress; + const datasetRegistryAddress = env.DATASET_REGISTRY_ADDRESS || defaultDatasetRegistryAddress; + + // Whitelist + const addOnlyAppWhitelistRegistryImpl = m.contract('AddOnlyAppWhitelistRegistry', [], { + id: 'AddOnlyAppWhitelistRegistryImpl', + }); + const addOnlyAppWhitelistRegistryProxy = m.contract( + 'TransparentUpgradeableProxy', + [ + addOnlyAppWhitelistRegistryImpl, + proxyAdminOwner, + '0x', // No initialization data. + ], + { + id: 'AddOnlyAppWhitelistRegistryProxy', + }, + ); + const addOnlyAppWhitelistRegistry = m.contractAt( + 'AddOnlyAppWhitelistRegistry', + addOnlyAppWhitelistRegistryProxy, + ); + + // DPS + const dataProtectorSharingImpl = m.contract( + 'DataProtectorSharing', + [pocoAddress, datasetRegistryAddress, addOnlyAppWhitelistRegistryProxy], + { + id: 'DataProtectorSharingImpl', + }, + ); + const dataProtectorSharingProxy = m.contract( + 'TransparentUpgradeableProxy', + [ + dataProtectorSharingImpl, + proxyAdminOwner, + '0x', // No initialization data. + ], + { + id: 'DataProtectorSharingProxy', + }, + ); + const dataProtectorSharing = m.contractAt('DataProtectorSharing', dataProtectorSharingProxy); + + return { addOnlyAppWhitelistRegistry, dataProtectorSharing }; + + // TODO verify contracts. +}); \ No newline at end of file diff --git a/packages/sharing-smart-contract/tsconfig.json b/packages/sharing-smart-contract/tsconfig.json new file mode 100644 index 000000000..7793ef8df --- /dev/null +++ b/packages/sharing-smart-contract/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "CommonJS", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true + }, + "include": ["ignition/modules"] +} From eaace5cba58c5b9e42593599f3e6ce06faa1a340 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 13 May 2025 16:49:19 +0200 Subject: [PATCH 30/42] Remove old deployment file --- .../sharing-smart-contract/scripts/deploy.js | 94 ------------------- 1 file changed, 94 deletions(-) delete mode 100644 packages/sharing-smart-contract/scripts/deploy.js diff --git a/packages/sharing-smart-contract/scripts/deploy.js b/packages/sharing-smart-contract/scripts/deploy.js deleted file mode 100644 index b5de0b793..000000000 --- a/packages/sharing-smart-contract/scripts/deploy.js +++ /dev/null @@ -1,94 +0,0 @@ -/* eslint-disable no-console */ -import hre from 'hardhat'; -import { - DATASET_REGISTRY_ADDRESS as defaultDatasetRegistryAddress, - POCO_ADDRESS as defaultPocoAddress, -} from '../config/config.js'; -import { env } from '../config/env.js'; -import { saveDeployment } from '../utils/utils.js'; - -const { ethers, upgrades } = hre; - -async function main() { - console.log('Starting deployment...'); - const [deployer] = await ethers.getSigners(); - console.log('Deploying contracts with the account:', deployer.address); - - const pocoAddress = env.POCO_ADDRESS || defaultPocoAddress; - const datasetRegistryAddress = env.DATASET_REGISTRY_ADDRESS || defaultDatasetRegistryAddress; - - console.log(`Using poco at ${pocoAddress}`); - console.log(`Using dataset registry at ${datasetRegistryAddress}`); - - const AddOnlyAppWhitelistRegistryFactory = await ethers.getContractFactory( - 'AddOnlyAppWhitelistRegistry', - ); - const addOnlyAppWhitelistRegistryContract = await upgrades.deployProxy( - AddOnlyAppWhitelistRegistryFactory, - { - kind: 'transparent', - }, - ); - await addOnlyAppWhitelistRegistryContract.waitForDeployment(); - const addOnlyAppWhitelistRegistryAddress = - await addOnlyAppWhitelistRegistryContract.getAddress(); - - const deployAddOnlyAppWhitelistRegistryTxReceipt = await addOnlyAppWhitelistRegistryContract - .deploymentTransaction() - .wait(); - - await saveDeployment('AddOnlyAppWhitelistRegistry')({ - address: addOnlyAppWhitelistRegistryAddress, - args: '', - block: deployAddOnlyAppWhitelistRegistryTxReceipt.blockNumber, - }); - - const DataProtectorSharingFactory = await ethers.getContractFactory('DataProtectorSharing'); - - const dataProtectorSharingConstructorArgs = [ - pocoAddress, - datasetRegistryAddress, - addOnlyAppWhitelistRegistryAddress, - ]; - const dataProtectorSharingContract = await upgrades.deployProxy(DataProtectorSharingFactory, { - kind: 'transparent', - constructorArgs: dataProtectorSharingConstructorArgs, - }); - await dataProtectorSharingContract.waitForDeployment(); - const proxyAddress = await dataProtectorSharingContract.getAddress(); - - const deployDataProtectorSharingTxReceipt = await dataProtectorSharingContract - .deploymentTransaction() - .wait(); - - await saveDeployment('DataProtectorSharing')({ - address: proxyAddress, - args: dataProtectorSharingConstructorArgs.join(' '), - block: deployDataProtectorSharingTxReceipt.blockNumber, - }); - - console.log(`Proxy AddOnlyAppWhitelistRegistry address: ${addOnlyAppWhitelistRegistryAddress}`); - console.log(`Proxy DataProtectorSharing address: ${proxyAddress}`); - - // Verify smart-contract - try { - await hre.run('verify:verify', { - address: addOnlyAppWhitelistRegistryAddress, - }); - } catch (e) { - console.log('Proxy verification for AppWhitelistRegistryContract may have failed :', e); - } - try { - await hre.run('verify:verify', { - address: proxyAddress, - constructorArguments: dataProtectorSharingConstructorArgs, - }); - } catch (e) { - console.log('Proxy verification for DataProtectorSharingContract may have failed :', e); - } -} - -main().catch((error) => { - console.error(error); - process.exitCode = 1; -}); From 35307bab2c719846a6f3cfa8b8dc57587c28b4df Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 13 May 2025 17:01:26 +0200 Subject: [PATCH 31/42] Update README --- packages/sharing-smart-contract/README.md | 25 ++++++++++------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/packages/sharing-smart-contract/README.md b/packages/sharing-smart-contract/README.md index 17cca8ff8..b0383f1c5 100644 --- a/packages/sharing-smart-contract/README.md +++ b/packages/sharing-smart-contract/README.md @@ -39,29 +39,26 @@ To verify the contracts: npm run verify ``` -### Deploy (Production) +### Deployment -To deploy the project on the production network - bellecour. -⚠️ Be sure before deploying on bellecour +To deploy the contracts on a local hardhat network, run: ```bash -npm run script:prod +npm run deploy # [-- --network ] if using an external local node. ``` -### Deploy (Test) - -To deploy the project on the test network - localhost. -You need first to start a local hardhat node which will be a fork of bellecour network : - +To deploy the project on a live network, two options are available: +1. Triggering the dedicated Github Action workflow (recommended). +2. By running: ```bash -npx hardhat node +npm run deploy -- --network ``` -Open a new terminal and run : +#### Note: +* Deployment on chains that support CreateX factory will deploy contracts +using `create2` strategy. +* Github Actions workflow should be used for production deployments. -```bash -npm run script:test -``` ### Run Tests From e7393c737dcdf1e5cdb380cd7c7773a8aba85758 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 13 May 2025 17:02:05 +0200 Subject: [PATCH 32/42] Add create2 strategy to ignition config --- packages/sharing-smart-contract/hardhat.config.cjs | 7 +++++++ packages/sharing-smart-contract/package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/sharing-smart-contract/hardhat.config.cjs b/packages/sharing-smart-contract/hardhat.config.cjs index b48647fa0..c34e6c4ca 100644 --- a/packages/sharing-smart-contract/hardhat.config.cjs +++ b/packages/sharing-smart-contract/hardhat.config.cjs @@ -90,6 +90,13 @@ module.exports = { }, }, }, + ignition: { + strategyConfig: { + create2: { + salt: "0x0000000000000000000000000000000000000000000000000000000000000000", + }, + }, + }, dependencyCompiler: { paths: [ '@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol', diff --git a/packages/sharing-smart-contract/package.json b/packages/sharing-smart-contract/package.json index d579e2b7c..470a9f44b 100644 --- a/packages/sharing-smart-contract/package.json +++ b/packages/sharing-smart-contract/package.json @@ -9,7 +9,7 @@ "clean": "hardhat clean", "compile": "hardhat clean && hardhat compile && npm run artifact-to-abis", "verify": "hardhat verify", - "deploy": "npm run compile && hardhat run ./scripts/deploy.js", + "deploy": "hardhat ignition deploy ignition/modules/DataProtectorSharingModule.cts", "update-env": "hardhat run ./scripts/updateEnv.js", "upgrade": "hardhat run ./scripts/upgrade.js", "upgrade-local-fork": "mkdir -p .openzeppelin/local-fork && cp -r .openzeppelin/prod/. .openzeppelin/local-fork && MANIFEST_DEFAULT_DIR=.openzeppelin/local-fork ENV=prod hardhat run ./scripts/upgrade-local-fork.js", From c47f3700b4f9f1eb630921317ac4fa57012ba26c Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 13 May 2025 17:28:08 +0200 Subject: [PATCH 33/42] Add new chains config --- packages/sharing-smart-contract/.env.template | 2 +- .../sharing-smart-contract/config/env.cjs | 11 +++++-- .../sharing-smart-contract/hardhat.config.cjs | 32 +++++++++++++++---- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/packages/sharing-smart-contract/.env.template b/packages/sharing-smart-contract/.env.template index 4c6302e73..3ba478b51 100644 --- a/packages/sharing-smart-contract/.env.template +++ b/packages/sharing-smart-contract/.env.template @@ -1,5 +1,5 @@ # wallet used for transactions -WALLET_PRIVATE_KEY=... +PRIVATE_KEY=... # environment to use for configuration (prod/staging). The default is prod. ENV=... diff --git a/packages/sharing-smart-contract/config/env.cjs b/packages/sharing-smart-contract/config/env.cjs index 988151ca5..063b65215 100644 --- a/packages/sharing-smart-contract/config/env.cjs +++ b/packages/sharing-smart-contract/config/env.cjs @@ -1,7 +1,7 @@ // Hardhat Ignition does not support ESM modules, so we use CommonJS syntax. // TODO refactor this to use ESM syntax when Hardhat Ignition supports it. -require('dotenv/config.js'); +require('dotenv/config'); const { z } = require('zod'); const addressRegex = /(^|\b)(0x)?[0-9a-fA-F]{64}(\b|$)/; @@ -9,7 +9,7 @@ const privateKeyRegex = /(^|\b)(0x)?[0-9a-fA-F]{64}(\b|$)/; const envSchema = z.object({ // Private key of the wallet used for transactions - WALLET_PRIVATE_KEY: z + PRIVATE_KEY: z .string() .regex(privateKeyRegex, 'Invalid private key format') .optional() @@ -37,6 +37,13 @@ const envSchema = z.object({ // Mnemonic for deployment or network interaction MNEMONIC: z.string().min(1, 'MNEMONIC cannot be empty').optional().or(z.literal('')), + + FUJI_RPC_URL: z.string().url('FUJI_RPC_URL must be a valid URL').optional(), + + ARBITRUM_SEPOLIA_RPC_URL: z + .string() + .url('ARBITRUM_SEPOLIA_RPC_URL must be a valid URL') + .optional(), }); module.exports = { diff --git a/packages/sharing-smart-contract/hardhat.config.cjs b/packages/sharing-smart-contract/hardhat.config.cjs index c34e6c4ca..a8fac8581 100644 --- a/packages/sharing-smart-contract/hardhat.config.cjs +++ b/packages/sharing-smart-contract/hardhat.config.cjs @@ -4,12 +4,10 @@ require('@openzeppelin/hardhat-upgrades'); require('hardhat-contract-sizer'); require('@openzeppelin/hardhat-upgrades'); require('hardhat-dependency-compiler'); -require('dotenv').config(); +const env = require('./config/env.cjs'); // TODO format -const { WALLET_PRIVATE_KEY } = process.env; - const bellecourBase = { gasPrice: 0, blockGasLimit: 6_700_000, @@ -37,14 +35,36 @@ module.exports = { bellecour: { ...bellecourBase, url: 'https://bellecour.iex.ec', - accounts: WALLET_PRIVATE_KEY ? [WALLET_PRIVATE_KEY] : [], + accounts: env.PRIVATE_KEY ? [env.PRIVATE_KEY] : [], + }, + avalancheFujiTestnet: { + chainId: 43113, + url: env.FUJI_RPC_URL || 'https://api.avax-test.network/ext/bc/C/rpc', + accounts: [ + env.PRIVATE_KEY || + '0x0000000000000000000000000000000000000000000000000000000000000000', + ], + blockGasLimit: 8_000_000, + }, + arbitrumSepolia: { + chainId: 421614, + url: env.ARBITRUM_SEPOLIA_RPC_URL || 'https://sepolia-rollup.arbitrum.io/rpc', + accounts: [ + process.env.PRIVATE_KEY || + '0x0000000000000000000000000000000000000000000000000000000000000000', + ], + blockGasLimit: 30_000_000, + }, + 'local-bellecour-fork': { + ...bellecourBase, + url: 'http://127.0.0.1:8545', }, // poco-chain native config 'dev-native': { chainId: 65535, - url: process.env.RPC_URL ?? 'http://localhost:8545', + url: env.RPC_URL ?? 'http://localhost:8545', accounts: { - mnemonic: process.env.MNEMONIC ?? '', + mnemonic: env.MNEMONIC ?? '', }, gasPrice: 0, }, From 6c6450626a3967ec7afabd3b2563fc277115beb9 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 13 May 2025 17:32:44 +0200 Subject: [PATCH 34/42] Clean --- packages/sharing-smart-contract/config/env.cjs | 2 +- packages/sharing-smart-contract/config/env.js | 4 ++-- packages/sharing-smart-contract/hardhat.config.cjs | 4 ---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/sharing-smart-contract/config/env.cjs b/packages/sharing-smart-contract/config/env.cjs index 063b65215..1789f731c 100644 --- a/packages/sharing-smart-contract/config/env.cjs +++ b/packages/sharing-smart-contract/config/env.cjs @@ -1,7 +1,7 @@ // Hardhat Ignition does not support ESM modules, so we use CommonJS syntax. // TODO refactor this to use ESM syntax when Hardhat Ignition supports it. -require('dotenv/config'); +require('dotenv/config.js'); const { z } = require('zod'); const addressRegex = /(^|\b)(0x)?[0-9a-fA-F]{64}(\b|$)/; diff --git a/packages/sharing-smart-contract/config/env.js b/packages/sharing-smart-contract/config/env.js index f9510c15d..a95a9d745 100644 --- a/packages/sharing-smart-contract/config/env.js +++ b/packages/sharing-smart-contract/config/env.js @@ -1,3 +1,3 @@ -import env from './env.cjs'; +import _env from './env.cjs'; -export const env = env.env; +export const env = _env.env; diff --git a/packages/sharing-smart-contract/hardhat.config.cjs b/packages/sharing-smart-contract/hardhat.config.cjs index a8fac8581..4843a7146 100644 --- a/packages/sharing-smart-contract/hardhat.config.cjs +++ b/packages/sharing-smart-contract/hardhat.config.cjs @@ -55,10 +55,6 @@ module.exports = { ], blockGasLimit: 30_000_000, }, - 'local-bellecour-fork': { - ...bellecourBase, - url: 'http://127.0.0.1:8545', - }, // poco-chain native config 'dev-native': { chainId: 65535, From d7f31d64dec5e14b58516b9423d1f41fc9b30217 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Wed, 14 May 2025 11:12:00 +0200 Subject: [PATCH 35/42] Fix deployment --- packages/sharing-smart-contract/config/env.cjs | 2 +- packages/sharing-smart-contract/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sharing-smart-contract/config/env.cjs b/packages/sharing-smart-contract/config/env.cjs index 1789f731c..6d754368a 100644 --- a/packages/sharing-smart-contract/config/env.cjs +++ b/packages/sharing-smart-contract/config/env.cjs @@ -4,7 +4,7 @@ require('dotenv/config.js'); const { z } = require('zod'); -const addressRegex = /(^|\b)(0x)?[0-9a-fA-F]{64}(\b|$)/; +const addressRegex = /(^|\b)(0x)?[0-9a-fA-F]{40}(\b|$)/; const privateKeyRegex = /(^|\b)(0x)?[0-9a-fA-F]{64}(\b|$)/; const envSchema = z.object({ diff --git a/packages/sharing-smart-contract/package.json b/packages/sharing-smart-contract/package.json index 470a9f44b..e5a875c6e 100644 --- a/packages/sharing-smart-contract/package.json +++ b/packages/sharing-smart-contract/package.json @@ -9,7 +9,7 @@ "clean": "hardhat clean", "compile": "hardhat clean && hardhat compile && npm run artifact-to-abis", "verify": "hardhat verify", - "deploy": "hardhat ignition deploy ignition/modules/DataProtectorSharingModule.cts", + "deploy": "hardhat ignition deploy ignition/modules/DataProtectorSharingModule.cts --strategy create2", "update-env": "hardhat run ./scripts/updateEnv.js", "upgrade": "hardhat run ./scripts/upgrade.js", "upgrade-local-fork": "mkdir -p .openzeppelin/local-fork && cp -r .openzeppelin/prod/. .openzeppelin/local-fork && MANIFEST_DEFAULT_DIR=.openzeppelin/local-fork ENV=prod hardhat run ./scripts/upgrade-local-fork.js", From 551332870022594cfc0f4533d1029ff7e1c5ed43 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Wed, 14 May 2025 11:30:12 +0200 Subject: [PATCH 36/42] Clean --- packages/sharing-smart-contract/README.md | 2 +- .../ignition/modules/DataProtectorSharingModule.cts | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/sharing-smart-contract/README.md b/packages/sharing-smart-contract/README.md index b0383f1c5..0b1b99946 100644 --- a/packages/sharing-smart-contract/README.md +++ b/packages/sharing-smart-contract/README.md @@ -49,7 +49,7 @@ npm run deploy # [-- --network ] if using an external local node. To deploy the project on a live network, two options are available: 1. Triggering the dedicated Github Action workflow (recommended). -2. By running: +2. Or adding a private key locally and running: ```bash npm run deploy -- --network ``` diff --git a/packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cts b/packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cts index 2b7287ad3..5a05fe1d6 100644 --- a/packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cts +++ b/packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cts @@ -1,4 +1,3 @@ -// import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'; const { buildModule } = require('@nomicfoundation/hardhat-ignition/modules'); const { @@ -57,6 +56,4 @@ module.exports = buildModule('DataProtectorSharingModule', (m) => { const dataProtectorSharing = m.contractAt('DataProtectorSharing', dataProtectorSharingProxy); return { addOnlyAppWhitelistRegistry, dataProtectorSharing }; - - // TODO verify contracts. -}); \ No newline at end of file +}); From 02737b5bb2e8d36369890a568bc37b630c2a2b9d Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Wed, 14 May 2025 17:33:58 +0200 Subject: [PATCH 37/42] Import deployments in OZ upgrades --- .../workflows/sharing-smart-contract-test.yml | 4 ++ ...ule.cts => DataProtectorSharingModule.cjs} | 0 packages/sharing-smart-contract/package.json | 2 +- .../sharing-smart-contract/scripts/deploy.js | 59 +++++++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) rename packages/sharing-smart-contract/ignition/modules/{DataProtectorSharingModule.cts => DataProtectorSharingModule.cjs} (100%) create mode 100644 packages/sharing-smart-contract/scripts/deploy.js diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index e15403958..a9a763389 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -83,6 +83,10 @@ jobs: echo "Error: Anvil did not start within the timeout period." exit 1 + - name: Test deployment script + working-directory: packages/sharing-smart-contract + run: npm run deploy -- --network local-bellecour-fork + - name: Upgrade test working-directory: packages/sharing-smart-contract run: npm run upgrade-local-fork -- --network local-bellecour-fork diff --git a/packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cts b/packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cjs similarity index 100% rename from packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cts rename to packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cjs diff --git a/packages/sharing-smart-contract/package.json b/packages/sharing-smart-contract/package.json index e5a875c6e..cce7a2ae7 100644 --- a/packages/sharing-smart-contract/package.json +++ b/packages/sharing-smart-contract/package.json @@ -9,7 +9,7 @@ "clean": "hardhat clean", "compile": "hardhat clean && hardhat compile && npm run artifact-to-abis", "verify": "hardhat verify", - "deploy": "hardhat ignition deploy ignition/modules/DataProtectorSharingModule.cts --strategy create2", + "deploy": "hardhat run scripts/deploy.js", "update-env": "hardhat run ./scripts/updateEnv.js", "upgrade": "hardhat run ./scripts/upgrade.js", "upgrade-local-fork": "mkdir -p .openzeppelin/local-fork && cp -r .openzeppelin/prod/. .openzeppelin/local-fork && MANIFEST_DEFAULT_DIR=.openzeppelin/local-fork ENV=prod hardhat run ./scripts/upgrade-local-fork.js", diff --git a/packages/sharing-smart-contract/scripts/deploy.js b/packages/sharing-smart-contract/scripts/deploy.js new file mode 100644 index 000000000..7a50b6e02 --- /dev/null +++ b/packages/sharing-smart-contract/scripts/deploy.js @@ -0,0 +1,59 @@ +import hre from 'hardhat'; +import DataProtectorSharingModule from '../ignition/modules/DataProtectorSharingModule.cjs'; +import { env } from "../config/env.js"; + +const { ethers } = hre; + +async function main() { + const pocoAddress = env.POCO_ADDRESS; + const datasetRegistryAddress = env.DATASET_REGISTRY_ADDRESS; + if (!pocoAddress || !datasetRegistryAddress) { + throw new Error('POCO_ADDRESS and DATASET_REGISTRY_ADDRESS are required.'); + } + console.log('Deploying DataProtectorSharingModule...'); + console.log('PoCo address:', pocoAddress); + console.log('DatasetRegistry address:', datasetRegistryAddress); + // Check if the CreateX factory is supported on the current network. + const isCreatexSupported = await isCreatexFactorySupported(); + if (isCreatexSupported) { + console.log('CreateX factory is supported.'); + } else { + console.log('⚠️ CreateX factory is NOT supported.'); + } + // Deploy contracts using Ignition module. + const { + addOnlyAppWhitelistRegistry, + dataProtectorSharing, + } = await hre.ignition.deploy(DataProtectorSharingModule, { + ...(isCreatexSupported && { + strategy: 'create2', + strategyConfig: hre.userConfig.ignition.strategyConfig.create2, + }), + displayUi: true, // for logs. + }); + // Import proxies in OZ `upgrades` plugin for future upgrades. + console.log(`Importing proxy contracts in OZ upgrades...`); + const whitelistProxyAddress = await addOnlyAppWhitelistRegistry.getAddress(); + await upgrades.forceImport( + whitelistProxyAddress, + await ethers.getContractFactory('AddOnlyAppWhitelistRegistry'), + { + kind: 'transparent', + }, + ); + await upgrades.forceImport( + await dataProtectorSharing.getAddress(), + await ethers.getContractFactory('DataProtectorSharing'), + { + kind: 'transparent', + constructorArgs: [pocoAddress, datasetRegistryAddress, whitelistProxyAddress], + }, + ); +} + +async function isCreatexFactorySupported() { +const code = await ethers.provider.getCode('0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed'); + return code !== '0x'; +} + +main().catch(console.error); From 58c82eee359d2ea1be19e6ade79312185616e9f8 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Wed, 14 May 2025 17:38:58 +0200 Subject: [PATCH 38/42] Clean deploy script --- .../sharing-smart-contract/scripts/deploy.js | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/packages/sharing-smart-contract/scripts/deploy.js b/packages/sharing-smart-contract/scripts/deploy.js index 7a50b6e02..e1214322d 100644 --- a/packages/sharing-smart-contract/scripts/deploy.js +++ b/packages/sharing-smart-contract/scripts/deploy.js @@ -1,9 +1,15 @@ import hre from 'hardhat'; +import { env } from '../config/env.js'; import DataProtectorSharingModule from '../ignition/modules/DataProtectorSharingModule.cjs'; -import { env } from "../config/env.js"; const { ethers } = hre; +/** + * This script deploys DataProtectorSharing contract and its dependencies using + * Hardhat Ignition and createX factory if supported. + * It also imports the deployed contracts into the OpenZeppelin upgrades plugin. + */ + async function main() { const pocoAddress = env.POCO_ADDRESS; const datasetRegistryAddress = env.DATASET_REGISTRY_ADDRESS; @@ -21,16 +27,16 @@ async function main() { console.log('⚠️ CreateX factory is NOT supported.'); } // Deploy contracts using Ignition module. - const { - addOnlyAppWhitelistRegistry, - dataProtectorSharing, - } = await hre.ignition.deploy(DataProtectorSharingModule, { - ...(isCreatexSupported && { - strategy: 'create2', - strategyConfig: hre.userConfig.ignition.strategyConfig.create2, - }), - displayUi: true, // for logs. - }); + const { addOnlyAppWhitelistRegistry, dataProtectorSharing } = await hre.ignition.deploy( + DataProtectorSharingModule, + { + ...(isCreatexSupported && { + strategy: 'create2', + strategyConfig: hre.userConfig.ignition.strategyConfig.create2, + }), + displayUi: true, // for logs. + }, + ); // Import proxies in OZ `upgrades` plugin for future upgrades. console.log(`Importing proxy contracts in OZ upgrades...`); const whitelistProxyAddress = await addOnlyAppWhitelistRegistry.getAddress(); @@ -52,7 +58,7 @@ async function main() { } async function isCreatexFactorySupported() { -const code = await ethers.provider.getCode('0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed'); + const code = await ethers.provider.getCode('0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed'); return code !== '0x'; } From a8306a40295923905df4da58c6f75347a8025b85 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Wed, 14 May 2025 17:48:16 +0200 Subject: [PATCH 39/42] Update changelog --- packages/sharing-smart-contract/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/sharing-smart-contract/CHANGELOG.md b/packages/sharing-smart-contract/CHANGELOG.md index ee59bd8ba..41507dc96 100644 --- a/packages/sharing-smart-contract/CHANGELOG.md +++ b/packages/sharing-smart-contract/CHANGELOG.md @@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file. ### Changed +- Import Ignition deployment in OZ upgrades plugin (#441) +- Deploy contracts using Hardhat Ignition (#440) - [BREAKING] Remove result proxy url from contract config and deal params (#438). - Fix Sharing contract constructor arguments order (#433) - Update blockscout url From 32e149a856588a6d69b15126cb501ede81ee345b Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Wed, 14 May 2025 17:52:34 +0200 Subject: [PATCH 40/42] Fix linter issues --- .../ignition/modules/DataProtectorSharingModule.cjs | 1 + packages/sharing-smart-contract/scripts/deploy.js | 2 +- packages/sharing-smart-contract/tsconfig.json | 10 ---------- 3 files changed, 2 insertions(+), 11 deletions(-) delete mode 100644 packages/sharing-smart-contract/tsconfig.json diff --git a/packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cjs b/packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cjs index 5a05fe1d6..f6de52ecd 100644 --- a/packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cjs +++ b/packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cjs @@ -1,3 +1,4 @@ +/* eslint-disable import/extensions */ const { buildModule } = require('@nomicfoundation/hardhat-ignition/modules'); const { diff --git a/packages/sharing-smart-contract/scripts/deploy.js b/packages/sharing-smart-contract/scripts/deploy.js index e1214322d..846af17ce 100644 --- a/packages/sharing-smart-contract/scripts/deploy.js +++ b/packages/sharing-smart-contract/scripts/deploy.js @@ -2,7 +2,7 @@ import hre from 'hardhat'; import { env } from '../config/env.js'; import DataProtectorSharingModule from '../ignition/modules/DataProtectorSharingModule.cjs'; -const { ethers } = hre; +const { ethers, upgrades } = hre; /** * This script deploys DataProtectorSharing contract and its dependencies using diff --git a/packages/sharing-smart-contract/tsconfig.json b/packages/sharing-smart-contract/tsconfig.json deleted file mode 100644 index 7793ef8df..000000000 --- a/packages/sharing-smart-contract/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "module": "CommonJS", - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true - }, - "include": ["ignition/modules"] -} From 0d52e58db11c5263d0598e2e259970e7ecb5c689 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Wed, 14 May 2025 18:03:31 +0200 Subject: [PATCH 41/42] Fix CI --- .github/workflows/sharing-smart-contract-test.yml | 5 ++++- packages/sharing-smart-contract/config/config.cjs | 2 ++ packages/sharing-smart-contract/scripts/deploy.js | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index a9a763389..a8f999710 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -85,7 +85,10 @@ jobs: - name: Test deployment script working-directory: packages/sharing-smart-contract - run: npm run deploy -- --network local-bellecour-fork + run: | + POCO_ADDRESS=0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f \ + DATASET_REGISTRY_ADDRESS=0x799DAa22654128d0C64d5b79eac9283008158730 \ + npm run deploy -- --network local-bellecour-fork - name: Upgrade test working-directory: packages/sharing-smart-contract diff --git a/packages/sharing-smart-contract/config/config.cjs b/packages/sharing-smart-contract/config/config.cjs index 7f69c1d50..dbeb44c74 100644 --- a/packages/sharing-smart-contract/config/config.cjs +++ b/packages/sharing-smart-contract/config/config.cjs @@ -1,6 +1,8 @@ // Hardhat Ignition does not support ESM modules, so we use CommonJS syntax. // TODO refactor this to use ESM syntax when Hardhat Ignition supports it. +// TODO define addresses by network. + module.exports = { POCO_ADDRESS: '0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f', DATASET_REGISTRY_ADDRESS: '0x799DAa22654128d0C64d5b79eac9283008158730', diff --git a/packages/sharing-smart-contract/scripts/deploy.js b/packages/sharing-smart-contract/scripts/deploy.js index 846af17ce..6c92e51db 100644 --- a/packages/sharing-smart-contract/scripts/deploy.js +++ b/packages/sharing-smart-contract/scripts/deploy.js @@ -62,4 +62,7 @@ async function isCreatexFactorySupported() { return code !== '0x'; } -main().catch(console.error); +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); From 787810579059b2f3bb154e549118cff53d99fee8 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Wed, 14 May 2025 18:11:21 +0200 Subject: [PATCH 42/42] Fix CI --- .github/workflows/sharing-smart-contract-test.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index a8f999710..19d38d060 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -83,13 +83,6 @@ jobs: echo "Error: Anvil did not start within the timeout period." exit 1 - - name: Test deployment script - working-directory: packages/sharing-smart-contract - run: | - POCO_ADDRESS=0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f \ - DATASET_REGISTRY_ADDRESS=0x799DAa22654128d0C64d5b79eac9283008158730 \ - npm run deploy -- --network local-bellecour-fork - - name: Upgrade test working-directory: packages/sharing-smart-contract run: npm run upgrade-local-fork -- --network local-bellecour-fork @@ -101,6 +94,13 @@ jobs: working-directory: packages/sharing-smart-contract run: npm run test -- --network local-bellecour-fork + - name: Test deployment script + working-directory: packages/sharing-smart-contract + run: | + POCO_ADDRESS=0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f \ + DATASET_REGISTRY_ADDRESS=0x799DAa22654128d0C64d5b79eac9283008158730 \ + npm run deploy -- --network local-bellecour-fork + - name: Set Directory Permissions working-directory: packages/sharing-smart-contract run: sudo chmod -R 777 .