-
Notifications
You must be signed in to change notification settings - Fork 41
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
feat(contracts): numerous improvements to deploy scripts (+). #1108
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e7b3f51
feat(contracts): numerous improvements to deploy scripts (+).
raulk 86123d1
prettier fmt.
raulk 1fa4db8
chore(ci): remove codespell. (#1109)
raulk 72cd7a0
chore(ci): fix pnpm audit vulns. (#1110)
raulk 59ce4c7
Merge branch 'main' into raulk/simplify-deploy
raulk c6178cc
chore(ci): increase pnpm audit threshold to moderate issues.
raulk 4a58a4d
use extendProvider instead of extendEnvironment.
raulk e2a182f
hardcode RPCs for static networks; better define auto.
raulk 4376db1
fix aderyn build.
raulk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,4 @@ jobs: | |
- name: NPM Audit | ||
run: | | ||
cd contracts | ||
pnpm audit | ||
pnpm audit --audit-level=moderate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,17 +78,3 @@ jobs: | |
run: cd contracts && pnpm exec prettier --check 'contracts/**/*.sol' 'test/*.sol' | ||
- name: Solhint check | ||
run: cd contracts && pnpm exec solhint 'contracts/**/*.sol' | ||
|
||
codespell: | ||
name: Codespell check | ||
runs-on: ubuntu-latest | ||
if: ${{ !github.event.pull_request.draft }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: CodeSpell check | ||
uses: codespell-project/[email protected] | ||
with: | ||
check_hidden: true | ||
check_filenames: true | ||
path: contracts/contracts/*,contracts/script/*,contracts/scripts/*,contracts/test/* | ||
ignore_words_file: contracts/.codespellignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { extendEnvironment } from 'hardhat/config' | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types' | ||
import '@nomiclabs/hardhat-ethers' | ||
import { ProviderError } from 'hardhat/internal/core/providers/errors' | ||
|
||
extendEnvironment((hre) => { | ||
injectFilecoinProvider(hre) | ||
}) | ||
|
||
const emptyBlock = { | ||
number: '0x0', | ||
hash: '0x0000000000000000000000000000000000000000000000000000000000000000', | ||
parentHash: '0x0000000000000000000000000000000000000000000000000000000000000000', | ||
mixHash: '0x0000000000000000000000000000000000000000000000000000000000000000', | ||
nonce: '0x0000000000000000', | ||
sha3Uncles: '0x0000000000000000000000000000000000000000000000000000000000000000', | ||
logsBloom: '0x' + '00'.repeat(256), | ||
transactionsRoot: '0x0000000000000000000000000000000000000000000000000000000000000000', | ||
stateRoot: '0x0000000000000000000000000000000000000000000000000000000000000000', | ||
receiptsRoot: '0x0000000000000000000000000000000000000000000000000000000000000000', | ||
miner: '0x0000000000000000000000000000000000000000', | ||
difficulty: '0x0', | ||
totalDifficulty: '0x0', | ||
extraData: '0x', | ||
size: '0x0', | ||
gasLimit: '0x0', | ||
gasUsed: '0x0', | ||
timestamp: '0x0', | ||
transactions: [], | ||
uncles: [], | ||
} | ||
|
||
function injectFilecoinProvider(hre: HardhatRuntimeEnvironment) { | ||
const interceptedRpcMethods = ['eth_getBlockByNumber', 'eth_getBlockByHash'] | ||
hre.network.provider = new Proxy(hre.network.provider, { | ||
get(target, prop, _receiver) { | ||
const orig = (target as any)[prop] | ||
// (prop === 'send' || prop === 'sendAsync') | ||
// Ethers / Web3 / Hardhat provider classes are a mess and they intermix through the call stack. | ||
// With this exact configuration, this code sees ExternalProvider#request(request: { method: string; params?: Array<any>; }); | ||
// calls only. But if we switch to Hardhat Ignition, this is likely to change. | ||
if (!(typeof orig === 'function')) { | ||
return orig | ||
} | ||
let methodFunc: (args: any[]) => string | ||
if (prop === 'send' || prop === 'sendAsync') { | ||
methodFunc = ([method]: any[]) => method | ||
} else if (prop === 'request') { | ||
methodFunc = ([{ method }]: any[]) => method | ||
} else { | ||
return orig | ||
} | ||
return async (...args: any[]) => { | ||
try { | ||
return await (target as any)[prop](...args) | ||
} catch (err) { | ||
const method = methodFunc(args) | ||
if ( | ||
interceptedRpcMethods.includes(method) && | ||
err.message.includes('requested epoch was a null round') | ||
) { | ||
console.warn('null round hit, returning empty block') | ||
return emptyBlock | ||
} | ||
console.log(`Rethrowing error ${err}`) | ||
throw err | ||
} | ||
} | ||
}, | ||
}) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cryptoAtwill @gvelez17 @avichalp here's the extension that injects a custom provider to deal with null rounds through the RPC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xBalbinus @rk-rishikesh I'll submit this to the Hardhat FEVM kit so Filecoin devs can also benefit.