-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Feature Request: Implement Staking Feature for Bee Nodes
Description
Beekeeper currently supports various operations on Bee node clusters, such as funding, restarting, and managing postage stamps. To extend its capabilities for managing Swarm Bee nodes, I propose adding a new "staking" feature. This would allow users to stake BZZ on Bee nodes, retrieve current stake values, and unstake, all through Beekeeper's orchestration.
Implementing this in Beekeeper would streamline operations for cluster management, similar to how node-funder handles funding or stamper manages postage batches.
Proposed Functionality
Add a new top-level command stake with subcommands for the core operations:
beekeeper stake deposit: Stake a specified amount of BZZ in WEI on targeted nodes.beekeeper stake get: Retrieve the current staked amount for targeted nodes.beekeeper stake withdraw: Unstake (withdraw) from targeted nodes.
These operations should leverage the Bee debug API endpoints:
- GET /stake: Retrieve staked amount.
- POST /stake/{amount}: Deposit stake.
- DELETE /stake: Withdraw stake.
Filtering should align with existing Beekeeper features:
- Support targeting entire clusters defined in the Beekeeper config (e.g., via
--cluster-nameflag). Filter by node groups (e.g.,--node-groupsflag). - Support targeting entire Kubernetes namespace using label selectors (e.g.,
--label-selectorflag, defaulting to something likeapp.kubernetes.io/name=bee, but customizable).
Operations should be parallelized where possible (e.g., using goroutines for concurrent API calls to multiple nodes), and include options for verbosity, and error handling (e.g., retry on failed API calls).
Reference Implementations
Simple bash scripts demonstrating the API interactions are available in the ethersphere/bee-scripts repo:
- stake-get.sh: Retrieves stake values from a list of nodes.
- stake-del.sh: Unstakes from nodes.
- stake.sh: Stakes a fixed amount on nodes.
These scripts fetch node debug URLs via Kubernetes ingress and perform the CURL operations. Beekeeper could abstract this by integrating with its existing Kubernetes client and node discovery logic.
Benefits
- Centralizes staking management in Beekeeper, reducing reliance on ad-hoc scripts.
- Enables automated staking in integration tests or production clusters.