Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add a database to the Deploy Campaign #58

Merged
merged 60 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
dcbfaa9
install mongodb, remove logdown, add docker-compose
Whytecrowe Oct 12, 2023
69b13c0
create MongoConnector class to instantiate the client and the DB
Whytecrowe Oct 12, 2023
5e2a31c
ignore docker files
Whytecrowe Oct 13, 2023
24b0627
create temp stencil for db adapter
Whytecrowe Oct 13, 2023
9858027
extend MongoDBConnector to work with DB versioning and save and read …
Whytecrowe Oct 13, 2023
09ace5e
add some versioning logic and connect to mongo adapter in the RootReg…
Whytecrowe Oct 13, 2023
208fcd5
add proper versioning logic for start and finish
Whytecrowe Oct 16, 2023
97fbc4f
change docker compose port to 27018
Whytecrowe Oct 16, 2023
990132e
add mongo test helper, update the campaign launcher and registrar test
Whytecrowe Oct 16, 2023
d3194a1
rename mongo connector to mongo adapter, add module level var to use …
Whytecrowe Oct 18, 2023
3f0a2e8
refine test mongo functions and add a stop function
Whytecrowe Oct 18, 2023
27a5807
modify some types and base deploy mission to not save deploy args
Whytecrowe Oct 18, 2023
cfa3dd9
rework logger functions to save to a module var so that we use the sa…
Whytecrowe Oct 18, 2023
90075db
add global setup methods for mocha tests, override hardhat test task …
Whytecrowe Oct 18, 2023
6a75bb4
modify runZnsCampaign() and RootRegistrar test for the new setup
Whytecrowe Oct 18, 2023
6be819f
fix some naming
Whytecrowe Oct 18, 2023
2b5d0fc
Merge branch 'deploy-proto' into deploy/add-database
Whytecrowe Nov 6, 2023
af19c65
remove redundant prop from campaign config
Whytecrowe Nov 6, 2023
94162a5
remove duplicated imports it test
Whytecrowe Nov 6, 2023
d2d1552
update yarn.lock
Whytecrowe Nov 7, 2023
dc6bd44
make mongo run in CI with default uri and name
Whytecrowe Nov 7, 2023
5944ab2
fix logger in db adapter
Whytecrowe Nov 7, 2023
76ee41d
add mongo defaults properly
Whytecrowe Nov 7, 2023
93eb809
small fixes for mongo adapter + isolate registrar test
Whytecrowe Nov 8, 2023
c909f75
refactor mongo adapter and add drop function to clear db manually thr…
Whytecrowe Nov 8, 2023
e8655f7
try adding docker to CI
Whytecrowe Nov 8, 2023
684ac3f
update docker config for CI
Whytecrowe Nov 8, 2023
54a2482
add ignored file and remove db dir from gitignore
Whytecrowe Nov 8, 2023
9e4353f
separate docker from hardhat test run
Whytecrowe Nov 8, 2023
3d59aa5
clean up rename and move mongo logic
Whytecrowe Nov 8, 2023
a5194d5
refactor mongo adapter class
Whytecrowe Nov 8, 2023
900083a
add docker down script and add docker scripts to CI
Whytecrowe Nov 8, 2023
260cede
try remove -d option from docker script
Whytecrowe Nov 8, 2023
3610501
Revert "try remove -d option from docker script"
Whytecrowe Nov 8, 2023
8407c06
try removing remote docker
Whytecrowe Nov 8, 2023
3bb1d91
Revert "try removing remote docker"
Whytecrowe Nov 8, 2023
43a0cae
try changing port
Whytecrowe Nov 8, 2023
15d2377
try with different uri
Whytecrowe Nov 8, 2023
2de738e
try env var
Whytecrowe Nov 9, 2023
2277b0e
revert
Whytecrowe Nov 9, 2023
072e646
fix errors in base deploy mission and move zns names to it's own file
Whytecrowe Nov 9, 2023
9c39a62
make mongo stop and async call, refactor dropDB to make it work even …
Whytecrowe Nov 9, 2023
3949bd9
add comments
Whytecrowe Nov 9, 2023
f96e937
lock specific version of zToken package
Whytecrowe Nov 9, 2023
4d3b68e
extend hardhat deployer to be able to get bytecode and factory
Whytecrowe Nov 9, 2023
95b4313
add hardcoded mainnet data for meow to the repo
Whytecrowe Nov 9, 2023
26418d9
extend meow naming and deploy logic to support both mocked and mainne…
Whytecrowe Nov 9, 2023
5cf4981
rename and move token class
Whytecrowe Nov 9, 2023
3704772
fix Circle config to properly work with mongo
Whytecrowe Nov 10, 2023
718621f
update solhint
Whytecrowe Nov 10, 2023
4c7d3c5
update yarn.lock
Whytecrowe Nov 10, 2023
3b0ac41
change instances in campaign state from array to object
Whytecrowe Nov 10, 2023
f65f718
add and comment out the bytecode comparison tool
Whytecrowe Nov 10, 2023
e561b30
add db drop to the mocha teardown
Whytecrowe Nov 10, 2023
6964a49
rework campaign smoke test to start testing campaign
Whytecrowe Nov 10, 2023
2fce3b6
remove all redundant code in TreasuryDM
Whytecrowe Nov 10, 2023
d169cca
return proper exit code after tests
Whytecrowe Nov 10, 2023
037bb9e
remove postDeploy hook from Treasury
Whytecrowe Nov 10, 2023
fa550c1
fix overriden test task to return failures instead of exiting
Whytecrowe Nov 13, 2023
614f1f4
fix small errors
Whytecrowe Nov 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ defaults: &defaults
working_directory: ~/repo
docker:
- image: cimg/node:18.15.0
- image: mongo:7.0.0-rc5-jammy

