Skip to content

Commit 0786bfa

Browse files
committed
Merge branch 'dev'
2 parents 9c6620a + 023bb95 commit 0786bfa

Some content is hidden

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

72 files changed

+2571
-1591
lines changed

.github/workflows/docker-image.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
tags: setavenger/blindbit-oracle:dev-${{ steps.commit.outputs.short }} # Use the short SHA to distinguish dev images
4444

4545
# Build and push the Docker image (tags)
46-
- name: Build and push Docker image
46+
- name: Build and push Docker image (tags)
4747
if: startsWith(github.ref, 'refs/tags/')
4848
uses: docker/build-push-action@v4
4949
with:
@@ -61,5 +61,3 @@ jobs:
6161
push: true
6262
build-args: --progress=plain
6363
tags: setavenger/blindbit-oracle:${{ github.ref_name }}
64-
65-

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ WORKDIR /app
66

77

88
RUN go mod download
9-
RUN env CGO_ENABLED=0 go build -o main ./src
9+
RUN env CGO_ENABLED=0 go build -o main ./cmd/blindbit-oracle
1010

1111
FROM busybox
1212
COPY --from=buildstage /app/main .

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Benchmark targets
2+
.PHONY: benchmark
3+
benchmark: build-benchmark
4+
@echo "Running benchmark..."
5+
./bin/benchmark $(ARGS)
6+
7+
.PHONY: benchmark-v1
8+
benchmark-v1: build-benchmark
9+
@echo "Running v1 HTTP benchmark only..."
10+
./bin/benchmark -v1 -v2=false $(ARGS)
11+
12+
.PHONY: benchmark-v2
13+
benchmark-v2: build-benchmark
14+
@echo "Running v2 gRPC benchmark only..."
15+
./bin/benchmark -v1=false -v2 $(ARGS)
16+
17+
.PHONY: compare
18+
compare: build-benchmark
19+
@echo "Comparing v1 and v2 data..."
20+
./bin/benchmark -compare $(ARGS)
21+
22+
.PHONY: build-benchmark
23+
build-benchmark:
24+
@echo "Building benchmark tool..."
25+
@mkdir -p bin
26+
go build -o bin/benchmark ./cmd/benchmark
27+
28+
# Example usage:
29+
# make benchmark ARGS="-startheight=100 -endheight=200"
30+
# make benchmark-v1 ARGS="-startheight=100 -endheight=200"
31+
# make benchmark-v2 ARGS="-startheight=100 -endheight=200"
32+
# make compare ARGS="-startheight=100 -endheight=200"

NOTES.md

Lines changed: 0 additions & 84 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ The installation process is still very manual. Will be improved based on feedbac
1313

