Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f77bbbd
feat: enable PostageLabel option for all checks creating batches
gacevicljubisa Jan 31, 2025
e8f004d
refactor: use geth-url as global flag
gacevicljubisa Feb 3, 2025
aaaa451
feat(stamper): introduce postage-label as filter
gacevicljubisa Feb 4, 2025
eddd25a
fix(stamper): log price in bzz
gacevicljubisa Feb 4, 2025
e188da5
feat(swap): add offset option for FetchBlockTime
gacevicljubisa Feb 4, 2025
a8fb443
feat: replace postage-amount with postage-ttl
gacevicljubisa Feb 5, 2025
1f3049b
chore: remove unused code
gacevicljubisa Feb 5, 2025
adc4496
chore: bump version to 0.26.0
gacevicljubisa Feb 5, 2025
d37aee5
Merge branch 'master' into postage-option
gacevicljubisa Feb 5, 2025
951694c
chore: go mod tidy
gacevicljubisa Feb 5, 2025
b907c87
fix: resolve deps
gacevicljubisa Feb 5, 2025
9f95aba
chore: update configs
gacevicljubisa Feb 5, 2025
8a77005
chore: update configs
gacevicljubisa Feb 5, 2025
e480b97
fix: set amount to 1000 if price is 0
gacevicljubisa Feb 5, 2025
7200d48
fix(stake): set geth-url
gacevicljubisa Feb 6, 2025
9e55a67
fix(redundancy): set PostageLabel type to string
gacevicljubisa Feb 6, 2025
c74f966
feat: automatically set semantic version number
gacevicljubisa Feb 6, 2025
76b8183
fix(swap): set options offset default to 1
gacevicljubisa Feb 6, 2025
8d38c86
fix(swap): improve FetchBlockTime if offset is too large
gacevicljubisa Feb 6, 2025
9df75f7
chore(swap): add log msg when offset too large
gacevicljubisa Feb 6, 2025
1173172
fix(swap): limit offset to at most of half of the latest block
gacevicljubisa Feb 6, 2025
ff0b7f2
fix(swap): increase offset to 1000
gacevicljubisa Feb 6, 2025
17ef902
Merge branch 'master' into postage-option
gacevicljubisa Feb 6, 2025
7ae4246
Merge branch 'master' into postage-option
gacevicljubisa Feb 6, 2025
caac25e
fix: improve error msgs and flag descriptions
gacevicljubisa Feb 7, 2025
f88f6b4
fix(orchestration): ensure that SwapClient is initialized
gacevicljubisa Feb 7, 2025
66115dd
fix(stamper): ensure that SwapClient is initialized
gacevicljubisa Feb 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ GO ?= go
GOLANGCI_LINT ?= golangci-lint
GOLANGCI_LINT_VERSION ?= v1.61.0
COMMIT ?= "$(shell git describe --long --dirty --always --match "" || true)"
LDFLAGS ?= -s -w -X github.com/ethersphere/beekeeper.commit=$(COMMIT)
VERSION ?= "$(shell git describe --tags --abbrev=0 | cut -c2-)"
LDFLAGS ?= -s -w \
-X github.com/ethersphere/beekeeper.commit="$(COMMIT)" \
-X github.com/ethersphere/beekeeper.version="$(VERSION)"

.PHONY: all
all: build lint vet test-race binary
Expand Down
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ It has following flags:

```console
--cluster-name string cluster name (default "default")
--geth-url string Endpoint to chain node. Required.
--help help for bee-cluster
--timeout duration timeout (default 30m0s)
--wallet-key string Hex-encoded private key for the Bee node wallet. Required.
Expand Down Expand Up @@ -307,7 +306,6 @@ It has the following flags:
--bzz-token-address string BZZ token address (default "0x6aab14fe9cccd64a502d23842d916eb5321c26e7")
--eth-account string ETH account address (default "0x62cab2b3b55f341f10348720ca18063cdb779ad5")
--eth-deposit float ETH amount to deposit
--geth-url string Geth node URL (default "http://geth-swap.geth-swap.dai.internal")
--help help for fund
--password password for generating Ethereum addresses (default "beekeeper")
--timeout duration timeout (default 5m0s)
Expand Down Expand Up @@ -381,7 +379,6 @@ It has following flags:
```console
--addresses strings Comma-separated list of Bee node addresses (must start with 0x). Overrides namespace and cluster name.
--cluster-name string Name of the Beekeeper cluster to target. Ignored if a namespace is specified.
--geth-url string Endpoint to chain node. Required.
--help help for node-funder
--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")
--min-native float Minimum amount of chain native coins (xDAI) nodes should have.
Expand Down Expand Up @@ -417,7 +414,6 @@ Command **node-operator** uses <https://github.com/ethersphere/node-funder> tool
It has following flags:

