Skip to content

Commit

Permalink
chore: Check the contracts are upgradeable
Browse files Browse the repository at this point in the history
  • Loading branch information
alainncls committed Nov 21, 2023
1 parent bd24d77 commit 20e6cc9
Show file tree
Hide file tree
Showing 18 changed files with 232 additions and 189 deletions.
39 changes: 37 additions & 2 deletions .github/workflows/smart-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,43 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Check contracts upgradeability
run: pnpm run check:upgradeability:ci
- name: Check contracts implementations
run: pnpm run check:implementations

- name: Create Linea testnet env file
run: |
cp ./env/.env.linea-goerli .env
echo INFURA_KEY=${{ secrets.INFURA_KEY }} >> .env
- name: Check contracts upgradeability on Linea testnet
run: pnpm run check:upgradeability linea-goerli

- name: Create Linea mainnet env file
run: |
rm .env
cp ./env/.env.linea .env
echo INFURA_KEY=${{ secrets.INFURA_KEY }} >> .env
- name: Check contracts upgradeability on Linea mainnet
run: pnpm run check:upgradeability linea

- name: Create Arbitrum testnet env file
run: |
rm .env
cp ./env/.env.arbitrum-goerli .env
echo INFURA_KEY=${{ secrets.INFURA_KEY }} >> .env
- name: Check contracts upgradeability on Arbitrum testnet
run: pnpm run check:upgradeability arbitrum-goerli

- name: Create Arbitrum mainnet env file
run: |
rm .env
cp ./env/.env.arbitrum .env
echo INFURA_KEY=${{ secrets.INFURA_KEY }} >> .env
- name: Check contracts upgradeability on Arbitrum mainnet
run: pnpm run check:upgradeability arbitrum

- name: Add upgradeability summary
run: |
Expand Down
41 changes: 0 additions & 41 deletions contracts/.env.example

This file was deleted.

5 changes: 2 additions & 3 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,9 @@ the last upgrade or the first deployment.
## Start upgrading

1. Check that your `.env` file contains the address of all the proxies
2. Upgrade only the implementations that changed since the last upgrade via the `pnpm run upgrade:all NETWORK_NAME`
command
2. Upgrade only the implementations that changed since the last upgrade via the `pnpm run upgrade NETWORK_NAME` command
3. _Optional_: Upgrade all the implementations by forcing their re-deployment via the
`pnpm run upgrade:all:force NETWORK_NAME` command
`pnpm run upgrade:force NETWORK_NAME` command

:warning: Note: Forcing the redeployment of all the implementations is more expensive!

Expand Down
14 changes: 14 additions & 0 deletions contracts/env/.env.arbitrum
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Config
INFURA_KEY=

PRIVATE_KEY_ARBITRUM_MAINNET=0000000000000000000000000000000000000000000000000000000000000001

ARBISCAN_API_KEY=

# Contracts
ROUTER_ADDRESS=0xa77196867bB03D04786EF636cDdD82f37A1248a9
ATTESTATION_REGISTRY_ADDRESS=0x335E9719e8eFE2a19A92E07BC4836160fC31cd7C
MODULE_REGISTRY_ADDRESS=0x3acF4daAB6cbc01546Dd4a96c9665B398d48A4ba
PORTAL_REGISTRY_ADDRESS=0x4042D0A54f997EE3a1b0F51e4813654199BFd8bD
SCHEMA_REGISTRY_ADDRESS=0xE96072F46EA0e42e538762dDc0aFa4ED8AE6Ec27
ATTESTATION_READER_ADDRESS=0x324C060A26444c3fB9B93e03d31e8cfF4b1715C1
14 changes: 14 additions & 0 deletions contracts/env/.env.arbitrum-goerli
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Config
INFURA_KEY=

PRIVATE_KEY_ARBITRUM_TESTNET=0000000000000000000000000000000000000000000000000000000000000001

ARBISCAN_API_KEY=

# Contracts
ROUTER_ADDRESS=0x746390cB11913d8F93BDF8a974cFEC724039B3Cc
ATTESTATION_REGISTRY_ADDRESS=0xCD839595FdA5A8111d5E03D42d9D9af60ee67B66
MODULE_REGISTRY_ADDRESS=0x58EE79284bE65b217Db408A0991314f9Ae84348A
PORTAL_REGISTRY_ADDRESS=0x7d6a914C1e33C141CB4a5e0095c1075E5649aFB2
SCHEMA_REGISTRY_ADDRESS=0x129043e80e0B4C7da61a622df0912c31D3414AA7
ATTESTATION_READER_ADDRESS=0x055E7d488eCACf9f1B0B42659c331C037505D4a1
15 changes: 15 additions & 0 deletions contracts/env/.env.linea
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Config
INFURA_KEY=