jobs:
test and coverage:
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ typechain-types
cache
artifacts

# Local DB
db

# hardhat-tenderly plugin
deployments

*.env
docker
docker*.tgz
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "2"
services:
mongo:
image: mongo:7.0.0-rc5-jammy
ports:
- "27018:27017"
volumes:
- mongo-data:/data/db
volumes:
mongo-data:
256 changes: 135 additions & 121 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,121 +1,135 @@
/* eslint-disable @typescript-eslint/no-var-requires, @typescript-eslint/no-unused-vars */
require("dotenv").config();

import { HardhatUserConfig } from "hardhat/config";
import * as tenderly from "@tenderly/hardhat-tenderly";
import "@nomicfoundation/hardhat-toolbox";
import "@nomiclabs/hardhat-ethers";
import "@nomicfoundation/hardhat-network-helpers";
import "@nomicfoundation/hardhat-chai-matchers";
import "@openzeppelin/hardhat-upgrades";
import "solidity-coverage";
import "solidity-docgen";
import "hardhat-gas-reporter";

// This call is needed to initialize Tenderly with Hardhat,
// the automatic verifications, though, don't seem to work,
// needing us to verify explicitly in code, however,
// for Tenderly to work properly with Hardhat this method
// needs to be called. The call below is commented out
// because if we leave it here, solidity-coverage
// does not work properly locally or in CI, so we
// keep it commented out and uncomment when using DevNet
// locally.
// !!! Uncomment this when using Tenderly DevNet !!!
// tenderly.setup({ automaticVerifications: false });

const config : HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.18",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: "0.8.3",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
],
overrides: {
"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": {
version: "0.8.9",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": {
version: "0.8.9",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
},
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts",
},
typechain: {
outDir: "typechain",
},
mocha: {
timeout: 5000000,
},
gasReporter: {
enabled: false,
},
networks: {
mainnet: {
url: "https://mainnet.infura.io/v3/97e75e0bbc6a4419a5dd7fe4a518b917",
gasPrice: 80000000000,
},
goerli: {
url: "https://goerli.infura.io/v3/77c3d733140f4c12a77699e24cb30c27",
timeout: 10000000,
},
devnet: {
// Add current URL that you spawned if not using automated spawning
url: `${process.env.DEVNET_RPC_URL}`,
chainId: 1,
},
},
etherscan: {
apiKey: `${process.env.ETHERSCAN_API_KEY}`,
},
tenderly: {
project: `${process.env.TENDERLY_PROJECT_SLUG}`,
username: `${process.env.TENDERLY_ACCOUNT_ID}`,
},
docgen: {
pages: "files",
templates: "docs/docgen-templates",
outputDir: "docs/contracts",
exclude: [
"upgrade-test-mocks/",
"upgradeMocks/",
"token/mocks/",
"utils/",
"oz-proxies/",
],
},
};

export default config;
/* eslint-disable @typescript-eslint/no-var-requires, @typescript-eslint/no-unused-vars */

import { mochaGlobalSetup, mochaGlobalTeardown } from "./test/mocha-global";

require("dotenv").config();

