Skip to content

Commit 19197e7

Browse files
authored
Merge pull request #28 from stakepeter/eth2-monitor/staging-troubleshooting
Fix Pectra/EIP-7549 attestation over-counting, add Erigon (Caplin) compatibility, repo & test rework
2 parents e4487e0 + 67f49b2 commit 19197e7

130 files changed

Lines changed: 14706 additions & 1849 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/golangci-lint.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,15 @@ jobs:
1616
- uses: actions/checkout@v4
1717
- uses: actions/setup-go@v5
1818
with:
19-
go-version: '1.23'
19+
go-version: '1.25'
2020
cache: false
2121
- name: golangci-lint
22-
uses: golangci/golangci-lint-action@v4
22+
uses: golangci/golangci-lint-action@v8
2323
with:
2424
# Require: The version of golangci-lint to use.
25-
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
26-
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
27-
version: v1.60
28-
29-
# XXX Workaround for https://github.com/golangci/golangci-lint-action/issues/135
30-
# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
31-
skip-pkg-cache: true
25+
# When `install-mode` is `binary` (default) the value can be v2.x.y or `latest` to use the latest version.
26+
# When `install-mode` is `goinstall` the value can be v2.x.y, `latest`, or the hash of a commit.
27+
version: v2.12.2
3228

3329
# Optional: working directory, useful for monorepos
3430
# working-directory: somedir
@@ -51,3 +47,15 @@ jobs:
5147

5248
# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
5349
# install-mode: "goinstall"
50+
51+
coverage:
52+
name: coverage
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v4
56+
- uses: actions/setup-go@v5
57+
with:
58+
go-version: '1.25'
59+
cache: false
60+
- name: go test -cover
61+
run: go test -cover ./...

.github/workflows/main.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,24 @@ jobs:
3232
# run: |
3333
# go get -u github.com/client9/misspell/cmd/misspell
3434
# $(go env GOPATH)/bin/misspell -locale US *.md $(find . -name '*.go')
35+
test:
36+
name: Run tests
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v3
40+
- uses: actions/setup-go@v3
41+
with:
42+
go-version: 1.25.x
43+
- name: go test
44+
run: go test ./...
3545
build:
3646
name: Build the executable
3747
runs-on: ubuntu-latest
48+
needs: [test]
3849
steps:
3950
- uses: actions/setup-go@v3
4051
with:
41-
go-version: 1.23.x
52+
go-version: 1.25.x
4253
- uses: actions/checkout@v3
4354
- name: Build
4455
run: |
@@ -49,7 +60,7 @@ jobs:
4960
}
5061
5162
mkdir -p build
52-
for arch in arm64 arm64; do
63+
for arch in amd64 arm64; do
5364
for os in linux darwin freebsd windows; do
5465
build "$arch" "$os"
5566
done

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,12 @@ eth2-monitor
150150
test-env/data/
151151
test-env/mev-relays.json
152152
test-env/.env
153+
154+
.idea
155+
.serena
156+
.env
157+
158+
# accidental `go build ./tools/fixturegen` from the repo root drops the
159+
# binary here; the tool is meant to be run via `go run ./tools/fixturegen`
160+
# or `make refresh-fixtures`, never built into the source tree.
161+
/fixturegen

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
golang 1.19.3
1+
golang 1.25.10

CLAUDE.md

Lines changed: 281 additions & 0 deletions
Large diffs are not rendered by default.

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:alpine3.19 AS builder
1+
FROM golang:1.25.10-alpine3.23 AS builder
22

33
RUN apk update && \
44
apk add --no-cache ca-certificates && \
@@ -16,10 +16,10 @@ RUN go mod download
1616
RUN go mod verify
1717

1818
COPY . .
19-
RUN go build -o /go/bin/eth2-monitor -ldflags '-extldflags "-static"'
19+
RUN go build -o /go/bin/eth2-monitor -ldflags '-extldflags "-static"' ./cmd/eth2-monitor
2020