PRIVATE_KEY_LINEA_MAINNET=0000000000000000000000000000000000000000000000000000000000000001

LINEASCAN_API_KEY=

# Contracts
ROUTER_ADDRESS=0x4d3a380A03f3a18A5dC44b01119839D8674a552E
PORTAL_REGISTRY_ADDRESS=0xd5d61e4ECDf6d46A63BfdC262af92544DFc19083
SCHEMA_REGISTRY_ADDRESS=0x0f95dCec4c7a93F2637eb13b655F2223ea036B59
MODULE_REGISTRY_ADDRESS=0xf851513A732996F22542226341748f3C9978438f
ATTESTATION_REGISTRY_ADDRESS=0x3de3893aa4Cdea029e84e75223a152FD08315138
ATTESTATION_READER_ADDRESS=0x40871e247CF6b8fd8794c9c56bB5c2b8a4FA3B6c
EAS_REGISTRY_ADDRESS=0xaEF4103A04090071165F78D45D83A0C0782c2B2a
16 changes: 16 additions & 0 deletions contracts/env/.env.linea-goerli
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Config
INFURA_KEY=

PRIVATE_KEY_LINEA_TESTNET=0000000000000000000000000000000000000000000000000000000000000001

LINEASCAN_API_KEY=

# Contracts
ROUTER_ADDRESS=0x736c78b2f2cBf4F921E8551b2acB6A5Edc9177D5
PORTAL_REGISTRY_ADDRESS=0x506f88a5Ca8D5F001f2909b029738A40042e42a6
SCHEMA_REGISTRY_ADDRESS=0xB2c4Da1f8F08A0CA25862509E5431289BE2b598B
MODULE_REGISTRY_ADDRESS=0x1a20b2CFA134686306436D2c9f778D7eC6c43A43
ATTESTATION_REGISTRY_ADDRESS=0xC765F28096F6121C2F2b82D35A4346280164428b
ATTESTATION_READER_ADDRESS=0x65c8294C7aF0f0bDDe51eF92AF850613bb629fc6
EAS_REGISTRY_ADDRESS=0xaEF4103A04090071165F78D45D83A0C0782c2B2a