import * as tenderly from "@tenderly/hardhat-tenderly";
import "@nomicfoundation/hardhat-toolbox";
import "@nomiclabs/hardhat-ethers";
import "@nomicfoundation/hardhat-network-helpers";
import "@nomicfoundation/hardhat-chai-matchers";
import "@openzeppelin/hardhat-upgrades";
import "solidity-coverage";
import "solidity-docgen";
import "hardhat-gas-reporter";
import { HardhatUserConfig, subtask } from "hardhat/config";
import { TASK_TEST_RUN_MOCHA_TESTS } from "hardhat/builtin-tasks/task-names";


subtask(TASK_TEST_RUN_MOCHA_TESTS)
.setAction(async (args, hre, runSuper) => {
await mochaGlobalSetup();
const testFailures = await runSuper(args);
await mochaGlobalTeardown();

return testFailures;
});

// This call is needed to initialize Tenderly with Hardhat,
// the automatic verifications, though, don't seem to work,
// needing us to verify explicitly in code, however,
// for Tenderly to work properly with Hardhat this method
// needs to be called. The call below is commented out
// because if we leave it here, solidity-coverage
// does not work properly locally or in CI, so we
// keep it commented out and uncomment when using DevNet
// locally.
// !!! Uncomment this when using Tenderly DevNet !!!
// tenderly.setup({ automaticVerifications: false });

const config : HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.18",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: "0.8.3",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
],
overrides: {
"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": {
version: "0.8.9",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": {
version: "0.8.9",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
},
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts",
},
typechain: {
outDir: "typechain",
},
mocha: {
timeout: 5000000,
},
gasReporter: {
enabled: false,
},
networks: {
mainnet: {
url: "https://mainnet.infura.io/v3/97e75e0bbc6a4419a5dd7fe4a518b917",
gasPrice: 80000000000,
},
goerli: {
url: "https://goerli.infura.io/v3/77c3d733140f4c12a77699e24cb30c27",
timeout: 10000000,
},
devnet: {
// Add current URL that you spawned if not using automated spawning
url: `${process.env.DEVNET_RPC_URL}`,
chainId: 1,
},
},
etherscan: {
apiKey: `${process.env.ETHERSCAN_API_KEY}`,
},
tenderly: {
project: `${process.env.TENDERLY_PROJECT_SLUG}`,
username: `${process.env.TENDERLY_ACCOUNT_ID}`,
},
docgen: {
pages: "files",
templates: "docs/docgen-templates",
outputDir: "docs/contracts",
exclude: [
"upgrade-test-mocks/",
"upgradeMocks/",
"token/mocks/",
"utils/",
"oz-proxies/",
],
},
};

export default config;
18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@
"clean": "hardhat clean",
"build": "yarn run clean && yarn run compile",
"typechain": "hardhat typechain",
"pretest": "yarn mongo:start",
"test": "hardhat test",
"test-local": "yarn test",
"posttest": "yarn mongo:stop",
"semantic-release": "semantic-release --tag-format='v${version}-dev'",
"coverage": "hardhat coverage",
"check-coverage": "istanbul check-coverage --statements 90 --branches 87 --functions 89 --lines 90",
"devnet": "ts-node src/tenderly/devnet/devnet-execute.ts",
"gas-cost": "ts-node src/utils/gas-costs.ts",
"docgen": "hardhat docgen"
"docgen": "hardhat docgen",
"mongo:start": "docker-compose up -d",
"mongo:stop": "docker-compose stop",
"mongo:down": "docker-compose down",
"mongo:drop": "ts-node src/utils/drop-db.ts"
},
"pre-commit": [
"lint"
Expand All @@ -49,15 +56,14 @@
"@types/mocha": "9.1.0",
"@types/node": "^18.15.11",
"@zero-tech/eslint-config-cpt": "0.2.7",
"@zero-tech/ztoken": "^2.0.0",
"@zero-tech/ztoken": "2.0.0",
"chai": "4.2.0",
"eslint": "^8.37.0",
"ethers": "5.5.1",
"hardhat": "2.13.0",
"hardhat-gas-reporter": "1.0.8",
"logdown": "3.3.1",
"semantic-release": "^21.0.1",
"solhint": "^3.4.1",
"solhint": "4.0.0",
"solidity-coverage": "^0.8.2",
"solidity-docgen": "^0.6.0-beta.35",
"ts-node": "10.9.1",
Expand All @@ -67,9 +73,7 @@
"dependencies": {
"axios": "^1.4.0",
"dotenv": "16.0.3",
"mongodb": "^6.1.0",
"winston": "^3.11.0"
},
"resolutions": {
"@solidity-parser/parser": "0.16.0"
}
}
Loading