Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/chatty-clouds-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@eth-optimism/hardhat-ovm": minor
---

allow overriding the ethers polling interval
7 changes: 5 additions & 2 deletions packages/hardhat-ovm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
"dependencies": {
"node-fetch": "^2.6.1"
},
"devDependencies": {
"@types/mocha": "^8.2.2",
"peerDependencies": {
"ethers": "^5.1.4",
"hardhat": "^2.1.2"
},
"devDependencies": {
"@types/mocha": "^8.2.2"
}
}
26 changes: 26 additions & 0 deletions packages/hardhat-ovm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import * as fs from 'fs'
import * as path from 'path'
import fetch from 'node-fetch'
import { ethers } from 'ethers'
import { subtask, extendEnvironment } from 'hardhat/config'
import { getCompilersDir } from 'hardhat/internal/util/global-dir'
import { Artifacts } from 'hardhat/internal/artifacts'
Expand All @@ -23,6 +24,10 @@ const OPTIMISM_SOLC_BIN_URL =
// default to 0.6.X instead?
const DEFAULT_OVM_SOLC_VERSION = '0.7.6'

// Poll the node every 50ms, to override ethers.js's default 4000ms causing OVM
// tests to be slow.
const OVM_POLLING_INTERVAL = 50

/**
* Find or generate an OVM soljson.js compiler file and return the path of this file.
* We pass the path to this file into hardhat.
Expand Down Expand Up @@ -200,5 +205,26 @@ extendEnvironment((hre) => {
;(hre as any).config.typechain.outDir += '-ovm'
}
}

// if ethers is present, override the polling interval to not wait the full
// duration in tests
if ((hre as any).ethers) {
;(hre as any).ethers.getSigners = async () => {
let signers = await (hre as any).ethers.getSigners()
signers = signers.map((s: any) => {
s._signer.provider.pollingInterval =
hre.network.config.interval || OVM_POLLING_INTERVAL
return s
})
return signers
}

const provider = new ethers.providers.JsonRpcProvider(
(hre as any).ethers.provider.url
)
provider.pollingInterval =
hre.network.config.interval || OVM_POLLING_INTERVAL
;(hre as any).ethers.provider = provider
}
}
})
2 changes: 2 additions & 0 deletions packages/hardhat-ovm/src/type-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ declare module 'hardhat/types/config' {
interface HardhatNetworkConfig {
ovm: boolean
ignoreRxList: string[]
interval?: number
}

interface HttpNetworkConfig {
ovm: boolean
ignoreRxList: string[]
interval?: number
}
}

Expand Down