Skip to content

Commit 2c85e06

Browse files
authored
chore: add makefile for tools (#2743)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. NOTE: PR titles should follow semantic commits: https://www.conventionalcommits.org/en/v1.0.0/ --> ## Overview <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. Ex: Closes #<issue number> -->
1 parent 6c7c85c commit 2c85e06

File tree

5 files changed

+226
-2
lines changed

5 files changed

+226
-2
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ include ./scripts/test.mk
33
include ./scripts/proto.mk
44
include ./scripts/utils.mk
55
include ./scripts/run.mk
6+
include ./tools/tools.mk
67

78
# Sets the default make target to `build`.
89
# Requires GNU Make >= v3.81.

tools/blob-decoder/README.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Blob Decoder
2+
3+
A web-based tool for decoding and inspecting blob data from the ev-node Data Availability layer.
4+
5+
## Overview
6+
7+
The `blob-decoder` tool provides a web interface for decoding protobuf-encoded blobs used in ev-node. It can decode blocks and other data structures from both hex and base64 encoded inputs, making it useful for debugging and inspecting DA layer data.
8+
9+
## Installation
10+
11+
Install using `go install`:
12+
13+
```bash
14+
go install github.com/evstack/ev-node/tools/blob-decoder@main
15+
```
16+
17+
After installation, the `blob-decoder` binary will be available in your `$GOPATH/bin` directory.
18+
19+
## Usage
20+
21+
### Running the Server
22+
23+
Start the blob decoder server:
24+
25+
```bash
26+
# Run on default port 8090
27+
blob-decoder
28+
29+
# Run on custom port
30+
blob-decoder 8080
31+
```
32+
33+
The server will start and display:
34+
35+
```
36+
╔═══════════════════════════════════╗
37+
║ Evolve Blob Decoder ║
38+
║ by ev.xyz ║
39+
╚═══════════════════════════════════╝
40+
41+
🚀 Server running at: http://localhost:8090
42+
⚡ Using native Evolve protobuf decoding
43+
44+
Press Ctrl+C to stop the server
45+
```
46+
47+
### Web Interface
48+
49+
Open your browser and navigate to `http://localhost:8090` to access the web interface.
50+
51+
The interface allows you to:
52+
- Paste blob data in either hex or base64 format
53+
- Automatically detect and decode the blob type
54+
- View decoded block headers, transactions, and other metadata
55+
- Inspect raw hex data and blob size information
56+
57+
### API Endpoint
58+
59+
The decoder also provides a REST API endpoint:
60+
61+
```bash
62+
POST /api/decode
63+
Content-Type: application/json
64+
65+
{
66+
"data": "<hex-or-base64-encoded-blob>",
67+
"encoding": "hex" | "base64"
68+
}
69+
```
70+
71+
Response:
72+
```json
73+
{
74+
"type": "Block",
75+
"data": {
76+
// Decoded block or data structure
77+
},
78+
"rawHex": "<hex-representation>",
79+
"size": 1234,
80+
"timestamp": "2024-01-01T00:00:00Z"
81+
}
82+
```
83+
84+
## Features
85+
86+
- **Auto-detection**: Automatically detects blob type (blocks, commits, etc.)
87+
- **Multiple Encodings**: Supports both hex and base64 encoded inputs
88+
- **Protobuf Decoding**: Native decoding of ev-node protobuf structures
89+
- **Web Interface**: User-friendly web interface for easy blob inspection
90+
- **REST API**: Programmatic access for automation and integration
91+
- **CORS Support**: Can be accessed from other web applications
92+
93+
## Examples
94+
95+
```bash
96+
# Start server on default port
97+
blob-decoder
98+
99+
# Start server on port 3000
100+
blob-decoder 3000
101+
102+
# Use with curl to decode a hex-encoded blob
103+
curl -X POST http://localhost:8090/api/decode \
104+
-H "Content-Type: application/json" \
105+
-d '{"data": "0x...", "encoding": "hex"}'
106+
```
107+
108+
## Use Cases
109+
110+
- Debug DA layer blob submissions
111+
- Inspect block structure and content
112+
- Validate blob encoding and decoding
113+
- Troubleshoot sync issues related to blob data
114+
- Educational tool for understanding ev-node data structures

tools/cache-analyzer/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,19 @@ This small program is designed to analyze the cache of a sync node.
66
It is useful to debug when the sync node is downloading from DA but not advancing.
77
This usually means the `DA_START_HEIGHT` is too late. This tool allows clearly to identify the first height fetched from DA.
88

9-
## Usage
9+
## Installation
10+
11+
Install using `go install`:
1012

11-
```sh
13+
```bash
1214
go install github.com/evstack/ev-node/tools/cache-analyzer@main
15+
```
16+
17+
After installation, the `cache-analyzer` binary will be available in your `$GOPATH/bin` directory.
18+
19+
## Usage
20+
21+
```bash
1322
cache-analyzer -data-dir ~/.appd/data/ -summary
1423
cache-analyzer -data-dir ~/.appd/data/ -limit 50
1524
```

tools/da-debug/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ A professional debugging tool for querying and inspecting Data Availability (DA)
66

77
The `da-debug` tool provides a command-line interface to interact with DA layers for debugging purposes. It offers two main commands: `query` for inspecting specific DA heights and `search` for finding blobs containing specific blockchain heights.
88

9+
## Installation
10+
11+
Install using `go install`:
12+
13+
```bash
14+
go install github.com/evstack/ev-node/tools/da-debug@main
15+
```
16+
17+
After installation, the `da-debug` binary will be available in your `$GOPATH/bin` directory.
18+
919
## Commands
1020

1121
### Query Command

tools/tools.mk

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# tools.mk - Build configuration for ev-node tools
2+
3+
# Tool names
4+
TOOLS := da-debug blob-decoder cache-analyzer
5+
6+
# Build directory
7+
TOOLS_BUILD_DIR := $(CURDIR)/build
8+
9+
# Version information (inherited from main build.mk if available)
10+
VERSION ?= $(shell git describe --tags --abbrev=0 2>/dev/null || echo "dev")
11+
GITSHA ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
12+
LDFLAGS ?= \
13+
-X main.Version=$(VERSION) \
14+
-X main.GitSHA=$(GITSHA)
15+
16+
# Individual tool build targets
17+
## build-tool-da-debug: Build da-debug tool
18+
build-tool-da-debug:
19+
@echo "--> Building da-debug tool"
20+
@mkdir -p $(TOOLS_BUILD_DIR)
21+
@cd tools/da-debug && go build -ldflags "$(LDFLAGS)" -o $(TOOLS_BUILD_DIR)/da-debug .
22+
@echo "--> da-debug built: $(TOOLS_BUILD_DIR)/da-debug"
23+
.PHONY: build-tool-da-debug
24+
25+
## build-tool-blob-decoder: Build blob-decoder tool
26+
build-tool-blob-decoder:
27+
@echo "--> Building blob-decoder tool"
28+
@mkdir -p $(TOOLS_BUILD_DIR)
29+
@cd tools/blob-decoder && go build -ldflags "$(LDFLAGS)" -o $(TOOLS_BUILD_DIR)/blob-decoder .
30+
@echo "--> blob-decoder built: $(TOOLS_BUILD_DIR)/blob-decoder"
31+
.PHONY: build-tool-blob-decoder
32+
33+
## build-tool-cache-analyzer: Build cache-analyzer tool
34+
build-tool-cache-analyzer:
35+
@echo "--> Building cache-analyzer tool"
36+
@mkdir -p $(TOOLS_BUILD_DIR)
37+
@cd tools/cache-analyzer && go build -ldflags "$(LDFLAGS)" -o $(TOOLS_BUILD_DIR)/cache-analyzer .
38+
@echo "--> cache-analyzer built: $(TOOLS_BUILD_DIR)/cache-analyzer"
39+
.PHONY: build-tool-cache-analyzer
40+
41+
# Build all tools
42+
## build-tools: Build all tools
43+
build-tools: $(addprefix build-tool-, $(TOOLS))
44+
@echo "--> All tools built successfully!"
45+
.PHONY: build-tools
46+
47+
# Install individual tools
48+
## install-tool-da-debug: Install da-debug tool to Go bin
49+
install-tool-da-debug:
50+
@echo "--> Installing da-debug tool"
51+
@cd tools/da-debug && go install -ldflags "$(LDFLAGS)" .
52+
@echo "--> da-debug installed to Go bin"
53+
.PHONY: install-tool-da-debug
54+
55+
## install-tool-blob-decoder: Install blob-decoder tool to Go bin
56+
install-tool-blob-decoder:
57+
@echo "--> Installing blob-decoder tool"
58+
@cd tools/blob-decoder && go install -ldflags "$(LDFLAGS)" .
59+
@echo "--> blob-decoder installed to Go bin"
60+
.PHONY: install-tool-blob-decoder
61+
62+
## install-tool-cache-analyzer: Install cache-analyzer tool to Go bin
63+
install-tool-cache-analyzer:
64+
@echo "--> Installing cache-analyzer tool"
65+
@cd tools/cache-analyzer && go install -ldflags "$(LDFLAGS)" .
66+
@echo "--> cache-analyzer installed to Go bin"
67+
.PHONY: install-tool-cache-analyzer
68+
69+
# Install all tools
70+
## install-tools: Install all tools to Go bin
71+
install-tools: $(addprefix install-tool-, $(TOOLS))
72+
@echo "--> All tools installed successfully!"
73+
.PHONY: install-tools
74+
75+
# Clean built tools
76+
## clean-tools: Remove built tool binaries
77+
clean-tools:
78+
@echo "--> Cleaning built tools"
79+
@rm -f $(addprefix $(TOOLS_BUILD_DIR)/, $(TOOLS))
80+
@echo "--> Tools cleaned"
81+
.PHONY: clean-tools
82+
83+
# List available tools
84+
## list-tools: List all available tools
85+
list-tools:
86+
@echo "Available tools:"
87+
@for tool in $(TOOLS); do \
88+
echo " - $$tool"; \
89+
done
90+
.PHONY: list-tools

0 commit comments

Comments
 (0)