-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix/inline config parse on large build inputs #8118
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
base: main
Are you sure you want to change the base?
Changes from all commits
112fe92
2d07a10
dcfa1b1
55a2dff
00e080f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "hardhat": patch | ||
| --- | ||
|
|
||
| Fix inline config reading for large buildinfo files |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,6 +91,7 @@ onuncaughtexception | |
| perché | ||
| perché | ||
| popd | ||
| popescuoctavian | ||
| PREVRANDAO | ||
| pushd | ||
| randao | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| ~/.foundry/bin/forge install --no-git \ | ||
| github.com/foundry-rs/forge-std@6853b9ec7df5dc0c213b05ae67785ad4f4baa0ea \ | ||
| github.com/runtimeverification/kontrol-cheatcodes@2c48ae1ab44228c199dca29414c0b4b18a3434e6 \ | ||
| github.com/ethereum-optimism/lib-keccak@3b1e7bbb4cc23e9228097cfebe42aedaf3b8f2b9 \ | ||
| github.com/OpenZeppelin/openzeppelin-contracts@ecd2ca2cd7cac116f7a37d0e474bbb3d7d5e1c4d \ | ||
| github.com/OpenZeppelin/openzeppelin-contracts-upgradeable@0a2cb9a445c365870ed7a8ab461b12acf3e27d63 \ | ||
| github.com/transmissions11/solmate@8f9b23f8838670afda0fd8983f2c41e8037ae6bc \ | ||
| github.com/safe-global/safe-contracts@bf943f80fec5ac647159d26161446ac5d716a294 \ | ||
| github.com/Vectorized/solady@502cc1ea718e6fa73b380635ee0868b0740595f0 \ | ||
| github.com/base/nitro-validator@0f006d2075637dd9640e530c4a7065f5c8bb2132 \ | ||
| github.com/base/op-enclave@a2d5398f04c3a8e4df929d58ee638ba4a037bfec \ | ||
| github.com/risc0/risc0-ethereum@a78ac4a52fe9cfa14120c3b496430f0d42e1d8d3 \ | ||
| github.com/succinctlabs/sp1-contracts@22c4a47cd0a388cb4e25b4f2513954e4275c74ca | ||
|
|
||
| ~/.foundry/bin/forge install --no-git \ | ||
| github.com/ethereum-optimism/superchain-registry@84bce73573f130008d84bae6e924163bab589a11 | ||
|
|
||
| git clone --no-checkout https://github.com/OpenZeppelin/openzeppelin-contracts.git lib/openzeppelin-contracts-v5 | ||
| git -C lib/openzeppelin-contracts-v5 checkout dbb6104ce834628e473d2173bbc9d47f81a9eec3 | ||
|
|
||
| git clone --no-checkout https://github.com/Vectorized/solady.git lib/solady-v0.0.245 | ||
| git -C lib/solady-v0.0.245 checkout 8583a6e386b897f3db142a541f86d5953eccd835 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "$schema": "../../scripts/end-to-end/schema/scenario.schema.json", | ||
| "description": "Base contracts main branch (Foundry Solidity test suite)", | ||
| "tags": ["external-repo"], | ||
| "repo": "popescuoctavian/base-contracts", | ||
| "commit": "8f365822e412f90a57b80ba6571815bb1152fe79", | ||
| "packageManager": "pnpm", | ||
| "submodules": true, | ||
| "preinstall": "./preinstall.sh", | ||
| "defaultCommand": "pnpm hardhat test solidity" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ import { | |
| HardhatError, | ||
| assertHardhatInvariant, | ||
| } from "@nomicfoundation/hardhat-errors"; | ||
| import { bytesToUtf8String } from "@nomicfoundation/hardhat-utils/bytes"; | ||
| import { readJsonFileAsStream } from "@nomicfoundation/hardhat-utils/fs"; | ||
|
|
||
| import { getFullyQualifiedName } from "../../../../utils/contract-names.js"; | ||
|
|
||
|
|
@@ -48,11 +48,11 @@ interface CollectedOverrides { | |
| * in the solc AST. It only extracts them from the build info where each | ||
| * test artifact's file was compiled as a root file. | ||
| */ | ||
| export function getTestFunctionOverrides( | ||
| export async function getTestFunctionOverrides( | ||
| testSuiteArtifacts: EdrArtifactWithMetadata[], | ||
| buildInfosAndOutputs: BuildInfoAndOutput[], | ||
| ): TestFunctionOverride[] { | ||
| const allRawOverrides = collectRawOverrides( | ||
| ): Promise<TestFunctionOverride[]> { | ||
| const allRawOverrides = await collectRawOverrides( | ||
| testSuiteArtifacts, | ||
| buildInfosAndOutputs, | ||
| ); | ||
|
|
@@ -62,10 +62,10 @@ export function getTestFunctionOverrides( | |
| return buildTestFunctionOverrides(allRawOverrides); | ||
| } | ||
|
|
||
| function collectRawOverrides( | ||
| async function collectRawOverrides( | ||
| testSuiteArtifacts: EdrArtifactWithMetadata[], | ||
| buildInfosAndOutputs: BuildInfoAndOutput[], | ||
| ): CollectedOverrides { | ||
| ): Promise<CollectedOverrides> { | ||
| const overrides: RawInlineOverride[] = []; | ||
| const methodIdentifiersByContract = new Map<string, Record<string, string>>(); | ||
|
|
||
|
|
@@ -153,8 +153,8 @@ function collectRawOverrides( | |
| continue; | ||
| } | ||
|
|
||
| const buildInfoOutput: SolidityBuildInfoOutput = JSON.parse( | ||
| bytesToUtf8String(buildInfoAndOutput.output), | ||
| const buildInfoOutput = await readJsonFileAsStream<SolidityBuildInfoOutput>( | ||
| buildInfoAndOutput.buildInfoOutputPath, | ||
| ); | ||
|
Comment on lines
+156
to
158
|
||
|
|
||
| for (const [ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,11 @@ | ||
| import type { EdrArtifactWithMetadata } from "../../../../../src/internal/builtin-plugins/solidity-test/edr-artifacts.js"; | ||
| import type { RawInlineOverride } from "../../../../../src/internal/builtin-plugins/solidity-test/inline-config/index.js"; | ||
|
|
||
| import { randomUUID } from "node:crypto"; | ||
| import { writeFileSync } from "node:fs"; | ||
| import { tmpdir } from "node:os"; | ||
| import { join } from "node:path"; | ||
|
|
||
| import { utf8StringToBytes } from "@nomicfoundation/hardhat-utils/bytes"; | ||
|
|
||
| export function makeRawOverride( | ||
|
|
@@ -57,7 +62,12 @@ export function makeBuildInfo( | |
| >, | ||
| solcVersion = "0.8.23", | ||
| buildInfoId = "test-build-info-id", | ||
| ): { buildInfo: Uint8Array; output: Uint8Array; buildInfoId: string } { | ||
| ): { | ||
| buildInfo: Uint8Array; | ||
| output: Uint8Array; | ||
| buildInfoId: string; | ||
| buildInfoOutputPath: string; | ||
| } { | ||
| const buildInfoJson = { | ||
| _format: "hh3-sol-build-info-1", | ||
| id: "test-build-info", | ||
|
|
@@ -121,9 +131,14 @@ export function makeBuildInfo( | |
| }, | ||
| }; | ||
|
|
||
| const outputJsonString = JSON.stringify(outputJson); | ||
| const buildInfoOutputPath = join(tmpdir(), `${randomUUID()}.json`); | ||
| writeFileSync(buildInfoOutputPath, outputJsonString); | ||
|
|
||
|
Comment on lines
+134
to
+137
|
||
| return { | ||
| buildInfo: utf8StringToBytes(JSON.stringify(buildInfoJson)), | ||
| output: utf8StringToBytes(JSON.stringify(outputJson)), | ||
| output: utf8StringToBytes(outputJsonString), | ||
| buildInfoId, | ||
| buildInfoOutputPath, | ||
| }; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.