Skip to content

Commit 5902ff4

Browse files
authored
Merge branch 'main' into pierrick/fix-peer-size-check
2 parents fcc0ad5 + 7cba5b6 commit 5902ff4

137 files changed

Lines changed: 10514 additions & 2524 deletions

File tree

Some content is hidden

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

.github/workflows/test.yml

Lines changed: 103 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ on:
99
type: string
1010

1111
jobs:
12-
build-docker-image:
13-
name: Build Docker Image
12+
build-rollkit-image:
13+
name: Build Rollkit Docker Image
14+
# skip building images for merge groups as they are already built on PRs and main
15+
if: github.event_name != 'merge_group'
1416
runs-on: ubuntu-latest
17+
permissions:
18+
packages: write
1519
steps:
1620
- name: Checkout code
1721
uses: actions/checkout@v4
@@ -26,18 +30,59 @@ jobs:
2630
username: ${{ github.actor }}
2731
password: ${{ secrets.GITHUB_TOKEN }}
2832

29-
- name: Build and push Docker image with PR tag
30-
uses: docker/build-push-action@v5
33+
- name: Build and push rollkit Docker image
34+
uses: docker/build-push-action@v6
3135
with:
3236
context: .
3337
push: true
38+
platforms: linux/amd64,linux/arm64
3439
tags: ghcr.io/${{ github.repository_owner }}/rollkit:${{ inputs.image-tag }}
3540

36-
upgrade-tests:
37-
needs: build-docker-image
41+
build-rollkit-evm-single-image:
42+
name: Build Rollkit EVM Single Docker Image
43+
# skip building images for merge groups as they are already built on PRs and main
44+
if: github.event_name != 'merge_group'
3845
runs-on: ubuntu-latest
46+
permissions:
47+
packages: write
3948
steps:
40-
- run: exit 0 # TODO: add upgrade test uses the image built in the build-docker-image step
49+
- name: Checkout code
50+
uses: actions/checkout@v4
51+
52+
- name: Set up Docker Buildx
53+
uses: docker/setup-buildx-action@v3
54+
55+
- name: Log in to GHCR
56+
uses: docker/login-action@v3
57+
with:
58+
registry: ghcr.io
59+
username: ${{ github.actor }}
60+
password: ${{ secrets.GITHUB_TOKEN }}
61+
62+
- name: Build and push rollkit-evm-single Docker image
63+
uses: docker/build-push-action@v6
64+
with:
65+
context: .
66+
file: apps/evm/single/Dockerfile
67+
push: true
68+
platforms: linux/amd64,linux/arm64
69+
tags: ghcr.io/${{ github.repository_owner }}/rollkit-evm-single:${{ inputs.image-tag }}
70+
71+
docker-tests:
72+
name: Docker E2E Tests
73+
needs: build-rollkit-image
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/checkout@v4
77+
- name: set up go
78+
uses: actions/setup-go@v5
79+
with:
80+
go-version-file: ./test/docker-e2e/go.mod
81+
- name: Run Docker E2E Tests
82+
run: make test-docker-e2e
83+
env:
84+
ROLLKIT_IMAGE_REPO: ghcr.io/${{ github.repository }}
85+
ROLLKIT_IMAGE_TAG: ${{ inputs.image-tag }}
4186

4287
build_all-apps:
4388
name: Build All Rollkit Binaries
@@ -74,14 +119,34 @@ jobs:
74119
go-version-file: ./go.mod
75120
- name: Run unit test
76121
run: make test-cover
77-
- name: upload coverage report
78-
uses: codecov/codecov-action@v5.4.3
122+
- name: Upload unit test coverage report
123+
uses: actions/upload-artifact@v4
79124
with:
80-
token: ${{ secrets.CODECOV_TOKEN }}
81-
file: ./coverage.txt
125+
name: unit-test-coverage-report-${{ github.sha }}
126+
path: ./coverage.txt
127+
128+
integration_test:
129+
name: Run Integration Tests
130+
runs-on: ubuntu-latest
131+
permissions:
132+
contents: read
133+
steps:
134+
- uses: actions/checkout@v4
135+
- name: set up go
136+
uses: actions/setup-go@v5
137+
with:
138+
go-version-file: ./go.mod
139+
- name: Run integration test
140+
run: make test-integration-cover
141+
- name: Upload integration test coverage report
142+
uses: actions/upload-artifact@v4
143+
with:
144+
name: integration-test-coverage-report-${{ github.sha }}
145+
path: ./node/coverage.txt
82146

83147
e2e-tests:
84148
name: Run E2E System Tests
149+
needs: build_all-apps
85150
runs-on: ubuntu-latest
86151
steps:
87152
- uses: actions/checkout@v4
@@ -94,6 +159,7 @@ jobs:
94159

