Skip to content

Commit 232b768

Browse files
committed
chore: update README and fix linting errors
1 parent 1e90f90 commit 232b768

File tree

4 files changed

+59
-170
lines changed

4 files changed

+59
-170
lines changed

Makefile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.PHONY: help lint lint-fix test build clean install
2+
3+
# default target when just running 'make'
4+
help:
5+
@echo "Available targets:"
6+
@echo " make lint - run linters on the codebase"
7+
@echo " make lint-fix - run linters and auto-fix issues where possible"
8+
@echo " make test - run all tests"
9+
@echo " make build - build the da-monitor binary"
10+
@echo " make install - install da-monitor to GOPATH/bin"
11+
@echo " make clean - remove build artifacts"
12+
13+
# run golangci-lint on the codebase
14+
lint:
15+
@echo "Running golangci-lint..."
16+
golangci-lint run ./...
17+
18+
# run golangci-lint with auto-fix
19+
lint-fix:
20+
@echo "Running golangci-lint with auto-fix..."
21+
golangci-lint run --fix ./...
22+
23+
# run all tests
24+
test:
25+
@echo "Running tests..."
26+
go test -v ./...
27+
28+
# build the binary
29+
build:
30+
@echo "Building da-monitor..."
31+
go build -o da-monitor
32+
33+
# install to GOPATH/bin
34+
install:
35+
@echo "Installing da-monitor..."
36+
go install
37+
38+
# clean build artifacts
39+
clean:
40+
@echo "Cleaning build artifacts..."
41+
rm -f da-monitor

README.md

Lines changed: 13 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,17 @@ The monitor command streams EVM block headers and verifies DA submission on Cele
3232

3333
```bash
3434
./da-monitor monitor \
35-
--header-namespace "0x0000000000000000000000000000000000000086c8d75ed85ef620ef51" \
36-
--data-namespace "0x00000000000000000000000000000000000000893f79d6e2c81a4d08c4"
35+
--header-namespace collect_testnet_header \
36+
--data-namespace collect_testnet_data
3737
```
3838

39-
### Verify a Specific Block
40-
41-
To verify a single block height instead of streaming:
42-
43-
```bash
44-
./da-monitor monitor \
45-
--header-namespace "0x0000000000000000000000000000000000000086c8d75ed85ef620ef51" \
46-
--data-namespace "0x00000000000000000000000000000000000000893f79d6e2c81a4d08c4" \
47-
--block-height 100
48-
```
4939

5040
### Enable Prometheus Metrics
5141

5242
```bash
5343
./da-monitor monitor \
54-
--header-namespace "0x0000000000000000000000000000000000000086c8d75ed85ef620ef51" \
55-
--data-namespace "0x00000000000000000000000000000000000000893f79d6e2c81a4d08c4" \
44+
--header-namespace collect_testnet_header \
45+
--data-namespace collect_testnet_data \
5646
--enable-metrics \
5747
--port 2112
5848
```
@@ -64,8 +54,8 @@ Metrics will be available at `http://localhost:2112/metrics`
6454
### Command-Line Flags
6555

6656
**Required:**
67-
- `--header-namespace`: Header namespace (29-byte hex string)
68-
- `--data-namespace`: Data namespace (29-byte hex string)
57+
- `--header-namespace`: Header namespace (e.g. collect_testnet_header )
58+
- `--data-namespace`: Data namespace (e.g. collect_testnet_data )
6959

7060
**Optional:**
7161
- `--evnode-addr`: ev-node Connect RPC address (default: `http://localhost:7331`)
@@ -74,7 +64,7 @@ Metrics will be available at `http://localhost:2112/metrics`
7464
- `--celestia-token`: Celestia authentication token (optional)
7565
- `--block-height`: Specific block height to verify (0 = stream mode, default: 0)
7666
- `--duration`: Duration in seconds to stream (0 = infinite, default: 30)
77-
- `--chainID`: Chain identifier for metrics labels (default: "testnet")
67+
- `--chain-id`: Chain identifier for metrics labels (default: "testnet")
7868
- `--enable-metrics`: Enable Prometheus metrics HTTP server (default: false)
7969
- `--port`: HTTP server port for metrics (default: 2112)
8070
- `--verbose`: Enable verbose logging (default: false)
@@ -83,164 +73,23 @@ Metrics will be available at `http://localhost:2112/metrics`
8373

8474
```bash
8575
./da-monitor monitor \
86-
--header-namespace "0x0000000000000000000000000000000000000086c8d75ed85ef620ef51" \
87-
--data-namespace "0x00000000000000000000000000000000000000893f79d6e2c81a4d08c4" \
76+
--header-namespace collect_testnet_header \
77+
--data-namespace collect_testnet_data \
8878
--evnode-addr "http://my-evnode:7331" \
89-
--evm-ws-url "ws://my-evm:8546" \
90-
--celestia-url "http://my-celestia:26658" \
91-
--duration 0 \
92-
--verbose
79+
--evm-ws-url "ws://my-evnode:8546" \
80+
--celestia-url "http://my-celestia:26658"
9381
```
9482