```console
--geth-url string Endpoint to chain node. Required.
--help help for node-operator
--min-native float Minimum amount of chain native coins (xDAI) nodes should have.
--min-swarm float Minimum amount of swarm tokens (xBZZ) nodes should have.
Expand Down Expand Up @@ -507,7 +503,6 @@ It has following subcommands:
```console
--batch-ids strings Comma separated list of postage batch IDs to top up. If not provided, all batches are topped up.
--cluster-name string Target Beekeeper cluster name.
--geth-url string Geth URL for chain state retrieval.
--help help for topup
--label-selector string Kubernetes label selector for filtering resources (use empty string for all). (default "beekeeper.ethswarm.org/node-funder=true")
--namespace string Kubernetes namespace (overrides cluster name).
Expand Down Expand Up @@ -565,7 +560,6 @@ It has following subcommands:
--batch-ids strings Comma separated list of postage batch IDs to set. If not provided, all batches are set.
--cluster-name string Target Beekeeper cluster name.
--dilution-depth uint16 Number of levels by which to increase the depth of a stamp during dilution. (default 1)
--geth-url string Geth URL for chain state retrieval.
--help help for set
--label-selector string Kubernetes label selector for filtering resources (use empty string for all). (default "beekeeper.ethswarm.org/node-funder=true")
--namespace string Kubernetes namespace (overrides cluster name).
Expand Down Expand Up @@ -603,6 +597,7 @@ example:
--config-git-repo string URL of the Git repository containing configuration files (uses the config-dir if not specified)
--config-git-username string Git username for authentication (required for private repositories)
--enable-k8s Enable Kubernetes client functionality (default true)
--geth-url string URL of the Ethereum-compatible blockchain RPC endpoint
--in-cluster Use the in-cluster Kubernetes client
--kubeconfig string Path to the kubeconfig file (default "~/.kube/config")
--log-verbosity string Log verbosity level (0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=trace) (default "info")
Expand Down
6 changes: 3 additions & 3 deletions cmd/beekeeper/cmd/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
"github.com/spf13/cobra"
)

var errMissingClusterName = fmt.Errorf("cluster name not provided")

