Skip to content

Commit 17e57bc

Browse files
authored
feat: Remove boost facets on Arbitrum Sepolia testnet (#299)
1 parent f53c7e3 commit 17e57bc

File tree

8 files changed

+86
-89
lines changed

8 files changed

+86
-89
lines changed

contracts/facets/IexecPocoBoostAccessorsFacet.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import {FacetBase} from "./FacetBase.v8.sol";
88
import {IexecPocoBoostAccessors} from "../interfaces/IexecPocoBoostAccessors.sol";
99
import {PocoStorageLib} from "../libs/PocoStorageLib.v8.sol";
1010

11+
//
12+
// Not deployed yet!
13+
//
14+
1115
/**
1216
* @title Getters contract for PoCo Boost facet.
1317
* @notice Access to PoCo Boost tasks must be done with PoCo Classic `IexecPocoAccessors`.

contracts/facets/IexecPocoBoostFacet.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ import {IexecPocoCommon} from "./IexecPocoCommon.sol";
2020
import {SignatureVerifier} from "./SignatureVerifier.v8.sol";
2121
import {PocoStorageLib} from "../libs/PocoStorageLib.v8.sol";
2222

23+
//
24+
// Not deployed yet!
25+
//
26+
2327
/**
2428
* @title PoCo Boost to reduce latency and increase throughput of deals.
2529
* @notice Works for deals with requested trust = 0.

deploy/0_deploy.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {
3838
import { DiamondArgsStruct } from '../typechain/contracts/Diamond';
3939
import { Ownable__factory } from '../typechain/factories/@openzeppelin/contracts/access';
4040
import { FactoryDeployer } from '../utils/FactoryDeployer';
41-
import config from '../utils/config';
41+
import config, { isArbitrumChainId, isArbitrumSepoliaChainId } from '../utils/config';
4242
import { getDeployerAndOwnerSigners } from '../utils/deploy-tools';
4343
import {
4444
getFunctionSelectors,
@@ -93,7 +93,8 @@ export default async function deploy() {
9393
const iexecLibOrders = {
9494
['contracts/libs/IexecLibOrders_v5.sol:IexecLibOrders_v5']: iexecLibOrdersAddress,
9595
};
96-
const isArbitrumMainnet = (await ethers.provider.getNetwork()).chainId === 42161n;
96+
const isArbitrumMainnetOrSepolia =
97+
isArbitrumChainId(chainId) || isArbitrumSepoliaChainId(chainId);
9798
const facets = [
9899
new IexecAccessorsABILegacyFacet__factory(),
99100
new IexecCategoryManagerFacet__factory(),
@@ -106,7 +107,7 @@ export default async function deploy() {
106107
new IexecPoco1Facet__factory(iexecLibOrders),
107108
new IexecPoco2Facet__factory(),
108109
new IexecPocoAccessorsFacet__factory(iexecLibOrders),
109-
...(!isArbitrumMainnet
110+
...(!isArbitrumMainnetOrSepolia
110111
? [
111112
new IexecPocoBoostFacet__factory(iexecLibOrders), // not deployed on Arbitrum mainnet
112113
new IexecPocoBoostAccessorsFacet__factory(), // not deployed on Arbitrum mainnet

scripts/upgrades/v6.1.0-bulk-processing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ used nowhere. They are duplicate of other existing functions:
2323
- `KITTY_RATIO()`
2424
- `REVEAL_DEADLINE_RATIO()`
2525
- `WORKERPOOL_STAKE_RATIO()`
26+
- Remove Boost facets from Arbitrum Sepolia to have the same setup on testnet and mainnet.
2627
- Add functions `viewApp`, `viewDataset`, and `viewWorkerpool` to read asset's details in a single transaction.
2728
- Add function `assertDatasetDealCompatibility` to allow the SMS to check compatibility of Bulk orders with a given deal.
2829

scripts/upgrades/v6.1.0-bulk-processing.ts

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
removeFunctionsFromDiamond,
1414
} from '../../utils/proxy-tools';
1515
import { tryVerify } from '../verify';
16-
import { isArbitrumFork } from '../../utils/config';
16+
import { isArbitrumChainId, isArbitrumSepoliaChainId } from '../../utils/config';
1717

1818
async function main() {
1919
console.log('Performing bulk processing upgrade...');
@@ -52,7 +52,21 @@ async function main() {
5252
factory: null,
5353
},
5454
];
55-
55+
if (isArbitrumSepoliaChainId(chainId)) {
56+
// Remove Boost facets on Arbitrum Sepolia.
57+
facetsToRemove.push(
58+
{
59+
name: 'IexecPocoBoostAccessorsFacet',
60+
address: '0xa23ABb680ecc9D2A51a0CcDE88604552340786Ae',
61+
factory: null,
62+
},
63+
{
64+
name: 'IexecPocoBoostFacet',
65+
address: '0x248df8EFE953B39f965e5C7272283096d20f5956',
66+
factory: null,
67+
},
68+
);
69+
}
5670
const facetsToAdd: FacetDetails[] = [
5771
{
5872
name: 'IexecPoco1Facet',
@@ -65,18 +79,14 @@ async function main() {
6579
factory: new IexecPocoAccessorsFacet__factory(iexecLibOrders),
6680
},
6781
];
82+
await deployFacets(deployer, chainId, facetsToAdd); // Adds deployed addresses to `facetsToAdd`.
6883
await printOnchainProxyFunctions(proxyAddress);
69-
// This function adds the address of each deployed facet to `facetsToAdd` array.
70-
await deployFacets(deployer, chainId, facetsToAdd);
7184
await removeFacetsFromDiamond(proxyAddress, proxyOwner, facetsToRemove);
72-
await printOnchainProxyFunctions(proxyAddress);
73-
if (isArbitrumFork() || chainId == 42161n) {
74-
// Remove these functions from Arbitrum Mainnet without removing
75-
// their facet completely.
85+
if (isArbitrumChainId(chainId)) {
86+
// Remove these functions from Arbitrum Mainnet without completely removing their facet.
7687
// On Arbitrum Mainnet, they were deployed in `IexecAccessorsABILegacyFacet`.
7788
// On Arbitrum Sepolia, they were deployed in `IexecAccessorsFacet` so no need
78-
// to remove them manually since they are automatically removed when executing
79-
// `removeFacetsFromDiamond`.
89+
// to remove them manually since the facet is removed in `removeFacetsFromDiamond`.
8090
const functionSignatures = [
8191
FunctionFragment.from('function CONTRIBUTION_DEADLINE_RATIO() view returns (uint256)'),
8292
FunctionFragment.from('function FINAL_DEADLINE_RATIO() view returns (uint256)'),
@@ -88,14 +98,12 @@ async function main() {
8898
FunctionFragment.from('function WORKERPOOL_STAKE_RATIO() view returns (uint256)'),
8999
];
90100
await removeFunctionsFromDiamond(proxyAddress, proxyOwner, functionSignatures);
91-
await printOnchainProxyFunctions(proxyAddress);
92101
}
93-
// TODO remove boost from Arbitrum Sepolia
102+
await printOnchainProxyFunctions(proxyAddress);
94103
await linkFacetsToDiamond(proxyAddress, proxyOwner, facetsToAdd);
95104
await printOnchainProxyFunctions(proxyAddress);
96105
console.log('Upgrade performed successfully!');
97-
// TODO pass only name as argument and get address from deployments.
98-
await tryVerify(facetsToAdd as { name: string; address: string }[]);
106+
await tryVerify(facetsToAdd.map((facet) => facet.name));
99107
}
100108

101109
if (require.main === module) {

scripts/verify.ts

Lines changed: 26 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
// SPDX-FileCopyrightText: 2024-2025 IEXEC BLOCKCHAIN TECH <[email protected]>
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import fs from 'fs';
54
import hre, { deployments } from 'hardhat';
6-
import path from 'path';
7-
8-
export interface ContractToVerify {
9-
name: string;
10-
address: string;
11-
constructorArguments?: any[];
12-
}
5+
import { Deployment } from 'hardhat-deploy/dist/types';
136

147
/**
158
* Verifies contracts on block explorer (e.g., Etherscan, Arbiscan).
@@ -18,7 +11,7 @@ export interface ContractToVerify {
1811
* @param contracts - Optional array of specific contracts to verify. If not provided,
1912
* will verify all contracts from the deployments/{network} directory.
2013
*/
21-
async function verify(contracts?: ContractToVerify[]): Promise<void> {
14+
async function verify(contractNames?: string[]): Promise<void> {
2215
const skippedNetworks: string[] = [
2316
'hardhat',
2417
'localhost',
@@ -30,34 +23,31 @@ async function verify(contracts?: ContractToVerify[]): Promise<void> {
3023
console.log(`\nSkipping verification on development network: ${hre.network.name}`);
3124
return;
3225
}
33-
34-
const contractsToVerify =
35-
contracts && contracts.length > 0 ? contracts : await getContractsFromDeployments();
36-
26+
let contracts: { [name: string]: Deployment } = {};
27+
if (contractNames) {
28+
// Get deployments of the specified contract names.
29+
for (const name of contractNames) {
30+
contracts[name] = await deployments.get(name);
31+
}
32+
} else {
33+
// If no specific contract names provided, verify all deployments.
34+
contracts = await deployments.all();
35+
contractNames = Object.keys(contracts);
36+
}
3737
console.log('\n=== Verifying contracts on block explorer ===');
38-
console.log(`Contracts to verify: ${contractsToVerify.map((c) => c.name).join(', ')}`);
38+
console.log(`Contracts to verify: ${contractNames.join(', ')}`);
3939
console.log('Waiting for block explorer to index the contracts...');
40-
await new Promise((resolve) => setTimeout(resolve, 60000));
41-
42-
for (const contract of contractsToVerify) {
40+
await new Promise((resolve) => setTimeout(resolve, 60000)); // 60s
41+
for (const name of contractNames) {
4342
try {
43+
const contract = contracts[name];
4444
await hre.run('verify:verify', {
4545
address: contract.address,
46-
constructorArguments: contract.constructorArguments || [],
46+
constructorArguments: contract.args,
4747
});
48-
console.log(`${contract.name} verified successfully`);
48+
console.log(`${name} verified successfully`);
4949
} catch (error: any) {
50-
console.error(`Error verifying ${contract.name}:`, error.message || error);
51-
if (
52-
typeof error.message === 'string' &&
53-
error.message.includes('has') &&
54-
error.message.includes('parameters but') &&
55-
error.message.includes('arguments were provided')
56-
) {
57-
console.error(
58-
`${contract.name} requires constructor arguments. Please add them to the deployment artifact.`,
59-
);
60-
}
50+
console.error(`Error verifying ${name}:`, error.message || error);
6151
}
6252
}
6353
console.log('\nVerification completed!');
@@ -69,46 +59,17 @@ async function verify(contracts?: ContractToVerify[]): Promise<void> {
6959
*
7060
* @param contracts - Optional array of specific contracts to verify.
7161
*/
72-
export async function tryVerify(contracts?: ContractToVerify[]): Promise<void> {
62+
export async function tryVerify(contractNames?: string[]): Promise<void> {
7363
try {
74-
await verify(contracts);
64+
await verify(contractNames);
7565
} catch (error) {
7666
console.error('Verification failed, but continuing with deployment:', error);
7767
}
7868
}
7969

80-
/**
81-
* Gets contracts to verify from deployments directory.
82-
*/
83-
async function getContractsFromDeployments(): Promise<ContractToVerify[]> {
84-
const jsonExtension = '.json';
85-
const contractNames = fs
86-
.readdirSync(path.resolve(__dirname, `../deployments/${hre.network.name}`))
87-
.filter((file) => file.endsWith(jsonExtension))
88-
.map((filePath) => filePath.replace(jsonExtension, ''));
89-
90-
if (contractNames.length === 0) {
91-
console.log(`\nNo contracts to verify on network: ${hre.network.name}`);
92-
return [];
93-
}
94-
95-
const contracts: ContractToVerify[] = [];
96-
for (const contractName of contractNames) {
97-
const deployment = await deployments.get(contractName);
98-
contracts.push({
99-
name: contractName,
100-
address: deployment.address,
101-
constructorArguments: deployment.args || [],
102-
});
103-
}
104-
return contracts;
105-
}
106-
10770
if (require.main === module) {
108-
verify()
109-
.then(() => process.exit(0))
110-
.catch((error) => {
111-
console.error(error);
112-
process.exit(1);
113-
});
71+
verify().catch((error) => {
72+
console.error(error);
73+
process.exit(1);
74+
});
11475
}

utils/config.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ export function isNativeChain(chain?: ChainConfig) {
1313
return false;
1414
}
1515

16+
export function isFork() {
17+
return isLocalFork() || isArbitrumSepoliaFork() || isArbitrumFork();
18+
}
19+
20+
// TODO remove or rename this function.
1621
export function isLocalFork() {
1722
return process.env.LOCAL_FORK === 'true';
1823
}
@@ -21,10 +26,26 @@ export function isArbitrumSepoliaFork() {
2126
return process.env.ARBITRUM_SEPOLIA_FORK === 'true';
2227
}
2328

29+
/**
30+
* Checks if the given chain ID is for the Arbitrum Sepolia network.
31+
* It could be a fork or the actual network.
32+
*/
33+
export function isArbitrumSepoliaChainId(chainId: bigint) {
34+
return chainId === 421614n;
35+
}
36+
2437
export function isArbitrumFork() {
2538
return process.env.ARBITRUM_FORK === 'true';
2639
}
2740

41+
/**
42+
* Checks if the given chain ID is for the Arbitrum mainnet network.
43+
* It could be a fork or the actual network.
44+
*/
45+
export function isArbitrumChainId(chainId: bigint) {
46+
return chainId === 42161n;
47+
}
48+
2849
/**
2950
* Get the config of the current chain or throw if it is not defined.
3051
*/

utils/proxy-tools.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
Ownable__factory,
3030
} from '../typechain';
3131
import { getBaseNameFromContractFactory, getDeployerAndOwnerSigners } from '../utils/deploy-tools';
32-
import { getChainConfig, isArbitrumFork, isArbitrumSepoliaFork } from './config';
32+
import { getChainConfig, isFork } from './config';
3333
import { FactoryDeployer } from './FactoryDeployer';
3434

3535
const POCO_STORAGE_LOCATION = '0x5862653c6982c162832160cf30593645e8487b257e44d77cdd6b51eee2651b00';
@@ -182,7 +182,7 @@ export async function printOnchainProxyFunctions(diamondProxyAddress: string) {
182182
totalFunctions += facet.functionSelectors.length;
183183
});
184184
console.log(
185-
`Onchain diamond proxy has ${facetsOnchain.length} facets and ${totalFunctions} total functions:`,
185+
`\nOnchain diamond proxy has ${facetsOnchain.length} facets and ${totalFunctions} total functions:`,
186186
);
187187
let i = 0;
188188
for (const facet of facetsOnchain) {
@@ -201,7 +201,7 @@ export async function printOnchainProxyFunctions(diamondProxyAddress: string) {
201201
*/
202202
export async function getUpgradeContext() {
203203
const { chainId, name: networkName } = await ethers.provider.getNetwork();
204-
console.log(`Network: ${networkName} (${chainId})`);
204+
console.log(`Network: ${networkName} (${chainId}) (isFork: ${isFork()})`);
205205
const { deployer, owner } = await getDeployerAndOwnerSigners();
206206
console.log('Deployer:', deployer.address);
207207
console.log('Owner:', owner.address);
@@ -222,10 +222,7 @@ export async function getUpgradeContext() {
222222
const proxyOnchainOwner = await Ownable__factory.connect(proxyAddress, owner).owner();
223223
console.log(`Diamond proxy onchain owner: ${proxyOnchainOwner}`);
224224
// Use impersonated signer for forked chains, otherwise use the real owner signer.
225-
const proxyOwner =
226-
isArbitrumSepoliaFork() || isArbitrumFork()
227-
? await ethers.getImpersonatedSigner(proxyOnchainOwner)
228-
: owner;
225+
const proxyOwner = isFork() ? await ethers.getImpersonatedSigner(proxyOnchainOwner) : owner;
229226
return {
230227
chainId,
231228
deployer,

0 commit comments

Comments
 (0)