From 6690d6ba0417afecf2228fbb7227549c6d6ae58a Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers Date: Thu, 8 May 2025 20:31:16 +0000 Subject: [PATCH 01/15] fix(container): removing unneeded shared network dependency, minor doc updates --- .devcontainer/README.md | 4 ++-- .devcontainer/docker-compose.yml | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.devcontainer/README.md b/.devcontainer/README.md index f0079a7b7..4bc1b0cd7 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -61,14 +61,14 @@ When the container starts, the `project-setup.sh` script will automatically run - Set up symlinks for package cache directories - Install project dependencies using yarn - Configure Git to use SSH signing with your forwarded SSH key -- Source shell customizations if available in PATH (currently depends on base image configuration) +- Source shell customizations if available in PATH ## Environment Variables Environment variables are defined in two places: 1. **docker-compose.yml**: Contains most of the environment variables for tools and caching -2. **Environment File**: Personal settings are stored in `/opt/configs/graphprotocol/contracts.env` +2. **Environment File**: Personal settings are stored in `/opt/configs/graphprotocol/contracts.env` on the host ### Git Configuration diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 293c78c92..adbc5b349 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -38,8 +38,6 @@ services: - PIP_CACHE_DIR=/cache/pip - PYTHONPYCACHEPREFIX=/cache/pycache - PYTHONDONTWRITEBYTECODE=1 - networks: - - shared volumes: # Mount cache directory - /cache:/cache @@ -56,7 +54,3 @@ services: - /cache/vscode-config:/home/vscode/.config - /cache/vscode-data:/home/vscode/.local/share - /cache/vscode-bin:/home/vscode/.local/bin - -networks: - shared: - external: true From cf6ef2500cc6d420f8525e2567591c5c44fabfa1 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers Date: Thu, 8 May 2025 20:42:01 +0000 Subject: [PATCH 02/15] fix: removing duplicated git signing message --- .devcontainer/project-setup.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/.devcontainer/project-setup.sh b/.devcontainer/project-setup.sh index 05b05dfb0..b00f33be2 100755 --- a/.devcontainer/project-setup.sh +++ b/.devcontainer/project-setup.sh @@ -131,7 +131,6 @@ else fi # Set up Git SSH signing -echo "Setting up Git SSH signing..." if [ -f "$SCRIPT_DIR/setup-git-signing.sh" ]; then "$SCRIPT_DIR/setup-git-signing.sh" else From 9b12a5f5a1c78e44138ff6b87a28a713dab445a9 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers Date: Thu, 8 May 2025 20:54:28 +0000 Subject: [PATCH 03/15] fix(README): making note of git repo location design --- .devcontainer/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.devcontainer/README.md b/.devcontainer/README.md index 4bc1b0cd7..474492317 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -47,13 +47,15 @@ This script creates all required cache directories on the host, including: The script is idempotent and can be run multiple times without issues. +The container was designed to be used for development with contracts repo at `/git/graphprotocol/contracts` and with `/git` mounted from the host by `docker-compose.yml`. + ### 2. Start the Dev Container After creating the cache directories, you can start the dev container: 1. Open VS Code 2. Use the "Remote-Containers: Open Folder in Container" command -3. Select the repository directory +3. Select the repository directory (for example `/git/graphprotocol/contracts`) When the container starts, the `project-setup.sh` script will automatically run and: From 06cafbc3c7a5314daa92ec860cc8bca12c52577f Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers Date: Thu, 15 May 2025 10:35:58 +0000 Subject: [PATCH 04/15] fix(container): do not install hardhat, install cloc --- .devcontainer/Dockerfile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 06c026bd7..d45a4c0cd 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -22,7 +22,7 @@ RUN apt update && apt install -y \ # Install Node.js RUN npm install -g n && n 20.12.0 - + # Install Solidity compiler using pipx (isolated environment) RUN pipx install solc-select && \ pipx ensurepath && \ @@ -40,10 +40,13 @@ RUN pipx install solc-select && \ cp -r /root/.solc-select/* /home/vscode/.solc-select/ && \ chown -R vscode:vscode /home/vscode/.solc-select -# Install Hardhat and related tools as root -RUN npm install -g hardhat@2.22.16 @nomicfoundation/hardhat-ethers@3.0.8 ethers@6.13.4 && \ - ln -sf /usr/local/lib/node_modules/hardhat/internal/cli/cli.js /usr/local/bin/hardhat && \ - chmod +x /usr/local/bin/hardhat +RUN npm install -g ethers@6.13.4 + +# Install cloc for code analysis +RUN npm install -g cloc + +# Install cloc for code analysis +RUN npm install -g cloc # Install Foundry for Anvil (as root for global installation) RUN curl -L https://foundry.paradigm.xyz | bash && \ From 496ac943ec6019e699f52cc66fbc9225d6579ca4 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers Date: Fri, 9 May 2025 11:05:10 +0000 Subject: [PATCH 05/15] feat: script to count Solidity code changes between branches --- scripts/count-changes | 76 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 scripts/count-changes diff --git a/scripts/count-changes b/scripts/count-changes new file mode 100755 index 000000000..338da6bb5 --- /dev/null +++ b/scripts/count-changes @@ -0,0 +1,76 @@ +#!/bin/bash + +# Count changes in Solidity files between two branches, categorizing by code, comments, and blank lines +set -euo pipefail + +# Check if cloc is installed +if ! command -v cloc &> /dev/null; then + echo "Error: cloc is not installed. Install with: sudo npm install -g cloc" + exit 1 +fi + +# Define the branches to compare +BASE_BRANCH="${1:-main}" # Default to 'main' if no argument provided +CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) + +echo "Comparing Solidity changes between $BASE_BRANCH and $CURRENT_BRANCH..." +echo + +# Get all modified Solidity contract files +ALL_FILES=$(git diff --name-only "$BASE_BRANCH" -- 'packages/*/contracts/**/*.sol') + +# Get excluded files (mock and test files) +EXCLUDED_FILES=$(echo "$ALL_FILES" | grep -E '(/mocks?/|/tests?/|Mock[A-Z].*\.sol$|.*Test\.sol$|Test[A-Z].*\.sol$)' || true) + +# Get included files (non-mock, non-test files) +FILES=$(echo "$ALL_FILES" | grep -v -E '(/mocks?/|/tests?/|Mock[A-Z].*\.sol$|.*Test\.sol$|Test[A-Z].*\.sol$)' || true) + +# Check if there are any files to process +if [ -z "$FILES" ]; then + echo "No Solidity files changed between $BASE_BRANCH and $CURRENT_BRANCH." + exit 0 +fi + +echo "Found changed Solidity files (excluding mocks and tests):" +echo "$FILES" | sed 's/^/- /' +echo + +# Display excluded files if any +if [ -n "$EXCLUDED_FILES" ]; then + echo "Excluded mock and test files:" + echo "$EXCLUDED_FILES" | sed 's/^/- /' + echo +fi + +# Create directories for diff analysis +TEMP_DIR=$(mktemp -d) +trap 'rm -rf "$TEMP_DIR"' EXIT +mkdir -p "$TEMP_DIR/old" +mkdir -p "$TEMP_DIR/new" + +# Extract all changed files +for file in $FILES; do + if [ -f "$file" ]; then + # Create directory structure + dir=$(dirname "$file") + mkdir -p "$TEMP_DIR/new/$dir" + mkdir -p "$TEMP_DIR/old/$dir" + + # Copy current version + cp "$file" "$TEMP_DIR/new/$file" + + # Get old version if it exists + if git show "$BASE_BRANCH:$file" &>/dev/null; then + git show "$BASE_BRANCH:$file" > "$TEMP_DIR/old/$file" + fi + fi +done + +# Run cloc diff on all files +echo "Summary of changes (excluding mock and test files):" +echo "================================================" +cloc --diff "$TEMP_DIR/old" "$TEMP_DIR/new" --include-lang=Solidity --quiet + +echo +echo "Note: This analysis only counts changes in Solidity files, excluding mock and test contracts." +echo "The 'same' category shows lines that were unchanged in modified files." From a27db3bf043279b46c0d00ee0d0bad9d2c1f3adf Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers Date: Mon, 12 May 2025 11:42:24 +0000 Subject: [PATCH 06/15] fix: ignore forge-artifacts --- .devcontainer/Dockerfile | 2 ++ .gitignore | 1 + packages/issuance/lib/forge-std | 1 + 3 files changed, 4 insertions(+) create mode 160000 packages/issuance/lib/forge-std diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index d45a4c0cd..2b13bbf9f 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -75,6 +75,8 @@ RUN chmod 755 /usr/local/bin/* && \ # Switch back to vscode user USER vscode +RUN forge install foundry-rs/forge-std + # Set environment variables ENV PATH="/usr/local/bin:/home/vscode/.foundry/bin:/home/vscode/.local/bin:/root/.local/bin:$PATH" diff --git a/.gitignore b/.gitignore index 45e325072..08bb97ade 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,7 @@ addresses-fork.json # Forge artifacts cache_forge +forge-artifacts/ # Graph client .graphclient diff --git a/packages/issuance/lib/forge-std b/packages/issuance/lib/forge-std new file mode 160000 index 000000000..77041d2ce --- /dev/null +++ b/packages/issuance/lib/forge-std @@ -0,0 +1 @@ +Subproject commit 77041d2ce690e692d6e03cc812b57d1ddaa4d505 From 5df3f7712dc1a82f506e1b2140d161a47958289d Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers Date: Thu, 15 May 2025 11:11:22 +0000 Subject: [PATCH 07/15] fix: only install cloc once --- .devcontainer/Dockerfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 2b13bbf9f..3c66cf426 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -45,9 +45,6 @@ RUN npm install -g ethers@6.13.4 # Install cloc for code analysis RUN npm install -g cloc -# Install cloc for code analysis -RUN npm install -g cloc - # Install Foundry for Anvil (as root for global installation) RUN curl -L https://foundry.paradigm.xyz | bash && \ /root/.foundry/bin/foundryup && \ From bc0ba819ddf0831ef15c8d98fd8a42692e956c5b Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers Date: Thu, 15 May 2025 11:13:10 +0000 Subject: [PATCH 08/15] fix: don't install forge-std, will be submodule --- .devcontainer/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 3c66cf426..bd19f0905 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -72,8 +72,6 @@ RUN chmod 755 /usr/local/bin/* && \ # Switch back to vscode user USER vscode -RUN forge install foundry-rs/forge-std - # Set environment variables ENV PATH="/usr/local/bin:/home/vscode/.foundry/bin:/home/vscode/.local/bin:/root/.local/bin:$PATH" From 1d9e114cb11a8a246acaf6bd27ad50f6e4650a2b Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers Date: Thu, 15 May 2025 11:37:51 +0000 Subject: [PATCH 09/15] fix: more robust filename handling --- scripts/count-changes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/count-changes b/scripts/count-changes index 338da6bb5..151c136d0 100755 --- a/scripts/count-changes +++ b/scripts/count-changes @@ -49,7 +49,7 @@ mkdir -p "$TEMP_DIR/old" mkdir -p "$TEMP_DIR/new" # Extract all changed files -for file in $FILES; do +echo "$FILES" | while read -r file; do if [ -f "$file" ]; then # Create directory structure dir=$(dirname "$file") From bf74dc6d6d216ef379e1c3eb85ef6e499fe72f31 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Thu, 15 May 2025 12:47:52 +0100 Subject: [PATCH 10/15] Update scripts/count-changes More robust handling of unusual filenames. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- scripts/count-changes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/count-changes b/scripts/count-changes index 151c136d0..db079f24d 100755 --- a/scripts/count-changes +++ b/scripts/count-changes @@ -49,7 +49,7 @@ mkdir -p "$TEMP_DIR/old" mkdir -p "$TEMP_DIR/new" # Extract all changed files -echo "$FILES" | while read -r file; do +echo "$FILES" | while IFS= read -r file; do if [ -f "$file" ]; then # Create directory structure dir=$(dirname "$file") From d79a1b2c7538c52c6fbe465199886f7f62403498 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers Date: Thu, 15 May 2025 12:01:54 +0000 Subject: [PATCH 11/15] fix: not intended to be part of this branch --- packages/issuance/lib/forge-std | 1 - 1 file changed, 1 deletion(-) delete mode 160000 packages/issuance/lib/forge-std diff --git a/packages/issuance/lib/forge-std b/packages/issuance/lib/forge-std deleted file mode 160000 index 77041d2ce..000000000 --- a/packages/issuance/lib/forge-std +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 77041d2ce690e692d6e03cc812b57d1ddaa4d505 From ffa854c482659cf94e908dc1e6b69d561b729f17 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers Date: Wed, 21 May 2025 06:18:47 +0000 Subject: [PATCH 12/15] fix(lint): dev container whitespace lints --- .devcontainer/README.md | 1 + .devcontainer/devcontainer.json | 82 ++++++++++++++++----------------- 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/.devcontainer/README.md b/.devcontainer/README.md index 474492317..1dbe7395a 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -21,6 +21,7 @@ The dev container provides a consistent development environment with caching to The container uses a simple caching system: 1. **Host Cache Directories**: Created on the host and mounted into the container + - `/cache/vscode-cache` → `/home/vscode/.cache` - `/cache/vscode-config` → `/home/vscode/.config` - `/cache/vscode-data` → `/home/vscode/.local/share` diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8bb295680..8d7fb643d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,44 +1,42 @@ { - "name": "graph contracts", - "dockerComposeFile": [ - "docker-compose.yml" - ], - "service": "dev-graph-contracts", - "features": { - "ghcr.io/devcontainers/features/git:1": { - "configureGitHubCLI": true, - "gitCredentialHelper": "cache" - }, - "ghcr.io/devcontainers/features/github-cli:1": {}, - "ghcr.io/devcontainers/features/common-utils:2.5.3": {}, - "ghcr.io/devcontainers/features/node:1": { - "version": "20" - }, - "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {} - }, - "postCreateCommand": ".devcontainer/project-setup.sh", - "remoteUser": "vscode", - "workspaceFolder": "${localWorkspaceFolder}", - "customizations": { - "vscode": { - "extensions": [ - "rust-lang.rust-analyzer", - "tamasfe.even-better-toml", - "usernamehw.errorlens", - "yzhang.markdown-all-in-one", - "DavidAnson.vscode-markdownlint", - "shd101wyy.markdown-preview-enhanced", - "bierner.markdown-preview-github-styles", - "Gruntfuggly.todo-tree", - "ms-azuretools.vscode-docker", - "donjayamanne.githistory", - "eamodio.gitlens", - "fill-labs.dependi", - "streetsidesoftware.code-spell-checker", - "Augment.vscode-augment", - "NomicFoundation.hardhat-solidity", - "foundry-rs.foundry-vscode" - ] - } - } + "name": "graph contracts", + "dockerComposeFile": ["docker-compose.yml"], + "service": "dev-graph-contracts", + "features": { + "ghcr.io/devcontainers/features/git:1": { + "configureGitHubCLI": true, + "gitCredentialHelper": "cache" + }, + "ghcr.io/devcontainers/features/github-cli:1": {}, + "ghcr.io/devcontainers/features/common-utils:2.5.3": {}, + "ghcr.io/devcontainers/features/node:1": { + "version": "20" + }, + "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {} + }, + "postCreateCommand": ".devcontainer/project-setup.sh", + "remoteUser": "vscode", + "workspaceFolder": "${localWorkspaceFolder}", + "customizations": { + "vscode": { + "extensions": [ + "rust-lang.rust-analyzer", + "tamasfe.even-better-toml", + "usernamehw.errorlens", + "yzhang.markdown-all-in-one", + "DavidAnson.vscode-markdownlint", + "shd101wyy.markdown-preview-enhanced", + "bierner.markdown-preview-github-styles", + "Gruntfuggly.todo-tree", + "ms-azuretools.vscode-docker", + "donjayamanne.githistory", + "eamodio.gitlens", + "fill-labs.dependi", + "streetsidesoftware.code-spell-checker", + "Augment.vscode-augment", + "NomicFoundation.hardhat-solidity", + "foundry-rs.foundry-vscode" + ] + } + } } From ebebc9f6d9a0787657febd5d22b0ba377baa6837 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers <50174308+RembrandtK@users.noreply.github.com> Date: Wed, 21 May 2025 13:16:31 +0100 Subject: [PATCH 13/15] fix: remove container name, avoid conflicts via automatic generation Without a container name will automatically be picked based on dir --- .devcontainer/docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index adbc5b349..b286fcb56 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -1,6 +1,5 @@ services: dev-graph-contracts: - container_name: dev-graph-contracts build: context: . dockerfile: Dockerfile From d35b6bac4a36edc075b2044b6c3c9b5e5704561c Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers Date: Sat, 24 May 2025 15:50:41 +0000 Subject: [PATCH 14/15] fix(container): reducing amount of caching to avoid cross environment issues --- .devcontainer/README.md | 55 ++++++++++-------------- .devcontainer/docker-compose.yml | 57 ++++++++++--------------- .devcontainer/project-setup.sh | 72 ++++---------------------------- 3 files changed, 50 insertions(+), 134 deletions(-) diff --git a/.devcontainer/README.md b/.devcontainer/README.md index 1dbe7395a..c27c20c33 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -18,41 +18,30 @@ The dev container provides a consistent development environment with caching to ## Cache System -The container uses a simple caching system: +The container uses a conservative caching approach to prevent cache corruption issues: -1. **Host Cache Directories**: Created on the host and mounted into the container +1. **Local Cache Directories**: Each container instance maintains its own cache directories - - `/cache/vscode-cache` → `/home/vscode/.cache` - - `/cache/vscode-config` → `/home/vscode/.config` - - `/cache/vscode-data` → `/home/vscode/.local/share` - - `/cache/vscode-bin` → `/home/vscode/.local/bin` - - `/cache/*` → Tool-specific cache directories + - `vscode-cache` → `/home/vscode/.cache` (VS Code cache) + - `vscode-config` → `/home/vscode/.config` (VS Code configuration) + - `vscode-data` → `/home/vscode/.local/share` (VS Code data) + - `vscode-bin` → `/home/vscode/.local/bin` (User binaries) -2. **Package Cache Symlinks**: Created inside the container by project-setup.sh - - Each package's cache directory is symlinked to a subdirectory in `/cache/hardhat` +2. **Safe Caches Only**: Only caches that won't cause cross-branch issues are configured -## Setup Instructions - -### 1. Host Setup (One-time) - -Before starting the dev container for the first time, run the included host setup script to create the necessary cache directories on the host: - -```bash -sudo /git/graphprotocol/contracts/.devcontainer/host-setup.sh -``` + - GitHub CLI: `/home/vscode/.cache/github` + - Python packages: `/home/vscode/.cache/pip` -This script creates all required cache directories on the host, including: +3. **Intentionally Not Cached**: These tools use their default cache locations to avoid contamination + - NPM, Yarn (different dependency versions per branch) + - Foundry, Solidity (different compilation artifacts per branch) + - Hardhat (different build artifacts per branch) -- Standard VS Code directories (for .cache, .config, etc.) -- Tool-specific cache directories (for npm, yarn, cargo, etc.) - -The script is idempotent and can be run multiple times without issues. - -The container was designed to be used for development with contracts repo at `/git/graphprotocol/contracts` and with `/git` mounted from the host by `docker-compose.yml`. +## Setup Instructions -### 2. Start the Dev Container +### Start the Dev Container -After creating the cache directories, you can start the dev container: +To start the dev container: 1. Open VS Code 2. Use the "Remote-Containers: Open Folder in Container" command @@ -60,8 +49,6 @@ After creating the cache directories, you can start the dev container: When the container starts, the `project-setup.sh` script will automatically run and: -- Create package-specific cache directories -- Set up symlinks for package cache directories - Install project dependencies using yarn - Configure Git to use SSH signing with your forwarded SSH key - Source shell customizations if available in PATH @@ -87,11 +74,13 @@ These environment variables are needed for Git commit signing to work properly. ## Troubleshooting -If you encounter permission denied errors when trying to access directories, make sure you've run the `host-setup.sh` script on the host before starting the container: +### Cache Issues -```bash -sudo .devcontainer/host-setup.sh -``` +If you encounter build or compilation issues that seem related to cached artifacts: + +1. **Rebuild the container**: This will start with fresh local caches +2. **Clean project caches**: Run `yarn clean` to clear project-specific build artifacts +3. **Clear node modules**: Delete `node_modules` and run `yarn install` again ### Git SSH Signing Issues diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index b286fcb56..a9f485d4c 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -3,53 +3,38 @@ services: build: context: . dockerfile: Dockerfile - x-bake: - cache-from: - - type=local,src=/cache/docker - cache-to: - - type=local,dest=/cache/docker,mode=max env_file: - /opt/configs/graphprotocol/contracts.env environment: - # Cache directories - - FOUNDRY_CACHE_DIR=/cache/foundry - - SOLC_CACHE=/cache/solidity + # Essential for large builds + - NODE_OPTIONS=--max-old-space-size=4096 - # GitHub - - GH_CONFIG_DIR=/cache/github + # Clean development environment + - PYTHONDONTWRITEBYTECODE=1 - # XDG standard directories + # Standard user directories - XDG_CACHE_HOME=/home/vscode/.cache - XDG_CONFIG_HOME=/home/vscode/.config - XDG_DATA_HOME=/home/vscode/.local/share - # Tool-specific settings - - HARDHAT_CACHE_DIR=/cache/hardhat - - HARDHAT_ANALYTICS=true - - HARDHAT_NO_ANALYTICS_PROMPT=true - - # Node.js settings - - NPM_CONFIG_CACHE=/cache/npm - - YARN_CACHE_FOLDER=/cache/yarn - - NODE_OPTIONS=--max-old-space-size=4096 + # Safe caches (won't cause cross-branch issues) + - GH_CONFIG_DIR=/home/vscode/.cache/github + - PIP_CACHE_DIR=/home/vscode/.cache/pip - # Python settings - - PIP_CACHE_DIR=/cache/pip - - PYTHONPYCACHEPREFIX=/cache/pycache - - PYTHONDONTWRITEBYTECODE=1 + # Note: NPM, Yarn, Foundry, and Solidity caches are intentionally not set + # to avoid cross-branch contamination. Tools will use their default locations. volumes: - # Mount cache directory - - /cache:/cache - - # System-specific mounts that need specific locations - - /cache/apt:/var/cache/apt - - /cache/apt-lib:/var/lib/apt - # Git repo root - /git:/git - # Local cache directories for XDG standards - - /cache/vscode-cache:/home/vscode/.cache - - /cache/vscode-config:/home/vscode/.config - - /cache/vscode-data:/home/vscode/.local/share - - /cache/vscode-bin:/home/vscode/.local/bin + # Local directories for user data (keep local to container) + - vscode-cache:/home/vscode/.cache + - vscode-config:/home/vscode/.config + - vscode-data:/home/vscode/.local/share + - vscode-bin:/home/vscode/.local/bin + +volumes: + vscode-cache: + vscode-config: + vscode-data: + vscode-bin: diff --git a/.devcontainer/project-setup.sh b/.devcontainer/project-setup.sh index b00f33be2..313cd25d8 100755 --- a/.devcontainer/project-setup.sh +++ b/.devcontainer/project-setup.sh @@ -11,73 +11,15 @@ REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" echo "Script directory: $SCRIPT_DIR" echo "Repository root: $REPO_ROOT" -# Check if cache directories exist -echo "Checking if cache directories exist..." +# Set up local user directories with proper permissions +echo "Setting up local user directories..." -# Required cache directories -REQUIRED_DIRS=( - "/cache/hardhat" - "/cache/npm" - "/cache/yarn" -) +# Ensure all user directories exist and have proper ownership +sudo mkdir -p /home/vscode/.cache /home/vscode/.config /home/vscode/.local/share /home/vscode/.local/bin +sudo chown -R vscode:vscode /home/vscode/.cache /home/vscode/.config /home/vscode/.local +sudo chmod -R 755 /home/vscode/.cache /home/vscode/.config /home/vscode/.local -# Check if required directories exist -missing_dirs=() -for dir in "${REQUIRED_DIRS[@]}"; do - if [ ! -d "$dir" ]; then - missing_dirs+=("$dir") - fi -done - -# If any required directories are missing, show a warning -# Note: With set -u, we need to ensure missing_dirs is always initialized -if [ "${#missing_dirs[@]}" -gt 0 ]; then - echo "WARNING: The following required cache directories are missing:" - for dir in "${missing_dirs[@]}"; do - echo " - $dir" - done - echo "Please run the host setup script before starting the container:" - echo " sudo .devcontainer/host-setup.sh" - echo "Continuing anyway, but you may encounter issues..." -fi - -# Set up cache symlinks -echo "Setting up cache symlinks..." - -# Function to create symlinks for package cache directories -setup_cache_symlink() { - # With set -u, we need to ensure all parameters are provided - if [ "$#" -ne 1 ]; then - echo "Error: setup_cache_symlink requires exactly 1 argument (package_name)" - return 1 - fi - - local package_name=$1 - local cache_path="$REPO_ROOT/packages/${package_name}/cache" - local cache_dest="/cache/hardhat/${package_name}" - - # Skip if the package directory doesn't exist - if [ ! -d "$REPO_ROOT/packages/${package_name}" ]; then - return - fi - - # Create the package-specific cache directory if it doesn't exist - if [ ! -d "$cache_dest" ]; then - echo "Creating package-specific cache directory: $cache_dest" - mkdir -p "$cache_dest" - chmod -R 777 "$cache_dest" - fi - - # Create the symlink (will replace existing symlink if it exists) - ln -sf "$cache_dest" "$cache_path" - echo "Created symlink for ${package_name} cache" -} - -# Set up cache symlinks for main packages -setup_cache_symlink "contracts" -setup_cache_symlink "horizon" -setup_cache_symlink "subgraph-service" -setup_cache_symlink "data-edge" +echo "User directories set up with proper permissions" # Install project dependencies echo "Installing project dependencies..." From 84d3a0964d7f22388e4184a7b94c09747c51e6d1 Mon Sep 17 00:00:00 2001 From: Rembrandt Kuipers Date: Sat, 24 May 2025 16:30:37 +0000 Subject: [PATCH 15/15] fix(container): do not prompt for corepack download --- .devcontainer/docker-compose.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index a9f485d4c..794054a87 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -12,6 +12,9 @@ services: # Clean development environment - PYTHONDONTWRITEBYTECODE=1 + # Disable interactive prompts + - COREPACK_ENABLE_DOWNLOAD_PROMPT=0 + # Standard user directories - XDG_CACHE_HOME=/home/vscode/.cache - XDG_CONFIG_HOME=/home/vscode/.config