Skip to content

Commit db9c7e3

Browse files
authored
chore: Add upgrade reports (#292)
1 parent 060014e commit db9c7e3

File tree

5 files changed

+154
-21
lines changed

5 files changed

+154
-21
lines changed

.github/workflows/upgrade-facets.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# This is a template workflow for upgrading PoCo facets.
2-
# Update the script path for each specific upgrade.
2+
# Update the script path (UPGRADE_SCRIPT environment variable) for each specific upgrade.
3+
34
name: Upgrade PoCo Facets
45

56
on:
@@ -32,6 +33,7 @@ jobs:
3233
contents: write # Required to commit artifacts.
3334
pull-requests: write # Required to create pull requests.
3435
env:
36+
UPGRADE_SCRIPT: 'v6.1.0-bulk-processing.ts' # Update this for each specific upgrade.
3537
# For commit action
3638
COMMIT_MESSAGE: 'chore: Save upgrade artifacts - ${{ inputs.network }} (runId:${{ github.run_id }})'
3739
GHA_BOT_NAME: 'GitHub Actions Bot'
@@ -65,7 +67,7 @@ jobs:
6567
elif [ "${{ inputs.network }}" == "arbitrum" ]; then
6668
export ARBITRUM_FORK=true
6769
fi
68-
npx hardhat run scripts/upgrades/apply-v6.1.0-upgrade.ts --network hardhat
70+
npx hardhat run scripts/upgrades/${{ env.UPGRADE_SCRIPT }} --network hardhat
6971
7072
- name: Execute upgrade on live network
7173
if: inputs.dry_run == false
@@ -76,7 +78,7 @@ jobs:
7678
RPC_URL: ${{ secrets.RPC_URL }}
7779
EXPLORER_API_KEY: ${{ secrets.EXPLORER_API_KEY }}
7880
run: |
79-
npx hardhat run scripts/upgrades/apply-v6.1.0-upgrade.ts --network ${{ inputs.network }}
81+
npx hardhat run scripts/upgrades/${{ env.UPGRADE_SCRIPT }} --network ${{ inputs.network }}
8082
8183
- name: Push artifacts to the current branch
8284
if: inputs.dry_run == false && github.ref != 'refs/heads/main'

scripts/upgrades/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# PoCo Smart Contracts Upgrade Guide
2+
3+
This document explains the recommended steps for creating and applying
4+
a safe, traceable, and reproducible upgrade to the PoCo Diamond proxy.
5+
6+
## Upgrade Steps
7+
8+
0. **Ensure all tests pass**:<br>
9+
Run the full test suite to make sure everything is working before starting an upgrade.
10+
11+
1. **Create a new upgrade script**:<br>
12+
Name the script using the version and upgrade name format: `vX.Y.Z-upgrade-name.ts`.
13+
14+
2. **Create a corresponding Markdown report**:<br>
15+
Copy the template file `v0.0.0-template.md` and rename it to match the script: `vX.Y.Z-upgrade-name.md`.
16+
17+
3. **Update GitHub Actions**:<br>
18+
Modify `upgrade-facets.yml` workflow to call the new upgrade script.
19+
20+
4. **Upgrade on Testnet**:
21+
- ⚠️ Always upgrade on the testnet first.
22+
- Trigger the upgrade workflow on GitHub and choose the testnet network.
23+
- Start with a **dry run** to simulate the upgrade.
24+
- Once verified, apply the upgrade on the live testnet.
25+
26+
5. **Upgrade on Mainnet**:
27+
- Trigger the upgrade workflow on GitHub and choose the mainnet network.
28+
- Perform a dry run first.
29+
- Apply the upgrade on the mainnet.
30+
- Merge the artifacts PR after successful execution.
31+
32+
6. **Update upgrade report**:<br>
33+
Fill in all required information in `vX.Y.Z-upgrade-name.ts` (tx hashes, logs, ...).
34+
35+
7. **Create a release**
36+
- Use **Release Please** to tag the upgrade version and create the release on GitHub.
37+
38+
39+
Following these steps ensures upgrades are **safe, traceable, and reproducible**.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Upgrade v0.0.0 - Awesome Feature
2+
3+
- **Date**: YYYY-MM-DD
4+
- **Git tag**: [vX.Y.Z](https://github.com/iExecBlockchainComputing/PoCo/releases/tag/<tag>)
5+
- **Upgrade script**: `./v0.0.0-awesome-feature.ts`
6+
- **Upgrade tx hash**:
7+
- **Testnet**: [0xabc...def](https://arbiscan.io/tx/<hash>)
8+
- **Mainnet**: [0xabc...def](https://arbiscan.io/tx/<hash>)
9+
- **Upgrade GitHub Action run**:
10+
- **Testnet**: [runId](https://github.com/iExecBlockchainComputing/PoCo/actions/runs/<runId>)
11+
- **Mainnet**: [runId](https://github.com/iExecBlockchainComputing/PoCo/actions/runs/<runId>)
12+
13+
## Summary of changes
14+
15+
- Add awesome feature
16+
- Remove deprecated function
17+
- Rename badly named getter
18+
19+
## Deployment logs
20+
21+
```
22+
TODO
23+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Upgrade v6.1.0 - Bulk Processing
2+
3+
- **Date**: 2025-10-16
4+
- **Git tag**: [v6.1.0](https://github.com/iExecBlockchainComputing/PoCo/releases/tag/v6.1.0)
5+
- **Upgrade script**: `./v6.1.0-bulk-processing.ts`
6+
- **Upgrade tx hash**: // TODO
7+
- **Testnet**: [0xabc...def](https://arbiscan.io/tx/<hash>)
8+
- **Mainnet**: [0xabc...def](https://arbiscan.io/tx/<hash>)
9+
- **Upgrade GitHub Action run**: // TODO
10+
- **Testnet**: [runId](https://github.com/iExecBlockchainComputing/PoCo/actions/runs/<runId>)
11+
- **Mainnet**: [runId](https://github.com/iExecBlockchainComputing/PoCo/actions/runs/<runId>)
12+
13+
## Summary of changes
14+
15+
- Add functions `viewApp`, `viewDataset`, and `viewWorkerpool` to read asset's details in a single transaction.
16+
- Add function `assertDatasetDealCompatibility` to allow the SMS to check compatibility of Bulk orders with a given deal.
17+
18+
## Deployment logs
19+
20+
```
21+
TODO
22+
```

scripts/upgrades/apply-v6.1.0-upgrade.ts renamed to scripts/upgrades/v6.1.0-bulk-processing.ts

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

4+
import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers';
45
import { ZeroAddress } from 'ethers';
56
import { ethers } from 'hardhat';
67
import { FacetCutAction } from 'hardhat-deploy/dist/types';
7-
import type { IDiamond } from '../../typechain';
8+
import type { DiamondCutFacet, IDiamond } from '../../typechain';
89
import {
910
DiamondCutFacet__factory,
1011
DiamondLoupeFacet__factory,
@@ -19,7 +20,7 @@ import { linkContractToProxy } from '../../utils/proxy-tools';
1920
import { tryVerify } from '../verify';
2021
import { printFunctions } from './upgrade-helper';
2122

22-
(async () => {
23+
async function main() {
2324
console.log('Deploying and updating IexecPocoAccessorsFacet & IexecPoco1Facet...');
2425

2526
const { deployer, owner } = await getDeployerAndOwnerSigners();
@@ -50,12 +51,49 @@ import { printFunctions } from './upgrade-helper';
5051
proxyOwnerSigner,
5152
);
5253

53-
console.log('\n=== Step 1: Deploying all new facets ===');
54-
const factoryDeployer = new FactoryDeployer(deployer, chainId);
54+
const { iexecPocoAccessorsFacet, newIexecPoco1Facet } = await deployNewFacets(
55+
deployer,
56+
chainId,
57+
deploymentOptions.IexecLibOrders_v5,
58+
);
5559
const iexecLibOrders = {
5660
['contracts/libs/IexecLibOrders_v5.sol:IexecLibOrders_v5']:
5761
deploymentOptions.IexecLibOrders_v5,
5862
};
63+
const iexecPocoAccessorsFacetFactory = new IexecPocoAccessorsFacet__factory(iexecLibOrders);
64+
const newIexecPoco1FacetFactory = new IexecPoco1Facet__factory(iexecLibOrders);
65+
await removeOldFacetsFromDiamond(diamondProxyAsOwner, chainId);
66+
await linkNewFacetsToDiamond(
67+
diamondProxyAsOwner,
68+
iexecPocoAccessorsFacet,
69+
newIexecPoco1Facet,
70+
iexecPocoAccessorsFacetFactory,
71+
newIexecPoco1FacetFactory,
72+
);
73+
await tryVerify([
74+
{
75+
name: 'IexecPocoAccessorsFacet',
76+
address: iexecPocoAccessorsFacet,
77+
constructorArguments: [],
78+
},
79+
{
80+
name: 'IexecPoco1Facet',
81+
address: newIexecPoco1Facet,
82+
constructorArguments: [],
83+
},
84+
]);
85+
}
86+
87+
async function deployNewFacets(
88+
deployer: SignerWithAddress,
89+
chainId: bigint,
90+
iexecLibOrdersAddress: string,
91+
) {
92+
console.log('\n=== Step 1: Deploying all new facets ===');
93+
const factoryDeployer = new FactoryDeployer(deployer, chainId);
94+
const iexecLibOrders = {
95+
['contracts/libs/IexecLibOrders_v5.sol:IexecLibOrders_v5']: iexecLibOrdersAddress,
96+
};
5997

6098
console.log('Deploying new IexecPocoAccessorsFacet...');
6199
const iexecPocoAccessorsFacetFactory = new IexecPocoAccessorsFacet__factory(iexecLibOrders);
@@ -66,12 +104,16 @@ import { printFunctions } from './upgrade-helper';
66104
console.log('Deploying new IexecPoco1Facet...');
67105
const newIexecPoco1FacetFactory = new IexecPoco1Facet__factory(iexecLibOrders);
68106
const newIexecPoco1Facet = await factoryDeployer.deployContract(newIexecPoco1FacetFactory);
107+
return { iexecPocoAccessorsFacet, newIexecPoco1Facet };
108+
}
69109

110+
async function removeOldFacetsFromDiamond(diamondProxyAsOwner: DiamondCutFacet, chainId: bigint) {
111+
const diamondProxyAddress = await diamondProxyAsOwner.getAddress();
70112
console.log(
71113
'\n=== Step 2: Remove old facets (IexecAccessorsFacet & IexecPocoAccessorsFacet & IexecPoco1Facet) ===',
72114
);
73115

74-
const diamondLoupe = DiamondLoupeFacet__factory.connect(diamondProxyAddress, owner);
116+
const diamondLoupe = DiamondLoupeFacet__factory.connect(diamondProxyAddress, ethers.provider);
75117
const currentFacets = await diamondLoupe.facets();
76118

77119
console.log('\nCurrent facets in diamond:');
@@ -142,6 +184,16 @@ import { printFunctions } from './upgrade-helper';
142184
console.log('Diamond functions after removing old facets:');
143185
await printFunctions(diamondProxyAddress);
144186
}
187+
}
188+
189+
async function linkNewFacetsToDiamond(
190+
diamondProxyAsOwner: DiamondCutFacet,
191+
iexecPocoAccessorsFacet: string,
192+
newIexecPoco1Facet: string,
193+
iexecPocoAccessorsFacetFactory: IexecPocoAccessorsFacet__factory,
194+
newIexecPoco1FacetFactory: IexecPoco1Facet__factory,
195+
) {
196+
const diamondProxyAddress = await diamondProxyAsOwner.getAddress();
145197
console.log('\n=== Step 3: Updating diamond proxy with all new facets ===');
146198
console.log('Adding new IexecPocoAccessorsFacet...');
147199
await linkContractToProxy(
@@ -161,16 +213,11 @@ import { printFunctions } from './upgrade-helper';
161213
console.log('\nUpgrade completed successfully!');
162214
console.log(`New IexecPocoAccessorsFacet deployed at: ${iexecPocoAccessorsFacet}`);
163215
console.log(`New IexecPoco1Facet deployed at: ${newIexecPoco1Facet}`);
164-
await tryVerify([
165-
{
166-
name: 'IexecPocoAccessorsFacet',
167-
address: iexecPocoAccessorsFacet,
168-
constructorArguments: [],
169-
},
170-
{
171-
name: 'IexecPoco1Facet',
172-
address: newIexecPoco1Facet,
173-
constructorArguments: [],
174-
},
175-
]);
176-
})();
216+
}
217+
218+
if (require.main === module) {
219+
main().catch((error) => {
220+
console.error(error);
221+
process.exitCode = 1;
222+
});
223+
}

0 commit comments

Comments
 (0)