Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 2 additions & 43 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,52 +1,15 @@
FROM mcr.microsoft.com/devcontainers/base:debian

# Set non-interactive frontend for apt
ENV DEBIAN_FRONTEND=noninteractive
FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04

# Switch to root for installing packages
USER root

# Install additional dependencies
RUN apt update && apt install -y \
RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y \
build-essential \
curl \
jq \
python3 \
python3-pip \
python3-venv \
pipx \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*

# Install Node.js 20.x using NodeSource
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt update && \
apt install -y nodejs && \
apt clean && \
rm -rf /var/lib/apt/lists/*

# Install Solidity compiler using pipx (isolated environment)
RUN pipx install solc-select && \
pipx ensurepath && \
/root/.local/bin/solc-select install 0.8.27 && \
/root/.local/bin/solc-select use 0.8.27 && \
# Copy binaries to /usr/local/bin with proper permissions (not symlinks)
cp /root/.local/bin/solc /usr/local/bin/solc && \
cp /root/.local/bin/solc-select /usr/local/bin/solc-select && \
chmod 755 /usr/local/bin/solc && \
chmod 755 /usr/local/bin/solc-select && \
# Make sure pipx directory is accessible
chmod -R a+rx /root/.local/pipx && \
# Set up for vscode user
mkdir -p /home/vscode/.solc-select && \
cp -r /root/.solc-select/* /home/vscode/.solc-select/ && \
chown -R vscode:vscode /home/vscode/.solc-select

RUN npm install -g [email protected]

# 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 && \
Expand All @@ -61,10 +24,6 @@ RUN curl -L https://foundry.paradigm.xyz | bash && \
chmod 755 /usr/local/bin/forge && \
chmod 755 /usr/local/bin/chisel

# Set up pnpm
RUN corepack enable && \
corepack prepare [email protected] --activate

# Ensure all users have access to the tools
RUN chmod 755 /usr/local/bin/* && \
# Create a directory for vscode user's binaries
Expand Down
59 changes: 12 additions & 47 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,6 @@ The dev container provides a consistent development environment with caching to
1. **Docker Compose Configuration**: Defines the container setup, volume mounts, and environment variables
2. **Dockerfile**: Specifies the container image and installed tools
3. **project-setup.sh**: Configures the environment after container creation
4. **host-setup.sh**: Sets up the host environment before starting the container
5. **setup-git-signing.sh**: Automatically configures Git to use SSH signing with forwarded SSH keys

## Cache System

The container uses a conservative caching approach to prevent cache corruption issues:

1. **Local Cache Directories**: Each container instance maintains its own 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. **Safe Caches Only**: Only caches that won't cause cross-branch issues are configured
- GitHub CLI: `/home/vscode/.cache/github`
- Python packages: `/home/vscode/.cache/pip`

3. **Intentionally Not Cached**: These tools use their default cache locations to avoid contamination
- NPM (different dependency versions per branch)
- Foundry, Solidity (different compilation artifacts per branch)
- Hardhat (different build artifacts per branch)

## Setup Instructions

Expand All @@ -48,7 +27,7 @@ To start the dev container:
When the container starts, the `project-setup.sh` script will automatically run and:

- Install project dependencies using pnpm
- Configure Git to use SSH signing with your forwarded SSH key
- Configure basic Git settings (user.name, user.email) from environment variables
- Source shell customizations if available in PATH

## Environment Variables
Expand All @@ -60,10 +39,10 @@ Environment variables are defined in two places:

### Git Configuration

To enable Git commit signing, add the following settings to your environment file:
To configure Git user settings, add the following to your environment file:

```env
# Git settings for commit signing
# Git settings
GIT_USER_NAME=Your Name
[email protected]
```
Expand All @@ -72,34 +51,20 @@ These environment variables are needed for Git commit signing to work properly.

## Troubleshooting

### Cache Issues
### Build Issues

If you encounter build or compilation issues that seem related to cached artifacts:
If you encounter build or compilation issues:

1. **Rebuild the container**: This will start with fresh local caches
1. **Rebuild the container**: This will start with fresh isolated caches
2. **Clean project caches**: Run `pnpm clean` to clear project-specific build artifacts
3. **Clear node modules**: Delete `node_modules` and run `pnpm install` again

### Git SSH Signing Issues
### Git Authentication Issues

If you encounter issues with Git SSH signing:
If you encounter issues with Git operations:

1. **SSH Agent Forwarding**: Make sure SSH agent forwarding is properly set up in your VS Code settings
2. **GitHub Configuration**: Ensure your SSH key is added to GitHub as a signing key in your account settings
3. **Manual Setup**: If automatic setup fails, you can manually configure SSH signing:

```bash
# Check available SSH keys
ssh-add -l

# Configure Git to use SSH signing
git config --global gpg.format ssh
git config --global user.signingkey "key::ssh-ed25519 YOUR_KEY_CONTENT"
git config --global gpg.ssh.allowedSignersFile ~/.ssh/allowed_signers
git config --global commit.gpgsign true

# Create allowed signers file
echo "[email protected] ssh-ed25519 YOUR_KEY_CONTENT" > ~/.ssh/allowed_signers
```
1. **GitHub CLI**: Use `gh auth login` to authenticate with GitHub
2. **Git Configuration**: Set user.name and user.email if not configured via environment variables
3. **Commit Signing**: Handle commit signing on your host machine for security

For other issues, check the `project-setup.sh` and `setup-git-signing.sh` scripts for any errors.
For other issues, check the `project-setup.sh` script for any errors.
14 changes: 9 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "graph contracts",
"dockerComposeFile": ["docker-compose.yml"],
"service": "dev-graph-contracts",
"features": {
Expand All @@ -12,11 +11,16 @@
"ghcr.io/devcontainers/features/node:1": {
"version": "20"
},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
"ghcr.io/devcontainers/features/python:1": {
"version": "3.11"
}
},
"mounts": [
"source=${localWorkspaceFolder},target=/work/${localWorkspaceFolderBasename},type=bind,consistency=cached"
],
"postCreateCommand": ".devcontainer/project-setup.sh",
"remoteUser": "vscode",
"workspaceFolder": "${localWorkspaceFolder}",
"workspaceFolder": "/work/${localWorkspaceFolderBasename}",
"customizations": {
"vscode": {
"extensions": [
Expand All @@ -28,14 +32,14 @@
"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"
"foundry-rs.foundry-vscode",
"esbenp.prettier-vscode"
]
}
}
Expand Down
33 changes: 0 additions & 33 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,6 @@ services:
# Disable interactive prompts
- COREPACK_ENABLE_DOWNLOAD_PROMPT=0

# Standard user directories
- XDG_CACHE_HOME=/home/vscode/.cache
- XDG_CONFIG_HOME=/home/vscode/.config
- XDG_DATA_HOME=/home/vscode/.local/share

# Safe caches (won't cause cross-branch issues)
- GH_CONFIG_DIR=/home/vscode/.cache/github
- PIP_CACHE_DIR=/home/vscode/.cache/pip

# pnpm cache is safe to share due to content-addressable storage
- PNPM_HOME=/home/vscode/.local/share/pnpm
- PNPM_CACHE_DIR=/home/vscode/.cache/pnpm

# Note: NPM, Foundry, and Solidity caches are intentionally not set
# to avoid cross-branch contamination. Tools will use their default locations.
volumes:
# Git repo root
- /git:/git

# 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

# Shared pnpm cache (safe due to content-addressable storage)
- pnpm-store:/home/vscode/.local/share/pnpm
- pnpm-cache:/home/vscode/.cache/pnpm

volumes:
vscode-cache:
vscode-config:
vscode-data:
vscode-bin:
pnpm-store:
pnpm-cache:
37 changes: 33 additions & 4 deletions .devcontainer/project-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@ sudo chmod -R 755 /home/vscode/.cache /home/vscode/.config /home/vscode/.local

echo "User directories set up with proper permissions"

# Install Solidity compiler (moved from Dockerfile since Python/pipx is now available)
echo "Installing Solidity compiler..."
pipx install solc-select
pipx ensurepath
solc-select install 0.8.27
solc-select use 0.8.27

# Upgrade npm to latest version for better compatibility and security
echo "Upgrading npm to latest version..."
npm install -g npm@latest

npm install -g [email protected] cloc @anthropic-ai/claude-code

# Set up pnpm with correct version (matching package.json)
echo "Setting up pnpm..."
corepack enable
corepack prepare [email protected] --activate

# Verify pnpm is working
echo "Verifying pnpm installation..."
pnpm --version

# Install project dependencies
echo "Installing project dependencies..."
if [ -f "$REPO_ROOT/package.json" ]; then
Expand Down Expand Up @@ -72,11 +94,18 @@ else
echo "Shell customizations not found in PATH, skipping..."
fi

# Set up Git SSH signing
if [ -f "$SCRIPT_DIR/setup-git-signing.sh" ]; then
"$SCRIPT_DIR/setup-git-signing.sh"
# Set up basic Git configuration (user.name and user.email from environment)
echo "Setting up basic Git configuration..."
if [[ -n "${GIT_USER_NAME:-}" && -n "${GIT_USER_EMAIL:-}" ]]; then
echo "Setting Git user.name: $GIT_USER_NAME"
git config --global user.name "$GIT_USER_NAME"
echo "Setting Git user.email: $GIT_USER_EMAIL"
git config --global user.email "$GIT_USER_EMAIL"
echo "Git user configuration complete"
else
echo "WARNING: setup-git-signing.sh not found, skipping Git SSH signing setup"
echo "GIT_USER_NAME and/or GIT_USER_EMAIL not set - skipping Git user configuration"
echo "You can set these manually with: git config --global user.name 'Your Name'"
echo "and: git config --global user.email '[email protected]'"
fi

echo "Project-specific setup completed"
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ runs:
cache: 'pnpm'
- name: Set up pnpm via Corepack
shell: bash
run: corepack prepare pnpm@9.0.6 --activate
run: corepack prepare pnpm@10.17.0 --activate
- name: Install dependencies
shell: bash
run: pnpm install --frozen-lockfile
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ yarn-debug.log*
yarn-error.log*
node.log

# Core dumps
core
core.*

# Dependency directories
node_modules/
forge-std/
Expand Down Expand Up @@ -44,6 +48,9 @@ deployments/hardhat/
# Ignore solc bin output
bin/

# PNPM store (project-local)
.pnpm-store/

# Others
.env
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "GPL-2.0-or-later",
"repository": "[email protected]:graphprotocol/contracts.git",
"author": "The Graph team",
"packageManager": "pnpm@9.0.6+sha1.648f6014eb363abb36618f2ba59282a9eeb3e879",
"packageManager": "pnpm@10.17.0",
"scripts": {
"postinstall": "husky",
"clean": "pnpm -r run clean",
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
],
"scripts": {
"prepack": "pnpm build",
"clean": "rm -rf artifacts/ cache/ types/ abis/ build/ dist/ contracts/hardhat-dependency-compiler/",
"clean": "rm -rf artifacts/ cache/ types/ abis/ build/ dist/",
"build": "pnpm compile",
"compile": "hardhat compile",
"deploy": "pnpm predeploy && pnpm build",
Expand Down
Loading
Loading