95-
## How It Works
96-
97-
### Block Verification Flow
98-
99-
For each new block header:
100-
101-
1. **Header Reception**: Subscribes to EVM block headers via WebSocket
102-
2. **DA Query**: Queries ev-node Store API for DA heights where block was published
103-
3. **Verification**: Verifies header and data blobs on Celestia at those DA heights
104-
4. **Retry Logic**: Automatically retries with exponential backoff if DA submission is pending
105-
5. **Metrics**: Updates Prometheus metrics tracking verification status
106-
107-
### Retry Strategy
108-
109-
The monitor uses intelligent retry logic for pending DA submissions:
110-
- **Immediate**: First attempt right away
111-
- **20s**: Second attempt after 20 seconds
112-
- **40s**: Third attempt after 40 seconds
113-
- **60s**: Fourth attempt after 60 seconds
114-
- **90s**: Fifth attempt after 90 seconds
115-
- **120s**: Sixth and final attempt after 120 seconds
116-
117-
After max retries, unverified blocks are recorded in Prometheus metrics.
118-
11983
## Prometheus Metrics
12084

12185
When metrics are enabled, the following metrics are exposed:
12286

12387
### `da_monitor_unsubmitted_block_range_start`
12488
- **Type**: Gauge
125-
- **Labels**: `chain`, `blob_type`, `range_id`
89+
- **Labels**: `chain_id`, `blob_type`, `range_id`
12690
- **Description**: Start block height of unverified block ranges
12791

12892
### `da_monitor_unsubmitted_block_range_end`
12993
- **Type**: Gauge
130-
- **Labels**: `chain`, `blob_type`, `range_id`
94+
- **Labels**: `chain_id`, `blob_type`, `range_id`
13195
- **Description**: End block height of unverified block ranges
132-
133-
### Example Metrics
134-
135-
```
136-
# HELP da_monitor_unsubmitted_block_range_start start of unsubmitted block range
137-
# TYPE da_monitor_unsubmitted_block_range_start gauge
138-
da_monitor_unsubmitted_block_range_start{blob_type="header",chain="testnet",range_id="100-105"} 100
139-
140-
# HELP da_monitor_unsubmitted_block_range_end end of unsubmitted block range
141-
# TYPE da_monitor_unsubmitted_block_range_end gauge
142-
da_monitor_unsubmitted_block_range_end{blob_type="header",chain="testnet",range_id="100-105"} 105
143-
```
144-
145-
## Example Output
146-
147-
### Streaming Mode
148-
149-
```
150-
2024-01-15T10:30:45Z INF processing block block_height=150 hash=0x1234... has_transactions=true gas_used=21000
151-
2024-01-15T10:30:45Z INF header blob verified on Celestia block_height=150 namespace=header da_height=8423260 duration=45ms
152-
2024-01-15T10:30:45Z INF data blob verified on Celestia block_height=150 namespace=data da_height=8423260 duration=67ms
153-
```
154-
155-
### One-Shot Mode
156-
157-
```
158-
2024-01-15T10:30:45Z INF using header namespace header_namespace=0000000000000000000000000000000000000086c8d75ed85ef620ef51
159-
2024-01-15T10:30:45Z INF using data namespace data_namespace=00000000000000000000000000000000000000893f79d6e2c81a4d08c4
160-
2024-01-15T10:30:45Z INF processing block block_height=100 hash=0x5678... has_transactions=true gas_used=42000
161-
2024-01-15T10:30:45Z INF retrieved block data from ev-node header_da_height=8423100 data_da_height=8423100
162-
2024-01-15T10:30:45Z INF ✓ header blob VERIFIED on Celestia - commitment matches da_height=8423100
163-
2024-01-15T10:30:45Z INF data blob VERIFIED on Celestia da_height=8423100
164-
```
165-
166-
## Development
167-
168-
### Running Tests
169-
170-
```bash
171-
# Run all tests
172-
go test ./...
173-
174-
# Run tests with verbose output
175-
go test -v ./...
176-
177-
# Run tests with coverage
178-
go test -cover ./...
179-
```
180-
181-
### Building Docker Image
182-
183-
```bash
184-
docker build -t da-monitor .
185-
```
186-
187-
## Architecture
188-
189-
### Components
190-
191-
- **cmd/monitor.go**: CLI entry point and orchestration
192-
- **cmd/verifier.go**: Block verification and retry logic
193-
- **internal/celestia**: Celestia DA client
194-
- **internal/evm**: EVM client for header streaming
195-
- **internal/evnode**: ev-node Store API client
196-
- **internal/metrics**: Prometheus metrics tracking
197-
198-
### Key Types
199-
200-
```go
201-
// BlockVerifier handles verification of blocks against Celestia DA
202-
type BlockVerifier struct {
203-
evnodeClient *evnode.Client
204-
celestiaClient *celestia.Client
205-
evmClient *evm.Client
206-
headerNS []byte
207-
dataNS []byte
208-
metrics *metrics.Metrics
209-
chainID string
210-
}
211-
```
212-
213-
## Troubleshooting
214-
215-
### Connection Issues
216-
217-
If you see connection errors, verify your endpoints are correct:
218-
219-
```bash
220-
# Test ev-node connectivity
221-
curl http://localhost:7331
222-
223-
# Test Celestia connectivity
224-
curl http://localhost:26658
225-
```
226-
227-
### Missing Blobs
228-
229-
If blobs are not found on Celestia:
230-
- Check that the namespaces are correct
231-
- Verify DA submission is enabled on your ev-node
232-
- Check ev-node logs for DA submission errors
233-
- Wait for retry logic to complete (up to 5 minutes)
234-
235-
### Prometheus Metrics Not Available
236-
237-
Ensure you've enabled metrics:
238-
```bash
239-
./da-monitor monitor ... --enable-metrics --port 2112
240-
```
241-
242-
Then check: `http://localhost:2112/metrics`
243-
244-
## License
245-
246-
See LICENSE file for details.

