Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1e29b3c
add support to fuji fork
gfournieriExec Apr 3, 2025
5e833cd
use createX on deploy script and test on arbitrum sepolia / fuji fork
gfournieriExec Apr 3, 2025
7f0345c
update mocha timeout for real time fork
gfournieriExec Apr 3, 2025
804664d
add abritrum sepolia and fuji networks
gfournieriExec Apr 7, 2025
f6dfe7b
save RLC token address in deployment to get it in test
gfournieriExec Apr 7, 2025
d86109e
not working version
gfournieriExec Apr 8, 2025
c5372df
deploy factory on local hardhat network
gfournieriExec Apr 8, 2025
f7eba8e
save RLC address on deploy
gfournieriExec Apr 8, 2025
7246d45
add support to fork tests chain
gfournieriExec Apr 8, 2025
ba423b0
add clean hardhat on test:native
gfournieriExec Apr 8, 2025
8a2e36a
Merge branch 'feature/create-x-clean' of https://github.com/iExecBloc…
gfournieriExec Apr 9, 2025
029d916
add setUpLocalFork
gfournieriExec Apr 9, 2025
1b56be8
add clean before test native
gfournieriExec Apr 9, 2025
451b684
add support to generic factory on bellecour
gfournieriExec Apr 9, 2025
8a4f8f8
update Changelog
gfournieriExec Apr 9, 2025
3b792be
update fuji public rpc
gfournieriExec Apr 9, 2025
8356452
fixe timelock
gfournieriExec Apr 9, 2025
a8ffb0c
add clean on test npm
gfournieriExec Apr 10, 2025
385d8bb
lowercase for factory addy
gfournieriExec Apr 10, 2025
709b77c
use .then when possible
gfournieriExec Apr 10, 2025
06732be
remove knowned chain to customChains
gfournieriExec Apr 10, 2025
2237a04
remove useless verify sections for fuji and sepolia arbitrum network
gfournieriExec Apr 10, 2025
1d428be
use npx hardhat
gfournieriExec Apr 10, 2025
76cf6c4
update public fuji rpc to make it work
gfournieriExec Apr 11, 2025
c1bdebc
Refactors RLC deployment logic
gfournieriExec Apr 11, 2025
c671acd
Update CHANGELOG.md
gfournieriExec Apr 11, 2025
5558358
use rpc recommended by Zied
gfournieriExec Apr 11, 2025
f6c8f22
Refactor loadHardhatFixtureDeployment logic for improved readability
gfournieriExec Apr 11, 2025
fd50b3f
update setUpTokenFork name
gfournieriExec Apr 11, 2025
39b36e3
Refactor local fork setup by extracting account funding and proxy own…
gfournieriExec Apr 11, 2025
d2b00dd
Remove 'usefactory' parameter from v5 configuration and update relate…
gfournieriExec Apr 11, 2025
5e8c2f2
Add chainId configuration for Fuji and Arbitrum Sepolia networks
gfournieriExec Apr 11, 2025
1be040a
Refactor test scripts to use a unified clean command
gfournieriExec Apr 14, 2025
f06e9df
Refactor FactoryDeployer to unify contract deployment method and impr…
gfournieriExec Apr 14, 2025
417fa0f
remove useless hardfork specification
gfournieriExec Apr 14, 2025
af68498
Merge branch 'develop' into feature/create-x-clean
gfournieriExec Apr 15, 2025
80da385
update readme
gfournieriExec Apr 15, 2025
9c65946
Replace hardcoded mnemonic with HARDHAT_NETWORK_MNEMONIC in Fuji and …
gfournieriExec Apr 15, 2025
c1a0e6e
Rename setUpLocalFork to setUpLocalForkInNativeMode for clarity and u…
gfournieriExec Apr 15, 2025
69be4ab
remove useless else
gfournieriExec Apr 15, 2025
e737a6b
Refactor FactoryDeployer to use chainId and streamline factory initia…
gfournieriExec Apr 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
- [x] `IexecPoco2Delegate.sol`

### Features