95160
evm-tests:
96161
name: Run EVM Execution Tests
162+
needs: build_all-apps
97163
runs-on: ubuntu-latest
98164
steps:
99165
- uses: actions/checkout@v4
@@ -103,3 +169,29 @@ jobs:
103169
go-version-file: ./go.mod
104170
- name: EVM Tests
105171
run: make test-evm
172+
173+
combine_and_upload_coverage:
174+
name: Combine and Upload Coverage
175+
needs: [unit_test, integration_test]
176+
runs-on: ubuntu-latest
177+
permissions:
178+
contents: read
179+
actions: read
180+
steps:
181+
- uses: actions/checkout@v4
182+
- name: Download unit test coverage report
183+
uses: actions/download-artifact@v4
184+
with:
185+
name: unit-test-coverage-report-${{ github.sha }}
186+
path: ./unit-coverage
187+
- name: Download integration test coverage report
188+
uses: actions/download-artifact@v4
189+
with:
190+
name: integration-test-coverage-report-${{ github.sha }}
191+
path: ./integration-coverage
192+
- name: Upload combined coverage report
193+
uses: codecov/codecov-action@v5.4.3
194+
with:
195+
token: ${{ secrets.CODECOV_TOKEN }}
196+
files: ./unit-coverage/coverage.txt,./integration-coverage/coverage.txt
197+
flags: combined

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ proto/tendermint
44
types/pb/tendermint
55
.vscode/launch.json
66
.vscode/settings.json
7+
vendor
78
*/**.html
89
*.idea
910
*.env

.mockery.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
template: testify
2+
template-data:
3+
unroll-variadic: true
4+
packages:
5+
github.com/rollkit/rollkit/core/da:
6+
interfaces:
7+
DA:
8+
config:
9+
pkgname: mocks
10+
filename: da.go
11+
configs:
12+
- dir: ./da/internal/mocks
13+
- dir: ./test/mocks
14+
github.com/rollkit/rollkit/core/execution:
15+
interfaces:
16+
Executor:
17+
config:
18+
dir: ./test/mocks
19+
pkgname: mocks
20+
filename: execution.go
21+
github.com/rollkit/rollkit/core/sequencer:
22+
interfaces:
23+
Sequencer:
24+
config:
25+
dir: ./test/mocks
26+
pkgname: mocks
27+
filename: sequencer.go
28+
github.com/rollkit/rollkit/pkg/p2p:
29+
interfaces:
30+
P2PRPC:
31+
config:
32+
dir: ./test/mocks
33+
pkgname: mocks
34+
filename: p2p.go
35+
github.com/rollkit/rollkit/pkg/store:
36+
interfaces:
37+
Store:
38+
config:
39+
dir: ./test/mocks
40+
pkgname: mocks
41+
filename: store.go
42+
github.com/celestiaorg/go-header:
43+
interfaces:
44+
Store:
45+
config:
46+
dir: ./test/mocks
47+
pkgname: mocks
48+
filename: external/hstore.go

CLAUDE.md

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Rollkit is a sovereign rollup framework built in Go that allows developers to build rollups on any DA layer. It provides a modular architecture where components like the data availability layer, executor, and sequencer can be plugged in.
8+
9+
## Build and Development Commands
10+
11+
### Building
12+
- `make build` - Builds the Testapp CLI to `./build/testapp`
13+
- `make install` - Installs Testapp CLI to your Go bin directory
14+
- `make build-all` - Builds all Rollkit binaries
15+
- `make docker-build` - Builds Docker image tagged as `rollkit:local-dev`
16+
17+
### Testing
18+
- `make test` - Runs unit tests for all go.mod files
19+
- `make test-integration` - Runs integration tests (15m timeout)
20+
- `make test-e2e` - Runs end-to-end tests (requires building binaries first)
21+
- `make test-cover` - Generates code coverage report
22+
- `make test-all` - Runs all tests including Docker E2E tests
23+
24+
### Linting and Code Quality
25+
- `make lint` - Runs all linters (golangci-lint, markdownlint, hadolint, yamllint, goreleaser check, actionlint)
26+
- `make lint-fix` - Auto-fixes linting issues where possible
27+
- `make vet` - Runs go vet
28+
29+
### Development Utilities
30+
- `make deps` - Downloads dependencies and runs go mod tidy for all modules
31+
- `make proto-gen` - Generates protobuf files (requires Docker)
32+
- `make mock-gen` - Generates mocks using mockery
33+
- `make run-n NODES=3` - Run multiple nodes locally (default: 1)
34+
35+
## Code Architecture
36+
37+
### Core Package Structure
38+
The project uses a zero-dependency core package pattern:
39+
- **core/** - Contains only interfaces and types, no external dependencies
40+
- **block/** - Block management, creation, validation, and synchronization
41+
- **p2p/** - Networking layer built on libp2p
42+
- **sequencing/** - Modular sequencer implementations
43+
- **testapp/** - Reference implementation for testing
44+
45+
### Key Interfaces
46+
- **Executor** (core/executor.go) - Handles state transitions
47+
- **Sequencer** (core/sequencer.go) - Orders transactions
48+
- **DA** (core/da.go) - Data availability layer abstraction
49+
50+
### Modular Design
51+
- Each component has an interface in the core package
52+
- Implementations are in separate packages
53+
- Components are wired together via dependency injection
54+
- Multiple go.mod files enable modular builds
55+
56+
### P2P Architecture
57+
- Built on libp2p with GossipSub and Kademlia DHT
58+
- Nodes advertise capabilities (full/light, DA layers)
59+
- Automatic peer discovery with rendezvous points
60+
61+
## Testing Patterns
62+
63+
### Test Organization
64+
- Unit tests: `*_test.go` files alongside code
65+
- Integration tests: `test/integration/`
66+
- E2E tests: `test/e2e/`
67+
68+
### Running Specific Tests
69+
```bash
70+
# Run a single test
71+
go test -run TestSpecificFunction ./package/...
72+
73+
# Run with verbose output
74+
go test -v ./package/...
75+
76+
# Run with race detection
77+
go test -race ./package/...
78+
```
79+
80+
### Mock Generation
81+
- Mocks are defined in `.mockery.yaml`
82+
- Generate with `make mock-gen`
83+
- Mocks are placed in `mocks/` directories
84+
85+
## Code Style Guidelines
86+
87+
### Go Conventions
88+
- Follow standard Go formatting (enforced by golangci-lint)
89+
- Use meaningful variable names
90+
- Keep functions small and focused
91+
- Document exported types and functions
92+
- Use context.Context for cancellation
93+
94+
### Error Handling
95+
- Wrap errors with context using `fmt.Errorf`
96+
- Return errors early
97+
- Use custom error types for domain-specific errors
98+
99+
### Logging
100+
- Use structured logging (look for existing patterns)
101+
- Include relevant context in log messages
102+
- Use appropriate log levels
103+
104+
## Common Development Tasks
105+
106+
### Adding a New DA Layer
107+
1. Implement the `DA` interface from `core/da.go`
108+
2. Add configuration in the appropriate config package
109+
3. Wire it up in the initialization code
110+
4. Add tests following existing patterns
111+
112+
### Modifying Protobuf Definitions
113+
1. Edit `.proto` files in `types/pb/`
114+
2. Run `make proto-gen` to regenerate Go code
115+
3. Update any affected code
116+
4. Run tests to ensure compatibility
117+
118+
### Adding New Tests
119+
1. Place unit tests next to the code being tested
120+
2. Use table-driven tests where appropriate
121+
3. Mock external dependencies using mockery
122+
4. Ensure tests are deterministic
123+
124+
## Security Considerations
125+
126+
- Never expose private keys in logs or errors
127+
- Validate all inputs from external sources
128+
- Use secure random number generation
129+
- Follow the principle of least privilege
130+
- Be careful with concurrent access to shared state
131+
132+
## Performance Considerations
133+
134+
- The project uses concurrent processing extensively
135+
- Be mindful of goroutine leaks
136+
- Use buffered channels appropriately
137+
- Profile before optimizing
138+
- Consider memory allocation in hot paths
139+
140+
## Debugging Tips
141+
142+
- Use `make run-n NODES=2` to test multi-node scenarios locally
143+
- Check logs for error messages and stack traces
144+
- Use Go's built-in profiling tools for performance issues
145+
- The testapp provides a simple way to test changes
146+
147+
## Contributing Guidelines
148+
149+
- All code must pass linting (`make lint`)
150+
- All tests must pass (`make test-all`)
151+
- Follow the existing code patterns
152+
- Update tests when changing functionality
153+
- Keep commits focused and atomic

apps/evm/based/cmd/init.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,18 @@ func InitCmd() *cobra.Command {
6262

6363
// Initialize genesis without app state
6464
err = rollgenesis.CreateGenesis(homePath, chainID, 1, proposerAddress)
65+
genesisPath := rollgenesis.GenesisPath(homePath)
6566
if errors.Is(err, rollgenesis.ErrGenesisExists) {
6667
// check if existing genesis file is valid
67-
if genesis, err := rollgenesis.LoadGenesis(homePath); err == nil {
68+
if genesis, err := rollgenesis.LoadGenesis(genesisPath); err == nil {
6869
if err := genesis.Validate(); err != nil {
6970
return fmt.Errorf("existing genesis file is invalid: %w", err)
7071
}
7172
} else {
7273
return fmt.Errorf("error loading existing genesis file: %w", err)
7374
}
7475

75-
cmd.Printf("Genesis file already exists at %s, skipping creation.\n", homePath)
76+
cmd.Printf("Genesis file already exists at %s, skipping creation.\n", genesisPath)
7677
} else if err != nil {
7778
return fmt.Errorf("error initializing genesis file: %w", err)
7879
}

0 commit comments

Comments
 (0)