func (c *command) initCheckCmd() error {
const (
optionNameCreateCluster = "create-cluster"
Expand Down Expand Up @@ -89,7 +87,8 @@ func (c *command) initCheckCmd() error {

// set global config
checkGlobalConfig := config.CheckGlobalConfig{
Seed: c.globalConfig.GetInt64(optionNameSeed),
Seed: c.globalConfig.GetInt64(optionNameSeed),
GethURL: c.globalConfig.GetString(optionNameGethURL),
}

// run checks
Expand Down Expand Up @@ -124,6 +123,7 @@ func (c *command) initCheckCmd() error {
defer cancelCheck()

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

ch := make(chan error, 1)
go func() {
Expand Down
7 changes: 5 additions & 2 deletions cmd/beekeeper/cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,15 @@ func (c *command) setupCluster(ctx context.Context, clusterName string, startClu
if clusterConfig.IsUsingStaticEndpoints() {
return nil, errors.New("static endpoints are not supported for starting the cluster")
}
if chainNodeEndpoint = c.globalConfig.GetString(optionNameChainNodeEndpoint); chainNodeEndpoint == "" {
return nil, errors.New("chain node endpoint (geth-url) not provided")

if chainNodeEndpoint = c.globalConfig.GetString(optionNameGethURL); chainNodeEndpoint == "" {
return nil, errBlockchainEndpointNotProvided
}

if walletKey = c.globalConfig.GetString(optionNameWalletKey); walletKey == "" {
return nil, errors.New("wallet key not provided")
}

fundOpts = ensureFundingDefaults(clusterConfig.Funding.Export(), c.log)
}

Expand Down
32 changes: 20 additions & 12 deletions cmd/beekeeper/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
httptransport "github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/go-git/go-git/v5/storage/memory"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand All @@ -27,21 +27,27 @@ import (

const (
optionNameConfigDir = "config-dir"
optionNameConfigGitRepo = "config-git-repo"
optionNameConfigGitDir = "config-git-dir"
optionNameConfigGitBranch = "config-git-branch"
optionNameConfigGitUsername = "config-git-username"
optionNameConfigGitDir = "config-git-dir"
optionNameConfigGitPassword = "config-git-password"
optionNameConfigGitRepo = "config-git-repo"
optionNameConfigGitUsername = "config-git-username"
optionNameEnableK8S = "enable-k8s"
optionNameGethURL = "geth-url"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to blockchain-rpc-endpoint

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would require changes in helm charts?

optionNameInCluster = "in-cluster"
optionNameKubeconfig = "kubeconfig"
optionNameLogVerbosity = "log-verbosity"
optionNameLokiEndpoint = "loki-endpoint"
optionNameTracingEnabled = "tracing-enable"
optionNameTracingEndpoint = "tracing-endpoint"
optionNameTracingHost = "tracing-host"
optionNameTracingPort = "tracing-port"
optionNameTracingServiceName = "tracing-service-name"
optionNameEnableK8S = "enable-k8s"
optionNameInCluster = "in-cluster"
optionNameKubeconfig = "kubeconfig"
)

var (
errBlockchainEndpointNotProvided = errors.New("URL of the Ethereum-compatible blockchain RPC endpoint not provided; use the --geth-url flag")
errMissingClusterName = errors.New("cluster name not provided")
)

func init() {
Expand Down Expand Up @@ -154,6 +160,7 @@ func (c *command) initGlobalFlags() {
globalFlags.String(optionNameConfigGitBranch, "main", "Git branch to use for configuration files")
globalFlags.String(optionNameConfigGitUsername, "", "Git username for authentication (required for private repositories)")
globalFlags.String(optionNameConfigGitPassword, "", "Git password or personal access token for authentication (required for private repositories)")
globalFlags.String(optionNameGethURL, "", "URL of the ethereum compatible blockchain RPC endpoint")
globalFlags.String(optionNameLogVerbosity, "info", "Log verbosity level (0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=trace)")
globalFlags.String(optionNameLokiEndpoint, "", "HTTP endpoint for sending logs to Loki (e.g., http://loki.testnet.internal/loki/api/v1/push)")
globalFlags.Bool(optionNameTracingEnabled, false, "Enable tracing for performance monitoring and debugging")
Expand All @@ -169,11 +176,12 @@ func (c *command) initGlobalFlags() {
func (c *command) bindGlobalFlags() error {
for _, flag := range []string{
optionNameConfigDir,
optionNameConfigGitRepo,
optionNameConfigGitBranch,
optionNameConfigGitDir,
optionNameConfigGitUsername,
optionNameConfigGitPassword,
optionNameConfigGitRepo,
optionNameConfigGitUsername,
optionNameGethURL,
optionNameLogVerbosity,
optionNameLokiEndpoint,
} {
Expand Down Expand Up @@ -255,7 +263,7 @@ func (c *command) loadConfigDirectory() error {
// read configuration from git repo
fs := memfs.New()
if _, err := git.Clone(memory.NewStorage(), fs, &git.CloneOptions{
Auth: &httptransport.BasicAuth{
Auth: &http.BasicAuth{
Username: c.globalConfig.GetString(optionNameConfigGitUsername),
Password: c.globalConfig.GetString(optionNameConfigGitPassword),
},
Expand Down Expand Up @@ -412,8 +420,8 @@ func (c *command) executePeriodically(ctx context.Context, action func(ctx conte
}

func (c *command) setSwapClient() (err error) {
if len(c.globalConfig.GetString("geth-url")) > 0 {
gethUrl, err := url.Parse(c.globalConfig.GetString("geth-url"))
if c.globalConfig.IsSet(optionNameGethURL) {
gethUrl, err := url.Parse(c.globalConfig.GetString(optionNameGethURL))
if err != nil {
return fmt.Errorf("parsing Geth URL: %w", err)
}
Expand Down
8 changes: 3 additions & 5 deletions cmd/beekeeper/cmd/create_bee_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import (
)

const (
optionNameClusterName string = "cluster-name"
optionNameChainNodeEndpoint string = "geth-url"
optionNameWalletKey string = "wallet-key"
optionNameTimeout string = "timeout"
optionNameClusterName string = "cluster-name"
optionNameWalletKey string = "wallet-key"
optionNameTimeout string = "timeout"
)

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

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

Expand Down
2 changes: 0 additions & 2 deletions cmd/beekeeper/cmd/fund.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func (c *command) initFundCmd() (err error) {
optionNameAddressCount = "address-count"
optionNameEthAccount = "eth-account"
optionNameBzzTokenAddress = "bzz-token-address"
optionNameGethURL = "geth-url"
optionNameBzzDeposit = "bzz-deposit"
optionNameEthDeposit = "eth-deposit"
optionNameGBzzDeposit = "gBzz-deposit"
Expand Down Expand Up @@ -109,7 +108,6 @@ beekeeper fund --address-create --address-count 2 --bzz-deposit 100.0 --eth-depo
cmd.Flags().Int(optionNameAddressCount, 1, "number of Ethereum addresses to create")
cmd.Flags().String(optionNameBzzTokenAddress, "0x6aab14fe9cccd64a502d23842d916eb5321c26e7", "BZZ token address")
cmd.Flags().String(optionNameEthAccount, "0x62cab2b3b55f341f10348720ca18063cdb779ad5", "ETH account address")
cmd.Flags().String(optionNameGethURL, "http://geth-swap.geth-swap.staging.internal", "Geth node URL")
cmd.Flags().Float64(optionNameBzzDeposit, 0, "BZZ tokens amount to deposit")
cmd.Flags().Float64(optionNameGBzzDeposit, 0, "gBZZ tokens amount to deposit")
cmd.Flags().Float64(optionNameEthDeposit, 0, "ETH amount to deposit")
Expand Down
28 changes: 13 additions & 15 deletions cmd/beekeeper/cmd/node_funder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ const (

func (c *command) initNodeFunderCmd() (err error) {
const (
optionNameAddresses = "addresses"
optionNameNamespace = "namespace"
optionNameChainNodeEndpoint = "geth-url"
optionNameWalletKey = "wallet-key"
optionNameMinNative = "min-native"
optionNameMinSwarm = "min-swarm"
optionNameTimeout = "timeout"
optionNameLabelSelector = "label-selector"
optionNameAddresses = "addresses"
optionNameNamespace = "namespace"
optionNameWalletKey = "wallet-key"
optionNameMinNative = "min-native"
optionNameMinSwarm = "min-swarm"
optionNameTimeout = "timeout"
optionNameLabelSelector = "label-selector"
)

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

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

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

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

logger := funder.WithLoggerOption(c.log)
logOpt := funder.WithLoggerOption(c.log)

addresses := c.globalConfig.GetStringSlice(optionNameAddresses)
if len(addresses) > 0 {
cfg.Addresses = addresses
return c.executePeriodically(ctx, func(ctx context.Context) error {
return funder.Fund(ctx, cfg, nil, nil, logger)
return funder.Fund(ctx, cfg, nil, nil, logOpt)
})
}

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

cfg.Namespace = namespace
return c.executePeriodically(ctx, func(ctx context.Context) error {
return funder.Fund(ctx, cfg, funderClient, nil, logger)
return funder.Fund(ctx, cfg, funderClient, nil, logOpt)
})
}

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

return c.executePeriodically(ctx, func(ctx context.Context) error {
return funder.Fund(ctx, cfg, nil, nil, logger)
return funder.Fund(ctx, cfg, nil, nil, logOpt)
})
}

Expand All @@ -111,7 +110,6 @@ func (c *command) initNodeFunderCmd() (err error) {
cmd.Flags().StringSliceP(optionNameAddresses, "a", nil, "Comma-separated list of Bee node addresses (must start with 0x). Overrides namespace and cluster name.")
cmd.Flags().StringP(optionNameNamespace, "n", "", "Kubernetes namespace. Overrides cluster name if set.")
cmd.Flags().String(optionNameClusterName, "", "Name of the Beekeeper cluster to target. Ignored if a namespace is specified.")
cmd.Flags().String(optionNameChainNodeEndpoint, "", "Endpoint to chain node. Required.")
cmd.Flags().String(optionNameWalletKey, "", "Hex-encoded private key for the Bee node wallet. Required.")
cmd.Flags().Float64(optionNameMinNative, 0, "Minimum amount of chain native coins (xDAI) nodes should have.")
cmd.Flags().Float64(optionNameMinSwarm, 0, "Minimum amount of swarm tokens (xBZZ) nodes should have.")
Expand Down
21 changes: 9 additions & 12 deletions cmd/beekeeper/cmd/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ import (

func (c *command) initOperatorCmd() error {
const (
optionNameNamespace = "namespace"
optionNameChainNodeEndpoint = "geth-url"
optionNameWalletKey = "wallet-key"
optionNameMinNative = "min-native"
optionNameMinSwarm = "min-swarm"
optionNameTimeout = "timeout"
optionNameLabelSelector = "label-selector"
optionNameNamespace = "namespace"
optionNameWalletKey = "wallet-key"
optionNameMinNative = "min-native"
optionNameMinSwarm = "min-swarm"
optionNameTimeout = "timeout"
optionNameLabelSelector = "label-selector"
)

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

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

walletKey := c.globalConfig.GetString(optionNameWalletKey)
Expand All @@ -45,7 +43,7 @@ func (c *command) initOperatorCmd() error {
Log: c.log,
Namespace: namespace,
WalletKey: walletKey,
ChainNodeEndpoint: chainNodeEndpoint,
ChainNodeEndpoint: c.globalConfig.GetString(optionNameGethURL),
NativeToken: c.globalConfig.GetFloat64(optionNameMinNative),
SwarmToken: c.globalConfig.GetFloat64(optionNameMinSwarm),
K8sClient: c.k8sClient,
Expand All @@ -57,7 +55,6 @@ func (c *command) initOperatorCmd() error {
}

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