2121
# second step to build minimal image
22-
FROM alpine:3.21.3
22+
FROM alpine:3.23
2323

2424
# add common trusted certificates from the build stage
2525
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

Makefile

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,53 @@
11
VERSION = $(shell git describe --tags --abbrev=8 2>/dev/null)
22

3-
LDFLAGS += -X eth2-monitor/cmd.version=${VERSION}
3+
LDFLAGS += -X github.com/stakefish/eth2-monitor/internal/cli.version=${VERSION}
44

5-
.PHONY: all build eth2-monitor
5+
.PHONY: all build eth2-monitor lint test test-e2e refresh-fixtures refresh-scenario
66
all: build
77

88
build: eth2-monitor
99

1010
eth2-monitor:
1111
-@mkdir -p bin
1212
-@rm -f bin/$@
13-
go build -ldflags '$(LDFLAGS)' -o bin/$@ .
13+
go build -ldflags '$(LDFLAGS)' -o bin/$@ ./cmd/eth2-monitor
14+
15+
lint:
16+
golangci-lint run ./...
17+
18+
test:
19+
go test -cover ./...
20+
21+
test-e2e:
22+
go test -tags=e2e -count=1 -timeout=5m ./internal/beaconchain/... ./internal/monitoring/...
23+
24+
# Scenarios captured by tools/fixturegen. Each scenario gets its own
25+
# subdirectory under internal/beaconchain/testdata/beacon/<chain>/<scenario>/
26+
# (plus internal/monitoring/testdata/mev/ for the chain-agnostic mev
27+
# scenario). The head-stream-driven capture flow waits for live head
28+
# events on the configured BEACON_CHAIN_API endpoint — see
29+
# tools/fixturegen/main.go.
30+
SCENARIOS = _shared happy_path missed_proposal empty_block delayed_attestation cross_epoch_attestation mev
31+
32+
# CHAIN selects the chain subdirectory under testdata/beacon/. Defaults
33+
# to hoodi (the chain configured in test-env/.env). Set explicitly to
34+
# capture against a different network:
35+
# make refresh-fixtures CHAIN=sepolia
36+
CHAIN ?= hoodi
37+
38+
# Refresh every scenario sequentially. The head-stream selectors each
39+
# wait up to ~10 minutes for a matching head event, so a full
40+
# refresh-fixtures run can take 30-60 minutes on a normal-finality
41+
# testnet. Use refresh-scenario for targeted refreshes during
42+
# development. Reads $BEACON_CHAIN_API or test-env/.env.
43+
refresh-fixtures:
44+
@for s in $(SCENARIOS); do \
45+
echo "==> capturing scenario: $$s (chain=$(CHAIN))"; \
46+
go run ./tools/fixturegen --scenario=$$s --chain=$(CHAIN) || exit 1; \
47+
done
48+
49+
# Refresh a single scenario. Pass `SCENARIO=<name>` (e.g.
50+
# `make refresh-scenario SCENARIO=missed_proposal`). Honors CHAIN.
51+
refresh-scenario:
52+
@if [ -z "$(SCENARIO)" ]; then echo "usage: make refresh-scenario SCENARIO=<name> [CHAIN=<chain>]"; exit 2; fi
53+
go run ./tools/fixturegen --scenario=$(SCENARIO) --chain=$(CHAIN)

beaconchain/service.go

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

main.go renamed to cmd/eth2-monitor/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"os"
66
"time"
77

8-
"eth2-monitor/cmd"
8+
"github.com/stakefish/eth2-monitor/internal/cli"
99

1010
isatty "github.com/mattn/go-isatty"
1111
"github.com/rs/zerolog"
@@ -24,7 +24,7 @@ func init() {
2424
}
2525

2626
func main() {
27-
if err := cmd.Execute(); err != nil {
27+
if err := cli.Execute(); err != nil {
2828
fmt.Println(err)
2929
os.Exit(1)
3030
}

cmd/opts/opts.go

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

0 commit comments

Comments
 (0)