- Add CreateX factory for new chain deployment (#215)
- Support Arbitrum & Avalanche Fuji testnets (#215)
- Housekeeping (#207, )
- Add Halborn "Poco v5.5 & Voucher v1.0" audit report (#205)
- Refactor Factory deployer (#206)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ It contains:
- **"asset":** can be "Token" or "Native", select which escrow to use.
- **"token":** the address of the token to use. If asset is set to token, and no token address is provided, a mock will be deployed on the fly.
- **"v3":** a list of resources from a previous (v3) deployment. This allows previous resources to be automatically available. It also enables score transfer from v3 to v5. [optional]
- **"v5":** deployment parameters for the new version. If usefactory is set to true, and no salt is provided, `bytes32(0)` will be used by default.
- **"v5":** deployment parameters for the new version. If factory address is set, and no salt is provided, `bytes32(0)` will be used by default.

If you want to deploy the iExec PoCo V5 smart contracts on a new blockchain, the recommended process is to:

Expand Down
45 changes: 37 additions & 8 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"WorkerpoolRegistry": "0xc398052563469e6Ea7C442aBf124aADE7ec2CC92"
},
"v5": {
"usefactory": true,
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000",
"AppRegistry": "0xB1C52075b276f87b1834919167312221d50c9D16",
"DatasetRegistry": "0x799DAa22654128d0C64d5b79eac9283008158730",
Expand All @@ -63,7 +62,6 @@
"WorkerpoolRegistry": null
},
"v5": {
"usefactory": true,
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
Expand All @@ -79,7 +77,6 @@
"WorkerpoolRegistry": null
},
"v5": {
"usefactory": true,
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
Expand All @@ -96,7 +93,6 @@
"WorkerpoolRegistry": "0xdAD30AAb14F569830bFd26EdF72df876dc30D20c"
},
"v5": {
"usefactory": true,
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
Expand All @@ -112,7 +108,6 @@
"WorkerpoolRegistry": "0x3f4C18C322064576C048b1284b700288ffEf126B"
},
"v5": {
"usefactory": true,
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
Expand All @@ -126,7 +121,6 @@
"WorkerpoolRegistry": "0x1Cae59C7745A61dD37CD17f174745959D0f3f400"
},
"v5": {
"usefactory": true,
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
Expand All @@ -142,7 +136,43 @@
"v5": {
"ERC1538Proxy": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
"IexecLibOrders_v5": "0xE8b04c85C47fcEc0e9eE30D4034e2997f6519123",
"usefactory": true,
"factory": "0xfAC000a12dA42B871c0AaD5F25391aAe62958Db1",
"factoryType": "generic",
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
"43113": {
"_comment": "Avalanche Fuji Testnet",
"asset": "Token",
"token": "0xb96484C8B0e27B08a86661a3c19A028f4d3e89ad",
"richman": "0xd88CF17D89533816E99C0427581aa8C72129037D",
"uniswap": false,
"v3": {
"Hub": null,
"AppRegistry": null,
"DatasetRegistry": null,
"WorkerpoolRegistry": null
},
"v5": {
"factory": "0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed",
"factoryType": "createx",
"ERC1538Proxy": "0x14B465079537655E1662F012e99EBa3863c8B9E0",
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
"421614": {
"_comment": "Arbitrum Sepolia Testnet",
"asset": "Token",
"uniswap": false,
"v3": {
"Hub": null,
"AppRegistry": null,
"DatasetRegistry": null,
"WorkerpoolRegistry": null
},
"v5": {
"factory": "0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed",
"factoryType": "createx",
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
Expand All @@ -158,7 +188,6 @@
"WorkerpoolRegistry": null
},
"v5": {
"usefactory": true,
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
}
Expand Down
1 change: 0 additions & 1 deletion config/config_native.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"WorkerpoolRegistry": null
},
"v5": {
"usefactory": true,
"salt": "0xbe1a000000000000000000000000000000000000000000000000000000000000"
}
}
Expand Down
1 change: 0 additions & 1 deletion config/config_token.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"WorkerpoolRegistry": null
},
"v5": {
"usefactory": true,
"salt": "0xbe1a000000000000000000000000000000000000000000000000000000000000"
}
}
Expand Down
50 changes: 32 additions & 18 deletions deploy/0_deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers';
import { ZeroAddress, ZeroHash } from 'ethers';
import { ethers } from 'hardhat';
import { deployments, ethers } from 'hardhat';
import {
AppRegistry__factory,
DatasetRegistry__factory,
Expand Down Expand Up @@ -37,8 +37,8 @@ import {
WorkerpoolRegistry__factory,
} from '../typechain';
import { Ownable__factory } from '../typechain/factories/@openzeppelin/contracts/access';
import config from '../utils/config';
import { FactoryDeployer } from '../utils/FactoryDeployer';
import config from '../utils/config';
import { linkContractToProxy } from '../utils/proxy-tools';

/**
Expand All @@ -56,16 +56,15 @@ export default async function deploy() {
const chainId = (await ethers.provider.getNetwork()).chainId;
const [owner] = await ethers.getSigners();
const deploymentOptions = config.getChainConfigOrDefault(chainId);
const salt = process.env.SALT || deploymentOptions.v5.salt || ethers.ZeroHash;
const factoryDeployer = new FactoryDeployer(owner, salt);
const factoryDeployer = new FactoryDeployer(owner, chainId);
// Deploy RLC
const isTokenMode = !config.isNativeChain(deploymentOptions);
let rlcInstanceAddress = isTokenMode
? await getOrDeployRlc(deploymentOptions.token!, owner) // token
: ZeroAddress; // native
console.log(`RLC: ${rlcInstanceAddress}`);
// Deploy ERC1538 proxy contracts
const erc1538UpdateAddress = await factoryDeployer.deployWithFactory(
const erc1538UpdateAddress = await factoryDeployer.deployContract(
new ERC1538UpdateDelegate__factory(),
);
const transferOwnershipCall = await Ownable__factory.connect(
Expand All @@ -77,15 +76,15 @@ export default async function deploy() {
.catch(() => {
throw new Error('Failed to prepare transferOwnership data');
});
const erc1538ProxyAddress = await factoryDeployer.deployWithFactory(
const erc1538ProxyAddress = await factoryDeployer.deployContract(
new ERC1538Proxy__factory(),
[erc1538UpdateAddress],
transferOwnershipCall,
);
const erc1538: ERC1538Update = ERC1538Update__factory.connect(erc1538ProxyAddress, owner);
console.log(`IexecInstance found at address: ${await erc1538.getAddress()}`);
// Deploy library & modules
const iexecLibOrdersAddress = await factoryDeployer.deployWithFactory(
const iexecLibOrdersAddress = await factoryDeployer.deployContract(
new IexecLibOrders_v5__factory(),
);
const iexecLibOrders = {
Expand All @@ -112,7 +111,7 @@ export default async function deploy() {
new IexecPocoBoostAccessorsDelegate__factory(),
];
for (const module of modules) {
const address = await factoryDeployer.deployWithFactory(module);
const address = await factoryDeployer.deployContract(module);
await linkContractToProxy(erc1538, address, module);
}
// Verify linking on ERC1538Proxy
Expand All @@ -126,17 +125,17 @@ export default async function deploy() {
const [method, , contract] = await erc1538QueryInstance.functionByIndex(i);
console.log(`[${i}] ${contract} ${method}`);
}
const appRegistryAddress = await factoryDeployer.deployWithFactory(
const appRegistryAddress = await factoryDeployer.deployContract(
new AppRegistry__factory(),
[],
transferOwnershipCall,
);
const datasetRegistryAddress = await factoryDeployer.deployWithFactory(
const datasetRegistryAddress = await factoryDeployer.deployContract(
new DatasetRegistry__factory(),
[],
transferOwnershipCall,
);
const workerpoolRegistryAddress = await factoryDeployer.deployWithFactory(
const workerpoolRegistryAddress = await factoryDeployer.deployContract(
new WorkerpoolRegistry__factory(),
[],
transferOwnershipCall,
Expand Down Expand Up @@ -213,11 +212,26 @@ export default async function deploy() {
}

async function getOrDeployRlc(token: string, owner: SignerWithAddress) {
return token // token
? token
: await new RLC__factory()
.connect(owner)
.deploy()
.then((contract) => contract.waitForDeployment())
.then((contract) => contract.getAddress());
const rlcFactory = new RLC__factory().connect(owner);
let rlcAddress: string;

if (token) {
console.log(`Using existing RLC token at: ${token}`);
rlcAddress = token;
} else {
console.log('Deploying new RLC token...');
rlcAddress = await rlcFactory
.deploy()
.then((contract) => contract.waitForDeployment())
.then((contract) => contract.getAddress());
console.log(`New RLC token deployed at: ${rlcAddress}`);
}

await deployments.save('RLC', {
abi: (rlcFactory as any).constructor.abi,
address: rlcAddress,
bytecode: (await rlcFactory.getDeployTransaction()).data,
deployedBytecode: await ethers.provider.getCode(rlcAddress),
});
return rlcAddress;
}
65 changes: 64 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import chainConfig from './utils/config';

const isNativeChainType = chainConfig.isNativeChain();
const isLocalFork = process.env.LOCAL_FORK == 'true';
const isFujiFork = process.env.FUJI_FORK == 'true';
const isArbitrumSepoliaFork = process.env.ARBITRUM_SEPOLIA_FORK == 'true';
Comment on lines +16 to +17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping only a single variable isFork doesn't fit us?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is to select the current chain to fork either local as bellecour, fuji, or arbi
Maybe I can re-work on it, but did not seen yet how I could change it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gonna check that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some research, can't figure it out a better way than what we have rn

const bellecourBlockscoutUrl = 'https://blockscout.bellecour.iex.ec';

/**
Expand All @@ -28,6 +30,20 @@ const bellecourBaseConfig = {
blockGasLimit: 6_700_000,
};

// Avalanche Fuji specific configuration
const fujiBaseConfig = {
gasPrice: 25_000_000_000, // 25 Gwei default
blockGasLimit: 8_000_000,
chainId: 43113,
};

// Arbitrum Sepolia specific configuration
const arbitrumSepoliaBaseConfig = {
gasPrice: 100_000_000, // 0.1 Gwei default (Arbitrum has lower gas prices)
blockGasLimit: 30_000_000, // Arbitrum has higher block gas limits
chainId: 421614,
};

const settings = {
optimizer: {
enabled: true,
Expand Down Expand Up @@ -81,6 +97,26 @@ const config: HardhatUserConfig = {
},
chainId: 134,
}),
...(isFujiFork && {
forking: {
url: process.env.FUJI_RPC_URL || 'https://api.avax-test.network/ext/bc/C/rpc',
blockNumber: process.env.FUJI_BLOCK_NUMBER
? parseInt(process.env.FUJI_BLOCK_NUMBER)
: undefined,
},
...fujiBaseConfig,
}),
...(isArbitrumSepoliaFork && {
forking: {
url:
process.env.ARBITRUM_SEPOLIA_RPC_URL ||
'https://sepolia-rollup.arbitrum.io/rpc',
blockNumber: process.env.ARBITRUM_SEPOLIA_BLOCK_NUMBER
? parseInt(process.env.ARBITRUM_SEPOLIA_BLOCK_NUMBER)
: undefined,
},
...arbitrumSepoliaBaseConfig,
}),
},
'external-hardhat': {
...defaultHardhatNetworkParams,
Expand All @@ -93,6 +129,14 @@ const config: HardhatUserConfig = {
accounts: 'remote', // Override defaults accounts for impersonation
chainId: 134,
}),
...(isFujiFork && {
accounts: 'remote', // Override defaults accounts for impersonation
...fujiBaseConfig,
}),
...(isArbitrumSepoliaFork && {
accounts: 'remote', // Override defaults accounts for impersonation
...arbitrumSepoliaBaseConfig,
}),
},
'dev-native': {
chainId: 65535,
Expand Down Expand Up @@ -128,6 +172,22 @@ const config: HardhatUserConfig = {
mnemonic: process.env.MNEMONIC || '',
},
},
// Add Fuji as a network
avalancheFujiTestnet: {
url: process.env.FUJI_RPC_URL || 'https://api.avax-test.network/ext/bc/C/rpc',
accounts: {
mnemonic: process.env.MNEMONIC || HARDHAT_NETWORK_MNEMONIC,
},
...fujiBaseConfig,
},
// Add Arbitrum Sepolia as a network
'arbitrum-sepolia': {
url: process.env.ARBITRUM_SEPOLIA_RPC_URL || 'https://sepolia-rollup.arbitrum.io/rpc',
accounts: {
mnemonic: process.env.MNEMONIC || HARDHAT_NETWORK_MNEMONIC,
},
...arbitrumSepoliaBaseConfig,
},
viviani: {
chainId: 133,
url: 'https://viviani.iex.ec',
Expand Down Expand Up @@ -155,6 +215,8 @@ const config: HardhatUserConfig = {
etherscan: {
apiKey: {
mainnet: process.env.ETHERSCAN_API_KEY || '',
avalancheFujiTestnet: 'nothing', // a non-empty string is needed by the plugin.
arbitrumSepolia: process.env.ARBISCAN_API_KEY || '',
viviani: 'nothing', // a non-empty string is needed by the plugin.
bellecour: 'nothing', // a non-empty string is needed by the plugin.
},
Expand Down Expand Up @@ -195,6 +257,7 @@ const config: HardhatUserConfig = {
'@openzeppelin/contracts-v5/interfaces/IERC1271.sol',
// Used in deployment
'@amxx/factory/contracts/v6/GenericFactory.sol',
'createx/src/ICreateX.sol',
],
keep: true, // Slither requires compiled dependencies
},
Expand All @@ -218,7 +281,7 @@ const config: HardhatUserConfig = {
'Store.v8.sol',
],
},
mocha: { timeout: 50000 },
mocha: { timeout: 300000 },
};

/**
Expand Down
Loading