Skip to content

Commit

Permalink
Add back incomplete compiler settings
Browse files Browse the repository at this point in the history
  • Loading branch information
shanejearley committed Nov 30, 2022
1 parent 1136734 commit b6fde96
Show file tree
Hide file tree
Showing 23 changed files with 3,311 additions and 2,369 deletions.
5 changes: 5 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@
[submodule "contracts/ethereum/scripts/resources/consensus-specs"]
path = contracts/ethereum/scripts/resources/consensus-specs
url = https://github.com/ethereum/consensus-specs.git
[submodule "scripts/ssv/resources/ssv"]
path = scripts/ethereum/resources/ssv
url = https://github.com/consensusnetworks/ssv.git
branch = devnet
update = merge
2 changes: 1 addition & 1 deletion common/hardhat-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@types/node": "^17.0.38",
"esbuild": "^0.15.9",
"esno": "^0.16.3",
"hardhat": "^2.12.0",
"hardhat": "^2.12.2",
"typechain": "^8.1.0"
}
}
20 changes: 16 additions & 4 deletions common/hardhat-helpers/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import { ethers } from 'hardhat'
import { ethers, upgrades } from 'hardhat'

async function deployContract(name: string) {
async function deployContract(name: string, proxy?: boolean, args?: Record<string, any>, options?: Record<string, any>) {
if (!args) args = {}
if (!options) options = {}
const inputs = []
const factory = await ethers.getContractFactory(name)
const contract = await factory.deploy()
return await contract.deployed()
if (proxy) {
if (Object.keys(args).length) inputs.push([...Object.values(args)])
if (Object.keys(options).length) inputs.push(options)
const proxy = await upgrades.deployProxy(factory, ...inputs)
return await proxy.deployed()
} else {
if (Object.keys(args).length) inputs.push(...Object.values(args))
if (Object.keys(options).length) inputs.push(options)
const contract = await factory.deploy(...inputs)
return await contract.deployed()
}
}

export { deployContract }
2 changes: 2 additions & 0 deletions common/zx-helpers/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
16 changes: 16 additions & 0 deletions common/zx-helpers/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "@casimir/zx-helpers",
"private": true,
"main": "src/index.ts",
"scripts": {
"dev": "npx esno src/index.ts",
"build": "esbuild src/index.ts --bundle --minify --sourcemap --platform=node --target=esnext --outfile=dist/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"@types/node": "^17.0.38",
"esbuild": "^0.15.9",
"esno": "^0.16.3",
"zx": "^7.1.1"
}
}
14 changes: 14 additions & 0 deletions common/zx-helpers/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { $, ProcessOutput } from 'zx'

async function getContainerPort(image: string, port: string) {
const output = await $`docker port $(docker ps -a -q --filter ancestor=${image} --filter expose=${port} --format="{{.ID}}") ${port}`
const path = parseStdout(output)
return path.split(':')[1]
}

function parseStdout(output: ProcessOutput) {
const { stdout } = output
return stdout.replace('\n', '')
}

export { getContainerPort, parseStdout }
21 changes: 21 additions & 0 deletions common/zx-helpers/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"target": "ESNext",
"strict": true,
"preserveConstEnums": true,
"noEmit": true,
"sourceMap": false,
"module": "CommonJS",
"moduleResolution": "Node",
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true
},
"exclude": [
"node_modules"
],
"include": [
"./src/*"
]
}
64 changes: 44 additions & 20 deletions contracts/ethereum/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,24 @@ import '@nomiclabs/hardhat-ethers'
import { HardhatUserConfig } from 'hardhat/config'
import '@sebasgoldberg/hardhat-wsprovider'
import 'solidity-docgen'
import '@openzeppelin/hardhat-upgrades'

const forkUrl = process.env.ETHEREUM_FORK_RPC
const forkUrl = process.env.ETHEREUM_FORK_URL
const network = forkUrl?.includes('mainnet') ? 'mainnet' : forkUrl?.includes('goerli') ? 'goerli' : 'localhost'
const env = {
mainnet: {
linkTokenAddress: '',
ssvTokenAddress: '',
wethTokenAddress: ''
},
goerli: {
linkTokenAddress: '0x326C977E6efc84E512bB9C30f76E30c160eD06FB',
ssvTokenAddress: '0x3a9f01091C446bdE031E39ea8354647AFef091E7',
wethTokenAddress: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
}
}

const httpUrl = `http://localhost:${process.env.ETHEREUM_EXECUTION_HTTP_PORT}`
const mnemonic = process.env.BIP39_SEED

