diff --git a/crates/tools/js/benchmark/package.json b/crates/tools/js/benchmark/package.json index fa5e4621c..181645e0b 100644 --- a/crates/tools/js/benchmark/package.json +++ b/crates/tools/js/benchmark/package.json @@ -24,6 +24,7 @@ "mocha": "^10.0.0", "prettier": "^3.2.5", "simple-git": "^3.25.0", + "smol-toml": "^1.3.0", "tsx": "^4.7.1", "typescript": "~5.5.3" }, diff --git a/crates/tools/js/benchmark/src/solidity-tests.ts b/crates/tools/js/benchmark/src/solidity-tests.ts index 6320b5c8b..5a073c2e1 100644 --- a/crates/tools/js/benchmark/src/solidity-tests.ts +++ b/crates/tools/js/benchmark/src/solidity-tests.ts @@ -1,4 +1,4 @@ -/* +/* Baseline Source: https://github.com/NomicFoundation/forge-std/tree/js-benchmark-config @@ -27,6 +27,7 @@ import { ArtifactId, ContractData, } from "@ignored/edr"; +import TOML from "smol-toml"; // This is automatically cached in CI const RPC_CACHE_PATH = "./edr-cache"; @@ -94,7 +95,6 @@ export async function runForgeStdTests(forgeStdRepoPath: string) { ); const config = getConfig(forgeStdRepoPath); - const allResults = []; const runs = new Map(); const recordRun = recordTime.bind(null, runs); @@ -162,6 +162,19 @@ export async function runForgeStdTests(forgeStdRepoPath: string) { } function getConfig(forgeStdRepoPath: string): SolidityTestRunnerConfigArgs { + const foundryTomlPath = path.join(forgeStdRepoPath, "foundry.toml"); + + if (!fs.existsSync(foundryTomlPath)) { + throw new Error(`Get config failed: could not find ${foundryTomlPath}`); + } + const foundryToml = fs.readFileSync(foundryTomlPath, "utf8"); + const foundryTomlConfig = TOML.parse(foundryToml); + + const rpcEndpoints = foundryTomlConfig.rpc_endpoints as Record< + string, + string + >; + return { projectRoot: forgeStdRepoPath, rpcCachePath: RPC_CACHE_PATH, @@ -169,13 +182,7 @@ function getConfig(forgeStdRepoPath: string): SolidityTestRunnerConfigArgs { { path: forgeStdRepoPath, access: FsAccessPermission.ReadWrite }, ], testFail: true, - rpcEndpoints: { - // These are hardcoded in the `forge-std` foundry.toml - mainnet: - "https://eth-mainnet.alchemyapi.io/v2/WV407BEiBmjNJfKo9Uo_55u0z0ITyCOX", - optimism_sepolia: "https://sepolia.optimism.io/", - arbitrum_one_sepolia: "https://sepolia-rollup.arbitrum.io/rpc/", - }, + rpcEndpoints, fuzz: { // Used to ensure deterministic fuzz execution seed: "0x1234567890123456789012345678901234567890", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2ca976a8c..b8ee65e2e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -148,6 +148,9 @@ importers: simple-git: specifier: ^3.25.0 version: 3.26.0 + smol-toml: + specifier: ^1.3.0 + version: 1.3.0 tsx: specifier: ^4.7.1 version: 4.7.1 @@ -1838,6 +1841,7 @@ packages: eslint@8.57.0: resolution: {integrity: sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options. hasBin: true espree@9.6.1: @@ -2954,6 +2958,10 @@ packages: engines: {node: '>=6'} hasBin: true + smol-toml@1.3.0: + resolution: {integrity: sha512-tWpi2TsODPScmi48b/OQZGi2lgUmBCHy6SZrhi/FdnnHiU1GwebbCfuQuxsC3nHaLwtYeJGPrDZDIeodDOc4pA==} + engines: {node: '>= 18'} + solc@0.8.26: resolution: {integrity: sha512-yiPQNVf5rBFHwN6SIf3TUUvVAFKcQqmSUFeq+fb6pNRCo0ZCgpYOZDi3BVoezCPIAcKrVYd/qXlBLUP9wVrZ9g==} engines: {node: '>=10.0.0'} @@ -6344,6 +6352,8 @@ snapshots: wcwidth: 1.0.1 yargs: 15.4.1 + smol-toml@1.3.0: {} + solc@0.8.26(debug@4.3.7): dependencies: command-exists: 1.2.9