Skip to content

Commit 7bef5ae

Browse files
Merge branch 'main' into marko/2250
2 parents 1e6f42f + a89ee79 commit 7bef5ae

File tree

24 files changed

+3162
-119
lines changed

24 files changed

+3162
-119
lines changed

CLAUDE.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,28 @@ Rollkit is a sovereign rollup framework built in Go that allows developers to bu
99
## Build and Development Commands
1010

1111
### Building
12+
1213
- `make build` - Builds the Testapp CLI to `./build/testapp`
1314
- `make install` - Installs Testapp CLI to your Go bin directory
1415
- `make build-all` - Builds all Rollkit binaries
1516
- `make docker-build` - Builds Docker image tagged as `rollkit:local-dev`
1617

1718
### Testing
19+
1820
- `make test` - Runs unit tests for all go.mod files
1921
- `make test-integration` - Runs integration tests (15m timeout)
2022
- `make test-e2e` - Runs end-to-end tests (requires building binaries first)
2123
- `make test-cover` - Generates code coverage report
2224
- `make test-all` - Runs all tests including Docker E2E tests
2325

2426
### Linting and Code Quality
27+
2528
- `make lint` - Runs all linters (golangci-lint, markdownlint, hadolint, yamllint, goreleaser check, actionlint)
2629
- `make lint-fix` - Auto-fixes linting issues where possible
2730
- `make vet` - Runs go vet
2831

2932
### Development Utilities
33+
3034
- `make deps` - Downloads dependencies and runs go mod tidy for all modules
3135
- `make proto-gen` - Generates protobuf files (requires Docker)
3236
- `make mock-gen` - Generates mocks using mockery
@@ -35,37 +39,44 @@ Rollkit is a sovereign rollup framework built in Go that allows developers to bu
3539
## Code Architecture
3640