const hid = {
Expand All @@ -18,26 +34,28 @@ const hid = {
const compilerSettings = {
optimizer: {
enabled: true,
runs: 10000
runs: 1
}
}

const miningInterval = {
auto: false,
interval: 12000
}

const compilerVersions = ['0.8.16', '0.4.22', '0.6.11', '0.8.4']
// const externalCompilerVersions = ['0.4.22', '0.6.11', '0.8.4']
// if () {

// }


// Go to https://hardhat.org/config/ to learn more
const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: '0.6.11',
settings: { ...compilerSettings }
},
{
version: '0.8.4',
settings: { ...compilerSettings }
},
{
version: '0.8.16',
settings: { ...compilerSettings }
}
...compilerVersions.map(version => ({ version, settings: compilerSettings })),

]
},
paths: {
Expand All @@ -54,15 +72,21 @@ const config: HardhatUserConfig = {
accounts: mnemonic ? { ...hid, accountsBalance: '48000000000000000000' } : undefined,
chainId: 1337,
forking: forkUrl ? { url: forkUrl } : undefined,
mining: {
auto: false,
interval: 12000
}
mining: process.env.INTERVAL_MINING ? miningInterval : undefined,
allowUnlimitedContractSize: true,
gas: 'auto',
gasPrice: 'auto'
},
geth: {
url: 'http://localhost:51121',
accounts: mnemonic ? { ...hid } : undefined
url: httpUrl || 'http://localhost:8545',
accounts: mnemonic ? { ...hid } : undefined,
allowUnlimitedContractSize: true,
gas: 'auto',
gasPrice: 'auto'
}
},
mocha: {
timeout: 250000 // Default timeout * 10
}
}

Expand Down
12 changes: 10 additions & 2 deletions contracts/ethereum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
"name": "@casimir/ethereum",
"scripts": {
"dev:hardhat": "npx hardhat node",
"deploy:ssv": "npx hardhat run scripts/ssv.deploy.ts",
"dev:ssv": "npx hardhat run scripts/ssv.dev.ts",
"deploy:beacon": "npx hardhat run scripts/beacon.deploy.ts",
"deploy:ssv": "npx hardhat run scripts/ssv.deploy.ts",
"inspect:ssv": "npx hardhat run scripts/ssv.inspect.ts",
"docgen": "npx hardhat docgen",
"test": "mocha --require hardhat/register --recursive --exit --extension ts --timeout 25000",
"task:clean": "npx hardhat clean",
"task:compile": "npm run task:clean && npx hardhat compile",
"pretest": "npm run task:compile",
"postinstall": "npm run task:compile"
},
"devDependencies": {
Expand All @@ -16,6 +19,7 @@
"@nomiclabs/hardhat-waffle": "^2.0.3",
"@openzeppelin/contracts": "^4.8.0",
"@openzeppelin/contracts-upgradeable": "^4.8.0",
"@openzeppelin/hardhat-upgrades": "^1.21.0",
"@sebasgoldberg/hardhat-wsprovider": "^0.1.0",
"@typechain/ethers-v5": "^10.1.0",
"@typechain/hardhat": "^6.1.2",
Expand All @@ -25,11 +29,15 @@
"@types/node": "^17.0.45",
"chai": "^4.3.6",
"esno": "^0.16.3",
"hardhat": "^2.12.0",
"hardhat": "^2.12.2",
"localtunnel": "^2.0.2",
"mocha": "^10.0.0",
"solidity-docgen": "^0.6.0-beta.29",
"ts-node": "^10.8.2",
"typechain": "^8.1.0"
},
"dependencies": {
"@uniswap/v3-core": "^1.0.1",
"@uniswap/v3-periphery": "^1.4.3"
}
}
5 changes: 2 additions & 3 deletions contracts/ethereum/scripts/beacon.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { deployContract } from '@casimir/hardhat-helpers'

void async function () {
const name = 'DepositContract'
const { address, deployTransaction } = await deployContract(name)
const { hash } = deployTransaction
console.log(`${name} contract deployed to ${address} (see hash ${hash})`)
const { address } = await deployContract(name)
console.log(`${name} contract deployed to ${address}`)
process.exit(0)
}()
31 changes: 11 additions & 20 deletions contracts/ethereum/scripts/ssv.deploy.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
import { deployContract } from '@casimir/hardhat-helpers'

void async function () {

process.env.MINIMUM_BLOCKS_BEFORE_LIQUIDATION = '100'
process.env.OPERATOR_MAX_FEE_INCREASE = '3'
process.env.SET_OPERATOR_FEE_PERIOD = '259200' // 3 days
process.env.APPROVE_OPERATOR_FEE_PERIOD = '345600' // 4 days
process.env.VALIDATORS_PER_OPERATOR_LIMIT = '2000'
process.env.REGISTERED_OPERATORS_PER_ACCOUNT_LIMIT = '10'
process.env.DECLARE_OPERATOR_FEE_PERIOD = '0'
process.env.EXECUTE_OPERATOR_FEE_PERIOD = '86400'

const ssvContractNames = ['SSVRegistry', 'SSVToken', 'SSVNetwork', 'SSVManager']

for (const name of ssvContractNames) {
console.log(`Deploying ${name} contract...`)
const { address, deployTransaction } = await deployContract(name)
const { hash } = deployTransaction
process.env[`${name.toUpperCase()}_ADDRESS`] = address
console.log(`${name} contract deployed to ${address} (see hash ${hash})`)
}
process.exit(0)
const name = 'SSVManager'
const args = {
linkTokenAddress: process.env.LINK_TOKEN_ADDRESS,
ssvTokenAddress: process.env.SSV_TOKEN_ADDRESS,
wethTokenAddress: process.env.WETH_TOKEN_ADDRESS
}
const options = {}
const proxy = false
const { address } = await deployContract(name, proxy, args, options)
console.log(`${name} contract deployed to ${address}`)
process.exit(0)
}()
Loading

0 comments on commit b6fde96

Please sign in to comment.