Skip to content

Commit 581ef8b

Browse files
feat: add PostageTTL and PostageLabel options to all Beekeeper checks (#454)
* feat: enable PostageLabel option for all checks creating batches * refactor: use geth-url as global flag * feat(stamper): introduce postage-label as filter * fix(stamper): log price in bzz * feat(swap): add offset option for FetchBlockTime * feat: replace postage-amount with postage-ttl * chore: remove unused code * chore: bump version to 0.26.0 * chore: go mod tidy * fix: resolve deps * chore: update configs * chore: update configs * fix: set amount to 1000 if price is 0 * fix(stake): set geth-url * fix(redundancy): set PostageLabel type to string * feat: automatically set semantic version number * fix(swap): set options offset default to 1 * fix(swap): improve FetchBlockTime if offset is too large * chore(swap): add log msg when offset too large * fix(swap): limit offset to at most of half of the latest block * fix(swap): increase offset to 1000 * fix: improve error msgs and flag descriptions * fix(orchestration): ensure that SwapClient is initialized * fix(stamper): ensure that SwapClient is initialized
1 parent 6379ad8 commit 581ef8b

Some content is hidden

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

52 files changed

+597
-453
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ GO ?= go
22
GOLANGCI_LINT ?= golangci-lint
33
GOLANGCI_LINT_VERSION ?= v1.61.0
44
COMMIT ?= "$(shell git describe --long --dirty --always --match "" || true)"
5-
LDFLAGS ?= -s -w -X github.com/ethersphere/beekeeper.commit=$(COMMIT)
5+
VERSION ?= "$(shell git describe --tags --abbrev=0 | cut -c2-)"
6+
LDFLAGS ?= -s -w \
7+
-X github.com/ethersphere/beekeeper.commit="$(COMMIT)" \
8+
-X github.com/ethersphere/beekeeper.version="$(VERSION)"
69

710
.PHONY: all
811
all: build lint vet test-race binary

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ It has following flags:
242242

243243
```console
244244
--cluster-name string cluster name (default "default")
245-
--geth-url string Endpoint to chain node. Required.
246245
--help help for bee-cluster
247246
--timeout duration timeout (default 30m0s)
248247
--wallet-key string Hex-encoded private key for the Bee node wallet. Required.
@@ -307,7 +306,6 @@ It has the following flags:
307306
--bzz-token-address string BZZ token address (default "0x6aab14fe9cccd64a502d23842d916eb5321c26e7")
308307
--eth-account string ETH account address (default "0x62cab2b3b55f341f10348720ca18063cdb779ad5")
309308
--eth-deposit float ETH amount to deposit
310-
--geth-url string Geth node URL (default "http://geth-swap.geth-swap.dai.internal")
311309
--help help for fund
312310
--password password for generating Ethereum addresses (default "beekeeper")
313311
--timeout duration timeout (default 5m0s)
@@ -381,7 +379,6 @@ It has following flags:
381379
```console
382380
--addresses strings Comma-separated list of Bee node addresses (must start with 0x). Overrides namespace and cluster name.
383381
--cluster-name string Name of the Beekeeper cluster to target. Ignored if a namespace is specified.
384-
--geth-url string Endpoint to chain node. Required.
385382
--help help for node-funder
386383
--label-selector string Kubernetes label selector for filtering resources within the specified namespace. Use an empty string to select all resources. (default "beekeeper.ethswarm.org/node-funder=true")
387384
--min-native float Minimum amount of chain native coins (xDAI) nodes should have.
@@ -417,7 +414,6 @@ Command **node-operator** uses <https://github.com/ethersphere/node-funder> tool
417414
It has following flags:
418415

419416
```console
420-
--geth-url string Endpoint to chain node. Required.
421417
--help help for node-operator
422418
--min-native float Minimum amount of chain native coins (xDAI) nodes should have.
423419
--min-swarm float Minimum amount of swarm tokens (xBZZ) nodes should have.
@@ -507,7 +503,6 @@ It has following subcommands:
507503
```console
508504
--batch-ids strings Comma separated list of postage batch IDs to top up. If not provided, all batches are topped up.
509505
--cluster-name string Target Beekeeper cluster name.
510-
--geth-url string Geth URL for chain state retrieval.
511506
--help help for topup
512507
--label-selector string Kubernetes label selector for filtering resources (use empty string for all). (default "beekeeper.ethswarm.org/node-funder=true")
513508
--namespace string Kubernetes namespace (overrides cluster name).
@@ -565,7 +560,6 @@ It has following subcommands:
565560
--batch-ids strings Comma separated list of postage batch IDs to set. If not provided, all batches are set.
566561
--cluster-name string Target Beekeeper cluster name.
567562
--dilution-depth uint16 Number of levels by which to increase the depth of a stamp during dilution. (default 1)
568-
--geth-url string Geth URL for chain state retrieval.
569563
--help help for set
570564
--label-selector string Kubernetes label selector for filtering resources (use empty string for all). (default "beekeeper.ethswarm.org/node-funder=true")
571565
--namespace string Kubernetes namespace (overrides cluster name).
@@ -603,6 +597,7 @@ example:
603597
--config-git-repo string URL of the Git repository containing configuration files (uses the config-dir if not specified)
604598
--config-git-username string Git username for authentication (required for private repositories)
605599
--enable-k8s Enable Kubernetes client functionality (default true)
600+
--geth-url string URL of the Ethereum-compatible blockchain RPC endpoint
606601
--in-cluster Use the in-cluster Kubernetes client
607602
--kubeconfig string Path to the kubeconfig file (default "~/.kube/config")
608603
--log-verbosity string Log verbosity level (0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=trace) (default "info")

cmd/beekeeper/cmd/check.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import (
1414
"github.com/spf13/cobra"
1515
)
1616

17-
var errMissingClusterName = fmt.Errorf("cluster name not provided")
18-
1917
func (c *command) initCheckCmd() error {
2018
const (
2119
optionNameCreateCluster = "create-cluster"
@@ -89,7 +87,8 @@ func (c *command) initCheckCmd() error {
8987

9088
// set global config
9189
checkGlobalConfig := config.CheckGlobalConfig{
92-
Seed: c.globalConfig.GetInt64(optionNameSeed),
90+
Seed: c.globalConfig.GetInt64(optionNameSeed),
91+
GethURL: c.globalConfig.GetString(optionNameGethURL),
9392
}
9493

9594
// run checks
@@ -124,6 +123,7 @@ func (c *command) initCheckCmd() error {
124123
defer cancelCheck()
125124

126125
c.log.Infof("running check: %s", checkName)
126+
c.log.Debugf("check options: %+v", o)
127127

128128
ch := make(chan error, 1)
129129
go func() {

cmd/beekeeper/cmd/cluster.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,15 @@ func (c *command) setupCluster(ctx context.Context, clusterName string, startClu
132132
if clusterConfig.IsUsingStaticEndpoints() {
133133
return nil, errors.New("static endpoints are not supported for starting the cluster")
134134
}
135-
if chainNodeEndpoint = c.globalConfig.GetString(optionNameChainNodeEndpoint); chainNodeEndpoint == "" {
136-
return nil, errors.New("chain node endpoint (geth-url) not provided")
135+
136+
if chainNodeEndpoint = c.globalConfig.GetString(optionNameGethURL); chainNodeEndpoint == "" {
137+
return nil, errBlockchainEndpointNotProvided
137138
}
139+
138140
if walletKey = c.globalConfig.GetString(optionNameWalletKey); walletKey == "" {
139141
return nil, errors.New("wallet key not provided")
140142
}
143+
141144
fundOpts = ensureFundingDefaults(clusterConfig.Funding.Export(), c.log)
142145
}
143146

cmd/beekeeper/cmd/cmd.go

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"github.com/go-git/go-billy/v5/memfs"
1919
"github.com/go-git/go-git/v5"
2020
"github.com/go-git/go-git/v5/plumbing"
21-
httptransport "github.com/go-git/go-git/v5/plumbing/transport/http"
21+
"github.com/go-git/go-git/v5/plumbing/transport/http"
2222
"github.com/go-git/go-git/v5/storage/memory"
2323
"github.com/sirupsen/logrus"
2424
"github.com/spf13/cobra"
@@ -27,21 +27,27 @@ import (
2727

2828
const (
2929
optionNameConfigDir = "config-dir"
30-
optionNameConfigGitRepo = "config-git-repo"
31-
optionNameConfigGitDir = "config-git-dir"
3230
optionNameConfigGitBranch = "config-git-branch"
33-
optionNameConfigGitUsername = "config-git-username"
31+
optionNameConfigGitDir = "config-git-dir"
3432
optionNameConfigGitPassword = "config-git-password"
33+
optionNameConfigGitRepo = "config-git-repo"
34+
optionNameConfigGitUsername = "config-git-username"
35+
optionNameEnableK8S = "enable-k8s"
36+
optionNameGethURL = "geth-url"
37+
optionNameInCluster = "in-cluster"
38+
optionNameKubeconfig = "kubeconfig"
3539
optionNameLogVerbosity = "log-verbosity"
3640
optionNameLokiEndpoint = "loki-endpoint"
3741
optionNameTracingEnabled = "tracing-enable"
3842
optionNameTracingEndpoint = "tracing-endpoint"
3943
optionNameTracingHost = "tracing-host"
4044
optionNameTracingPort = "tracing-port"
4145
optionNameTracingServiceName = "tracing-service-name"
42-
optionNameEnableK8S = "enable-k8s"
43-
optionNameInCluster = "in-cluster"
44-
optionNameKubeconfig = "kubeconfig"
46+
)
47+
48+
var (
49+
errBlockchainEndpointNotProvided = errors.New("URL of the Ethereum-compatible blockchain RPC endpoint not provided; use the --geth-url flag")
50+
errMissingClusterName = errors.New("cluster name not provided")
4551
)
4652

4753
func init() {
@@ -154,6 +160,7 @@ func (c *command) initGlobalFlags() {
154160
globalFlags.String(optionNameConfigGitBranch, "main", "Git branch to use for configuration files")
155161
globalFlags.String(optionNameConfigGitUsername, "", "Git username for authentication (required for private repositories)")
156162
globalFlags.String(optionNameConfigGitPassword, "", "Git password or personal access token for authentication (required for private repositories)")
163+
globalFlags.String(optionNameGethURL, "", "URL of the ethereum compatible blockchain RPC endpoint")
157164
globalFlags.String(optionNameLogVerbosity, "info", "Log verbosity level (0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=trace)")
158165
globalFlags.String(optionNameLokiEndpoint, "", "HTTP endpoint for sending logs to Loki (e.g., http://loki.testnet.internal/loki/api/v1/push)")
159166
globalFlags.Bool(optionNameTracingEnabled, false, "Enable tracing for performance monitoring and debugging")
@@ -169,11 +176,12 @@ func (c *command) initGlobalFlags() {
169176
func (c *command) bindGlobalFlags() error {
170177
for _, flag := range []string{
171178
optionNameConfigDir,
172-
optionNameConfigGitRepo,
173179
optionNameConfigGitBranch,
174180
optionNameConfigGitDir,
175-
optionNameConfigGitUsername,
176181
optionNameConfigGitPassword,
182+
optionNameConfigGitRepo,
183+
optionNameConfigGitUsername,
184+
optionNameGethURL,
177185
optionNameLogVerbosity,
178186
optionNameLokiEndpoint,
179187
} {
@@ -255,7 +263,7 @@ func (c *command) loadConfigDirectory() error {
255263
// read configuration from git repo
256264
fs := memfs.New()
257265
if _, err := git.Clone(memory.NewStorage(), fs, &git.CloneOptions{
258-
Auth: &httptransport.BasicAuth{
266+
Auth: &http.BasicAuth{
259267
Username: c.globalConfig.GetString(optionNameConfigGitUsername),
260268
Password: c.globalConfig.GetString(optionNameConfigGitPassword),
261269
},
@@ -412,8 +420,8 @@ func (c *command) executePeriodically(ctx context.Context, action func(ctx conte
412420
}
413421

414422
func (c *command) setSwapClient() (err error) {
415-
if len(c.globalConfig.GetString("geth-url")) > 0 {
416-
gethUrl, err := url.Parse(c.globalConfig.GetString("geth-url"))
423+
if c.globalConfig.IsSet(optionNameGethURL) {
424+
gethUrl, err := url.Parse(c.globalConfig.GetString(optionNameGethURL))
417425
if err != nil {
418426
return fmt.Errorf("parsing Geth URL: %w", err)
419427
}

cmd/beekeeper/cmd/create_bee_cluster.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import (
88
)
99

1010
const (
11-
optionNameClusterName string = "cluster-name"
12-
optionNameChainNodeEndpoint string = "geth-url"
13-
optionNameWalletKey string = "wallet-key"
14-
optionNameTimeout string = "timeout"
11+
optionNameClusterName string = "cluster-name"
12+
optionNameWalletKey string = "wallet-key"
13+
optionNameTimeout string = "timeout"
1514
)
1615

1716
func (c *command) initCreateBeeCluster() *cobra.Command {
@@ -31,7 +30,6 @@ func (c *command) initCreateBeeCluster() *cobra.Command {
3130
}
3231

3332
cmd.Flags().String(optionNameClusterName, "", "cluster name")
34-
cmd.Flags().String(optionNameChainNodeEndpoint, "", "Endpoint to chain node. Required.")
3533
cmd.Flags().String(optionNameWalletKey, "", "Hex-encoded private key for the Bee node wallet. Required.")
3634
cmd.Flags().Duration(optionNameTimeout, 30*time.Minute, "timeout")
3735

cmd/beekeeper/cmd/fund.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ func (c *command) initFundCmd() (err error) {
1717
optionNameAddressCount = "address-count"
1818
optionNameEthAccount = "eth-account"
1919
optionNameBzzTokenAddress = "bzz-token-address"
20-
optionNameGethURL = "geth-url"
2120
optionNameBzzDeposit = "bzz-deposit"
2221
optionNameEthDeposit = "eth-deposit"
2322
optionNameGBzzDeposit = "gBzz-deposit"
@@ -109,7 +108,6 @@ beekeeper fund --address-create --address-count 2 --bzz-deposit 100.0 --eth-depo
109108
cmd.Flags().Int(optionNameAddressCount, 1, "number of Ethereum addresses to create")
110109
cmd.Flags().String(optionNameBzzTokenAddress, "0x6aab14fe9cccd64a502d23842d916eb5321c26e7", "BZZ token address")
111110
cmd.Flags().String(optionNameEthAccount, "0x62cab2b3b55f341f10348720ca18063cdb779ad5", "ETH account address")
112-
cmd.Flags().String(optionNameGethURL, "http://geth-swap.geth-swap.staging.internal", "Geth node URL")
113111
cmd.Flags().Float64(optionNameBzzDeposit, 0, "BZZ tokens amount to deposit")
114112
cmd.Flags().Float64(optionNameGBzzDeposit, 0, "gBZZ tokens amount to deposit")
115113
cmd.Flags().Float64(optionNameEthDeposit, 0, "ETH amount to deposit")

cmd/beekeeper/cmd/node_funder.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@ const (
1818

1919
func (c *command) initNodeFunderCmd() (err error) {
2020
const (
21-
optionNameAddresses = "addresses"
22-
optionNameNamespace = "namespace"
23-
optionNameChainNodeEndpoint = "geth-url"
24-
optionNameWalletKey = "wallet-key"
25-
optionNameMinNative = "min-native"
26-
optionNameMinSwarm = "min-swarm"
27-
optionNameTimeout = "timeout"
28-
optionNameLabelSelector = "label-selector"
21+
optionNameAddresses = "addresses"
22+
optionNameNamespace = "namespace"
23+
optionNameWalletKey = "wallet-key"
24+
optionNameMinNative = "min-native"
25+
optionNameMinSwarm = "min-swarm"
26+
optionNameTimeout = "timeout"
27+
optionNameLabelSelector = "label-selector"
2928
)
3029

3130
cmd := &cobra.Command{
@@ -41,8 +40,8 @@ func (c *command) initNodeFunderCmd() (err error) {
4140
},
4241
}
4342

44-
if cfg.ChainNodeEndpoint = c.globalConfig.GetString(optionNameChainNodeEndpoint); cfg.ChainNodeEndpoint == "" {
45-
return errors.New("chain node endpoint (geth-url) not provided")
43+
if cfg.ChainNodeEndpoint = c.globalConfig.GetString(optionNameGethURL); cfg.ChainNodeEndpoint == "" {
44+
return errBlockchainEndpointNotProvided
4645
}
4746

4847
if cfg.WalletKey = c.globalConfig.GetString(optionNameWalletKey); cfg.WalletKey == "" {
@@ -51,13 +50,13 @@ func (c *command) initNodeFunderCmd() (err error) {
5150

5251
defer c.log.Infof("node-funder done")
5352

54-
logger := funder.WithLoggerOption(c.log)
53+
logOpt := funder.WithLoggerOption(c.log)
5554

5655
addresses := c.globalConfig.GetStringSlice(optionNameAddresses)
5756
if len(addresses) > 0 {
5857
cfg.Addresses = addresses
5958
return c.executePeriodically(ctx, func(ctx context.Context) error {
60-
return funder.Fund(ctx, cfg, nil, nil, logger)
59+
return funder.Fund(ctx, cfg, nil, nil, logOpt)
6160
})
6261
}
6362

@@ -68,7 +67,7 @@ func (c *command) initNodeFunderCmd() (err error) {
6867

6968
cfg.Namespace = namespace
7069
return c.executePeriodically(ctx, func(ctx context.Context) error {
71-
return funder.Fund(ctx, cfg, funderClient, nil, logger)
70+
return funder.Fund(ctx, cfg, funderClient, nil, logOpt)
7271
})
7372
}
7473

@@ -93,7 +92,7 @@ func (c *command) initNodeFunderCmd() (err error) {
9392
}
9493

9594
return c.executePeriodically(ctx, func(ctx context.Context) error {
96-
return funder.Fund(ctx, cfg, nil, nil, logger)
95+
return funder.Fund(ctx, cfg, nil, nil, logOpt)
9796
})
9897
}
9998

@@ -111,7 +110,6 @@ func (c *command) initNodeFunderCmd() (err error) {
111110
cmd.Flags().StringSliceP(optionNameAddresses, "a", nil, "Comma-separated list of Bee node addresses (must start with 0x). Overrides namespace and cluster name.")
112111
cmd.Flags().StringP(optionNameNamespace, "n", "", "Kubernetes namespace. Overrides cluster name if set.")
113112
cmd.Flags().String(optionNameClusterName, "", "Name of the Beekeeper cluster to target. Ignored if a namespace is specified.")
114-
cmd.Flags().String(optionNameChainNodeEndpoint, "", "Endpoint to chain node. Required.")
115113
cmd.Flags().String(optionNameWalletKey, "", "Hex-encoded private key for the Bee node wallet. Required.")
116114
cmd.Flags().Float64(optionNameMinNative, 0, "Minimum amount of chain native coins (xDAI) nodes should have.")
117115
cmd.Flags().Float64(optionNameMinSwarm, 0, "Minimum amount of swarm tokens (xBZZ) nodes should have.")

cmd/beekeeper/cmd/operator.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ import (
1111

1212
func (c *command) initOperatorCmd() error {
1313
const (
14-
optionNameNamespace = "namespace"
15-
optionNameChainNodeEndpoint = "geth-url"
16-
optionNameWalletKey = "wallet-key"
17-
optionNameMinNative = "min-native"
18-
optionNameMinSwarm = "min-swarm"
19-
optionNameTimeout = "timeout"
20-
optionNameLabelSelector = "label-selector"
14+
optionNameNamespace = "namespace"
15+
optionNameWalletKey = "wallet-key"
16+
optionNameMinNative = "min-native"
17+
optionNameMinSwarm = "min-swarm"
18+
optionNameTimeout = "timeout"
19+
optionNameLabelSelector = "label-selector"
2120
)
2221

2322
cmd := &cobra.Command{
@@ -31,9 +30,8 @@ func (c *command) initOperatorCmd() error {
3130
return errors.New("namespace not provided")
3231
}
3332

34-
chainNodeEndpoint := c.globalConfig.GetString(optionNameChainNodeEndpoint)
35-
if chainNodeEndpoint == "" {
36-
return errors.New("chain node endpoint (geth-url) not provided")
33+
if !c.globalConfig.IsSet(optionNameGethURL) {
34+
return errBlockchainEndpointNotProvided
3735
}
3836

3937
walletKey := c.globalConfig.GetString(optionNameWalletKey)
@@ -45,7 +43,7 @@ func (c *command) initOperatorCmd() error {
4543
Log: c.log,
4644
Namespace: namespace,
4745
WalletKey: walletKey,
48-
ChainNodeEndpoint: chainNodeEndpoint,
46+
ChainNodeEndpoint: c.globalConfig.GetString(optionNameGethURL),
4947
NativeToken: c.globalConfig.GetFloat64(optionNameMinNative),
5048
SwarmToken: c.globalConfig.GetFloat64(optionNameMinSwarm),
5149
K8sClient: c.k8sClient,
@@ -57,7 +55,6 @@ func (c *command) initOperatorCmd() error {
5755
}
5856

5957
cmd.Flags().StringP(optionNameNamespace, "n", "", "Kubernetes namespace to scan for scheduled pods.")
60-
cmd.Flags().String(optionNameChainNodeEndpoint, "", "Endpoint to chain node. Required.")
6158
cmd.Flags().String(optionNameWalletKey, "", "Hex-encoded private key for the Bee node wallet. Required.")
6259
cmd.Flags().Float64(optionNameMinNative, 0, "Minimum amount of chain native coins (xDAI) nodes should have.")
6360
cmd.Flags().Float64(optionNameMinSwarm, 0, "Minimum amount of swarm tokens (xBZZ) nodes should have.")

0 commit comments

Comments
 (0)