Skip to content

Commit

Permalink
Feature/fix subgraph indexing issue (#281)
Browse files Browse the repository at this point in the history
acknowledge sharing contract upgrade-test fail
  • Loading branch information
PierreJeanjacquot authored Jun 7, 2024
2 parents 7446beb + 399419d commit dea977f
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 56 deletions.
24 changes: 10 additions & 14 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ steps:
echo "ABIs not up-to-date in packages/sdk, need to run 'npm run refresh-abis'"
exit 1
fi
depends_on:
- cat-drone-consider
- name: check-subgraph-abi
image: node:18.19
Expand All @@ -35,8 +33,6 @@ steps:
echo "ABIs not up-to-date in packages/subgraph, need to run 'npm run refresh-abis'"
exit 1
fi
depends_on:
- cat-drone-consider
- name: check-dapp-abi
image: node:18.19
Expand All @@ -48,8 +44,6 @@ steps:
echo "ABIs not up-to-date in protected-data-delivery-dapp/abis, need to run 'npm run refresh-abis'"
exit 1
fi
depends_on:
- cat-drone-consider
---
# deploy DataProtector smart contract in prod, dev or staging
Expand Down Expand Up @@ -296,6 +290,7 @@ steps:
depends_on:
- install-deps
- install-forge
- compile
- bellecour-fork-healthy

- name: forge-tests
Expand All @@ -307,6 +302,7 @@ steps:
depends_on:
- install-deps
- install-forge
- compile
- bellecour-fork-healthy

- name: smart-contract-dev-deployment
Expand Down Expand Up @@ -912,7 +908,7 @@ steps:
from_secret: nexus-password
tags:
- dev
- "dev-${DRONE_COMMIT}"
- 'dev-${DRONE_COMMIT}'
when:
branch:
- develop
Expand Down Expand Up @@ -1305,8 +1301,8 @@ steps:
POSTGRES_USER: graphnode
POSTGRES_PASSWORD: password
POSTGRES_DB: graphnode-db
PGDATA: "/var/lib/postgresql/data"
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C"
PGDATA: '/var/lib/postgresql/data'
POSTGRES_INITDB_ARGS: '-E UTF8 --locale=C'

- name: graphnode-postgres-healthy
image: bash
Expand Down Expand Up @@ -1353,7 +1349,7 @@ steps:
environment:
TZ: Europe/Paris
IEXEC_SMS_BLOCKCHAIN_NODE_ADDRESS: http://bellecour-fork:8545
IEXEC_HUB_ADDRESS: "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f"
IEXEC_HUB_ADDRESS: '0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f'
IEXEC_TEE_WORKER_PRE_COMPUTE_IMAGE: docker.io/iexechub/tee-worker-pre-compute:7.1.0-sconify-5.3.15-debug
IEXEC_TEE_WORKER_PRE_COMPUTE_FINGERPRINT: 9f0f782d6edc611baa23ca0978f555ee58ea70e092640c961e75c25e9e4b0f22
IEXEC_TEE_WORKER_PRE_COMPUTE_HEAP_SIZE_GB: 4
Expand All @@ -1362,7 +1358,7 @@ steps:
IEXEC_TEE_WORKER_POST_COMPUTE_HEAP_SIZE_GB: 4
IEXEC_IGNORED_SGX_ADVISORIES: INTEL-SA-00161,INTEL-SA-00289,INTEL-SA-00334,INTEL-SA-00381,INTEL-SA-00389,INTEL-SA-00220,INTEL-SA-00270,INTEL-SA-00293,INTEL-SA-00320,INTEL-SA-00329,INTEL-SA-00477
IEXEC_SCONE_TOLERATED_INSECURE_OPTIONS: debug-mode,hyperthreading,outdated-tcb
IEXEC_SMS_DISPLAY_DEBUG_SESSION: "true"
IEXEC_SMS_DISPLAY_DEBUG_SESSION: 'true'
IEXEC_SCONE_CAS_HOST: foo
IEXEC_SMS_IMAGE_LAS_IMAGE: foo
expose:
Expand All @@ -1383,7 +1379,7 @@ steps:
environment:
IEXEC_PRIVATE_CHAIN_ADDRESS: http://bellecour-fork:8545
IEXEC_PUBLIC_CHAIN_ADDRESS: http://bellecour-fork:8545
IEXEC_HUB_ADDRESS: "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f"
IEXEC_HUB_ADDRESS: '0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f'
MONGO_HOST: result-proxy-mongo
MONGO_PORT: 13202
IEXEC_IPFS_HOST: ipfs
Expand Down Expand Up @@ -1429,8 +1425,8 @@ steps:
CHAINS: BELLECOUR_FORK
BELLECOUR_FORK_ETH_RPC_HOST: http://bellecour-fork:8545
BELLECOUR_FORK_CHAIN_ID: 134
BELLECOUR_FORK_IS_NATIVE: "true"
BELLECOUR_FORK_IEXEC_ADDRESS: "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f"
BELLECOUR_FORK_IS_NATIVE: 'true'
BELLECOUR_FORK_IEXEC_ADDRESS: '0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f'
MONGO_HOST: market-mongo
REDIS_HOST: market-redis
RATE_LIMIT_MAX: 10000
Expand Down
14 changes: 14 additions & 0 deletions packages/sharing-smart-contract/.drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ steps:
depends_on:
- install-deps
- install-forge
- compile
- bellecour-fork-healthy

- name: upgrade-test
image: node:18.19
commands:
- cd packages/sharing-smart-contract
- export PATH="$PATH:/drone/src/.foundry/bin"
- npm run upgrade-local-fork -- --network ci-bellecour-fork
depends_on:
- install-deps
- install-forge
- compile
- bellecour-fork-healthy

- name: forge-tests
Expand All @@ -109,4 +122,5 @@ steps:
depends_on:
- install-deps
- install-forge
- compile
- bellecour-fork-healthy
3 changes: 3 additions & 0 deletions packages/sharing-smart-contract/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ coverage.json
.smart-contract-address
.constructor-args-params

# openzeppelin local-fork
.openzeppelin/local-fork

# Forge
out
cache_forge
Expand Down
1 change: 1 addition & 0 deletions packages/sharing-smart-contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"deploy": "npm run compile && hardhat run ./scripts/deploy.js",
"update-env": "hardhat run ./scripts/updateEnv.js",
"upgrade": "hardhat run ./scripts/upgrade.js",
"upgrade-local-fork": "mkdir -p .openzeppelin/local-fork && cp -r .openzeppelin/prod/. .openzeppelin/local-fork && MANIFEST_DEFAULT_DIR=.openzeppelin/local-fork ENV=prod hardhat run ./scripts/upgrade-local-fork.js",
"fillContracts": "hardhat run ./scripts/fillCollection.js",
"test": "hardhat test --bail",
"test:fuzzing": "rimraf ~/.foundry/cache/rpc/* && forge test -vvvv",
Expand Down
29 changes: 29 additions & 0 deletions packages/sharing-smart-contract/scripts/singleFunction/utils.js
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 packages/sharing-smart-contract/scripts/upgrade-local-fork.js
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;
});
Loading

0 comments on commit dea977f

Please sign in to comment.