Commit a14047b0 authored by Kelvin Fichter's avatar Kelvin Fichter

refactor: remove hardhat-ovm plugin and its deps

parent 1e63ffa0
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
# packages/contracts/ @smartcontracts @ben-chain @maurelian @elenadimitrova # packages/contracts/ @smartcontracts @ben-chain @maurelian @elenadimitrova
# packages/specs/protocol/ @smartcontracts @ben-chain @maurelian # packages/specs/protocol/ @smartcontracts @ben-chain @maurelian
# ops/ @tynes @karlfloersch # ops/ @tynes @karlfloersch
# packages/hardhat-ovm/ @smartcontracts
# packages/core-utils/ @smartcontracts @annieke @ben-chain # packages/core-utils/ @smartcontracts @annieke @ben-chain
# packages/common-ts/ @annieke # packages/common-ts/ @annieke
# packages/core-utils/src/watcher.ts @K-Ho # packages/core-utils/src/watcher.ts @K-Ho
......
...@@ -30,8 +30,5 @@ M-core-utils: ...@@ -30,8 +30,5 @@ M-core-utils:
M-dtl: M-dtl:
- any: ['packages/data-transport-layer/**/*'] - any: ['packages/data-transport-layer/**/*']
M-hardhat-ovm:
- any: ['packages/hardhat-ovm/**/*']
M-ops: M-ops:
- any: ['ops/**/*'] - any: ['ops/**/*']
...@@ -8,9 +8,7 @@ coverage.json ...@@ -8,9 +8,7 @@ coverage.json
dist dist
artifacts artifacts
artifacts-ovm
cache cache
cache-ovm
l2geth/build/bin l2geth/build/bin
packages/contracts/deployments/custom packages/contracts/deployments/custom
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
"eslint.workingDirectories": [ "eslint.workingDirectories": [
{"directory": "packages/core-utils", "changeProcessCWD": true }, {"directory": "packages/core-utils", "changeProcessCWD": true },
{"directory": "packages/common-ts", "changeProcessCWD": true }, {"directory": "packages/common-ts", "changeProcessCWD": true },
{"directory": "packages/hardhat-ovm", "changeProcessCWD": true },
{"directory": "packages/contracts", "changeProcessCWD": true }, {"directory": "packages/contracts", "changeProcessCWD": true },
{"directory": "packages/data-transport-layer", "changeProcessCWD": true }, {"directory": "packages/data-transport-layer", "changeProcessCWD": true },
{"directory": "packages/batch-submitter", "changeProcessCWD": true }, {"directory": "packages/batch-submitter", "changeProcessCWD": true },
......
...@@ -5,7 +5,6 @@ ...@@ -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). 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/core-utils
- packages/hardhat-ovm
- packages/common-ts - packages/common-ts
- integration-tests - integration-tests
......
...@@ -27,7 +27,6 @@ Extensive documentation is available [here](http://community.optimism.io/docs/). ...@@ -27,7 +27,6 @@ Extensive documentation is available [here](http://community.optimism.io/docs/).
* [`contracts`](./packages/contracts): Solidity smart contracts implementing the OVM * [`contracts`](./packages/contracts): Solidity smart contracts implementing the OVM
* [`core-utils`](./packages/core-utils): Low-level utilities and encoding packages * [`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 * [`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 * [`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 * [`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 * [`message-relayer`](./packages/message-relayer): Service for relaying L2 messages to L1
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
"test:integration": "hardhat --network optimism test", "test:integration": "hardhat --network optimism test",
"test:integration:live": "IS_LIVE_NETWORK=true 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", "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": { "devDependencies": {
"@eth-optimism/contracts": "^0.4.14", "@eth-optimism/contracts": "^0.4.14",
......
...@@ -21,7 +21,6 @@ COPY --from=builder /optimism/packages/contracts/package.json ./packages/contrac ...@@ -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/deployments ./packages/contracts/deployments
COPY --from=builder /optimism/packages/contracts/dist ./packages/contracts/dist 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 ./packages/contracts/artifacts
COPY --from=builder /optimism/packages/contracts/artifacts-ovm ./packages/contracts/artifacts-ovm
# copy the service # copy the service
WORKDIR /opt/optimism/packages/batch-submitter WORKDIR /opt/optimism/packages/batch-submitter
......
...@@ -22,7 +22,6 @@ COPY --from=builder /optimism/packages/contracts/package.json ./packages/contrac ...@@ -22,7 +22,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/deployments ./packages/contracts/deployments
COPY --from=builder /optimism/packages/contracts/dist ./packages/contracts/dist 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 ./packages/contracts/artifacts
COPY --from=builder /optimism/packages/contracts/artifacts-ovm ./packages/contracts/artifacts-ovm
# copy the service # copy the service
WORKDIR /opt/optimism/packages/data-transport-layer WORKDIR /opt/optimism/packages/data-transport-layer
......
...@@ -14,16 +14,12 @@ COPY --from=builder /optimism/node_modules ./node_modules ...@@ -14,16 +14,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/package.json ./packages/core-utils/package.json
COPY --from=builder /optimism/packages/core-utils/dist ./packages/core-utils/dist 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 # get the needed built artifacts
WORKDIR /opt/optimism/packages/contracts WORKDIR /opt/optimism/packages/contracts
COPY --from=builder /optimism/packages/contracts/dist ./dist COPY --from=builder /optimism/packages/contracts/dist ./dist
COPY --from=builder /optimism/packages/contracts/*.json ./ COPY --from=builder /optimism/packages/contracts/*.json ./
COPY --from=builder /optimism/packages/contracts/node_modules ./node_modules 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 ./artifacts
COPY --from=builder /optimism/packages/contracts/artifacts-ovm ./artifacts-ovm
# get non-build artifacts from the host # get non-build artifacts from the host
COPY packages/contracts/bin ./bin COPY packages/contracts/bin ./bin
......
...@@ -17,9 +17,6 @@ COPY --from=builder /optimism/packages/core-utils/dist ./packages/core-utils/dis ...@@ -17,9 +17,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/package.json ./packages/message-relayer/package.json
COPY --from=builder /optimism/packages/message-relayer/dist ./packages/message-relayer/dist 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 COPY --from=builder /optimism/packages/contracts ./packages/contracts
# get the needed built artifacts # get the needed built artifacts
......
...@@ -22,7 +22,6 @@ COPY --from=builder /optimism/packages/contracts/package.json ./packages/contrac ...@@ -22,7 +22,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/deployments ./packages/contracts/deployments
COPY --from=builder /optimism/packages/contracts/dist ./packages/contracts/dist 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 ./packages/contracts/artifacts
COPY --from=builder /optimism/packages/contracts/artifacts-ovm ./packages/contracts/artifacts-ovm
# copy the service # copy the service
WORKDIR /opt/optimism/packages/message-relayer WORKDIR /opt/optimism/packages/message-relayer
......
...@@ -26,7 +26,6 @@ WORKDIR /optimism ...@@ -26,7 +26,6 @@ WORKDIR /optimism
COPY *.json yarn.lock ./ COPY *.json yarn.lock ./
COPY packages/core-utils/package.json ./packages/core-utils/package.json COPY packages/core-utils/package.json ./packages/core-utils/package.json
COPY packages/common-ts/package.json ./packages/common-ts/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/contracts/package.json ./packages/contracts/package.json
COPY packages/data-transport-layer/package.json ./packages/data-transport-layer/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 COPY packages/batch-submitter/package.json ./packages/batch-submitter/package.json
......
...@@ -13,7 +13,6 @@ import '@nomiclabs/hardhat-waffle' ...@@ -13,7 +13,6 @@ import '@nomiclabs/hardhat-waffle'
import '@nomiclabs/hardhat-etherscan' import '@nomiclabs/hardhat-etherscan'
import 'hardhat-deploy' import 'hardhat-deploy'
import '@typechain/hardhat' import '@typechain/hardhat'
import '@eth-optimism/hardhat-ovm'
import './tasks/deploy' import './tasks/deploy'
import './tasks/l2-gasprice' import './tasks/l2-gasprice'
import './tasks/set-owner' import './tasks/set-owner'
...@@ -39,10 +38,8 @@ const config: HardhatUserConfig = { ...@@ -39,10 +38,8 @@ const config: HardhatUserConfig = {
tags: ['local'], tags: ['local'],
hardfork: 'istanbul', hardfork: 'istanbul',
}, },
// Add this network to your config!
optimism: { optimism: {
url: 'http://127.0.0.1:8545', url: 'http://127.0.0.1:8545',
ovm: true,
saveDeployments: false, saveDeployments: false,
}, },
'optimism-kovan': { 'optimism-kovan': {
...@@ -77,9 +74,6 @@ const config: HardhatUserConfig = { ...@@ -77,9 +74,6 @@ const config: HardhatUserConfig = {
}, },
}, },
}, },
ovm: {
solcVersion: '0.7.6+commit.3b061308',
},
typechain: { typechain: {
outDir: 'dist/types', outDir: 'dist/types',
target: 'ethers-v5', target: 'ethers-v5',
......
...@@ -5,9 +5,7 @@ ...@@ -5,9 +5,7 @@
"files": [ "files": [
"dist/**/*.js", "dist/**/*.js",
"dist/types/*.ts", "dist/types/*.ts",
"dist/types-ovm/*.ts",
"artifacts/contracts/**/*.json", "artifacts/contracts/**/*.json",
"artifacts-ovm/contracts/**/*.json",
"deployments/**/*.json", "deployments/**/*.json",
"OVM", "OVM",
"iOVM", "iOVM",
...@@ -24,10 +22,8 @@ ...@@ -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: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:typescript": "tsc -p ./tsconfig.build.json",
"build:contracts": "hardhat compile --show-stack-traces", "build:contracts": "hardhat compile --show-stack-traces",
"build:contracts:ovm": "hardhat compile --network optimism",
"build:dump": "ts-node \"bin/take-dump.ts\"", "build:dump": "ts-node \"bin/take-dump.ts\"",
"build:typechain": "hardhat typechain", "build:typechain": "hardhat typechain",
"build:typechain:ovm": "hardhat --network optimism typechain",
"test": "yarn run test:contracts", "test": "yarn run test:contracts",
"test:contracts": "hardhat test --show-stack-traces", "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", "test:gas": "hardhat test \"test/contracts/OVM/execution/OVM_StateManager.gas-spec.ts\" --no-compile --show-stack-traces",
...@@ -38,7 +34,7 @@ ...@@ -38,7 +34,7 @@
"lint:check": "eslint .", "lint:check": "eslint .",
"lint:fix": "yarn lint:check --fix", "lint:fix": "yarn lint:check --fix",
"lint:contracts": "yarn solhint -f table contracts/optimistic-ethereum/**/*.sol", "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", "deploy": "ts-node \"./bin/deploy.ts\" && yarn generate:markdown",
"serve": "./bin/serve_dump.sh", "serve": "./bin/serve_dump.sh",
"prepublishOnly": "yarn copyfiles -u 2 \"contracts/optimistic-ethereum/**/*\" ./", "prepublishOnly": "yarn copyfiles -u 2 \"contracts/optimistic-ethereum/**/*\" ./",
...@@ -60,7 +56,6 @@ ...@@ -60,7 +56,6 @@
}, },
"devDependencies": { "devDependencies": {
"@codechecks/client": "^0.1.11", "@codechecks/client": "^0.1.11",
"@eth-optimism/hardhat-ovm": "^0.2.4",
"@eth-optimism/smock": "^1.1.10", "@eth-optimism/smock": "^1.1.10",
"@ethersproject/transactions": "^5.4.0", "@ethersproject/transactions": "^5.4.0",
"@nomiclabs/hardhat-ethers": "^2.0.2", "@nomiclabs/hardhat-ethers": "^2.0.2",
......
...@@ -3,6 +3,5 @@ ...@@ -3,6 +3,5 @@
set -e set -e
yarn build:contracts yarn build:contracts
yarn build:contracts:ovm
yarn generate:artifacts yarn generate:artifacts
yarn build:typescript yarn build:typescript
...@@ -15,9 +15,6 @@ const fs = require('fs') ...@@ -15,9 +15,6 @@ const fs = require('fs')
const evmArtifactPaths = getContractJsonFiles( const evmArtifactPaths = getContractJsonFiles(
path.resolve(__dirname, `../artifacts/contracts`) path.resolve(__dirname, `../artifacts/contracts`)
) )
const ovmArtifactPaths = getContractJsonFiles(
path.resolve(__dirname, `../artifacts-ovm/contracts`)
)
const content = ` const content = `
/* eslint-disable @typescript-eslint/no-var-requires, no-empty */ /* eslint-disable @typescript-eslint/no-var-requires, no-empty */
...@@ -26,18 +23,6 @@ const fs = require('fs') ...@@ -26,18 +23,6 @@ const fs = require('fs')
DO NOT EDIT. 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 ${evmArtifactPaths
.map((artifactPath) => { .map((artifactPath) => {
const artifact = require(artifactPath) const artifact = require(artifactPath)
...@@ -51,17 +36,7 @@ const fs = require('fs') ...@@ -51,17 +36,7 @@ const fs = require('fs')
}) })
.join('\n')} .join('\n')}
export const getContractArtifact = (name: string, ovm: boolean): any => { export const getContractArtifact = (name: string): any => {
if (ovm) {
return {
${ovmArtifactPaths
.map((artifactPath) => {
const artifact = require(artifactPath)
return `${artifact.contractName}: ovm__${artifact.contractName}`
})
.join(',\n')}
}[name]
} else {
return { return {
${evmArtifactPaths ${evmArtifactPaths
.map((artifactPath) => { .map((artifactPath) => {
...@@ -71,7 +46,6 @@ const fs = require('fs') ...@@ -71,7 +46,6 @@ const fs = require('fs')
.join(',\n')} .join(',\n')}
}[name] }[name]
} }
}
` `
fs.writeFileSync(`./src/contract-artifacts.ts`, content) fs.writeFileSync(`./src/contract-artifacts.ts`, content)
......
import { Signer, Contract, providers, ethers } from 'ethers' import { Signer, Contract } from 'ethers'
import { Provider } from '@ethersproject/abstract-provider' import { Provider } from '@ethersproject/abstract-provider'
import { getL1ContractData, getL2ContractData } from './contract-data' import { getL1ContractData, getL2ContractData } from './contract-data'
......
...@@ -112,15 +112,15 @@ export const getL1ContractData = (network: Network) => { ...@@ -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_ETH = require('../artifacts/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_L2CrossDomainMessenger = require('../artifacts/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_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_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_DeployerWhitelist = require('../artifacts/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_ECDSAContractAccount = require('../artifacts/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 OVM_SequencerEntrypoint = require('../artifacts/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 ERC1820Registry = require('../artifacts/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 Lib_AddressManager = require('../artifacts/contracts/optimistic-ethereum/libraries/resolver/Lib_AddressManager.sol/Lib_AddressManager.json')
export const getL2ContractData = () => { export const getL2ContractData = () => {
return { return {
......
import { import { ethers } from 'ethers'
ethers,
ContractFactory,
Signer,
providers,
Contract,
constants,
} from 'ethers'
import { Interface } from 'ethers/lib/utils'
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 // 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 // the contracts, but we need the contracts to be compiled before the contract-artifacts.ts
// file can be generated. // file can be generated.
// eslint-disable-next-line @typescript-eslint/no-var-requires // eslint-disable-next-line @typescript-eslint/no-var-requires
const { getContractArtifact } = require('./contract-artifacts') const { getContractArtifact } = require('./contract-artifacts')
const artifact = getContractArtifact(name, ovm) const artifact = getContractArtifact(name)
if (artifact === undefined) { if (artifact === undefined) {
throw new Error(`Unable to find artifact for contract: ${name}`) throw new Error(`Unable to find artifact for contract: ${name}`)
} }
return artifact return artifact
} }
export const getContractInterface = ( export const getContractInterface = (name: string): ethers.utils.Interface => {
name: string, const definition = getContractDefinition(name)
ovm?: boolean
): Interface => {
const definition = getContractDefinition(name, ovm)
return new ethers.utils.Interface(definition.abi) return new ethers.utils.Interface(definition.abi)
} }
export const getContractFactory = ( export const getContractFactory = (
name: string, name: string,
signer?: Signer, signer?: ethers.Signer
ovm?: boolean ): ethers.ContractFactory => {
): ContractFactory => { const definition = getContractDefinition(name)
const definition = getContractDefinition(name, ovm) const contractInterface = getContractInterface(name)
const contractInterface = getContractInterface(name, ovm) return new ethers.ContractFactory(
return new ContractFactory(contractInterface, definition.bytecode, signer) contractInterface,
definition.bytecode,
signer
)
} }
export const loadContract = ( export const loadContract = (
name: string, name: string,
address: string, address: string,
provider: providers.JsonRpcProvider provider: ethers.providers.JsonRpcProvider
): Contract => { ): ethers.Contract => {
return new Contract(address, getContractInterface(name) as any, provider) return new ethers.Contract(
address,
getContractInterface(name) as any,
provider
)
} }
export const loadContractFromManager = async (args: { export const loadContractFromManager = async (args: {
name: string name: string
proxy?: string proxy?: string
Lib_AddressManager: Contract Lib_AddressManager: ethers.Contract
provider: providers.JsonRpcProvider provider: ethers.providers.JsonRpcProvider
}): Promise<Contract> => { }): Promise<ethers.Contract> => {
const { name, proxy, Lib_AddressManager, provider } = args const { name, proxy, Lib_AddressManager, provider } = args
const address = await Lib_AddressManager.getAddress(proxy ? proxy : name) const address = await Lib_AddressManager.getAddress(proxy ? proxy : name)
if (address === ethers.constants.AddressZero) {
if (address === constants.AddressZero) {
throw new Error( throw new Error(
`Lib_AddressManager does not have a record for a contract named: ${name}` `Lib_AddressManager does not have a record for a contract named: ${name}`
) )
} }
return loadContract(name, address, provider) return loadContract(name, address, provider)
} }
...@@ -27,10 +27,7 @@ task('set-l2-gasprice') ...@@ -27,10 +27,7 @@ task('set-l2-gasprice')
provider provider
) )
const GasPriceOracleArtifact = getContractDefinition( const GasPriceOracleArtifact = getContractDefinition('OVM_GasPriceOracle')
'OVM_GasPriceOracle',
true
)
const GasPriceOracle = new ethers.Contract( const GasPriceOracle = new ethers.Contract(
predeploys.OVM_GasPriceOracle, predeploys.OVM_GasPriceOracle,
......
/* Internal Imports */
import {
ExecutionManagerTestRunner,
TestDefinition,
OVM_TX_GAS_LIMIT,
NON_NULL_BYTES32,
REVERT_FLAGS,
VERIFIED_EMPTY_CONTRACT_HASH,
} from '../../../../helpers'
const DUMMY_REVERT_DATA =
'0xdeadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420'
const DEAD_ADDRESS = '0xdeaddeaddeaddeaddeaddeaddeaddeaddead1234'
const test_ovmCALL: TestDefinition = {
name: 'Basic tests for ovmCALL',
preState: {
ExecutionManager: {
ovmStateManager: '$OVM_STATE_MANAGER',
ovmSafetyChecker: '$OVM_SAFETY_CHECKER',
messageRecord: {
nuisanceGasLeft: OVM_TX_GAS_LIMIT,
},
},
StateManager: {
owner: '$OVM_EXECUTION_MANAGER',
accounts: {
$DUMMY_OVM_ADDRESS_1: {
codeHash: NON_NULL_BYTES32,
ethAddress: '$OVM_CALL_HELPER',
},
$DUMMY_OVM_ADDRESS_2: {
codeHash: NON_NULL_BYTES32,
ethAddress: '$OVM_CALL_HELPER',
},
$DUMMY_OVM_ADDRESS_3: {
codeHash: VERIFIED_EMPTY_CONTRACT_HASH,
ethAddress: '0x' + '00'.repeat(20),
},
},
verifiedContractStorage: {
$DUMMY_OVM_ADDRESS_1: {
[NON_NULL_BYTES32]: true,
},
},
},
},
parameters: [
{
name: 'ovmCALL(ADDRESS_1) => ovmADDRESS',
steps: [
{
functionName: 'ovmCALL',
functionParams: {
gasLimit: OVM_TX_GAS_LIMIT,
target: '$DUMMY_OVM_ADDRESS_1',
subSteps: [
{
functionName: 'ovmADDRESS',
expectedReturnValue: '$DUMMY_OVM_ADDRESS_1',
},
],
},
expectedReturnStatus: true,
},
],
},
{
name: 'ovmCALL(ADDRESS_1) => ovmSSTORE',
steps: [
{
functionName: 'ovmCALL',
functionParams: {
gasLimit: OVM_TX_GAS_LIMIT,
target: '$DUMMY_OVM_ADDRESS_1',
subSteps: [
{
functionName: 'ovmSSTORE',
functionParams: {
key: NON_NULL_BYTES32,
value: NON_NULL_BYTES32,
},
expectedReturnStatus: true,
},
],
},
expectedReturnStatus: true,
},
],
},
{
name: 'ovmCALL(ADDRESS_1) => ovmSSTORE + ovmSLOAD, ovmCALL(ADDRESS_1) => ovmSLOAD',
steps: [
{
functionName: 'ovmCALL',
functionParams: {
gasLimit: OVM_TX_GAS_LIMIT,
target: '$DUMMY_OVM_ADDRESS_1',
subSteps: [
{
functionName: 'ovmSSTORE',
functionParams: {
key: NON_NULL_BYTES32,
value: NON_NULL_BYTES32,
},
expectedReturnStatus: true,
},
{
functionName: 'ovmSLOAD',
functionParams: {
key: NON_NULL_BYTES32,
},
expectedReturnStatus: true,
expectedReturnValue: NON_NULL_BYTES32,
},
],
},
expectedReturnStatus: true,
},
{
functionName: 'ovmCALL',
functionParams: {
gasLimit: OVM_TX_GAS_LIMIT,
target: '$DUMMY_OVM_ADDRESS_1',
subSteps: [
{
functionName: 'ovmSLOAD',
functionParams: {
key: NON_NULL_BYTES32,
},
expectedReturnStatus: true,
expectedReturnValue: NON_NULL_BYTES32,
},
],
},
expectedReturnStatus: true,
},
],
},
{
name: 'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_2) => ovmADDRESS + ovmCALLER',
steps: [
{
functionName: 'ovmCALL',
functionParams: {
gasLimit: OVM_TX_GAS_LIMIT,
target: '$DUMMY_OVM_ADDRESS_1',
subSteps: [
{
functionName: 'ovmCALL',
functionParams: {
gasLimit: OVM_TX_GAS_LIMIT,
target: '$DUMMY_OVM_ADDRESS_2',
subSteps: [
{
functionName: 'ovmADDRESS',
expectedReturnValue: '$DUMMY_OVM_ADDRESS_2',
},
{
functionName: 'ovmCALLER',
expectedReturnValue: '$DUMMY_OVM_ADDRESS_1',
},
],
},
expectedReturnStatus: true,
},
],
},
expectedReturnStatus: true,
},
],
},
{
name: 'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_3)',
steps: [
{
functionName: 'ovmCALL',
functionParams: {
gasLimit: OVM_TX_GAS_LIMIT,
target: '$DUMMY_OVM_ADDRESS_1',
subSteps: [
{
functionName: 'ovmCALL',
functionParams: {
gasLimit: OVM_TX_GAS_LIMIT,
target: '$DUMMY_OVM_ADDRESS_3',
calldata: '0x',
},
expectedReturnStatus: true,
},
],
},
expectedReturnStatus: true,
expectedReturnValue: '0x',
},
],
},
{
name: 'ovmCALL(ADDRESS_1) => INTENTIONAL_REVERT',
steps: [
{
functionName: 'ovmCALL',
functionParams: {
gasLimit: OVM_TX_GAS_LIMIT,
target: '$DUMMY_OVM_ADDRESS_1',
subSteps: [
{
functionName: 'evmREVERT',
returnData: {
flag: REVERT_FLAGS.INTENTIONAL_REVERT,
data: DUMMY_REVERT_DATA,
},
},
],
},
expectedReturnStatus: false,
expectedReturnValue: DUMMY_REVERT_DATA,
},
],
},
{
name: 'ovmCALL(ADDRESS_1) => EXCEEDS_NUISANCE_GAS',
steps: [
{
functionName: 'ovmCALL',
functionParams: {
gasLimit: OVM_TX_GAS_LIMIT,
target: '$DUMMY_OVM_ADDRESS_1',
subSteps: [
{
functionName: 'evmREVERT',
returnData: {
flag: REVERT_FLAGS.EXCEEDS_NUISANCE_GAS,
},
},
],
},
expectedReturnStatus: false,
expectedReturnValue: '0x',
},
],
},
{
name: 'ovmCALL(0xdeaddeaddead...) returns (true, 0x)',
steps: [
{
functionName: 'ovmCALL',
functionParams: {
gasLimit: OVM_TX_GAS_LIMIT,
target: DEAD_ADDRESS,
subSteps: [],
},
expectedReturnStatus: true,
expectedReturnValue: {
ovmSuccess: true,
returnData: '0x',
},
},
],
},
],
}
const runner = new ExecutionManagerTestRunner()
runner.run(test_ovmCALL)
...@@ -71,7 +71,7 @@ const test_ovmCREATEEOA: TestDefinition = { ...@@ -71,7 +71,7 @@ const test_ovmCREATEEOA: TestDefinition = {
}, },
expectedReturnStatus: true, expectedReturnStatus: true,
expectedReturnValue: fromHexString( expectedReturnValue: fromHexString(
getContractDefinition('OVM_ProxyEOA', true).deployedBytecode getContractDefinition('OVM_ProxyEOA').deployedBytecode
).length, ).length,
}, },
], ],
......
/* Internal Imports */
import { constants } from 'ethers'
import {
ExecutionManagerTestRunner,
TestDefinition,
OVM_TX_GAS_LIMIT,
NON_NULL_BYTES32,
VERIFIED_EMPTY_CONTRACT_HASH,
} from '../../../../helpers'
const GAS_METADATA_ADDRESS = '0x06a506a506a506a506a506a506a506a506a506a5'
enum GasMetadataKey {
CURRENT_EPOCH_START_TIMESTAMP,
CUMULATIVE_SEQUENCER_QUEUE_GAS,
CUMULATIVE_L1TOL2_QUEUE_GAS,
PREV_EPOCH_SEQUENCER_QUEUE_GAS,
PREV_EPOCH_L1TOL2_QUEUE_GAS,
}
const keyToBytes32 = (key: GasMetadataKey): string => {
return '0x' + `0${key}`.padStart(64, '0')
}
const test_run: TestDefinition = {
name: 'Basic tests for ovmCALL',
preState: {
ExecutionManager: {
ovmStateManager: '$OVM_STATE_MANAGER',
ovmSafetyChecker: '$OVM_SAFETY_CHECKER',
messageRecord: {
nuisanceGasLeft: OVM_TX_GAS_LIMIT,
},
},
StateManager: {
owner: '$OVM_EXECUTION_MANAGER',
accounts: {
$DUMMY_OVM_ADDRESS_1: {
codeHash: NON_NULL_BYTES32,
ethAddress: '$OVM_CALL_HELPER',
},
$DUMMY_OVM_ADDRESS_2: {
codeHash: NON_NULL_BYTES32,
ethAddress: '$OVM_CALL_HELPER',
},
$DUMMY_OVM_ADDRESS_3: {
codeHash: VERIFIED_EMPTY_CONTRACT_HASH,
ethAddress: '0x' + '00'.repeat(20),
},
},
contractStorage: {
[GAS_METADATA_ADDRESS]: {
[keyToBytes32(GasMetadataKey.CURRENT_EPOCH_START_TIMESTAMP)]: 1,
[keyToBytes32(GasMetadataKey.CUMULATIVE_SEQUENCER_QUEUE_GAS)]: 0,
[keyToBytes32(GasMetadataKey.CUMULATIVE_L1TOL2_QUEUE_GAS)]: 0,
[keyToBytes32(GasMetadataKey.PREV_EPOCH_SEQUENCER_QUEUE_GAS)]: 0,
[keyToBytes32(GasMetadataKey.PREV_EPOCH_L1TOL2_QUEUE_GAS)]: 0,
},
},
verifiedContractStorage: {
[GAS_METADATA_ADDRESS]: {
[keyToBytes32(GasMetadataKey.CURRENT_EPOCH_START_TIMESTAMP)]: true,
[keyToBytes32(GasMetadataKey.CUMULATIVE_SEQUENCER_QUEUE_GAS)]: true,
[keyToBytes32(GasMetadataKey.CUMULATIVE_L1TOL2_QUEUE_GAS)]: true,
[keyToBytes32(GasMetadataKey.PREV_EPOCH_SEQUENCER_QUEUE_GAS)]: true,
[keyToBytes32(GasMetadataKey.PREV_EPOCH_L1TOL2_QUEUE_GAS)]: true,
},
},
},
},
parameters: [
{
name: 'run => ovmCALL(ADDRESS_1) => ovmADDRESS',
// TODO: Appears to be failing because of a bug in smock.
skip: true,
steps: [
{
functionName: 'run',
functionParams: {
timestamp: 0,
queueOrigin: 0,
entrypoint: '$OVM_CALL_HELPER',
origin: constants.AddressZero,
msgSender: constants.AddressZero,
gasLimit: OVM_TX_GAS_LIMIT,
subSteps: [
{
functionName: 'ovmCALL',
functionParams: {
gasLimit: OVM_TX_GAS_LIMIT,
target: '$DUMMY_OVM_ADDRESS_1',
subSteps: [
{
functionName: 'ovmADDRESS',
expectedReturnValue: '$DUMMY_OVM_ADDRESS_1',
},
],
},
expectedReturnStatus: true,
},
],
},
},
],
},
// This functionality has moved to the OVM_StateTransitioner,
// but leaving here for future reference on how to use this feature of the EM TestRunner.
// {
// name: 'run with insufficient gas supplied',
// steps: [
// {
// functionName: 'run',
// suppliedGas: OVM_TX_GAS_LIMIT / 2,
// functionParams: {
// timestamp: 0,
// queueOrigin: 0,
// entrypoint: '$OVM_CALL_HELPER',
// origin: constants.AddressZero,
// msgSender: constants.AddressZero,
// gasLimit: OVM_TX_GAS_LIMIT,
// subSteps: [],
// },
// expectedRevertValue: 'Not enough gas to execute deterministically',
// },
// ],
// },
],
}
const runner = new ExecutionManagerTestRunner()
runner.run(test_run)
...@@ -231,24 +231,21 @@ export class ExecutionManagerTestRunner { ...@@ -231,24 +231,21 @@ export class ExecutionManagerTestRunner {
const DeployerWhitelist = await getContractFactory( const DeployerWhitelist = await getContractFactory(
'OVM_DeployerWhitelist', 'OVM_DeployerWhitelist',
AddressManager.signer, AddressManager.signer
true
).deploy() ).deploy()
this.contracts.OVM_DeployerWhitelist = DeployerWhitelist this.contracts.OVM_DeployerWhitelist = DeployerWhitelist
const OvmEth = await getContractFactory( const OvmEth = await getContractFactory(
'OVM_ETH', 'OVM_ETH',
AddressManager.signer, AddressManager.signer
true
).deploy() ).deploy()
this.contracts.OVM_ETH = OvmEth this.contracts.OVM_ETH = OvmEth
this.contracts.OVM_ProxyEOA = await getContractFactory( this.contracts.OVM_ProxyEOA = await getContractFactory(
'OVM_ProxyEOA', 'OVM_ProxyEOA',
AddressManager.signer, AddressManager.signer
true
).deploy() ).deploy()
this.contracts.OVM_ExecutionManager = await ( this.contracts.OVM_ExecutionManager = await (
......
module.exports = {
extends: '../../.eslintrc.js',
}
module.exports = {
...require('../../.prettierrc.js'),
};
\ No newline at end of file
(The MIT License)
Copyright 2020-2021 Optimism
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# @eth-optimism/hardhat-ovm
A plugin that brings OVM compiler support to Hardhat projects.
## Installation
```
yarn add --dev @eth-optimism/hardhat-ovm
```
Next, import the plugin inside your `hardhat.config.js`:
```js
// hardhat.config.js
require("@eth-optimism/hardhat-ovm")
```
Or if using TypeScript:
```ts
// hardhat.config.ts
import "@eth-optimism/hardhat-ovm"
```
## Configuration
**By default, this plugin will use OVM compiler version 0.7.6**.
Configure this plugin by adding an `ovm` field to your Hardhat config:
```js
// hardhat.config.js
require("@eth-optimism/hardhat-ovm")
module.exports = {
ovm: {
solcVersion: 'X.Y.Z' // Your version goes here.
}
}
```
This package also has typings so it won't break your Hardhat config if you're using TypeScript.
This diff is collapsed.
import 'hardhat/types/config'
declare module 'hardhat/types/config' {
interface HardhatUserConfig {
ovm?: {
solcVersion?: string
}
}
interface HardhatConfig {
ovm?: {
solcVersion?: string
}
}
interface HardhatNetworkUserConfig {
ovm?: boolean
ignoreRxList?: string[]
}
interface HttpNetworkUserConfig {
ovm?: boolean
ignoreRxList?: string[]
}
interface HardhatNetworkConfig {
ovm: boolean
ignoreRxList: string[]
interval?: number
}
interface HttpNetworkConfig {
ovm: boolean
ignoreRxList: string[]
interval?: number
}
}
declare module 'hardhat/types/runtime' {
interface Network {
ovm: boolean
ignoreRxList: string[]
}
}
{
"extends": "../../tsconfig.build.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
},
"include": [
"src/**/*"
]
}
{
"extends": "../../tsconfig.json"
}
...@@ -2606,10 +2606,10 @@ ...@@ -2606,10 +2606,10 @@
dependencies: dependencies:
"@types/tz-offset" "*" "@types/tz-offset" "*"
"@types/node-fetch@^2.5.10", "@types/node-fetch@^2.5.5": "@types/node-fetch@^2.5.5", "@types/node-fetch@^2.5.8":
version "2.5.12" version "2.5.10"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.12.tgz#8a6f779b1d4e60b7a57fb6fd48d84fb545b9cc66" resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.10.tgz#9b4d4a0425562f9fcea70b12cb3fcdd946ca8132"
integrity sha512-MKgC4dlq4kKNa/mYrwpKfzQMB5X3ee5U6fSprkKpToBqBmX4nFZL9cW5jl6sWn+xpRJ7ypWh2yyqqr8UUCstSw== integrity sha512-IpkX0AasN44hgEad0gEF/V6EgR5n69VEqPEgnmoM8GsIGro3PowbWs4tR6IhxUTyPLpOn+fiGG6nrQhcmoCuIQ==
dependencies: dependencies:
"@types/node" "*" "@types/node" "*"
form-data "^3.0.0" form-data "^3.0.0"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment