Skip to content

Commit f5743f0

Browse files
committed
chore: merge master into feat/bzz-token-address
2 parents 6d6ea64 + 5036b62 commit f5743f0

62 files changed

Lines changed: 2812 additions & 2191 deletions

Some content is hidden

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ _test
2424
dist/
2525
.idea/
2626
.vscode/
27+
.claude/
2728
.vs/
2829
.DS_Store
2930
tmp/

AGENTS.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# AGENTS.md
2+
3+
This file provides guidance to AI coding assistants (Claude Code, Cursor, and others) when working with code in this repository.
4+
5+
## Project overview
6+
7+
Beekeeper is the orchestration and integration-testing tool for [Ethereum Swarm Bee](https://github.com/ethersphere/bee) clusters. A single Go CLI (`cmd/beekeeper`, built on Cobra/Viper) covers several distinct jobs:
8+
9+
- **Cluster lifecycle** — create/delete Bee clusters as Kubernetes resources (`create`, `delete`).
10+
- **Integration checks** — run tests such as `pingpong`, `pushsync`, `retrieval` against a cluster (`check`). This is the primary purpose; checks are also what Bee's CI runs against PRs.
11+
- **Operational tooling against already-running clusters**`stamper` (postage batch create/topup/dilute/set), `node-funder`/`node-operator` (top up ETH/BZZ), `nuke` (DB reset + resync), `restart`.
12+
13+
Beekeeper consumes Bee as a library (`github.com/ethersphere/bee/v2` in `go.mod`) for shared types (e.g. `swarm.Address`, postage) and talks to running nodes over Bee's HTTP API.
14+
15+
## Essential commands
16+
17+
```bash
18+
make binary # build ./dist/beekeeper (CGO disabled, version stamped via -ldflags)
19+
make test # unit tests: go test -v ./pkg/...
20+
make lint # golangci-lint (pinned v2.10.1; auto-installs if missing)
21+
```
22+
23+
Run a single test: `go test -run TestName ./pkg/<package>/...` (add `-race` to mirror CI).
24+
25+
CI (`.github/workflows/go.yml`) runs `make vet`, `make check-whitespace`, golangci-lint, `make build`, and `make test`. PR titles are linted as Conventional Commits (`.github/workflows/pr-title.yml`).
26+
27+
Requires Go 1.26. For a full local cluster (K3s/k3d + Geth), follow the **Local Development** quick start in `README.md`.
28+
29+
## How a run is wired together
30+
31+
The root command (`cmd/beekeeper/cmd/cmd.go`) builds shared dependencies in `PersistentPreRunE` before any subcommand runs:
32+
33+
1. Loads global config (Viper: `$HOME/.beekeeper.yaml`, flags, env).
34+
2. Loads the **config directory** (cluster/check definitions) from a local path *or* a Git repo.
35+
3. Constructs the logger (optional Loki), the Kubernetes client (unless `--enable-k8s=false`), and the swap/blockchain client (`swap.NotSet{}` when no `geth-url`).
36+
37+
Subcommands receive these via the `command` struct and pass them into runners/clients as constructor args — there is no global singleton.
38+
39+
## Architecture
40+
41+
The big-picture layers (each is one or more packages under `pkg/`):
42+
43+
- **Config (`pkg/config/`)** — parses the YAML config dir (`clusters`, `node-groups`, `bee-configs`, `checks`, `simulations`), resolves `_inherit` inheritance, and exports into the `orchestration.*Options` types. Read from a local dir or a Git repo (`config-git-repo`).
44+
- **Orchestration (`pkg/orchestration/`)** — backend-agnostic `Cluster``NodeGroup``Node` model. The `k8s/` backend translates it into Kubernetes resources; `notset/` is the no-op fallback when K8s is disabled.
45+
- **Checks (`pkg/check/`)** — each check implements the `beekeeper.Action` interface and is registered by name in the `Checks` map in `pkg/config/check.go`; `pkg/check/runner.go` resolves names to implementations and runs them.
46+
- **Clients**`pkg/bee/` (+ `pkg/bee/api/`) is the HTTP client for a running Bee node; `pkg/k8s/` wraps the Kubernetes client (tested with client-go's fake clientset; `pkg/k8s/mocks/` holds only the `ClientConfig`/RoundTripper doubles); `pkg/swap/` is the Geth/blockchain client.
47+
- **Operational packages**`stamper`, `nuker`, `restart`, `funder` act on already-running nodes and discover them through `pkg/node/` (`NodeProvider`: Beekeeper cluster, namespace+label, or Helm), not the orchestration layer.
48+
49+
## Deployment / operating modes
50+
51+
Commands work against clusters provisioned in three different ways — know which one applies:
52+
53+
1. **Beekeeper-managed Kubernetes** — Beekeeper creates the cluster from the config dir (`create bee-cluster`); checks/ops resolve nodes from the cluster definition.
54+
2. **Static endpoints (no Kubernetes)** — set `enable-k8s: false` and point at static Bee node URLs in config (see `config/public-testnet-static.yaml`). Used for public-testnet checks.
55+
3. **Externally-deployed clusters**`stamper`/`nuke`/`restart`/`node-funder` target nodes by namespace/label or a Helm deployment (`--deployment-type=helm`), without a Beekeeper cluster definition.
56+
57+
## Conventions
58+
59+
- **Code style**: prefer clear, idiomatic Go that follows standard best practices and principles — small focused functions, explicit error wrapping with context, no premature abstraction. Keep changes minimal and consistent with the surrounding code.
60+
- **Commits & PR titles**: Conventional Commits, lowercase type, no trailing period, `feat(scope): …` style (enforced by `commitlint.config.js`). Do not push commits; when a commit message is requested, use the subject line only — no body/description.
61+
- **Tests**: prefer external test packages (`package foo_test`). Test the `pkg/k8s` clients against client-go's fake clientset instead of a live cluster — `fake.NewClientset()` with `PrependReactor` for error paths, and `watch.NewRaceFreeFake` + `PrependWatchReactor` for watch paths (buffer/drive events, bound tests with `context.WithTimeout`, never `time.Sleep`). The only hand-written mock left is `pkg/k8s/mocks` (the `ClientConfig`/`RoundTripper` doubles backing `pkg/k8s/k8s_test.go`). The race detector must pass.
62+
- **Dependencies**: do not add or bump modules unless the task requires it (Dependabot handles routine bumps).
63+
- **Linting**: `gofmt` + `gofumpt` formatting and the linters in `.golangci.yml` (errorlint, errname, nilerr, goconst, misspell, unconvert, copyloopvar) must pass. Note this repo does **not** use BSD copyright file headers — don't add them.
64+
65+
## Pre-commit checklist
66+
67+
Run before committing: `make build`, `make vet`, `make lint`, `make test` (use `make test-race` when touching concurrent code). Keep changes minimal and focused on the task.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@AGENTS.md

cmd/beekeeper/cmd/cluster.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,13 @@ func setupBootnodes(ctx context.Context,
247247
nodeName = node.Name
248248
}
249249

250-
bConfig.Bootnodes = fmt.Sprintf(node.Bootnodes, clusterConfig.GetNamespace()) // TODO: improve bootnode management, support more than 2 bootnodes
251-
bootnodesOut = bConfig.Bootnodes
252-
nodeOpts := setupNodeOptions(node, &bConfig)
250+
// each node gets its own config copy, as the bootnode list is
251+
// node-specific and nodes are set up concurrently
252+
nodeConfig := bConfig
253+
bootnodes := fmt.Sprintf(node.Bootnodes, clusterConfig.GetNamespace()) // TODO: improve bootnode management, support more than 2 bootnodes
254+
nodeConfig.Bootnodes = &[]string{bootnodes}
255+
bootnodesOut = bootnodes
256+
nodeOpts := setupNodeOptions(node, &nodeConfig)
253257
nodeCount++
254258
go setupOrAddNode(ctx, startCluster, inCluster, ng, nodeName, nodeOpts, nodeResultChan, orchestration.WithNoOptions())
255259
}
@@ -299,8 +303,8 @@ func setupNodes(ctx context.Context,
299303
}
300304
bConfig := beeConfig.Export()
301305

302-
if bConfig.Bootnodes == "" {
303-
bConfig.Bootnodes = bootnodesIn
306+
if (bConfig.Bootnodes == nil || len(*bConfig.Bootnodes) == 0) && bootnodesIn != "" {
307+
bConfig.Bootnodes = &[]string{bootnodesIn}
304308
}
305309
ngOptions.BeeConfig = &bConfig
306310

config/config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ bee-configs:
9494
block-time: 1
9595
blockchain-rpc-endpoint: "ws://geth-swap.bee-playground.svc.swarm1.local:8546"
9696
bootnode-mode: false
97-
bootnodes: ""
97+
bootnode: []
9898
bzz-token-address: "0x6aab14fe9cccd64a502d23842d916eb5321c26e7"
9999
cache-capacity: 1000000
100100
chequebook-enable: true
101-
cors-allowed-origins: ""
101+
cors-allowed-origins: []
102102
data-dir: "/home/bee/.bee"
103103
db-block-cache-capacity: 33554432
104104
db-disable-seeks-compaction: false
@@ -118,19 +118,19 @@ bee-configs:
118118
postage-stamp-start-block: 1
119119
price-oracle-address: "0x5aFE06fcC0855a76a15c3544b0886EDBE3294d62"
120120
redistribution-address: "0x09Ad42a7d020244920309FfA14EA376dd2D3b7d5"
121-
resolver-options: ""
121+
resolver-options: []
122122
staking-address: "0xfc28330f1ecE0ef2371B724E0D19c1EE60B728b2"
123123
storage-incentives-enable: true
124124
swap-enable: true
125125
swap-factory-address: "0xdD661f2500bA5831e3d1FEbAc379Ea1bF80773Ac"
126126
swap-initial-deposit: 500000000000000000
127-
tracing-enabled: true
127+
tracing-enable: true
128128
tracing-endpoint: "10.10.11.199:6831"
129129
tracing-service-name: "bee"
130130
verbosity: 5 # 1=error, 2=warn, 3=info, 4=debug, 5=trace
131131
warmup-time: 0s
132132
welcome-message: "Welcome to the Swarm, you are Bee-ing connected!"
133-
withdrawal-addresses-whitelist: "0xec44cb15b1b033e74d55ac5d0e24d861bde54532"
133+
withdrawal-addresses-whitelist: ["0xec44cb15b1b033e74d55ac5d0e24d861bde54532"]
134134
bootnode:
135135
_inherit: "default"
136136
bootnode-mode: true

config/local.yaml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ bee-configs:
152152
block-time: 1
153153
blockchain-rpc-endpoint: "ws://geth-swap:8546"
154154
bootnode-mode: false
155-
bootnodes: ""
155+
bootnode: []
156156
bzz-token-address: "0x6aab14fe9cccd64a502d23842d916eb5321c26e7"
157157
cache-capacity: 20000
158158
chequebook-enable: true
159-
cors-allowed-origins: ""
159+
cors-allowed-origins: []
160160
data-dir: "/home/bee/.bee"
161161
db-block-cache-capacity: 33554432
162162
db-disable-seeks-compaction: false
@@ -179,7 +179,7 @@ bee-configs:
179179
postage-stamp-start-block: 1
180180
price-oracle-address: "0x5aFE06fcC0855a76a15c3544b0886EDBE3294d62"
181181
redistribution-address: "0x09Ad42a7d020244920309FfA14EA376dd2D3b7d5"
182-
resolver-options: ""
182+
resolver-options: []
183183
staking-address: "0xfc28330f1ecE0ef2371B724E0D19c1EE60B728b2"
184184
storage-incentives-enable: true
185185
swap-enable: true
@@ -188,14 +188,13 @@ bee-configs:
188188
verbosity: 5
189189
warmup-time: 0s
190190
welcome-message: "Welcome to the Swarm, this is a local cluster!"
191-
withdrawal-addresses-whitelist: "0xec44cb15b1b033e74d55ac5d0e24d861bde54532"
191+
withdrawal-addresses-whitelist: ["0xec44cb15b1b033e74d55ac5d0e24d861bde54532"]
192192
bootnode-local-dns-autotls:
193193
_inherit: "bee-local-dns"
194194
bootnode-mode: true
195195
p2p-wss-enable: true
196196
bee-local-autotls:
197197
_inherit: "bee-local-dns"
198-
bootnode: /dnsaddr/bootnode-0-headless.local.svc.cluster.local
199198
p2p-wss-enable: true
200199
bee-local-light-autotls:
201200
_inherit: "bee-local-light"
@@ -210,14 +209,11 @@ bee-configs:
210209
bootnode-mode: true
211210
bee-local-dns:
212211
_inherit: "bee-local"
213-
bootnode: /dnsaddr/localhost
214212
bootnode-local-dns:
215213
_inherit: "bee-local"
216-
bootnode: /dnsaddr/localhost
217214
bootnode-mode: true
218215
bee-local-light:
219216
_inherit: "bee-local"
220-
bootnode: /dnsaddr/localhost
221217
full-node: false
222218
bee-local-gc:
223219
_inherit: "bee-local"

config/public-testnet.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ node-groups:
4646
bee-configs:
4747
sepolia:
4848
_inherit: ""
49-
bootnodes: "/dnsaddr/testnet.ethswarm.org"
49+
bootnode: ["/dnsaddr/testnet.ethswarm.org"]
5050
full-node: true
5151

5252
checks:

config/staging.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ clusters:
1818
mode: node
1919
bee-config: staging
2020
config: staging
21-
count: 5
21+
count: 1
2222

2323
# node-groups defines node groups that can be registered in the cluster
2424
# node-groups may inherit it's configuration from already defined node-group and override specific fields from it
@@ -34,14 +34,14 @@ bee-configs:
3434
_inherit: ""
3535
api-addr: ":1633"
3636
blockchain-rpc-endpoint: http://rpc-sepolia-haproxy.default.svc.swarm1.local
37-
bootnodes: /dnsaddr/testnet.ethswarm.org
37+
bootnode: ["/dnsaddr/testnet.ethswarm.org"]
3838
full-node: true
3939
mainnet: false
4040
network-id: 10
4141
p2p-addr: ":1634"
4242
password: "beekeeper"
4343
swap-enable: true
44-
tracing-enabled: true
44+
tracing-enable: true
4545
tracing-endpoint: "10.10.11.199:6831"
4646
tracing-service-name: "bee"
4747
verbosity: 4

config/testnet-bee-playground.yaml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ clusters:
99
api-insecure-tls: true
1010
api-scheme: http
1111
funding:
12-
eth: 0.1
12+
eth: 0.01
1313
bzz: 3.0
1414
node-groups:
1515
bootnode:
@@ -44,33 +44,16 @@ bee-configs:
4444
api-addr: :1633
4545
block-time: 12
4646
blockchain-rpc-endpoint: http://rpc-sepolia-haproxy.default.svc.swarm1.local
47-
bootnode-mode: false
48-
bootnodes: # /dnsaddr/testnet.ethswarm.org
49-
cache-capacity: 1000000
47+
# bootnode: [dnsaddr/testnet.ethswarm.org]
5048
chequebook-enable: true
51-
cors-allowed-origins: ""
5249
data-dir: "/home/bee/.bee"
53-
db-block-cache-capacity: 33554432
54-
db-disable-seeks-compaction: true
55-
db-open-files-limit: 200
56-
db-write-buffer-size: 33554432
5750
full-node: true
5851
mainnet: false
59-
nat-addr: ""
6052
network-id: 5
6153
p2p-addr: :1634
62-
p2p-ws-enable: true
6354
password: "beekeeper"
64-
payment-early-percent: 50
65-
payment-threshold: 13500000
66-
payment-tolerance-percent: 25
67-
postage-stamp-start-block: 0
6855
storage-incentives-enable: true
6956
swap-enable: true
70-
swap-initial-deposit: 0
71-
tracing-enabled: false
72-
tracing-endpoint: "10.10.11.199:6831"
73-
tracing-service-name: "bee-playground"
7457
verbosity: 5
7558
warmup-time: 5m0s
7659
welcome-message: Welcome to the bee-playground!

go.mod

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/go-git/go-billy/v5 v5.9.0
1414
github.com/go-git/go-git/v5 v5.19.1
1515
github.com/google/uuid v1.6.0
16-
github.com/gorilla/websocket v1.5.3
16+
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674
1717
github.com/ipshipyard/p2p-forge v0.7.0
1818
github.com/libp2p/go-libp2p v0.46.0
1919
github.com/miekg/dns v1.1.66
@@ -29,9 +29,9 @@ require (
2929
golang.org/x/crypto v0.50.0
3030
golang.org/x/sync v0.20.0
3131
gopkg.in/yaml.v3 v3.0.1
32-
k8s.io/api v0.31.10
33-
k8s.io/apimachinery v0.31.10
34-
k8s.io/client-go v0.31.10
32+
k8s.io/api v0.33.12
33+
k8s.io/apimachinery v0.33.12
34+
k8s.io/client-go v0.33.12
3535
resenje.org/x v0.6.0
3636
)
3737

@@ -69,21 +69,18 @@ require (
6969
github.com/go-logr/logr v1.4.3 // indirect
7070
github.com/go-logr/stdr v1.2.2 // indirect
7171
github.com/go-ole/go-ole v1.3.0 // indirect
72-
github.com/go-openapi/jsonpointer v0.19.6 // indirect
72+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
7373
github.com/go-openapi/jsonreference v0.20.2 // indirect
74-
github.com/go-openapi/swag v0.22.4 // indirect
74+
github.com/go-openapi/swag v0.23.0 // indirect
7575
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
7676
github.com/gogo/protobuf v1.3.2 // indirect
7777
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
78-
github.com/golang/protobuf v1.5.4 // indirect
79-
github.com/google/gnostic-models v0.6.8 // indirect
78+
github.com/google/gnostic-models v0.6.9 // indirect
8079
github.com/google/go-cmp v0.7.0 // indirect
81-
github.com/google/gofuzz v1.2.0 // indirect
8280
github.com/hashicorp/errwrap v1.1.0 // indirect
8381
github.com/hashicorp/go-multierror v1.1.1 // indirect
8482
github.com/holiman/uint256 v1.3.2 // indirect
8583
github.com/huin/goupnp v1.3.0 // indirect
86-
github.com/imdario/mergo v0.3.13 // indirect
8784
github.com/inconshreveable/mousetrap v1.1.0 // indirect
8885
github.com/ipfs/go-cid v0.5.0 // indirect
8986
github.com/ipfs/go-log/v2 v2.6.0 // indirect
@@ -146,7 +143,7 @@ require (
146143
github.com/pkg/errors v0.9.1 // indirect
147144
github.com/prometheus/client_model v0.6.2 // indirect
148145
github.com/prometheus/procfs v0.16.1 // indirect
149-
github.com/quic-go/quic-go v0.57.1 // indirect
146+
github.com/quic-go/quic-go v0.59.1 // indirect
150147
github.com/sagikazarmark/locafero v0.7.0 // indirect
151148
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
152149
github.com/shirou/gopsutil v3.21.5+incompatible // indirect
@@ -156,7 +153,6 @@ require (
156153
github.com/spf13/afero v1.12.0 // indirect
157154
github.com/spf13/cast v1.7.1 // indirect
158155
github.com/spf13/pflag v1.0.6 // indirect
159-
github.com/stretchr/objx v0.5.2 // indirect
160156
github.com/subosito/gotenv v1.6.0 // indirect
161157
github.com/supranational/blst v0.3.16-0.20250831170142-f48500c1fdbe // indirect
162158
github.com/tklauser/go-sysconf v0.3.12 // indirect
@@ -191,12 +187,12 @@ require (
191187
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
192188
gopkg.in/inf.v0 v0.9.1 // indirect
193189
gopkg.in/warnings.v0 v0.1.2 // indirect
194-
gopkg.in/yaml.v2 v2.4.0 // indirect
195190
k8s.io/klog/v2 v2.130.1 // indirect
196-
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
197-
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
191+
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect
192+
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
198193
lukechampine.com/blake3 v1.4.1 // indirect
199-
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
200-
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
194+
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
195+
sigs.k8s.io/randfill v1.0.0 // indirect
196+
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
201197
sigs.k8s.io/yaml v1.4.0 // indirect
202198
)

0 commit comments

Comments
 (0)