cmd/monitor.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const (
3131
flagVerbose = "verbose"
3232
flagBlockHeight = "block-height"
3333
flagPort = "port"
34-
flagChain = "chainID"
34+
flagChain = "chain-id"
3535
flagEnableMetrics = "enable-metrics"
3636

3737
metricsPath = "/metrics"
@@ -73,7 +73,7 @@ func NewMonitorCmd() *cobra.Command {
7373
cmd.Flags().StringVar(&flags.headerNS, flagHeaderNS, "", "Header namespace (29-byte hex, required)")
7474
cmd.Flags().StringVar(&flags.dataNS, flagDataNS, "", "Data namespace (29-byte hex, required)")
7575
cmd.Flags().Int64Var(&flags.blockHeight, flagBlockHeight, 0, "Specific block height to verify (0 = stream mode)")
76-
cmd.Flags().IntVar(&flags.duration, flagDuration, 30, "Duration in seconds to stream (0 = infinite, ignored if block-height is set)")
76+
cmd.Flags().IntVar(&flags.duration, flagDuration, 0, "Duration in seconds to stream (0 = infinite, ignored if block-height is set)")
7777
cmd.Flags().BoolVar(&flags.verbose, flagVerbose, false, "Enable verbose logging")
7878
cmd.Flags().BoolVar(&flags.enableMetrics, flagEnableMetrics, false, "Enable Prometheus metrics HTTP server")
7979
cmd.Flags().IntVar(&flags.port, flagPort, 2112, "HTTP server port for metrics (only used if --enable-metrics is set)")
@@ -159,15 +159,14 @@ func monitorAndVerifyDataAndHeaders(cmd *cobra.Command, args []string) error {
159159
defer func() {
160160
cfg.EvmClient.Close()
161161
cfg.CelestiaClient.Close()
162-
//cfg.EVNodeClient.Close()
163162
}()
164163

165164
// start HTTP server for metrics if enabled
166165
if flags.enableMetrics {
167166
http.Handle(metricsPath, promhttp.Handler())
168167
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
169168
w.WriteHeader(http.StatusOK)
170-
w.Write([]byte("OK"))
169+
_, _ = w.Write([]byte("OK"))
171170
})
172171

173172
serverAddr := fmt.Sprintf(":%d", flags.port)

internal/metrics/metrics.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ func NewWithRegistry(namespace string, registerer prometheus.Registerer) *Metric
3939
Name: "unsubmitted_block_range_start",
4040
Help: "start of unsubmitted block range",
4141
},
42-
[]string{"chain", "blob_type", "range_id"},
42+
[]string{"chain_id", "blob_type", "range_id"},
4343
),
4444
UnsubmittedRangeEnd: factory.NewGaugeVec(
4545
prometheus.GaugeOpts{
4646
Namespace: namespace,
4747
Name: "unsubmitted_block_range_end",
4848
Help: "end of unsubmitted block range",
4949
},
50-
[]string{"chain", "blob_type", "range_id"},
50+
[]string{"chain_id", "blob_type", "range_id"},
5151
),
5252
ranges: make(map[string][]*blockRange),
5353
}

0 commit comments

Comments
 (0)