Skip to content

Commit d7dd62d

Browse files
authored
Merge pull request #944 from graphprotocol/horizon
2 parents bdc6613 + 1eb4250 commit d7dd62d

File tree

706 files changed

+397628
-8647
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

706 files changed

+397628
-8647
lines changed

.devcontainer/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ The dev container provides a consistent development environment with caching to
2121
The container uses a conservative caching approach to prevent cache corruption issues:
2222

2323
1. **Local Cache Directories**: Each container instance maintains its own cache directories
24-
2524
- `vscode-cache``/home/vscode/.cache` (VS Code cache)
2625
- `vscode-config``/home/vscode/.config` (VS Code configuration)
2726
- `vscode-data``/home/vscode/.local/share` (VS Code data)
2827
- `vscode-bin``/home/vscode/.local/bin` (User binaries)
2928

3029
2. **Safe Caches Only**: Only caches that won't cause cross-branch issues are configured
31-
3230
- GitHub CLI: `/home/vscode/.cache/github`
3331
- Python packages: `/home/vscode/.cache/pip`
3432

.gitignore

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ packages/*/.eslintcache
2828

2929
# Build artifacts
3030
dist/
31+
dist-v5/
3132
build/
33+
typechain/
34+
typechain-types/
35+
types/
36+
types-v5/
37+
wagmi/
3238
types/
3339
deployments/hardhat/
3440

@@ -51,12 +57,11 @@ lcov.info
5157
hardhat-dependency-compiler/
5258

5359
# Local test files
54-
addresses-local.json
5560
localNetwork.json
5661
arbitrum-addresses-local.json
57-
tx-*.log
5862
addresses-fork.json
5963
addresses-hardhat.json
64+
addresses-local*.json
6065
addresses-local-network.json
6166

6267
# Keys
@@ -71,10 +76,16 @@ packages/issuance/lib/forge-std/
7176
# Graph client
7277
.graphclient
7378

79+
# Tx builder and logger
80+
tx-*.log
7481
tx-builder-*.json
7582
!tx-builder-template.json
7683

7784
# Hardhat Ignition
85+
**/ignition/deployments/*-localhost/
86+
**/ignition/deployments/*-hardhat/
87+
**/ignition/deployments/*-31337/
88+
**/ignition/deployments/*-1337/
7889
**/chain-31337/
7990
**/chain-1377/
8091
**/horizon-localhost/

.markdownlintignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Third-party libraries in lib directories
5+
**/lib/
6+
7+
# Build outputs
8+
**/build/
9+
**/dist/
10+
**/artifacts/
11+
**/typechain-types/
12+
**/types/
13+
**/cache/
14+
**/cached/
15+
cache
16+
typechain/
17+
bin/
18+
forge-artifacts/
19+
out/
20+
21+
# Coverage and reports
22+
coverage/
23+
reports/
24+
coverage.json
25+
lcov.info
26+
.nyc_output/
27+
28+
# Other generated files
29+
.eslintcache
30+
packages/*/.eslintcache
31+
deployments/hardhat/
32+
.graphclient
33+
**/chain-31337/
34+
**/chain-1377/
35+
**/horizon-localhost/
36+
**/horizon-hardhat/
37+
**/subgraph-service-localhost/
38+
**/subgraph-service-hardhat/
39+
.changeset/

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ yarn.lock
55

66
# Dependencies (from .gitignore)
77
node_modules/
8+
9+
# Third-party libraries in lib directories
10+
**/lib/
811
forge-std/
912

1013
# Build outputs (from .gitignore)

.solhint.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
"quotes": ["error", "double"],
88
"reason-string": ["off"],
99
"not-rely-on-time": "off",
10-
"no-empty-blocks": "off"
10+
"no-empty-blocks": "off",
11+
"named-parameters-mapping": "warn",
12+
"private-vars-leading-underscore": "off",
13+
"func-name-mixedcase": "off",
14+
"var-name-mixedcase": "off",
15+
"gas-custom-errors": "off"
1116
}
1217
}

