beekeeper icon indicating copy to clipboard operation
beekeeper copied to clipboard

feat(cmd): implement staking command

Open akrem-chabchoub opened this issue 3 months ago • 0 comments

PR Description: Implement Staking Feature for Bee Nodes

Implements: #517

Overview

This PR implements a comprehensive staking feature for Beekeeper that allows users to manage BZZ stakes on Bee nodes through a centralized CLI interface. The feature supports both Kubernetes namespace targeting and Beekeeper cluster targeting with parallel execution and robust error handling.

Changes

  • Added beekeeper stake deposit command to deposit BZZ stake on targeted Bee nodes
  • Added beekeeper stake get command to retrieve current stake amounts from targeted nodes
  • Added beekeeper stake withdraw command to withdraw (migrate) stake from targeted nodes
  • Implemented cluster mode targeting with --cluster-name flag
  • Implemented namespace mode targeting with --namespace and --label-selector flags
  • Added node group filtering with --node-groups flag (defaults to "bee" nodes)
  • Added parallel execution support with --parallel flag for better performance
  • Implemented comprehensive error handling with user-friendly messages
  • Added proper K8s client initialization with PreRunE for namespace mode
  • Refactored code to eliminate duplication and improve maintainability

Usage Examples

# Deposit 1000 WEI stake on all bee nodes in a cluster
beekeeper stake deposit --amount 1000 --cluster-name local-dns

# Get current stake amounts from nodes in a namespace
beekeeper stake get --namespace local --label-selector app=bee

# Withdraw stake from specific node groups
beekeeper stake withdraw --cluster-name local-dns --node-groups bee,light

# Use parallel execution for better performance
beekeeper stake deposit --amount 5000 --cluster-name local-dns --parallel 10

Technical Details

  • Uses existing pkg/bee/api/stake.go API endpoints
  • Leverages pkg/orchestration for cluster management
  • Integrates with pkg/node for namespace-based discovery
  • Utilizes math/big for precise WEI amount handling
  • Implements parallel processing with goroutines and channels
  • Provides comprehensive input validation and error handling

akrem-chabchoub avatar Sep 01 '25 16:09 akrem-chabchoub