1414
- Endpoints were expanded and have a slightly different syntax now [see endpoints](#endpoints)
1515

16-
### Requirements
16+
## Requirements
1717

1818
- RPC access to a bitcoin full node
1919
- unpruned because we need the prevouts for every transaction in the block with a taproot output
2020
- Note: Indexing will take longer if the rpc calls take longer;
2121
You might also want to allow more rpc workers on your node to speed things up.
2222
- Processing a block takes ~100ms-300ms
2323
- Disk space (~10Gb)
24-
- go 1.20 installed
24+
- go 1.21 installed
2525

2626
### Build
2727

@@ -45,10 +45,6 @@ You still have to set up a config file in any case as the rpc users can't and **
4545

4646
You can now also decide which index you want to run. This setting can be set in the config file (blindbit.toml).
4747

48-
## Known Errors
49-
50-
No known issues.
51-
5248
## Todos
5349

5450
- [ ] Add flags to control setup
@@ -88,6 +84,7 @@ No known issues.
8884
```text
8985
GET("/info") // returns basic information about the oracle instance
9086
GET("/block-height") // returns the height of the indexing server
87+
GET("/block-hash/:blockheight") // returns the block-hash for a certain block-height
9188
GET("/tweaks/:blockheight?dustLimit=<sat_amount>") // returns tweak data (cut-through); optional parameter dustLimit can be omitted; filtering happens per request, so virtually any amount can be specified
9289
GET("/tweak-index/:blockheight?dustLimit=<sat_amount>") // returns the full tweak index (no cut-through); optional parameter dustLimit can be omitted; filtering happens per request, so virtually any amount can be specified
9390
GET("/spent-index/:blockheight") // returns the spent outpoints index (see https://github.com/setavenger/BIP0352-light-client-specification?tab=readme-ov-file#spent-utxos)

blindbit.example.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# possible values: trace, debug, info, warn, error
2+
log_level = "debug"
3+
14
# 0.0.0.0:8000 to expose outside of localhost
25
# default: "127.0.0.1:8000"
36
host = "127.0.0.1:8000"

cmd/benchmark/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Oracle Benchmark Tool
2+
3+
This tool benchmarks the performance difference between v1 (HTTP) and v2 (gRPC streaming) APIs for fetching block data.
4+
5+
## Building
6+
7+
```bash
8+
make build-benchmark
9+
```
10+
11+
## Usage
12+
13+
### Run both benchmarks
14+
```bash
15+
./bin/benchmark -startheight=100 -endheight=200
16+
```
17+
18+
### Run only v1 HTTP benchmark
19+
```bash
20+
./bin/benchmark -v1 -v2=false -startheight=100 -endheight=200
21+
```
22+
23+
### Run only v2 gRPC benchmark
24+
```bash
25+
./bin/benchmark -v1=false -v2 -startheight=100 -endheight=200
26+
```
27+
28+
### Compare v1 and v2 data (validation)
29+
```bash
30+
./bin/benchmark -compare -startheight=100 -endheight=200
31+
```
32+
33+
### Using Makefile
34+
```bash
35+
# Run both
36+
make benchmark ARGS="-startheight=100 -endheight=200"
37+
38+
# Run only v1
39+
make benchmark-v1 ARGS="-startheight=100 -endheight=200"
40+
41+
# Run only v2
42+
make benchmark-v2 ARGS="-startheight=100 -endheight=200"
43+
44+
# Compare data
45+
make benchmark ARGS="-compare -startheight=264100 -endheight=264200"
46+
```
47+
48+
## Command Line Flags
49+
50+
- `-startheight`: Start block height (default: 1)
51+
- `-endheight`: End block height (default: 10)
52+
- `-http`: HTTP API base URL (default: "http://127.0.0.1:8000")
53+
- `-grpc`: gRPC server host:port (default: "127.0.0.1:50051")
54+
- `-v1`: Run v1 HTTP benchmark (default: true)
55+
- `-v2`: Run v2 gRPC benchmark (default: true)
56+
- `-compare`: Compare v1 and v2 data instead of benchmarking (default: false)
57+
58+
## What it measures
59+
60+
The benchmark fetches block data (tweaks, filters) for each block height in the range and measures:
61+
62+
- Total time to fetch all blocks
63+
- Blocks processed per second
64+
- Individual block fetch times
65+
66+
## Expected Results
67+
68+
- **v1 (HTTP)**: Makes individual HTTP requests for each block, good for small ranges
69+
- **v2 (gRPC)**: Uses streaming to fetch all blocks in one connection, better for large ranges
70+
71+
The gRPC streaming approach should show better performance for larger block ranges due to reduced connection overhead and better batching.

cmd/benchmark/main.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
6+
"github.com/rs/zerolog"
7+
"github.com/setavenger/blindbit-lib/logging"
8+
"github.com/setavenger/blindbit-oracle/internal/benchmark"
9+
)
10+
11+
func main() {
12+
var (
13+
startHeight = flag.Uint64("startheight", 1, "Start block height")
14+
endHeight = flag.Uint64("endheight", 10, "End block height")
15+
httpURL = flag.String("http", "http://127.0.0.1:8000", "HTTP API base URL")
16+
grpcHost = flag.String("grpc", "127.0.0.1:50051", "gRPC server host:port")
17+
runV1 = flag.Bool("v1", true, "Run v1 HTTP benchmark")
18+
runV2 = flag.Bool("v2", true, "Run v2 gRPC benchmark")
19+
compare = flag.Bool("compare", false, "Compare v1 and v2 data instead of benchmarking")
20+
)
21+
flag.Parse()
22+
23+
// Setup logging
24+
logging.SetLogLevel(zerolog.InfoLevel)
25+
26+
if *compare {
27+
logging.L.Info().
28+
Uint64("start_height", *startHeight).
29+
Uint64("end_height", *endHeight).
30+
Msg("Starting data comparison")
31+
32+
benchmark.CompareV1V2Results(*startHeight, *endHeight, *httpURL, *grpcHost)
33+
return
34+
}
35+
36+
logging.L.Info().
37+
Uint64("start_height", *startHeight).
38+
Uint64("end_height", *endHeight).
39+
Msg("Starting benchmark")
40+
41+
if *runV1 {
42+
logging.L.Info().Msg("=== Running V1 HTTP Benchmark ===")
43+
benchmark.BenchmarkV1(*startHeight, *endHeight, *httpURL)
44+
}
45+
46+
if *runV2 {
47+
logging.L.Info().Msg("=== Running V2 gRPC Streaming Benchmark ===")
48+
benchmark.BenchmarkV2(*startHeight, *endHeight, *grpcHost)
49+
}
50+
51+
logging.L.Info().Msg("Benchmark completed")
52+
}

0 commit comments

Comments
 (0)