Skip to content

Commit fc7d5b6

Browse files
authored
fix(ethereum): don't rely on exec'ing in /tmp (#19599)
Fixes and unflakes src/composed/web3signer/e2e_multi_validator_node_key_store.test.ts - Fix "Permission denied" error when deploying L1 contracts in our docker compose scripts due to `/tmp` being mounted as noexec tmpfs - Instead of copying solc binary to temp directory, we update `foundry.toml` to use absolute path to the original location Included: - Copy `test/shouting.t.sol` to appease forge cache warnings about missing source files
2 parents 9e54139 + 441096b commit fc7d5b6

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

.test_patterns.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,6 @@ tests:
270270
owners:
271271
- *david
272272

273-
- regex: "src/composed/web3signer/e2e_multi_validator_node_key_store.test.ts"
274-
owners:
275-
- *grego
276-
277273
- regex: "amm_flow.sh"
278274
owners:
279275
- *grego

yarn-project/ethereum/src/deploy_aztec_l1_contracts.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { fileURLToPath } from '@aztec/foundation/url';
1010
import { bn254 } from '@noble/curves/bn254';
1111
import type { Abi, Narrow } from 'abitype';
1212
import { spawn } from 'child_process';
13-
import { cpSync, existsSync, mkdirSync, mkdtempSync, readdirSync, rmSync } from 'fs';
13+
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'fs';
1414
import { tmpdir } from 'os';
1515
import { dirname, join, resolve } from 'path';
1616
import readline from 'readline';
@@ -141,11 +141,14 @@ function cleanupDeployDir() {
141141
*/
142142
export function prepareL1ContractsForDeployment(): string {
143143
if (preparedDeployDir && existsSync(preparedDeployDir)) {
144+
logger.verbose(`Using cached deployment directory: ${preparedDeployDir}`);
144145
return preparedDeployDir;
145146
}
146147

147148
const basePath = getL1ContractsPath();
149+
logger.verbose(`Preparing L1 contracts from: ${basePath}`);
148150
const tempDir = mkdtempSync(join(tmpdir(), '.foundry-deploy-'));
151+
logger.verbose(`Created temp directory for deployment: ${tempDir}`);
149152
preparedDeployDir = tempDir;
150153
process.on('exit', cleanupDeployDir);
151154

@@ -157,13 +160,21 @@ export function prepareL1ContractsForDeployment(): string {
157160
cpSync(join(basePath, 'src'), join(tempDir, 'src'), copyOpts);
158161
cpSync(join(basePath, 'script'), join(tempDir, 'script'), copyOpts);
159162
cpSync(join(basePath, 'generated'), join(tempDir, 'generated'), copyOpts);
160-
cpSync(join(basePath, 'foundry.toml'), join(tempDir, 'foundry.toml'));
163+
// Kludge: copy test/ to appease forge cache which references test/shouting.t.sol
164+
cpSync(join(basePath, 'test'), join(tempDir, 'test'), copyOpts);
161165
cpSync(join(basePath, 'foundry.lock'), join(tempDir, 'foundry.lock'));
162-
for (const file of readdirSync(basePath)) {
163-
if (file.startsWith('solc-')) {
164-
cpSync(join(basePath, file), join(tempDir, file));
165-
}
166+
167+
// Update foundry.toml to use absolute path to solc binary (avoids copying to noexec tmpfs)
168+
const foundryTomlPath = join(basePath, 'foundry.toml');
169+
let foundryToml = readFileSync(foundryTomlPath, 'utf-8');
170+
const solcPathMatch = foundryToml.match(/solc\s*=\s*"\.\/solc-([^"]+)"/);
171+
if (solcPathMatch) {
172+
const solcVersion = solcPathMatch[1];
173+
const absoluteSolcPath = join(basePath, `solc-${solcVersion}`);
174+
foundryToml = foundryToml.replace(/solc\s*=\s*"\.\/solc-[^"]+"/, `solc = "${absoluteSolcPath}"`);
175+
logger.verbose(`Updated solc path in foundry.toml to: ${absoluteSolcPath}`);
166176
}
177+
writeFileSync(join(tempDir, 'foundry.toml'), foundryToml);
167178

168179
mkdirSync(join(tempDir, 'broadcast'));
169180
return tempDir;

yarn-project/l1-artifacts/scripts/copy-foundry-artifacts.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ mkdir -p "l1-contracts/script" "l1-contracts/lib" "l1-contracts/broadcast"
1919
# Copy build artifacts, cache, sources, and config (preserving timestamps for cache validity)
2020
cp -rp "$src"/{out,cache,src,generated} "l1-contracts/"
2121
cp -rp "$src/script/deploy" "l1-contracts/script/" # only deploy/, other scripts depend on test files
22+
# Kludge: copy one test file to appease forge cache which references test/shouting.t.sol
23+
mkdir -p "l1-contracts/test"
24+
cp -p "$src/test/shouting.t.sol" "l1-contracts/test/"
2225
cp -p "$src"/{foundry.toml,foundry.lock,solc-*} "l1-contracts/"
2326
abs_dest=$(pwd)/l1-contracts
2427
# Keep only the foundry relevant files from lib

0 commit comments

Comments
 (0)