-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/fix subgraph indexing issue (#281)
acknowledge sharing contract upgrade-test fail
- Loading branch information
Showing
7 changed files
with
186 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/sharing-smart-contract/scripts/singleFunction/utils.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export const impersonate = async ({ rpcUrl, address }) => { | ||
await fetch(rpcUrl, { | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
method: 'hardhat_impersonateAccount', | ||
params: [address], | ||
id: 1, | ||
jsonrpc: '2.0', | ||
}), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
}; | ||
|
||
export const stopImpersonate = async ({ rpcUrl, address }) => { | ||
await fetch(rpcUrl, { | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
method: 'hardhat_stopImpersonatingAccount', | ||
params: [address], | ||
id: 1, | ||
jsonrpc: '2.0', | ||
}), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
}; |
84 changes: 84 additions & 0 deletions
84
packages/sharing-smart-contract/scripts/upgrade-local-fork.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* eslint-disable no-console */ | ||
import { getEnvironment } from '@iexec/dataprotector-environments'; | ||
import hre from 'hardhat'; | ||
import { POCO_PROTECTED_DATA_REGISTRY_ADDRESS, POCO_PROXY_ADDRESS } from '../config/config.js'; | ||
import { impersonate, stopImpersonate } from './singleFunction/utils.js'; | ||
|
||
const { ethers, upgrades } = hre; | ||
|
||
async function main() { | ||
const { ENV } = process.env; | ||
console.log(`using ENV: ${ENV}`); | ||
|
||
const rpcUrl = hre.network.config.url; | ||
console.log('rpcUrl', rpcUrl); | ||
|
||
const provider = new ethers.JsonRpcProvider(rpcUrl); | ||
|
||
const { dataprotectorSharingContractAddress, addOnlyAppWhitelistRegistryContractAddress } = getEnvironment(ENV); | ||
|
||
const adminAddress = await upgrades.erc1967.getAdminAddress(dataprotectorSharingContractAddress); | ||
console.log(`Proxy at ${dataprotectorSharingContractAddress} administered by ${adminAddress}`); | ||
|
||
const adminOwner = await new ethers.Contract( | ||
adminAddress, | ||
[ | ||
{ | ||
inputs: [], | ||
name: 'owner', | ||
outputs: [ | ||
{ | ||
internalType: 'address', | ||
name: '', | ||
type: 'address', | ||
}, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
], | ||
provider, | ||
).owner(); | ||
|
||
console.log(`admin contract owned by ${adminOwner}`); | ||
|
||
console.log('Starting upgrade with admin owner impersonation...'); | ||
|
||
const upgradeDeployer = new ethers.JsonRpcSigner(provider, adminOwner); | ||
await impersonate({ rpcUrl, address: adminOwner }); | ||
|
||
console.log('Deploying contracts with the account:', adminOwner); | ||
console.log(`Upgrading proxy at address: ${dataprotectorSharingContractAddress}`); | ||
|
||
const dataProtectorSharingConstructorArgs = [ | ||
POCO_PROXY_ADDRESS, | ||
POCO_PROTECTED_DATA_REGISTRY_ADDRESS, | ||
addOnlyAppWhitelistRegistryContractAddress, | ||
]; | ||
|
||
const DataProtectorSharingFactoryV2 = (await ethers.getContractFactory('DataProtectorSharing')).connect( | ||
upgradeDeployer, | ||
); | ||
|
||
const proxyUpgrade = await upgrades.upgradeProxy(dataprotectorSharingContractAddress, DataProtectorSharingFactoryV2, { | ||
kind: 'transparent', | ||
constructorArgs: dataProtectorSharingConstructorArgs, | ||
txOverrides: { gasPrice: 0 }, | ||
}); | ||
|
||
const upgradeTx = proxyUpgrade.deployTransaction; | ||
|
||
console.log(`Upgrade tx ${upgradeTx.hash}`); | ||
// wait for upgrade | ||
await upgradeTx.wait(); | ||
|
||
await stopImpersonate({ rpcUrl, address: adminAddress }); | ||
|
||
const implementationAddress = await upgrades.erc1967.getImplementationAddress(dataprotectorSharingContractAddress); | ||
console.log('New implementation address (DataProtectorSharing.sol):', implementationAddress); | ||
} | ||
|
||
main().catch(error => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
}); |
Oops, something went wrong.