Skip to content

Commit

Permalink
refactor: remove hardhat-ovm plugin and its deps
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcontracts committed Oct 1, 2021
1 parent b39ea3b commit 322475c
Show file tree
Hide file tree
Showing 37 changed files with 54 additions and 2,263 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -7,7 +7,6 @@
# packages/contracts/ @smartcontracts @ben-chain @maurelian @elenadimitrova
# packages/specs/protocol/ @smartcontracts @ben-chain @maurelian
# ops/ @tynes @karlfloersch
# packages/hardhat-ovm/ @smartcontracts
# packages/core-utils/ @smartcontracts @annieke @ben-chain
# packages/common-ts/ @annieke
# packages/core-utils/src/watcher.ts @K-Ho
Expand Down
3 changes: 0 additions & 3 deletions .github/labeler.yml
Expand Up @@ -30,8 +30,5 @@ M-core-utils:
M-dtl:
- any: ['packages/data-transport-layer/**/*']

M-hardhat-ovm:
- any: ['packages/hardhat-ovm/**/*']

M-ops:
- any: ['ops/**/*']
2 changes: 0 additions & 2 deletions .gitignore
Expand Up @@ -8,9 +8,7 @@ coverage.json

dist
artifacts
artifacts-ovm
cache
cache-ovm

l2geth/build/bin
packages/contracts/deployments/custom
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Expand Up @@ -6,7 +6,6 @@
"eslint.workingDirectories": [
{"directory": "packages/core-utils", "changeProcessCWD": true },
{"directory": "packages/common-ts", "changeProcessCWD": true },
{"directory": "packages/hardhat-ovm", "changeProcessCWD": true },
{"directory": "packages/contracts", "changeProcessCWD": true },
{"directory": "packages/data-transport-layer", "changeProcessCWD": true },
{"directory": "packages/batch-submitter", "changeProcessCWD": true },
Expand Down
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Expand Up @@ -5,7 +5,6 @@

These packages only require 1 reviewer (all other packages require 2 reviewers, unless the changes do not affect production or test code).
- packages/core-utils
- packages/hardhat-ovm
- packages/common-ts
- integration-tests

Expand Down
1 change: 0 additions & 1 deletion README.md
Expand Up @@ -27,7 +27,6 @@ Extensive documentation is available [here](http://community.optimism.io/docs/).
* [`contracts`](./packages/contracts): Solidity smart contracts implementing the OVM
* [`core-utils`](./packages/core-utils): Low-level utilities and encoding packages
* [`common-ts`](./packages/common-ts): Common tools for TypeScript code that runs in Node
* [`hardhat-ovm`](./packages/hardhat-ovm): Hardhat plugin which enables the [OVM Compiler](https://github.com/ethereum-optimism/solidity)
* [`data-transport-layer`](./packages/data-transport-layer): Event indexer, allowing the `l2geth` node to access L1 data
* [`batch-submitter`](./packages/batch-submitter): Daemon for submitting L2 transaction and state root batches to L1
* [`message-relayer`](./packages/message-relayer): Service for relaying L2 messages to L1
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/package.json
Expand Up @@ -14,7 +14,7 @@
"test:integration": "hardhat --network optimism test",
"test:integration:live": "IS_LIVE_NETWORK=true hardhat --network optimism test",
"test:sync": "hardhat --network optimism test sync-tests/*.spec.ts --no-compile",
"clean": "rimraf cache artifacts artifacts-ovm cache-ovm"
"clean": "rimraf cache artifacts"
},
"devDependencies": {
"@eth-optimism/contracts": "^0.4.13",
Expand Down
1 change: 0 additions & 1 deletion ops/docker/Dockerfile.batch-submitter
Expand Up @@ -20,7 +20,6 @@ COPY --from=builder /optimism/packages/contracts/package.json ./packages/contrac
COPY --from=builder /optimism/packages/contracts/deployments ./packages/contracts/deployments
COPY --from=builder /optimism/packages/contracts/dist ./packages/contracts/dist
COPY --from=builder /optimism/packages/contracts/artifacts ./packages/contracts/artifacts
COPY --from=builder /optimism/packages/contracts/artifacts-ovm ./packages/contracts/artifacts-ovm

# copy the service
WORKDIR /opt/optimism/packages/batch-submitter
Expand Down
1 change: 0 additions & 1 deletion ops/docker/Dockerfile.data-transport-layer
Expand Up @@ -21,7 +21,6 @@ COPY --from=builder /optimism/packages/contracts/package.json ./packages/contrac
COPY --from=builder /optimism/packages/contracts/deployments ./packages/contracts/deployments
COPY --from=builder /optimism/packages/contracts/dist ./packages/contracts/dist
COPY --from=builder /optimism/packages/contracts/artifacts ./packages/contracts/artifacts
COPY --from=builder /optimism/packages/contracts/artifacts-ovm ./packages/contracts/artifacts-ovm

# copy the service
WORKDIR /opt/optimism/packages/data-transport-layer
Expand Down
4 changes: 0 additions & 4 deletions ops/docker/Dockerfile.deployer
Expand Up @@ -13,16 +13,12 @@ COPY --from=builder /optimism/node_modules ./node_modules
COPY --from=builder /optimism/packages/core-utils/package.json ./packages/core-utils/package.json
COPY --from=builder /optimism/packages/core-utils/dist ./packages/core-utils/dist

COPY --from=builder /optimism/packages/hardhat-ovm/package.json ./packages/hardhat-ovm/package.json
COPY --from=builder /optimism/packages/hardhat-ovm/dist ./packages/hardhat-ovm/dist

# get the needed built artifacts
WORKDIR /opt/optimism/packages/contracts
COPY --from=builder /optimism/packages/contracts/dist ./dist
COPY --from=builder /optimism/packages/contracts/*.json ./
COPY --from=builder /optimism/packages/contracts/node_modules ./node_modules
COPY --from=builder /optimism/packages/contracts/artifacts ./artifacts
COPY --from=builder /optimism/packages/contracts/artifacts-ovm ./artifacts-ovm

# get non-build artifacts from the host
COPY packages/contracts/bin ./bin
Expand Down
3 changes: 0 additions & 3 deletions ops/docker/Dockerfile.integration-tests
Expand Up @@ -16,9 +16,6 @@ COPY --from=builder /optimism/packages/core-utils/dist ./packages/core-utils/dis
COPY --from=builder /optimism/packages/message-relayer/package.json ./packages/message-relayer/package.json
COPY --from=builder /optimism/packages/message-relayer/dist ./packages/message-relayer/dist

COPY --from=builder /optimism/packages/hardhat-ovm/package.json ./packages/hardhat-ovm/package.json
COPY --from=builder /optimism/packages/hardhat-ovm/dist ./packages/hardhat-ovm/dist

COPY --from=builder /optimism/packages/contracts ./packages/contracts

# get the needed built artifacts
Expand Down
1 change: 0 additions & 1 deletion ops/docker/Dockerfile.message-relayer
Expand Up @@ -21,7 +21,6 @@ COPY --from=builder /optimism/packages/contracts/package.json ./packages/contrac
COPY --from=builder /optimism/packages/contracts/deployments ./packages/contracts/deployments
COPY --from=builder /optimism/packages/contracts/dist ./packages/contracts/dist
COPY --from=builder /optimism/packages/contracts/artifacts ./packages/contracts/artifacts
COPY --from=builder /optimism/packages/contracts/artifacts-ovm ./packages/contracts/artifacts-ovm

# copy the service
WORKDIR /opt/optimism/packages/message-relayer
Expand Down
1 change: 0 additions & 1 deletion ops/docker/Dockerfile.monorepo
Expand Up @@ -26,7 +26,6 @@ WORKDIR /optimism
COPY *.json yarn.lock ./
COPY packages/core-utils/package.json ./packages/core-utils/package.json
COPY packages/common-ts/package.json ./packages/common-ts/package.json
COPY packages/hardhat-ovm/package.json ./packages/hardhat-ovm/package.json
COPY packages/contracts/package.json ./packages/contracts/package.json
COPY packages/data-transport-layer/package.json ./packages/data-transport-layer/package.json
COPY packages/batch-submitter/package.json ./packages/batch-submitter/package.json
Expand Down
6 changes: 0 additions & 6 deletions packages/contracts/hardhat.config.ts
Expand Up @@ -13,7 +13,6 @@ import '@nomiclabs/hardhat-waffle'
import '@nomiclabs/hardhat-etherscan'
import 'hardhat-deploy'
import '@typechain/hardhat'
import '@eth-optimism/hardhat-ovm'
import './tasks/deploy'
import './tasks/l2-gasprice'
import './tasks/set-owner'
Expand All @@ -39,10 +38,8 @@ const config: HardhatUserConfig = {
tags: ['local'],
hardfork: 'istanbul',
},
// Add this network to your config!
optimism: {
url: 'http://127.0.0.1:8545',
ovm: true,
saveDeployments: false,
},
'optimism-kovan': {
Expand Down Expand Up @@ -77,9 +74,6 @@ const config: HardhatUserConfig = {
},
},
},
ovm: {
solcVersion: '0.7.6+commit.3b061308',
},
typechain: {
outDir: 'dist/types',
target: 'ethers-v5',
Expand Down
7 changes: 1 addition & 6 deletions packages/contracts/package.json
Expand Up @@ -5,9 +5,7 @@
"files": [
"dist/**/*.js",
"dist/types/*.ts",
"dist/types-ovm/*.ts",
"artifacts/contracts/**/*.json",
"artifacts-ovm/contracts/**/*.json",
"deployments/**/*.json",
"OVM",
"iOVM",
Expand All @@ -24,10 +22,8 @@
"build:mainnet": "yarn run build:contracts && yarn run build:typescript && yarn run build:copy && CHAIN_ID=10 yarn run build:dump && yarn run build:typechain",
"build:typescript": "tsc -p ./tsconfig.build.json",
"build:contracts": "hardhat compile --show-stack-traces",
"build:contracts:ovm": "hardhat compile --network optimism",
"build:dump": "ts-node \"bin/take-dump.ts\"",
"build:typechain": "hardhat typechain",
"build:typechain:ovm": "hardhat --network optimism typechain",
"test": "yarn run test:contracts",
"test:contracts": "hardhat test --show-stack-traces",
"test:gas": "hardhat test \"test/contracts/OVM/execution/OVM_StateManager.gas-spec.ts\" --no-compile --show-stack-traces",
Expand All @@ -38,7 +34,7 @@
"lint:check": "eslint .",
"lint:fix": "yarn lint:check --fix",
"lint:contracts": "yarn solhint -f table contracts/optimistic-ethereum/**/*.sol",
"clean": "rm -rf ./dist ./artifacts ./artifacts-ovm ./cache ./cache-ovm ./tsconfig.build.tsbuildinfo",
"clean": "rm -rf ./dist ./artifacts ./cache ./tsconfig.build.tsbuildinfo",
"deploy": "ts-node \"./bin/deploy.ts\" && yarn generate:markdown",
"serve": "./bin/serve_dump.sh",
"prepublishOnly": "yarn copyfiles -u 2 \"contracts/optimistic-ethereum/**/*\" ./",
Expand All @@ -60,7 +56,6 @@
},
"devDependencies": {
"@codechecks/client": "0.1.10-beta",
"@eth-optimism/hardhat-ovm": "^0.2.3",
"@eth-optimism/smock": "^1.1.10",
"@ethersproject/transactions": "^5.4.0",
"@nomiclabs/hardhat-ethers": "^2.0.1",
Expand Down
1 change: 0 additions & 1 deletion packages/contracts/scripts/build.sh
Expand Up @@ -3,6 +3,5 @@
set -e

yarn build:contracts
yarn build:contracts:ovm
yarn generate:artifacts
yarn build:typescript
44 changes: 9 additions & 35 deletions packages/contracts/scripts/generate-artifacts.js
Expand Up @@ -15,9 +15,6 @@ const fs = require('fs')
const evmArtifactPaths = getContractJsonFiles(
path.resolve(__dirname, `../artifacts/contracts`)
)
const ovmArtifactPaths = getContractJsonFiles(
path.resolve(__dirname, `../artifacts-ovm/contracts`)
)

const content = `
/* eslint-disable @typescript-eslint/no-var-requires, no-empty */
Expand All @@ -26,18 +23,6 @@ const fs = require('fs')
DO NOT EDIT.
*/
${ovmArtifactPaths
.map((artifactPath) => {
const artifact = require(artifactPath)
const relPath = path.relative(__dirname, artifactPath)
return `
let ovm__${artifact.contractName}
try {
ovm__${artifact.contractName} = require('${relPath}')
} catch {}
`
})
.join('\n')}
${evmArtifactPaths
.map((artifactPath) => {
const artifact = require(artifactPath)
Expand All @@ -51,26 +36,15 @@ const fs = require('fs')
})
.join('\n')}
export const getContractArtifact = (name: string, ovm: boolean): any => {
if (ovm) {
return {
${ovmArtifactPaths
.map((artifactPath) => {
const artifact = require(artifactPath)
return `${artifact.contractName}: ovm__${artifact.contractName}`
})
.join(',\n')}
}[name]
} else {
return {
${evmArtifactPaths
.map((artifactPath) => {
const artifact = require(artifactPath)
return `${artifact.contractName}: ${artifact.contractName}`
})
.join(',\n')}
}[name]
}
export const getContractArtifact = (name: string): any => {
return {
${evmArtifactPaths
.map((artifactPath) => {
const artifact = require(artifactPath)
return `${artifact.contractName}: ${artifact.contractName}`
})
.join(',\n')}
}[name]
}
`

Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/src/connect-contracts.ts
@@ -1,4 +1,4 @@
import { Signer, Contract, providers, ethers } from 'ethers'
import { Signer, Contract } from 'ethers'
import { Provider } from '@ethersproject/abstract-provider'
import { getL1ContractData, getL2ContractData } from './contract-data'

Expand Down
16 changes: 8 additions & 8 deletions packages/contracts/src/contract-data.ts
Expand Up @@ -112,15 +112,15 @@ export const getL1ContractData = (network: Network) => {
}
}

const OVM_ETH = require('../artifacts-ovm/contracts/optimistic-ethereum/OVM/predeploys/OVM_ETH.sol/OVM_ETH.json')
const OVM_L2CrossDomainMessenger = require('../artifacts-ovm/contracts/optimistic-ethereum/OVM/bridge/messaging/OVM_L2CrossDomainMessenger.sol/OVM_L2CrossDomainMessenger.json')
const OVM_L2ToL1MessagePasser = require('../artifacts-ovm/contracts/optimistic-ethereum/OVM/predeploys/OVM_L2ToL1MessagePasser.sol/OVM_L2ToL1MessagePasser.json')
const OVM_ETH = require('../artifacts/contracts/optimistic-ethereum/OVM/predeploys/OVM_ETH.sol/OVM_ETH.json')
const OVM_L2CrossDomainMessenger = require('../artifacts/contracts/optimistic-ethereum/OVM/bridge/messaging/OVM_L2CrossDomainMessenger.sol/OVM_L2CrossDomainMessenger.json')
const OVM_L2ToL1MessagePasser = require('../artifacts/contracts/optimistic-ethereum/OVM/predeploys/OVM_L2ToL1MessagePasser.sol/OVM_L2ToL1MessagePasser.json')
const OVM_L1MessageSender = require('../artifacts/contracts/optimistic-ethereum/OVM/predeploys/OVM_L1MessageSender.sol/OVM_L1MessageSender.json')
const OVM_DeployerWhitelist = require('../artifacts-ovm/contracts/optimistic-ethereum/OVM/predeploys/OVM_DeployerWhitelist.sol/OVM_DeployerWhitelist.json')
const OVM_ECDSAContractAccount = require('../artifacts-ovm/contracts/optimistic-ethereum/OVM/predeploys/OVM_ECDSAContractAccount.sol/OVM_ECDSAContractAccount.json')
const OVM_SequencerEntrypoint = require('../artifacts-ovm/contracts/optimistic-ethereum/OVM/predeploys/OVM_SequencerEntrypoint.sol/OVM_SequencerEntrypoint.json')
const ERC1820Registry = require('../artifacts-ovm/contracts/optimistic-ethereum/OVM/predeploys/ERC1820Registry.sol/ERC1820Registry.json')
const Lib_AddressManager = require('../artifacts-ovm/contracts/optimistic-ethereum/libraries/resolver/Lib_AddressManager.sol/Lib_AddressManager.json')
const OVM_DeployerWhitelist = require('../artifacts/contracts/optimistic-ethereum/OVM/predeploys/OVM_DeployerWhitelist.sol/OVM_DeployerWhitelist.json')
const OVM_ECDSAContractAccount = require('../artifacts/contracts/optimistic-ethereum/OVM/predeploys/OVM_ECDSAContractAccount.sol/OVM_ECDSAContractAccount.json')
const OVM_SequencerEntrypoint = require('../artifacts/contracts/optimistic-ethereum/OVM/predeploys/OVM_SequencerEntrypoint.sol/OVM_SequencerEntrypoint.json')
const ERC1820Registry = require('../artifacts/contracts/optimistic-ethereum/OVM/predeploys/ERC1820Registry.sol/ERC1820Registry.json')
const Lib_AddressManager = require('../artifacts/contracts/optimistic-ethereum/libraries/resolver/Lib_AddressManager.sol/Lib_AddressManager.json')

export const getL2ContractData = () => {
return {
Expand Down
56 changes: 25 additions & 31 deletions packages/contracts/src/contract-defs.ts
@@ -1,66 +1,60 @@
import {
ethers,
ContractFactory,
Signer,
providers,
Contract,
constants,
} from 'ethers'
import { Interface } from 'ethers/lib/utils'
import { ethers } from 'ethers'

export const getContractDefinition = (name: string, ovm?: boolean): any => {
export const getContractDefinition = (name: string): any => {
// We import this using `require` because hardhat tries to build this file when compiling
// the contracts, but we need the contracts to be compiled before the contract-artifacts.ts
// file can be generated.
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { getContractArtifact } = require('./contract-artifacts')
const artifact = getContractArtifact(name, ovm)
const artifact = getContractArtifact(name)
if (artifact === undefined) {
throw new Error(`Unable to find artifact for contract: ${name}`)
}
return artifact
}

export const getContractInterface = (
name: string,
ovm?: boolean
): Interface => {
const definition = getContractDefinition(name, ovm)
export const getContractInterface = (name: string): ethers.utils.Interface => {
const definition = getContractDefinition(name)
return new ethers.utils.Interface(definition.abi)
}

export const getContractFactory = (
name: string,
signer?: Signer,
ovm?: boolean
): ContractFactory => {
const definition = getContractDefinition(name, ovm)
const contractInterface = getContractInterface(name, ovm)
return new ContractFactory(contractInterface, definition.bytecode, signer)
signer?: ethers.Signer
): ethers.ContractFactory => {
const definition = getContractDefinition(name)
const contractInterface = getContractInterface(name)
return new ethers.ContractFactory(
contractInterface,
definition.bytecode,
signer
)
}

export const loadContract = (
name: string,
address: string,
provider: providers.JsonRpcProvider
): Contract => {
return new Contract(address, getContractInterface(name) as any, provider)
provider: ethers.providers.JsonRpcProvider
): ethers.Contract => {
return new ethers.Contract(
address,
getContractInterface(name) as any,
provider
)
}

export const loadContractFromManager = async (args: {
name: string
proxy?: string
Lib_AddressManager: Contract
provider: providers.JsonRpcProvider
}): Promise<Contract> => {
Lib_AddressManager: ethers.Contract
provider: ethers.providers.JsonRpcProvider
}): Promise<ethers.Contract> => {
const { name, proxy, Lib_AddressManager, provider } = args
const address = await Lib_AddressManager.getAddress(proxy ? proxy : name)

if (address === constants.AddressZero) {
if (address === ethers.constants.AddressZero) {
throw new Error(
`Lib_AddressManager does not have a record for a contract named: ${name}`
)
}

return loadContract(name, address, provider)
}
5 changes: 1 addition & 4 deletions packages/contracts/tasks/l2-gasprice.ts
Expand Up @@ -27,10 +27,7 @@ task('set-l2-gasprice')
provider
)

const GasPriceOracleArtifact = getContractDefinition(
'OVM_GasPriceOracle',
true
)
const GasPriceOracleArtifact = getContractDefinition('OVM_GasPriceOracle')

const GasPriceOracle = new ethers.Contract(
predeploys.OVM_GasPriceOracle,
Expand Down

0 comments on commit 322475c

Please sign in to comment.