CLAUDE.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Repository Overview
6+
7+
This is The Graph Protocol's smart contracts monorepo - a decentralized network for querying and indexing blockchain data. It uses pnpm workspaces to manage multiple packages.
8+
9+
## Key Commands
10+
11+
### Build and Development
12+
13+
```bash
14+
# Install dependencies (uses pnpm)
15+
pnpm install
16+
17+
# Build all packages
18+
pnpm build
19+
20+
# Clean build artifacts
21+
pnpm clean
22+
23+
# Deep clean (including node_modules)
24+
pnpm clean:all
25+
```
26+
27+
### Testing
28+
29+
```bash
30+
# Run all tests
31+
pnpm test
32+
33+
# Run tests with coverage
34+
pnpm test:coverage
35+
36+
# Test a specific package
37+
cd packages/<package-name> && pnpm test
38+
39+
# Test a single file (in contracts package)
40+
cd packages/contracts && npx hardhat test test/<FILE_NAME>.ts
41+
42+
# Run Foundry tests (in horizon/subgraph-service)
43+
cd packages/horizon && pnpm test
44+
45+
# Run integration tests
46+
cd packages/horizon && pnpm test:integration
47+
48+
# Run deployment tests
49+
cd packages/horizon && pnpm test:deployment
50+
```
51+
52+
### Linting and Formatting
53+
54+
```bash
55+
# Run all linters
56+
pnpm lint
57+
58+
# Format code
59+
pnpm format
60+
61+
# Individual linters
62+
pnpm lint:ts # TypeScript/JavaScript
63+
pnpm lint:sol # Solidity
64+
pnpm lint:natspec # NatSpec comments
65+
pnpm lint:md # Markdown
66+
pnpm lint:json # JSON files
67+
pnpm lint:yaml # YAML files
68+
```
69+
70+
## Architecture Overview
71+
72+
### Package Structure
73+
74+
1. **contracts** - Original Graph Protocol contracts (staking, curation, disputes)
75+
- Uses Hardhat for development
76+
- Contains E2E testing framework for protocol validation
77+
78+
2. **horizon** - Next iteration of The Graph protocol
79+
- Uses Hardhat + Foundry for testing
80+
- Deployment via Hardhat Ignition
81+
- Migration path from original protocol
82+
83+
3. **subgraph-service** - Data service implementation for Graph Horizon
84+
- Manages disputes and allocations
85+
- Part of the Horizon ecosystem
86+
87+
4. **interfaces** - Shared contract interfaces
88+
- Centralized repository for all Solidity contract interfaces
89+
- Used by multiple packages/programs for contract implementation and interaction
90+
- Generates TypeScript types for distribution via npm
91+
- Defaults to ethers v6 type generation
92+
- Includes Wagmi type generation support
93+
- Includes ethers v5 type generation
94+
- Published types can be imported by any TypeScript program
95+
96+
5. **token-distribution** - Token locking and vesting contracts
97+
- GraphTokenLockWallet and GraphTokenLockManager
98+
- L2 token distribution functionality
99+
100+
6. **toolshed** - Shared development utilities
101+
- Deployment helpers
102+
- Test fixtures
103+
- Hardhat extensions
104+
105+
### Key Architectural Patterns
106+
107+
- **Proxy Upgradeable Pattern**: Most contracts use OpenZeppelin's upgradeable proxy pattern
108+
- **Storage Separation**: Storage contracts are separate from logic contracts
109+
- **Governor/Controller Pattern**: Access control through Governor and Controller contracts
110+
- **Modular Design**: Clear separation between protocol layers and services
111+
112+
### Testing Strategy
113+
114+
- **Unit Tests**: TypeScript tests using Hardhat Test Environment
115+
- **Foundry Tests**: Solidity tests (`.t.sol` files) for horizon and subgraph-service
116+
- **Integration Tests**: Cross-contract interaction testing
117+
- **E2E Tests**: Full protocol deployment and operation validation
118+
119+
### Deployment
120+
121+
- Contract addresses stored in `addresses.json` files per package
122+
- Multi-network support (mainnet, testnets, Arbitrum chains)
123+
- Hardhat Ignition for deployment management
124+
- Migration scripts for upgrading from original protocol to Horizon
125+
126+
## Development Tips
127+
128+
### Working with Horizon
129+
130+
Horizon packages use both Hardhat and Foundry. When developing:
131+
132+
1. Use `forge test` for Foundry tests
133+
2. Use `pnpm test:integration` for integration tests
134+
3. Set required RPC URLs using `npx hardhat vars set <variable>`
135+
136+
### Contract Verification
137+
138+
For contract verification on block explorers:
139+
140+
```bash
141+
npx hardhat vars set ARBISCAN_API_KEY <your-key>
142+
```
143+
144+
### Changesets for Versioning
145+
146+
When making changes that should be published:
147+
148+
```bash
149+
# Create a changeset
150+
pnpm changeset
151+
152+
# Version packages (maintainer only)
153+
pnpm changeset version
154+
155+
# Publish to npm (maintainer only)
156+
pnpm changeset publish
157+
```
158+
159+
### Security Considerations
160+
161+
- Audit reports available in `audits/` directories
162+
- Use existing proxy patterns and access control mechanisms
163+
- Follow established upgrade procedures for contract modifications
164+
- Report security issues through Immunefi bounty program

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@
3333