3741
### Core Package Structure
42+
3843
The project uses a zero-dependency core package pattern:
44+
3945
- **core/** - Contains only interfaces and types, no external dependencies
4046
- **block/** - Block management, creation, validation, and synchronization
4147
- **p2p/** - Networking layer built on libp2p
4248
- **sequencing/** - Modular sequencer implementations
4349
- **testapp/** - Reference implementation for testing
4450

4551
### Key Interfaces
52+
4653
- **Executor** (core/executor.go) - Handles state transitions
4754
- **Sequencer** (core/sequencer.go) - Orders transactions
4855
- **DA** (core/da.go) - Data availability layer abstraction
4956

5057
### Modular Design
58+
5159
- Each component has an interface in the core package
5260
- Implementations are in separate packages
5361
- Components are wired together via dependency injection
5462
- Multiple go.mod files enable modular builds
5563

5664
### P2P Architecture
65+
5766
- Built on libp2p with GossipSub and Kademlia DHT
5867
- Nodes advertise capabilities (full/light, DA layers)
5968
- Automatic peer discovery with rendezvous points
6069

6170
## Testing Patterns
6271

6372
### Test Organization
73+
6474
- Unit tests: `*_test.go` files alongside code
6575
- Integration tests: `test/integration/`
6676
- E2E tests: `test/e2e/`
6777

6878
### Running Specific Tests
79+
6980
```bash
7081
# Run a single test
7182
go test -run TestSpecificFunction ./package/...
@@ -78,44 +89,51 @@ go test -race ./package/...
7889
```
7990

8091
### Mock Generation
92+
8193
- Mocks are defined in `.mockery.yaml`
8294
- Generate with `make mock-gen`
8395
- Mocks are placed in `mocks/` directories
8496

8597
## Code Style Guidelines
8698

8799
### Go Conventions
100+
88101
- Follow standard Go formatting (enforced by golangci-lint)
89102
- Use meaningful variable names
90103
- Keep functions small and focused
91104
- Document exported types and functions
92105
- Use context.Context for cancellation
93106

94107
### Error Handling
108+
95109
- Wrap errors with context using `fmt.Errorf`
96110
- Return errors early
97111
- Use custom error types for domain-specific errors
98112

99113
### Logging
114+
100115
- Use structured logging (look for existing patterns)
101116
- Include relevant context in log messages
102117
- Use appropriate log levels
103118

104119
## Common Development Tasks
105120

106121
### Adding a New DA Layer
122+
107123
1. Implement the `DA` interface from `core/da.go`
108124
2. Add configuration in the appropriate config package
109125
3. Wire it up in the initialization code
110126
4. Add tests following existing patterns
111127

112128
### Modifying Protobuf Definitions
129+
113130
1. Edit `.proto` files in `types/pb/`
114131
2. Run `make proto-gen` to regenerate Go code
115132
3. Update any affected code
116133
4. Run tests to ensure compatibility
117134

118135
### Adding New Tests
136+
119137
1. Place unit tests next to the code being tested
120138
2. Use table-driven tests where appropriate
121139
3. Mock external dependencies using mockery
@@ -150,4 +168,4 @@ go test -race ./package/...
150168
- All tests must pass (`make test-all`)
151169
- Follow the existing code patterns
152170
- Update tests when changing functionality
153-
- Keep commits focused and atomic
171+
- Keep commits focused and atomic

apps/evm/based/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ require (
178178
github.com/libp2p/go-libp2p-asn-util v0.4.1 // indirect
179179
github.com/libp2p/go-libp2p-kad-dht v0.29.1 // indirect
180180
github.com/libp2p/go-libp2p-kbucket v0.6.5 // indirect
181-
github.com/libp2p/go-libp2p-pubsub v0.14.0 // indirect
181+
github.com/libp2p/go-libp2p-pubsub v0.14.1 // indirect
182182
github.com/libp2p/go-libp2p-record v0.3.1 // indirect
183183
github.com/libp2p/go-libp2p-routing-helpers v0.7.4 // indirect
184184
github.com/libp2p/go-msgio v0.3.0 // indirect

apps/evm/based/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,8 @@ github.com/libp2p/go-libp2p-kad-dht v0.29.1 h1:RyD1RnnkXOh1gwBCrMQ6ZVfTJECY5yDOY
551551
github.com/libp2p/go-libp2p-kad-dht v0.29.1/go.mod h1:tZEFTKWCsY0xngypKyAIwNDNZOBiikSUIgd/BjTF5Ms=
552552
github.com/libp2p/go-libp2p-kbucket v0.6.5 h1:Fsl1YvZcMwqrR4DYrTO02yo9PGYs2HBQIT3lGXFMTxg=
553553
github.com/libp2p/go-libp2p-kbucket v0.6.5/go.mod h1:U6WOd0BvnSp03IQSrjgM54tg7zh1UUNsXLJqAQzClTA=
554-
github.com/libp2p/go-libp2p-pubsub v0.14.0 h1:+YxFHOdrk45szLb8G/fVsWwg4pdx0nVUXoZdLvYw2VY=
555-
github.com/libp2p/go-libp2p-pubsub v0.14.0/go.mod h1:MKPU5vMI8RRFyTP0HfdsF9cLmL1nHAeJm44AxJGJx44=
554+
github.com/libp2p/go-libp2p-pubsub v0.14.1 h1:XK/rPKZKhPvRrtsjvfwrOZPnQQbGLmaEg7u6qnJfn8U=
555+
github.com/libp2p/go-libp2p-pubsub v0.14.1/go.mod h1:MKPU5vMI8RRFyTP0HfdsF9cLmL1nHAeJm44AxJGJx44=
556556
github.com/libp2p/go-libp2p-record v0.3.1 h1:cly48Xi5GjNw5Wq+7gmjfBiG9HCzQVkiZOUZ8kUl+Fg=
557557
github.com/libp2p/go-libp2p-record v0.3.1/go.mod h1:T8itUkLcWQLCYMqtX7Th6r7SexyUJpIyPgks757td/E=
558558
github.com/libp2p/go-libp2p-routing-helpers v0.7.4 h1:6LqS1Bzn5CfDJ4tzvP9uwh42IB7TJLNFJA6dEeGBv84=

apps/evm/single/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Note: Replace `<path_to>` with the actual path to the rollkit repository. If you
4646
4747
The sequencer can be configured using various command-line flags. The most important ones are:
4848
49-
- `--rollkit.node.aggregator`: Set to true to run in aggregator mode
49+
- `--rollkit.node.aggregator`: Set to true to run in sequencer mode
5050
- `--rollkit.signer.passphrase`: Passphrase for the signer
5151
- `--evm.jwt-secret`: JWT secret for EVM communication
5252
- `--evm.genesis-hash`: Genesis hash of the EVM chain
@@ -85,7 +85,7 @@ The sequencer can be configured using various command-line flags. The most impor
8585
```bash
8686
./evm-single start \
8787
--home ~/.evm-single-full-node \
88-
--evm.jwt-secret $(cat ../../../execution/evm/docker/jwttoken/jwt.hex) \
88+
--evm.jwt-secret $(cat <path_to>/execution/evm/docker/jwttoken/jwt.hex) \
8989
--evm.genesis-hash 0x2b8bbb1ea1e04f9c9809b4b278a8687806edc061a356c7dbc491930d8e922503 \
9090
--rollkit.rpc.address=127.0.0.1:46657 \
9191
--rollkit.p2p.listen_address=/ip4/127.0.0.1/tcp/7677 \

apps/evm/single/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ services:
5252
- rollkit-network
5353

5454
rollkit-evm-single:
55-
image: ghcr.io/rollkit/rollkit-evm-single:v0.1.6
55+
image: ghcr.io/rollkit/rollkit-evm-single:pr-2394
5656
depends_on:
5757
rollkit-reth:
5858
condition: service_started
5959
local-da:
6060
condition: service_started
6161
volumes:
62-
- evm-single-data:/data
62+
- evm-single-data:/root/.evm-single/
6363
entrypoint: /usr/bin/entrypoint.sh
6464
environment:
6565
- EVM_ENGINE_URL=http://rollkit-reth:8551

apps/evm/single/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ require (
179179
github.com/libp2p/go-libp2p-asn-util v0.4.1 // indirect
180180
github.com/libp2p/go-libp2p-kad-dht v0.29.1 // indirect
181181
github.com/libp2p/go-libp2p-kbucket v0.6.5 // indirect
182-
github.com/libp2p/go-libp2p-pubsub v0.14.0 // indirect
182+
github.com/libp2p/go-libp2p-pubsub v0.14.1 // indirect
183183
github.com/libp2p/go-libp2p-record v0.3.1 // indirect
184184
github.com/libp2p/go-libp2p-routing-helpers v0.7.4 // indirect
185185
github.com/libp2p/go-msgio v0.3.0 // indirect

apps/evm/single/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,8 @@ github.com/libp2p/go-libp2p-kad-dht v0.29.1 h1:RyD1RnnkXOh1gwBCrMQ6ZVfTJECY5yDOY
551551
github.com/libp2p/go-libp2p-kad-dht v0.29.1/go.mod h1:tZEFTKWCsY0xngypKyAIwNDNZOBiikSUIgd/BjTF5Ms=
552552
github.com/libp2p/go-libp2p-kbucket v0.6.5 h1:Fsl1YvZcMwqrR4DYrTO02yo9PGYs2HBQIT3lGXFMTxg=
553553
github.com/libp2p/go-libp2p-kbucket v0.6.5/go.mod h1:U6WOd0BvnSp03IQSrjgM54tg7zh1UUNsXLJqAQzClTA=
554-
github.com/libp2p/go-libp2p-pubsub v0.14.0 h1:+YxFHOdrk45szLb8G/fVsWwg4pdx0nVUXoZdLvYw2VY=
555-
github.com/libp2p/go-libp2p-pubsub v0.14.0/go.mod h1:MKPU5vMI8RRFyTP0HfdsF9cLmL1nHAeJm44AxJGJx44=
554+
github.com/libp2p/go-libp2p-pubsub v0.14.1 h1:XK/rPKZKhPvRrtsjvfwrOZPnQQbGLmaEg7u6qnJfn8U=
555+
github.com/libp2p/go-libp2p-pubsub v0.14.1/go.mod h1:MKPU5vMI8RRFyTP0HfdsF9cLmL1nHAeJm44AxJGJx44=
556556
github.com/libp2p/go-libp2p-record v0.3.1 h1:cly48Xi5GjNw5Wq+7gmjfBiG9HCzQVkiZOUZ8kUl+Fg=
557557
github.com/libp2p/go-libp2p-record v0.3.1/go.mod h1:T8itUkLcWQLCYMqtX7Th6r7SexyUJpIyPgks757td/E=
558558
github.com/libp2p/go-libp2p-routing-helpers v0.7.4 h1:6LqS1Bzn5CfDJ4tzvP9uwh42IB7TJLNFJA6dEeGBv84=

apps/testapp/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ require (
8585
github.com/libp2p/go-libp2p-asn-util v0.4.1 // indirect
8686
github.com/libp2p/go-libp2p-kad-dht v0.29.1 // indirect
8787
github.com/libp2p/go-libp2p-kbucket v0.6.5 // indirect
88-
github.com/libp2p/go-libp2p-pubsub v0.14.0 // indirect
88+
github.com/libp2p/go-libp2p-pubsub v0.14.1 // indirect
8989
github.com/libp2p/go-libp2p-record v0.3.1 // indirect
9090
github.com/libp2p/go-libp2p-routing-helpers v0.7.4 // indirect
9191
github.com/libp2p/go-msgio v0.3.0 // indirect

apps/testapp/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ github.com/libp2p/go-libp2p-kad-dht v0.29.1 h1:RyD1RnnkXOh1gwBCrMQ6ZVfTJECY5yDOY
254254
github.com/libp2p/go-libp2p-kad-dht v0.29.1/go.mod h1:tZEFTKWCsY0xngypKyAIwNDNZOBiikSUIgd/BjTF5Ms=
255255
github.com/libp2p/go-libp2p-kbucket v0.6.5 h1:Fsl1YvZcMwqrR4DYrTO02yo9PGYs2HBQIT3lGXFMTxg=
256256
github.com/libp2p/go-libp2p-kbucket v0.6.5/go.mod h1:U6WOd0BvnSp03IQSrjgM54tg7zh1UUNsXLJqAQzClTA=
257-
github.com/libp2p/go-libp2p-pubsub v0.14.0 h1:+YxFHOdrk45szLb8G/fVsWwg4pdx0nVUXoZdLvYw2VY=
258-
github.com/libp2p/go-libp2p-pubsub v0.14.0/go.mod h1:MKPU5vMI8RRFyTP0HfdsF9cLmL1nHAeJm44AxJGJx44=
257+
github.com/libp2p/go-libp2p-pubsub v0.14.1 h1:XK/rPKZKhPvRrtsjvfwrOZPnQQbGLmaEg7u6qnJfn8U=
258+
github.com/libp2p/go-libp2p-pubsub v0.14.1/go.mod h1:MKPU5vMI8RRFyTP0HfdsF9cLmL1nHAeJm44AxJGJx44=
259259
github.com/libp2p/go-libp2p-record v0.3.1 h1:cly48Xi5GjNw5Wq+7gmjfBiG9HCzQVkiZOUZ8kUl+Fg=
260260
github.com/libp2p/go-libp2p-record v0.3.1/go.mod h1:T8itUkLcWQLCYMqtX7Th6r7SexyUJpIyPgks757td/E=
261261
github.com/libp2p/go-libp2p-routing-helpers v0.7.4 h1:6LqS1Bzn5CfDJ4tzvP9uwh42IB7TJLNFJA6dEeGBv84=

execution/evm/execution.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,21 @@ func (c *EngineClient) ExecuteTxs(ctx context.Context, txs [][]byte, blockHeight
181181
txsPayload[i] = "0x" + hex.EncodeToString(tx)
182182
}
183183

184-
_, _, prevGasLimit, _, err := c.getBlockInfo(ctx, blockHeight-1)
184+
prevBlockHash, _, prevGasLimit, prevTimestamp, err := c.getBlockInfo(ctx, blockHeight-1)
185185
if err != nil {
186186
return nil, 0, fmt.Errorf("failed to get block info: %w", err)
187187
}
188188

189+
ts := uint64(timestamp.Unix())
190+
if ts <= prevTimestamp {
191+
ts = prevTimestamp + 1 // Subsequent blocks must have a higher timestamp.
192+
}
193+
189194
c.mu.Lock()
190195
args := engine.ForkchoiceStateV1{
191-
HeadBlockHash: c.currentHeadBlockHash,
192-
SafeBlockHash: c.currentSafeBlockHash,
193-
FinalizedBlockHash: c.currentFinalizedBlockHash,
196+
HeadBlockHash: prevBlockHash,
197+
SafeBlockHash: prevBlockHash,
198+
FinalizedBlockHash: prevBlockHash,
194199
}
195200
c.mu.Unlock()
196201

@@ -200,7 +205,7 @@ func (c *EngineClient) ExecuteTxs(ctx context.Context, txs [][]byte, blockHeight
200205
// Create rollkit-compatible payload attributes with flattened structure
201206
rollkitPayloadAttrs := map[string]interface{}{
202207
// Standard Ethereum payload attributes (flattened) - using camelCase as expected by JSON
203-
"timestamp": uint64(timestamp.Unix()),
208+
"timestamp": ts,
204209
"prevRandao": c.derivePrevRandao(blockHeight),
205210
"suggestedFeeRecipient": c.feeRecipient,
206211
"withdrawals": []*types.Withdrawal{},

0 commit comments

Comments
 (0)