Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/deploy-smart-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
echo "Deploying to: ${{ inputs.network }} with ${{ inputs.environment }} environment"
npm run deploy -- --network ${{ inputs.network }}

- name: Update config.json with ERC1538Proxy address
- name: Update config.json with Diamond proxy address
if: inputs.network != 'hardhat'
run: npx hardhat run scripts/tools/update-config.ts --network ${{ inputs.network }}

Expand Down
2 changes: 1 addition & 1 deletion config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
"v5": {
"factory": "0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed",
"factoryType": "createx",
"ERC1538Proxy": "0x14B465079537655E1662F012e99EBa3863c8B9E0",
"DiamondProxy": "0x14B465079537655E1662F012e99EBa3863c8B9E0",
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
Expand Down
26 changes: 13 additions & 13 deletions deploy/0_deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ export default async function deploy() {
.catch(() => {
throw new Error('Failed to prepare transferOwnership data');
});
const erc1538ProxyAddress = await deployDiamondProxyWithDefaultFacets(
const diamondProxyAddress = await deployDiamondProxyWithDefaultFacets(
owner,
// transferOwnershipCall, //TODO
);
const erc1538 = DiamondCutFacet__factory.connect(erc1538ProxyAddress, owner);
console.log(`IexecInstance found at address: ${await erc1538.getAddress()}`);
const diamond = DiamondCutFacet__factory.connect(diamondProxyAddress, owner);
console.log(`IexecInstance found at address: ${await diamond.getAddress()}`);
// Deploy library & modules
const iexecLibOrdersAddress = await factoryDeployer.deployContract(
new IexecLibOrders_v5__factory(),
Expand Down Expand Up @@ -103,21 +103,21 @@ export default async function deploy() {
];
for (const module of modules) {
const address = await factoryDeployer.deployContract(module);
await linkContractToProxy(erc1538, address, module);
await linkContractToProxy(diamond, address, module);
}
// Verify linking on ERC1538Proxy
const erc1538QueryInstance: DiamondLoupeFacet = DiamondLoupeFacet__factory.connect(
erc1538ProxyAddress,
// Verify linking on Diamond Proxy
const diamondLoupeFacetInstance: DiamondLoupeFacet = DiamondLoupeFacet__factory.connect(
diamondProxyAddress,
owner,
);
const facets = await erc1538QueryInstance.facets();
const facets = await diamondLoupeFacetInstance.facets();
const functionCount = facets
.map((facet) => facet.functionSelectors.length)
.reduce((acc, curr) => acc + curr, 0);
console.log(`The deployed ERC1538Proxy now supports ${functionCount} functions:`);
console.log(`The deployed Diamond Proxy now supports ${functionCount} functions:`);
// TODO
// for (let i = 0; i < Number(functionCount); i++) {
// const [method, , contract] = await erc1538QueryInstance.functionByIndex(i);
// const [method, , contract] = await diamondLoupeFacetInstance.functionByIndex(i);
// console.log(`[${i}] ${contract} ${method}`);
// }
/**
Expand Down Expand Up @@ -174,11 +174,11 @@ export default async function deploy() {
}

// Set main configuration
const iexecAccessorsInstance = IexecAccessors__factory.connect(erc1538ProxyAddress, owner);
const iexecAccessorsInstance = IexecAccessors__factory.connect(diamondProxyAddress, owner);
const iexecInitialized = (await iexecAccessorsInstance.eip712domain_separator()) != ZeroHash;
if (!iexecInitialized) {
// TODO replace this with DiamondInit.init().
await IexecMaintenanceDelegate__factory.connect(erc1538ProxyAddress, owner)
await IexecMaintenanceDelegate__factory.connect(diamondProxyAddress, owner)
.configure(
rlcInstanceAddress,
'Staked RLC',
Expand All @@ -195,7 +195,7 @@ export default async function deploy() {
const catCountBefore = await iexecAccessorsInstance.countCategory();
for (let i = Number(catCountBefore); i < config.categories.length; i++) {
const category = config.categories[i];
await IexecCategoryManager__factory.connect(erc1538ProxyAddress, owner)
await IexecCategoryManager__factory.connect(diamondProxyAddress, owner)
.createCategory(
category.name,
JSON.stringify(category.description),
Expand Down
14 changes: 7 additions & 7 deletions scripts/boost/1_add-modules-to-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ import {
const chainId = (await ethers.provider.getNetwork()).chainId;
const deploymentOptions = config.getChainConfig(chainId).v5;
console.log('Link Boost functions to proxy:');
if (!deploymentOptions.ERC1538Proxy) {
throw new Error('ERC1538Proxy is required');
if (!deploymentOptions.DiamondProxy) {
throw new Error('DiamondProxy is required');
}
const erc1538ProxyAddress = deploymentOptions.ERC1538Proxy;
const diamondProxyAddress = deploymentOptions.DiamondProxy;
const iexecPocoBoostDelegateAddress = (await deployments.get('IexecPocoBoostDelegate')).address; // Bellecour: 0x8425229f979AB3b0dDDe00D475D762cA4d6a5eFc
const iexecPocoBoostAccessorsDelegateAddress = (
await deployments.get('IexecPocoBoostAccessorsDelegate')
).address; // Bellecour: 0x56185a2b0dc8b556BBfBAFB702BC971Ed75e868C
const [account] = await ethers.getSigners();
const timelockAddress = await Ownable__factory.connect(erc1538ProxyAddress, account).owner(); // Bellecour: 0x4611B943AA1d656Fc669623b5DA08756A7e288E9
const timelockAddress = await Ownable__factory.connect(diamondProxyAddress, account).owner(); // Bellecour: 0x4611B943AA1d656Fc669623b5DA08756A7e288E9
const iexecPocoBoostProxyUpdate = encodeModuleProxyUpdate(
IexecPocoBoost__factory.createInterface(),
iexecPocoBoostDelegateAddress,
Expand All @@ -43,7 +43,7 @@ import {
const operationSalt = '0x0be814a62c44af32241a2c964e5680d1b25c783473c6e7875cbc8071770d7ff0'; // Random
const delay = BigInt(60 * 60 * 24 * 7);
const updateProxyArgs = [
Array(2).fill(erc1538ProxyAddress),
Array(2).fill(diamondProxyAddress),
Array(2).fill(0),
[iexecPocoBoostProxyUpdate, iexecPocoBoostAccessorsProxyUpdate],
ZeroHash,
Expand All @@ -68,7 +68,7 @@ import {
await time.increase(delay);
console.log('Time traveling..');
await printBlockTime();
await printFunctions(erc1538ProxyAddress);
await printFunctions(diamondProxyAddress);
console.log('Executing proxy update..');
await timelockInstance
.connect(timelockAdminSigner)
Expand All @@ -77,5 +77,5 @@ import {
console.log(tx);
tx.wait();
});
await printFunctions(erc1538ProxyAddress);
await printFunctions(diamondProxyAddress);
})();
6 changes: 3 additions & 3 deletions scripts/set-callback-gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import { IexecAccessors__factory, IexecMaintenanceDelegate__factory } from '../t
}
console.log(`Setting callback-gas to ${requestedCallbackGas.toLocaleString()} ..`);
const [owner] = await ethers.getSigners();
const erc1538ProxyAddress = (await deployments.get('ERC1538Proxy')).address;
const diamondProxyAddress = (await deployments.get('Diamond')).address;
const viewCallbackGas = async () =>
(await IexecAccessors__factory.connect(erc1538ProxyAddress, owner).callbackgas())
(await IexecAccessors__factory.connect(diamondProxyAddress, owner).callbackgas())
.toNumber()
.toLocaleString();
const callbackGasBefore = await viewCallbackGas();
await IexecMaintenanceDelegate__factory.connect(erc1538ProxyAddress, owner)
await IexecMaintenanceDelegate__factory.connect(diamondProxyAddress, owner)
.setCallbackGas(requestedCallbackGas)
.then((tx) => tx.wait());
console.log(`Changed callback-gas from ${callbackGasBefore} to ${await viewCallbackGas()}`);
Expand Down
18 changes: 9 additions & 9 deletions scripts/sponsoring/1_add-modules-to-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ export async function addModulesToProxy() {
const chainId = (await ethers.provider.getNetwork()).chainId;
const deploymentOptions = config.getChainConfig(chainId).v5;
console.log('Link functions to proxy:');
if (!deploymentOptions.ERC1538Proxy) {
throw new Error('ERC1538Proxy is required');
if (!deploymentOptions.DiamondProxy) {
throw new Error('DiamondProxy is required');
}
const erc1538ProxyAddress = deploymentOptions.ERC1538Proxy;
const diamondProxyAddress = deploymentOptions.DiamondProxy;
const iexecOrderManagementAddress = (await hre.deployments.get('IexecOrderManagementDelegate'))
.address;
const iexecPoco1DelegateAddress = (await hre.deployments.get('IexecPoco1Delegate')).address;
const iexecPoco2DelegateAddress = (await hre.deployments.get('IexecPoco2Delegate')).address;
const iexecPocoAccessorsDelegateAddress = (
await hre.deployments.get('IexecPocoAccessorsDelegate')
).address;
await printFunctions(erc1538ProxyAddress);
await printFunctions(diamondProxyAddress);

console.log('Functions about to be added to proxy:');
const timelockAddress = await Ownable__factory.connect(
erc1538ProxyAddress,
diamondProxyAddress,
ethers.provider,
).owner();
const iexecOrderManagementProxyUpdate = encodeModuleProxyUpdate(
Expand Down Expand Up @@ -73,7 +73,7 @@ export async function addModulesToProxy() {
iexecPocoAccessorsProxyUpdate,
];
const updateProxyArgs = [
Array(updates.length).fill(erc1538ProxyAddress),
Array(updates.length).fill(diamondProxyAddress),
Array(updates.length).fill(0),
updates,
ZeroHash,
Expand Down Expand Up @@ -104,7 +104,7 @@ export async function addModulesToProxy() {
console.log('Time traveling..');
await executeUpgrade();

return erc1538ProxyAddress;
return diamondProxyAddress;

async function scheduleUpgrade() {
await timelockInstance
Expand All @@ -118,7 +118,7 @@ export async function addModulesToProxy() {

async function executeUpgrade() {
await printBlockTime();
await printFunctions(erc1538ProxyAddress);
await printFunctions(diamondProxyAddress);
console.log('Executing proxy update..');
await timelockInstance
.connect(timelockAdminSigner)
Expand All @@ -127,6 +127,6 @@ export async function addModulesToProxy() {
console.log(x);
return x.wait();
});
await printFunctions(erc1538ProxyAddress);
await printFunctions(diamondProxyAddress);
}
}
8 changes: 4 additions & 4 deletions scripts/tools/update-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ async function main(): Promise<void> {
const chainId = network.chainId.toString();

console.log(`Working with network: ${networkName} (Chain ID: ${chainId})`);
const deployment = await deployments.get('ERC1538Proxy');
const deployment = await deployments.get('DiamondProxy');
const contractAddress = deployment.address;

if (!contractAddress || contractAddress === 'null') {
console.error(`Failed to extract a valid ERC1538Proxy address from deployment file`);
console.error(`Failed to extract a valid DiamondProxy address from deployment file`);
process.exit(1);
}

console.log(`Found ERC1538Proxy address: ${contractAddress}`);
console.log(`Found DiamondProxy address: ${contractAddress}`);
const localConfig = config;

// Ensure the chain structure exists
Expand All @@ -47,7 +47,7 @@ async function main(): Promise<void> {
localConfig.chains[chainId].v5 = {};
}

const contractKey = 'ERC1538Proxy';
const contractKey = 'DiamondProxy';
const previousValue = localConfig.chains[chainId].v5[contractKey] || 'null';
localConfig.chains[chainId].v5[contractKey] = contractAddress;

Expand Down
13 changes: 7 additions & 6 deletions scripts/upgrades/upgrade-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ async function printBlockTime() {
}
}

async function printFunctions(erc1538ProxyAddress: string) {
const erc1538QueryInstance: ERC1538Query = ERC1538Query__factory.connect(
erc1538ProxyAddress,
// TODO: update this function to use DiamonLoup
async function printFunctions(diamondProxyAddress: string) {
const diamondQueryInstance: ERC1538Query = ERC1538Query__factory.connect(
diamondProxyAddress,
ethers.provider,
);
const functionCount = Number(await erc1538QueryInstance.totalFunctions());
console.log(`ERC1538Proxy supports ${functionCount} functions:`);
const functionCount = Number(await diamondQueryInstance.totalFunctions());
console.log(`DiamondProxy supports ${functionCount} functions:`);
for (let i = 0; i < functionCount; i++) {
const [method, , contract] = await erc1538QueryInstance.functionByIndex(i);
const [method, , contract] = await diamondQueryInstance.functionByIndex(i);
console.log(`[${i}] ${contract} ${method}`);
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/utils/fixture-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export async function fundAccounts(
* Transfers ownership of all contracts
*/
export async function transferAllOwnerships(chainConfig: any) {
if (chainConfig.v5.ERC1538Proxy) {
if (chainConfig.v5.DiamondProxy) {
// Transfer proxy ownership from Timelock or current owner to a known EOA.
await transferProxyOwnership(chainConfig.v5.ERC1538Proxy);
await transferProxyOwnership(chainConfig.v5.DiamondProxy);
}
const registries = [
{ name: 'AppRegistry', address: (await deployments.get('AppRegistry')).address },
Expand Down
14 changes: 7 additions & 7 deletions test/utils/hardhat-fixture-deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ async function deployAll() {
*/
async function setUpLocalForkInNativeMode() {
const chainId = (await ethers.provider.getNetwork()).chainId;
const proxyAddress = config.getChainConfig(chainId).v5.ERC1538Proxy;
const proxyAddress = config.getChainConfig(chainId).v5.DiamondProxy;
if (!proxyAddress) {
throw new Error('ERC1538Proxy is required');
throw new Error('DiamondProxy is required');
}
await fundAccounts(proxyAddress, proxyAddress, true);
await transferAllOwnerships(config.getChainConfig(chainId));
Expand All @@ -48,16 +48,16 @@ async function setUpLocalForkInTokenMode() {
}
await transferAllOwnerships(chainConfig);

const proxyAddress = chainConfig.v5.ERC1538Proxy;
const proxyAddress = chainConfig.v5.DiamondProxy;
if (proxyAddress) {
console.log(`Using existing ERC1538Proxy at ${proxyAddress}`);
console.log(`Using existing DiamondProxy at ${proxyAddress}`);
return proxyAddress;
} else {
console.log('No existing ERC1538Proxy found, deploying new contracts');
console.log('No existing DiamondProxy found, deploying new contracts');
// Deploy all contracts
await deploy();
const newProxyAddress = (await deployments.get('ERC1538Proxy')).address;
console.log(`Deployed new ERC1538Proxy at ${newProxyAddress}`);
const newProxyAddress = (await deployments.get('Diamond')).address;
console.log(`Deployed new DiamondProxy at ${newProxyAddress}`);
return newProxyAddress;
}
}
Expand Down
3 changes: 2 additions & 1 deletion utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ type ChainConfig = {
AppRegistry?: string;
DatasetRegistry?: string;
WorkerpoolRegistry?: string;
ERC1538Proxy?: string;
ERC1538Proxy?: string; // Deprecated, use DiamondProxy instead TODO: to remove
DiamondProxy?: string;
IexecLibOrders_v5?: string;
};
};
Expand Down
4 changes: 2 additions & 2 deletions utils/proxy-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ interface AbiParameter {
}

/**
* Link a contract to an ERC1538 proxy.
* @param proxy contract to ERC1538 proxy.
* Link a contract to a Diamond proxy.
* @param proxy contract to Diamond proxy.
* @param contractAddress The contract address to link to the proxy.
* @param contractFactory The contract factory to link to the proxy.
*/
Expand Down