3434
This repository is a pnpm workspaces monorepo containing the following packages:
3535

36-
| Package | Latest version | Description |
37-
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------- |
38-
| [contracts](./packages/contracts) | [![npm version](https://badge.fury.io/js/@graphprotocol%2Fcontracts.svg)](https://badge.fury.io/js/@graphprotocol%2Fcontracts) | Contracts enabling the open and permissionless decentralized network known as The Graph protocol. |
39-
| [horizon](./packages/horizon) | - | Contracts for Graph Horizon, the next iteration of The Graph protocol. |
40-
| [token-distribution](./packages/token-distribution) | [![npm version](https://badge.fury.io/js/@graphprotocol%2Ftoken-distribution.svg)](https://badge.fury.io/js/@graphprotocol%2Ftoken-distribution) | Contracts managing token locks for network participants |
41-
| [sdk](./packages/sdk) | [![npm version](https://badge.fury.io/js/@graphprotocol%2Fsdk.svg)](https://badge.fury.io/js/@graphprotocol%2Fsdk) | TypeScript based SDK to interact with the protocol contracts |
42-
| [issuance](./packages/issuance) | [![npm version](https://badge.fury.io/js/@graphprotocol%2Fissuance.svg)](https://badge.fury.io/js/@graphprotocol%2Fissuance) | Smart contracts for The Graph's token issuance functionality |
43-
| [data-edge](./packages/data-edge) | [![npm version](https://badge.fury.io/js/@graphprotocol%2Fdata-edge.svg)](https://badge.fury.io/js/@graphprotocol%2Fdata-edge) | Data edge testing and utilities for The Graph protocol |
44-
| [common](./packages/common) | [![npm version](https://badge.fury.io/js/@graphprotocol%2Fcommon.svg)](https://badge.fury.io/js/@graphprotocol%2Fcommon) | Common utilities and configuration for Graph Protocol packages |
36+
| Package | Latest version | Description |
37+
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------- |
38+
| [contracts](./packages/contracts) | [![npm version](https://badge.fury.io/js/@graphprotocol%2Fcontracts.svg)](https://badge.fury.io/js/@graphprotocol%2Fcontracts) | Contracts enabling the open and permissionless decentralized network known as The Graph protocol. |
39+
| [data-edge](./packages/data-edge) | - | Data edge testing and utilities for The Graph protocol. |
40+
| [hardhat-graph-protocol](./packages/hardhat-graph-protocol) | [![npm version](https://badge.fury.io/js/hardhat-graph-protocol.svg)](https://badge.fury.io/js/hardhat-graph-protocol) | A Hardhat plugin that extends the runtime environment with functionality for The Graph protocol. |
41+
| [horizon](./packages/horizon) | [![npm version](https://badge.fury.io/js/@graphprotocol%2Fhorizon.svg)](https://badge.fury.io/js/@graphprotocol%2Fhorizon) | Contracts for Graph Horizon, the next iteration of The Graph protocol. |
42+
| [interfaces](./packages/interfaces) | [![npm version](https://badge.fury.io/js/@graphprotocol%2Finterfaces.svg)](https://badge.fury.io/js/@graphprotocol%2Finterfaces) | Contract interfaces for The Graph protocol contracts. |
43+
| [subgraph-service](./packages/subgraph-service) | [![npm version](https://badge.fury.io/js/@graphprotocol%2Fsubgraph-service.svg)](https://badge.fury.io/js/@graphprotocol%2Fsubgraph-service) | Contracts for the Subgraph data service in Graph Horizon. |
44+
| [token-distribution](./packages/token-distribution) | [![npm version](https://badge.fury.io/js/@graphprotocol%2Ftoken-distribution.svg)](https://badge.fury.io/js/@graphprotocol%2Ftoken-distribution) | Contracts managing token locks for network participants. |
45+
| [toolshed](./packages/toolshed) | [![npm version](https://badge.fury.io/js/@graphprotocol%2Ftoolshed.svg)](https://badge.fury.io/js/@graphprotocol%2Ftoolshed) | A collection of tools and utilities for the Graph Protocol TypeScript components. |
4546

4647
## Development
4748

count-patterns.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Include patterns (files to count):
99
packages/issuance/contracts/**/*.sol
1010
packages/contracts/contracts/rewards/RewardsManager*.sol
11-
packages/common/contracts/**/*.sol
11+
packages/interfaces/contracts/**/*.sol
1212

1313
# Exclude patterns (files to ignore):
1414
!*/mocks/*.sol

eslint.config.mjs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ export function getGitignorePatterns(customGitignorePath = null) {
126126
return translateGitignorePatterns(gitignorePath, repoRoot)
127127
}
128128

129-
export default [
129+
/** @type {import('eslint').Linter.Config[]} */
130+
const eslintConfig = [
130131
// Include .gitignore patterns
131132
includeGitignore(),
132133

@@ -205,8 +206,9 @@ export default [
205206
'@typescript-eslint/no-unused-vars': [
206207
'error',
207208
{
208-
varsIgnorePattern: 'Null|Active|Closed|graph|_i',
209-
argsIgnorePattern: '_',
209+
varsIgnorePattern: '^_|Null|Active|Closed|graph|_i',
210+
argsIgnorePattern: '^_',
211+
caughtErrorsIgnorePattern: '^_',
210212
},
211213
],
212214
},
@@ -231,8 +233,8 @@ export default [
231233
'no-unused-vars': [
232234
'error',
233235
{
234-
varsIgnorePattern: 'Null|Active|Closed|graph|_i',
235-
argsIgnorePattern: '_',
236+
varsIgnorePattern: '^_|Null|Active|Closed|graph|_i',
237+
argsIgnorePattern: '^_',
236238
},
237239
],
238240
},
@@ -266,7 +268,11 @@ export default [
266268
// Additional global ignores and unignores
267269
{
268270
ignores: [
269-
// Keep any patterns that might not be in .gitignore
271+
// Autogenerated GraphClient files (committed but should not be linted)
272+
'**/.graphclient-extracted/**',
273+
'**/.graphclient/**',
274+
// Third-party dependencies (Forge libraries, etc.)
275+
'**/lib/**',
270276
],
271277
},
272278

@@ -275,3 +281,5 @@ export default [
275281
files: ['packages/**/*.{js,ts,cjs,mjs,jsx,tsx}'],
276282
},
277283
]
284+
285+
export default eslintConfig

natspec-smells.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111

1212
/** @type {import('@defi-wonderland/natspec-smells').Config} */
1313
module.exports = {
14-
include: ['packages/issuance/contracts/**/*.sol', 'packages/common/contracts/**/*.sol'],
14+
include: [
15+
'packages/issuance/contracts/**/*.sol',
16+
'packages/interfaces/contracts/**/*.sol',
17+
'packages/horizon/contracts/**/*.sol',
18+
'packages/subgraph-service/contracts/**/*.sol',
19+
],
1520

1621
root: './',
1722

0 commit comments

Comments
 (0)