Skip to content

❄️ Graph Horizon and Subgraph Service ❄️ #944

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

Open
wants to merge 649 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
649 commits
Select commit Hold shift + click to select a range
65b6d26
feat: add migrate ignition modules
tmigone Jan 24, 2025
3260bd2
fix: remove rpc
tmigone Jan 24, 2025
5e16b7e
feat: add more improvements to ignition deployment system
tmigone Jan 24, 2025
ea7fb75
Merge pull request #1091 from graphprotocol/mde/merge-horizon-staking…
tmigone Jan 27, 2025
83a3ec6
Merge branch 'horizon' into mde/horizon-migrate-scripts
tmigone Jan 27, 2025
17692b7
Merge pull request #1084 from graphprotocol/mde/horizon-migrate-scripts
tmigone Jan 27, 2025
353902e
Merge branch 'horizon' into tmigone/ignition-v0.15.9
tmigone Jan 27, 2025
519c5d8
Merge pull request #1087 from graphprotocol/tmigone/ignition-v0.15.9
tmigone Jan 27, 2025
835519f
Merge branch 'horizon' into tmigone/ignition-refactor
tmigone Jan 27, 2025
c3c94ca
Merge pull request #1093 from graphprotocol/tmigone/ignition-refactor
tmigone Jan 27, 2025
e8e2e9f
feat: create a base hardhat config
tmigone Jan 27, 2025
e7b02ae
feat: ensure ignition deploy script handles contract ownership
tmigone Jan 27, 2025
07aa0a2
chore: move ownership calls for payments contract to their modules
tmigone Jan 28, 2025
ea21739
fix: transfer payments contracts ownership to governor in migrate script
tmigone Jan 28, 2025
4799228
Merge pull request #1094 from graphprotocol/tmigone/tooling-improvements
tmigone Jan 28, 2025
5711907
feat: breakout ignition migration script by runner
tmigone Jan 28, 2025
a12bb20
fix: ensure governor account is not loaded in any non-governor module
tmigone Jan 28, 2025
7db331d
chore: reduce contract sizes to fit 24kb HorizonStaking and SubgraphS…
Maikol Jan 28, 2025
8c29d86
fix: further decouple governor modules from deployer modules
tmigone Jan 28, 2025
768bc83
chore: add contract address to signer proof message
Maikol Jan 28, 2025
fbdb3f1
feat: create migration scripts for subgraph service
tmigone Jan 28, 2025
5e58c8e
chore: changes to horizon events
Maikol Jan 28, 2025
7e10b2e
fix: add Horizon prefix to stake events
Maikol Jan 29, 2025
e2ea28c
fix: Horizon migration script fixes (#1100)
Maikol Feb 6, 2025
c75a0a4
Merge pull request #1095 from graphprotocol/tmigone/horizon-deploymen…
tmigone Feb 6, 2025
ccfaedc
fix: make legacy allos internal, bump optimizer runs to 100
tmigone Feb 6, 2025
859debf
fix: set optimizer runs on foundry config
tmigone Feb 6, 2025
11a993b
Merge pull request #1096 from graphprotocol/mde/reduce-contract-sizes
tmigone Feb 6, 2025
a4cb2d4
Merge pull request #1099 from graphprotocol/mde/horizon-event-changes
tmigone Feb 6, 2025
dfc6c97
Merge pull request #1098 from graphprotocol/mde/add-contract-address-…
tmigone Feb 6, 2025
6d64b7e
fix: rework base config file
tmigone Feb 6, 2025
88498d1
test: fix test using previously public variable
tmigone Feb 6, 2025
2872fd3
chore: fix linting issues
tmigone Feb 7, 2025
83dae89
ci: build all required packages for subgraph service ci
tmigone Feb 7, 2025
6e8335d
Merge pull request #1101 from graphprotocol/tmigone/horizon-fix-ci
tmigone Feb 7, 2025
33557eb
Merge branch 'main' into horizon
tmigone Feb 7, 2025
8f922a1
chore: remove e2e scenarios tests from contracts package
tmigone Feb 7, 2025
09a6fa8
chore: add paymentId to TAPCollector tokens tracking
Maikol Jan 28, 2025
fe025c3
fix: rename to collectorId and use collectorId on subgraph service
Maikol Feb 7, 2025
2af2e68
chore: rename collectorId to collectionId
tmigone Feb 10, 2025
3dc3140
Merge pull request #1097 from graphprotocol/mde/add-unique-id-to-coll…
tmigone Feb 10, 2025
6d1afc0
feat: extract cancel thaw escrow to its own function
tmigone Dec 11, 2024
74645a2
feat: add collector address to the RAV
tmigone Dec 11, 2024
744bc85
test: improve coverage for GraphPayments
tmigone Dec 13, 2024
eaec959
chore: some minor improvements to GraphPayments and tests
tmigone Dec 13, 2024
9b79fdb
fix: couple minor improvments to PaymentsEscrow and some new tests
tmigone Dec 13, 2024
90978a9
chore: revert adding collector address to RAV
tmigone Feb 6, 2025
20396ba
chore: revert adding collector address to RAV in SubgraphService
tmigone Feb 6, 2025
51976ec
Merge pull request #1078 from graphprotocol/tmigone/post-trust-change…
tmigone Feb 10, 2025
01db6e5
feat: dont issue rewards to allos less than one epoch old
tmigone Feb 10, 2025
7cd08cb
chore: ensure contract size is below 24kB
tmigone Feb 10, 2025
f6923b9
test: fix rewards manager tests
tmigone Feb 10, 2025
d0060b1
Merge pull request #1103 from graphprotocol/tmigone/allo-min-duration
tmigone Feb 11, 2025
dd2e735
chore: rename TAPCollector to GraphTallyCollector
tmigone Feb 11, 2025
94d541a
chore: rename TAPCollector in hardhat-graph-protocol package
tmigone Feb 11, 2025
010277e
Merge pull request #1106 from graphprotocol/tmigone/graph-tally
tmigone Feb 11, 2025
57c5acc
fix: ignition modules to output correct name of contracts
tmigone Feb 11, 2025
c5ca097
fix(horizon): add explicit check of provision existance before accept…
tmigone Feb 12, 2025
375c78f
chore: add request type to thaw request events
tmigone Feb 12, 2025
25376af
chore: modify build script to allow building only horizon packages
tmigone Feb 12, 2025
e9b72a7
test: add test for delegation on a non existing provision
tmigone Feb 13, 2025
0e9f9d3
Merge pull request #1107 from graphprotocol/tmigone/gre-alias
tmigone Feb 13, 2025
1b55b04
fix: Add 'test' to lint:sol (prettier)
matiasedgeandnode Feb 17, 2025
870a073
fix: SubgraphService run lint:sol
matiasedgeandnode Feb 17, 2025
3cccb4b
fix: Horizon add 'test' to lint:sol (prettier)
matiasedgeandnode Feb 17, 2025
3ad5707
fix: Horizon run lint:sol
matiasedgeandnode Feb 17, 2025
0df54e3
Merge pull request #1112 from graphprotocol/ma/horizon-fix-prettier
tmigone Feb 18, 2025
504d85b
feat: refactor deployment tooling, use task instead of script
tmigone Feb 14, 2025
1b9914d
feat: refactor deplyoment tooling for subgraph service
tmigone Feb 14, 2025
f2b120a
chore: update readme
tmigone Feb 14, 2025
6db8d05
fix: couple fixes for migration scripts
tmigone Feb 17, 2025
4260ce6
chore: update README.md
tmigone Feb 17, 2025
f978dbb
chore: remove not used deps
tmigone Feb 17, 2025
176d5b1
fix: dont import tasks on initial build run
tmigone Feb 18, 2025
fac2515
fix: remove dead export
tmigone Feb 18, 2025
9647fa8
chore: skip building token-distribution if api key not set
tmigone Feb 18, 2025
2e57fe7
fix: exit code 0 for token dist script
tmigone Feb 18, 2025
9287fa0
chore: add localnostNoSecureAccounts network to base hardhat config
tmigone Feb 18, 2025
44dd7ea
chore: update hardhat-secure-accounts to latest
tmigone Feb 18, 2025
333f98e
feat: allow overriding localhost rpc
tmigone Feb 18, 2025
e5aa136
chore: make localhost chain id a configurable variable
tmigone Feb 18, 2025
cbeb2e5
fix: ignition script bug
tmigone Feb 18, 2025
7bceb49
Merge pull request #1111 from graphprotocol/tmigone/horizon-deploymen…
tmigone Feb 18, 2025
5e09533
Merge pull request #1108 from graphprotocol/tmigone/horizon-subgraph-…
tmigone Feb 18, 2025
1f065e4
chore: refactor config files naming
tmigone Feb 19, 2025
1869d06
feat: allow overriding localhost accounts
tmigone Feb 19, 2025
9dc80f9
refactor: add Authorizable
matiasedgeandnode Feb 13, 2025
314c6da
Merge pull request #1110 from graphprotocol/ma/horizon-authorizable
matiasedgeandnode Feb 21, 2025
292dc69
fix: only allow subgraph service as verifier during transition period
tmigone Feb 21, 2025
662bf93
chore: fix comments
tmigone Feb 21, 2025
6460b84
chore: invert require checks for gas efficiency
tmigone Feb 21, 2025
c90a4ec
Merge pull request #1114 from graphprotocol/tmigone/fix-escape-hatch
tmigone Feb 21, 2025
cc74032
chore: fix test config to support forge v1
tmigone Feb 21, 2025
7df009f
Merge pull request #1115 from graphprotocol/tmigone/fix-escape-hatch
tmigone Feb 21, 2025
0b7730a
fix: a few fixes
tmigone Feb 24, 2025
26d5caa
Merge pull request #1118 from graphprotocol/tmigone/horizon-last-minu…
tmigone Feb 25, 2025
7187543
chore: change some events for easier indexing
tmigone Feb 25, 2025
830f7e8
fix: ensure subgraph service contracts are owned by governor
tmigone Feb 25, 2025
7bac074
Merge pull request #1119 from graphprotocol/tmigone/more-subgraph-cha…
tmigone Feb 25, 2025
401657e
chore: upload audit reports
tmigone Feb 27, 2025
5a4a550
fix: avoid boolean literals as conditionals
tmigone Feb 27, 2025
28c5bda
chore: natspec and other documentation changes
tmigone Feb 27, 2025
6435f64
chore: natspec documentation changes on subgraph service contracts
tmigone Feb 27, 2025
adf520e
chore: dont run natspec smells on lint
tmigone Feb 27, 2025
56e044a
chore: use calldata instead of memory
tmigone Feb 27, 2025
2e8d285
chore: remove duplicated imports
tmigone Feb 27, 2025
fc83f8f
chore: no todo comments
tmigone Feb 27, 2025
72066de
chore: dont use named returns
tmigone Feb 28, 2025
4f60b0c
chore: add security contact to the contracts
tmigone Feb 28, 2025
77ab0c7
chore: better getter name in dispute manager
tmigone Feb 28, 2025
5557c5e
chore: remove named returns
tmigone Feb 28, 2025
99f215c
chore: use custom errors
tmigone Feb 28, 2025
9e8004e
chore: clarify casting safety
tmigone Feb 28, 2025
36efdac
chore: remove unused modifier
tmigone Feb 28, 2025
da95d8b
Merge pull request #1123 from graphprotocol/tmigone/horizon-pre-audit…
tmigone Mar 3, 2025
2ed8546
fix: add collection id to rav typehash (OZ CR-01)
tmigone Mar 7, 2025
698259d
fix: prevent indexer lockout in subgraph service (OZ CR-02)
tmigone Mar 7, 2025
9d92442
fix: limit allowed thawing period range in the subgraph service (OZ M…
tmigone Mar 21, 2025
c4c3675
fix: save last parameter staged timestamp on provisions (OZ M-01)
tmigone Mar 21, 2025
2918ebe
chore: document importance of maxThawingPeriod variable
tmigone Apr 23, 2025
a43232a
chore: clarify thawing period overflow case
tmigone May 2, 2025
c58197a
fix: ensure invalid thaw requests are ignored by getThawedTokens (OZ …
tmigone Mar 21, 2025
5e27d62
fix: document possible temporary thaw requests blockage when thawing …
tmigone Mar 21, 2025
0a7719f
fix: prevent provision validity grief attack (OZ M-03)
tmigone Mar 25, 2025
c807a94
fix: remove redundant code (OZ N-01)
tmigone Mar 25, 2025
40c9a28
fix: only check conditions for param that is changing when changing p…
tmigone Mar 26, 2025
37faf78
fix: use solidity division instead of fixed point scaling (OZ L-04)
tmigone Mar 27, 2025
5adebe8
fix: rename misleading custom error name (OZ CR-03)
tmigone Mar 7, 2025
5744c86
fix: add extra parameters to contract events (OZ CR-04)
juanmardefago Feb 26, 2025
c8a7944
chore: typo
tmigone May 2, 2025
fc25c39
fix: prevent legacy slash from breaking provision accounting (OZ H-01)
tmigone Apr 23, 2025
927af0d
chore: rename function for clarity (OZ H-01)
tmigone Apr 30, 2025
8e07001
fix: ensure legacy slash unlocks correct amount
tmigone May 16, 2025
8c941cd
fix: default value for delegation ratio (OZ L-06)
tmigone Apr 24, 2025
6216621
fix: use encodeCall instead of unsafe alternatives (OZ L-10)
tmigone Apr 24, 2025
3761755
fix: ensure getRewards and takeRewards return 0 for closed allos (OZ …
tmigone Apr 29, 2025
40706ca
chore: document reentrancy risk vector
tmigone May 2, 2025
a01004e
fix: allow partial RAV collection in subgraph service (OZ L-13)
tmigone Apr 29, 2025
c7656f8
fix: ensure dispute cancellation is not affected by dispute period ch…
tmigone Apr 29, 2025
fec7173
fix: add cancellableAt to indexing disputes as well
tmigone May 2, 2025
3453c00
fix: remove unnecessary restriction (OZ N-02)
tmigone Apr 29, 2025
1012087
chore: remove unused code (OZ N-03)
tmigone Apr 29, 2025
14948be
chore: missing docstrings (OZ N-08)
tmigone Apr 29, 2025
c183fcd
chore: rename shadowed variables (OZ N-09)
tmigone Apr 29, 2025
f288348
chore: update incorrect comments (OZ N-10)
tmigone Apr 29, 2025
de935f0
chore: rename misleading vars (OZ N-11)
tmigone Apr 29, 2025
6fb20d7
chore: gas optimizations (OZ N-12)
tmigone Apr 29, 2025
46010c8
fix: prevent slashing DoS (OZ M-02)
tmigone Apr 30, 2025
7d517bf
fix: ensure delegations are always slashable (OZ H-02)
tmigone Apr 30, 2025
9ce4d11
chore: tests
tmigone May 2, 2025
792302a
chore: fix some copy in dispute manager comments
tmigone Mar 28, 2025
4a3cf2c
feat: require poi metadata when collecting rewards
tmigone Mar 28, 2025
c0e83cf
fix: allow payments to be routed to a provided address
tmigone May 8, 2025
b5fc680
fix: update contracts to allow compilation from horizon package
tmigone May 20, 2025
5787df8
fix: multiple tooling changes
tmigone May 20, 2025
d5bc312
chore: fix pnpm lock file
tmigone May 20, 2025
7d70566
Merge pull request #1116 from graphprotocol/tmigone/horizon-post-oz-a…
tmigone May 20, 2025
dadb233
chore: add latest audit
tmigone May 20, 2025
ad600bb
Merge pull request #1122 from graphprotocol/tmigone/horizon-audit-rep…
tmigone May 20, 2025
1edfe12
ci: update node version to 22
tmigone May 20, 2025
ffa75d1
fix: change hardhat toolshed to export ts
tmigone May 20, 2025
b8a0c14
feat: make transaction logging optional
tmigone May 21, 2025
7715ce2
fix: ensure transaction logging wrapping is disabled with boolean flag
tmigone May 22, 2025
d52644a
fix: ensure toolshed core components dont import hardhat runtime
tmigone May 22, 2025
eeee812
fix: auto balance set in local network
tmigone May 22, 2025
bbdef06
chore: bump version
tmigone May 22, 2025
ea14f20
fix: target undefined error
tmigone May 22, 2025
0247adb
chore: linting and other minor issues
tmigone May 23, 2025
ca4daad
chore: add proper ignition config files for local network
tmigone May 23, 2025
4368221
fix: protocol activity script small fixes
tmigone May 23, 2025
18b34c0
chore: improve activity script
tmigone May 23, 2025
e1663dd
feat: add GNS to deployments
tmigone May 27, 2025
9d6d356
chore: add encode stop service data function
Maikol May 30, 2025
fa4c2f5
chore: bump patch version
Maikol May 30, 2025
a7c9646
chore: publish new toolshed version
tmigone Jun 2, 2025
8f21cdb
fix: type issue with GNS on toolshed
tmigone Jun 2, 2025
f8809ac
ci: fix lockfile
tmigone Jun 2, 2025
3adce5a
fix: proper fix for type issues with GNS and SubgraphNFT
tmigone Jun 2, 2025
d07e8d9
ci: fix package lock
tmigone Jun 2, 2025
7870182
lint: fix linting script
matiasedgeandnode Jun 3, 2025
609bc3d
Merge pull request #1180 from graphprotocol/ma/horizon-lint
matiasedgeandnode Jun 3, 2025
79ed5a1
Add dev container config to Horizon (#1181)
RembrandtK Jun 4, 2025
fa04596
fix: prevent GraphTallyCollector from accepting non QueryFee payments
tmigone Jun 5, 2025
97dceb1
fix: allow creating multiple disputes for same allo/poi tuple
tmigone Jun 5, 2025
d89440a
fix: consider delegation when deciding if an indexer is disputable
tmigone Jun 5, 2025
a7d22d9
Merging from main for Horizon upgrades in preparation for contract PR…
RembrandtK Jun 10, 2025
2eb49a0
chore: update toolshed to use latest lint config
tmigone Jun 11, 2025
c7c8891
chore: update hardhat-graph-protocol to latest linting config
tmigone Jun 11, 2025
fd56cd7
chore: update horizon to latest linting config
tmigone Jun 11, 2025
79f996c
fix: skip token-distribution build if studio api key not set
Maikol Jun 11, 2025
c0ccb8e
chore: use top level solhint config for horizon and add graph rules
tmigone Jun 11, 2025
ab2f60e
Merge branch 'horizon' of github.com:graphprotocol/contracts into hor…
tmigone Jun 11, 2025
767ba2c
chore: update horizon natspec smells config
tmigone Jun 11, 2025
f129d36
chore: update subgraph service to use latest lint config
tmigone Jun 11, 2025
903e83f
chore: some lint fixes
tmigone Jun 11, 2025
8596344
chore: remove unused yarn file
tmigone Jun 11, 2025
c3d96e4
chore: do not use forge dependency system
tmigone Jun 11, 2025
be8d5a1
chore: move all interfaces to dedicated package
tmigone Jun 11, 2025
942c1aa
chore: lint
tmigone Jun 11, 2025
f86ffbb
chore: build interface types
tmigone Jun 11, 2025
63b8c27
fix: import in contracts package
tmigone Jun 11, 2025
32ef00c
chore: move sdk to own repo, update versions
tmigone Jun 12, 2025
f8bb3a5
chore: update toolshed to use interfaces package
tmigone Jun 12, 2025
7f21b0b
chore: break circular dep in toolshed, fix contracts ethers versions
tmigone Jun 12, 2025
be1acc5
chore: lint
tmigone Jun 12, 2025
8aef58d
chore: fully implement interfaces for toolshed
tmigone Jun 13, 2025
0112d1b
chore: import hre statically in horizon and subgraph service
tmigone Jun 13, 2025
9c67f29
chore: remove unused files
tmigone Jun 13, 2025
495e576
chore: lint packages
tmigone Jun 13, 2025
71b90c4
fix: remove dead import
tmigone Jun 13, 2025
0f7080d
feat: create address book if doesnt exist when running deploy task
tmigone Jun 13, 2025
2bfd7e0
fix: add some missing interface details
tmigone Jun 13, 2025
62eb5aa
fix: couple fixes to make integration tests pass
tmigone Jun 13, 2025
5f707a8
chore: update subgraph service to work wiht latest interfaces
tmigone Jun 13, 2025
2c94da4
chore: final changes to use interfaces package
tmigone Jun 17, 2025
5ef5fe9
chore: lint and replace some imports
tmigone Jun 17, 2025
e75ae57
chore: bump package versions and publish
tmigone Jun 18, 2025
039a32e
chore: make interfaces package public
tmigone Jun 18, 2025
f6c2e1c
chore: bump package versions
tmigone Jun 18, 2025
1c7e4cf
fix: ensure close allo behavior consistent with legacy
tmigone Jun 17, 2025
31edeed
fix: ensure dist is published for interfaces package
tmigone Jun 18, 2025
4f23eea
chore: add missing interfaces and fix npm publishing issues
tmigone Jun 18, 2025
fbe38f9
fix: add ICuration to L2Curation interface
tmigone Jun 18, 2025
ed51926
fix: add more stuff missing from interfaces
tmigone Jun 18, 2025
b4fe809
chore: ensure workspace dependencies are not pinned to specific versions
tmigone Jun 19, 2025
a8469af
chore: better gitignore
tmigone Jun 19, 2025
8b7f14c
chore: fix pnpm lock file
tmigone Jun 19, 2025
291c6ff
Revert "fix: prevent GraphTallyCollector from accepting non QueryFee …
tmigone Jul 8, 2025
4d4cffa
chore: add latest audit report
tmigone Jul 8, 2025
77007c0
Merge branch 'horizon' into tmigone/horizon-fixes-june
tmigone Jul 8, 2025
28d810e
Merge branch 'horizon' into tmigone/horizon-interfaces
tmigone Jul 8, 2025
d14870e
test: fix package tests
tmigone Jul 8, 2025
bcb63c1
feat: add wagmi type generation to interface package
tmigone Jul 10, 2025
72162d1
chore: bump package version
tmigone Jul 10, 2025
59154fb
chore: support ethersv5 types for interfaces
tmigone Jul 10, 2025
b762037
feat: add ethers v5 type generation to interfaces package
tmigone Jul 10, 2025
a32f413
ci: remove unnecessary workflows
tmigone Jul 10, 2025
9d85394
chore: add script to compare bytecode
tmigone Jul 14, 2025
523d3b1
chore: use bytecode instead of deployedBytecode in bytecode compare s…
tmigone Jul 14, 2025
8812eb1
Merge pull request #1187 from graphprotocol/tmigone/horizon-interfaces
tmigone Jul 15, 2025
51c2c1d
fix: interfaces architecture and add missing GNS functions
Maikol Jul 22, 2025
bd38c83
feat: add vesting interfaces for Horizon protocol
Maikol Jul 23, 2025
59e87cf
chore: release [email protected] and [email protected]
Maikol Jul 23, 2025
d28477f
fix: export conditions order in interfaces package for Next.js compat…
Maikol Jul 24, 2025
4689fec
chore: extract horizon and subgraph-service addresses to a new addres…
Maikol Jul 29, 2025
ef8b05d
Merge pull request #1211 from graphprotocol/mde/address-book-package
Maikol Jul 30, 2025
0834478
chore: release [email protected]
Maikol Jul 30, 2025
db7fd6d
chore: add CHANGELOG for [email protected]
Maikol Jul 30, 2025
f22e83a
fix: add missing nextAccountSeqID and multicall to IL2GNSToolshed int…
Maikol Aug 4, 2025
f3107aa
chore: release [email protected]
Maikol Aug 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 0 additions & 5 deletions .changeset/smooth-balloons-stare.md

This file was deleted.

84 changes: 84 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
FROM mcr.microsoft.com/devcontainers/base:debian

# Set non-interactive frontend for apt
ENV DEBIAN_FRONTEND=noninteractive

# Switch to root for installing packages
USER root

# Install additional dependencies
RUN apt update && 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 && \
# Copy binaries to /usr/local/bin with proper permissions
cp /root/.foundry/bin/anvil /usr/local/bin/anvil && \
cp /root/.foundry/bin/cast /usr/local/bin/cast && \
cp /root/.foundry/bin/forge /usr/local/bin/forge && \
cp /root/.foundry/bin/chisel /usr/local/bin/chisel && \
# Ensure proper permissions
chmod 755 /usr/local/bin/anvil && \
chmod 755 /usr/local/bin/cast && \
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
mkdir -p /home/vscode/.local/bin && \
chown -R vscode:vscode /home/vscode/.local/bin

# Switch back to vscode user
USER vscode

# Set environment variables
ENV PATH="/usr/local/bin:/home/vscode/.foundry/bin:/home/vscode/.local/bin:/root/.local/bin:$PATH"

# Create .bashrc additions for PATH
RUN echo 'export PATH="/usr/local/bin:$HOME/.local/bin:$PATH"' >> $HOME/.bashrc

# Set the default command
CMD ["sleep", "infinity"]
107 changes: 107 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Graph Protocol Contracts Dev Container

This directory contains configuration files for the Graph Protocol contracts development container.

> **Note:** This dev container setup is a work in progress and will not be fully portable.

## Overview

The dev container provides a consistent development environment with caching to improve performance.

### Key Components

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

### Start the Dev Container

To start the dev container:

1. Open VS Code
2. Use the "Remote-Containers: Open Folder in Container" command
3. Select the repository directory (for example `/git/graphprotocol/contracts`)

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
- 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` on the host

### Git Configuration

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

```env
# Git settings for commit signing
GIT_USER_NAME=Your Name
[email protected]
```

These environment variables are needed for Git commit signing to work properly. If they are not defined, Git commit signing will not be configured, but the container will still work for other purposes.

## Troubleshooting

### Cache Issues

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 `pnpm clean` to clear project-specific build artifacts
3. **Clear node modules**: Delete `node_modules` and run `pnpm install` again

### Git SSH Signing Issues

If you encounter issues with Git SSH signing:

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
```

For other issues, check the `project-setup.sh` and `setup-git-signing.sh` scripts for any errors.
42 changes: 42 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +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"
]
}
}
}
53 changes: 53 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
services:
dev-graph-contracts:
build:
context: .
dockerfile: Dockerfile
env_file:
- /opt/configs/graphprotocol/contracts.env
environment:
# Essential for large builds
- NODE_OPTIONS=--max-old-space-size=4096

# 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
- 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:
48 changes: 48 additions & 0 deletions .devcontainer/host-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# Host setup script for Graph Protocol Contracts dev container
# Run this script on the host before starting the dev container
# Usage: sudo .devcontainer/host-setup.sh

set -euo pipefail

echo "Setting up host environment for Graph Protocol Contracts dev container..."

# Check if running as root
if [ "$(id -u)" -ne 0 ]; then
echo "Error: This script must be run as root (sudo)" >&2
exit 1
fi

CACHE_DIRS=(
"/cache/vscode-cache"
"/cache/vscode-config"
"/cache/vscode-data"
"/cache/vscode-bin"
"/cache/hardhat"
"/cache/npm"
"/cache/yarn"
"/cache/pip"
"/cache/pycache"
"/cache/solidity"
"/cache/foundry"
"/cache/github"
"/cache/apt"
"/cache/apt-lib"
)

echo "Creating cache directories..."
for dir in "${CACHE_DIRS[@]}"; do
if [ ! -d "$dir" ]; then
echo "Creating $dir"
mkdir -p "$dir"
chmod 777 "$dir"
else
echo "$dir already exists"
fi
done

# Note: Package-specific directories will be created by the project-setup.sh script
# inside the container, as they are tied to the project structure

echo "Host setup completed successfully!"
echo "You can now start or rebuild your dev container."
Loading