27 changes: 12 additions & 15 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,36 @@ const config: HardhatUserConfig = {
hardhat: {},
"arbitrum-goerli": {
url: "https://goerli-rollup.arbitrum.io/rpc",
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
accounts:
process.env.PRIVATE_KEY_ARBITRUM_TESTNET !== undefined ? [process.env.PRIVATE_KEY_ARBITRUM_TESTNET] : [],
},
arbitrum: {
url: "https://arb1.arbitrum.io/rpc",
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
accounts:
process.env.PRIVATE_KEY_ARBITRUM_MAINNET !== undefined ? [process.env.PRIVATE_KEY_ARBITRUM_MAINNET] : [],
},
"linea-goerli": {
url: `https://linea-goerli.infura.io/v3/${process.env.INFURA_KEY ?? ""}`,
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
accounts: process.env.PRIVATE_KEY_LINEA_TESTNET !== undefined ? [process.env.PRIVATE_KEY_LINEA_TESTNET] : [],
},
linea: {
url: `https://linea-mainnet.infura.io/v3/${process.env.INFURA_KEY ?? ""}`,
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
sepolia: {
url: `https://sepolia.infura.io/v3/${process.env.INFURA_KEY ?? ""}`,
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
accounts: process.env.PRIVATE_KEY_LINEA_MAINNET !== undefined ? [process.env.PRIVATE_KEY_LINEA_MAINNET] : [],
},
"scroll-sepolia": {
url: "https://sepolia-rpc.scroll.io/" || "",
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
url: "https://sepolia-rpc.scroll.io/",
accounts: process.env.PRIVATE_KEY_SCROLL_TESTNET !== undefined ? [process.env.PRIVATE_KEY_SCROLL_TESTNET] : [],
},
},
paths: {
sources: "./src",
},
etherscan: {
apiKey: {
"arbitrum-goerli": process.env.ETHERSCAN_API_KEY ?? "",
arbitrum: process.env.ETHERSCAN_API_KEY ?? "",
"linea-goerli": process.env.ETHERSCAN_API_KEY ?? "",
linea: process.env.ETHERSCAN_API_KEY ?? "",
sepolia: process.env.ETHERSCAN_API_KEY ?? "",
"arbitrum-goerli": process.env.ARBISCAN_API_KEY ?? "",
arbitrum: process.env.ARBISCAN_API_KEY ?? "",
"linea-goerli": process.env.LINEASCAN_API_KEY ?? "",
linea: process.env.LINEASCAN_API_KEY ?? "",
"scroll-sepolia": process.env.SCROLL_API_KEY ?? "",
},
customChains: [
Expand Down
11 changes: 5 additions & 6 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@
],
"scripts": {
"build": "forge build",
"check:upgradeability": "npx hardhat run script/upgrade/checkUpgradeability.ts",
"check:upgradeability:ci": "cp .env.example .env && pnpm run check:upgradeability",
"check:upgradeable": "npx hardhat run script/upgrade/checkUpgradeable.ts --network",
"check:implementations": "npx hardhat run script/upgrade/checkImplementations.ts",
"check:upgradeability": "npx hardhat run script/upgrade/checkUpgradeability.ts --network",
"clean": "rm -rf lcov.info coverage artifacts cache_hardhat cache out typechain-types",
"decode": "npx hardhat run script/decode.ts",
"deploy:all": "npx hardhat run script/deploy/deployEverything.ts --network",
"deploy": "npx hardhat run script/deploy/deployEverything.ts --network",
"deploy:post": "npx hardhat run script/deploy/postDeployment.ts --network",
"encode": "npx hardhat run script/encode.ts",
"lint": "pnpm solhint \"{script,src,test}/**/*.sol\"",
"reimport": "npx hardhat run script/recreateNetworkFile.ts --network",
"test": "forge test",
"upgrade:all": "npx hardhat run script/upgrade/upgradeEverything.ts --network",
"upgrade:all:force": "npx hardhat run script/upgrade/forceUpgradeEverything.ts --network"
"upgrade": "npx hardhat run script/upgrade/upgradeEverything.ts --network",
"upgrade:force": "npx hardhat run script/upgrade/forceUpgradeEverything.ts --network"
},
"devDependencies": {
"@nomicfoundation/hardhat-ethers": "^3.0.4",
Expand Down
22 changes: 0 additions & 22 deletions contracts/script/deploy/deployIncorrectModule.ts

This file was deleted.

22 changes: 0 additions & 22 deletions contracts/script/deploy/deployMsgSenderModule.ts

This file was deleted.

17 changes: 13 additions & 4 deletions contracts/script/deploy/postDeployment.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ethers } from "hardhat";
import dotenv from "dotenv";
import { Contract } from "ethers";
import { SchemaRegistry } from "../../typechain-types";

dotenv.config({ path: "../.env" });

async function main() {
const proxyAddress = process.env.SCHEMA_REGISTRY_ADDRESS ?? "";
console.log("Creating relationship schema using schema registry, with proxy at", proxyAddress);
const schemaRegistry = await ethers.getContractAt("SchemaRegistry", proxyAddress);
console.log(`Creating canonical Schemas using the SchemaRegistry at ${proxyAddress}`);
const schemaRegistry: SchemaRegistry = await ethers.getContractAt("SchemaRegistry", proxyAddress);

await createSchema(
schemaRegistry,
Expand All @@ -23,21 +23,30 @@ async function main() {
"https://schema.org/Property",
"string namedGraph, bytes32 subject, string predicate, bytes32 object",
);
await createSchema(
schemaRegistry,
"Offchain",
"Represents a link to an offchain payload",
"https://schema.org/Property",
"(bytes32 schemaId, string uri)",
);
}

async function createSchema(
schemaRegistry: Contract,
schemaRegistry: SchemaRegistry,
schemaName: string,
schemaDescription: string,
schemaContext: string,
schemaString: string,
) {
const schemaId = await schemaRegistry.getIdFromSchemaString(schemaString);
const schemaExists = await schemaRegistry.isRegistered(schemaId);

if (!schemaExists) {
const tx = await schemaRegistry.createSchema(schemaName, schemaDescription, schemaContext, schemaString);
await tx.wait();
const schemaCreated = await schemaRegistry.isRegistered(schemaId);

if (schemaCreated) {
console.log(`Schema "${schemaName}" successfully created with ID ${schemaId}`);
} else {
Expand Down
Loading

0 comments on commit 20e6cc9

Please sign in to comment.