Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1 Inform users who are missing out on bonus commission #713

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 24 additions & 7 deletions rocketpool-cli/node/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ func getStatus(c *cli.Context) error {

// Fee distributor details
fmt.Printf("%s=== Fee Distributor and Smoothing Pool ===%s\n", colorGreen, colorReset)
fmt.Printf("The node's fee distributor %s%s%s has a balance of %.6f ETH.\n", colorBlue, status.FeeRecipientInfo.FeeDistributorAddress.Hex(), colorReset, math.RoundDown(eth.WeiToEth(status.FeeDistributorBalance), 6))
if cfg.IsNativeMode && !status.FeeRecipientInfo.IsInSmoothingPool && !status.FeeRecipientInfo.IsInOptOutCooldown {
fmt.Printf("%sNOTE: You are in Native Mode; you MUST ensure that your Validator Client is using this address as its fee recipient!%s\n", colorYellow, colorReset)
}
if !status.IsFeeDistributorInitialized {
fmt.Printf("\n%sThe fee distributor hasn't been initialized yet. When you are able, please initialize it with `rocketpool node initialize-fee-distributor`.%s\n", colorYellow, colorReset)
}
if status.FeeRecipientInfo.IsInSmoothingPool {
fmt.Printf(
"The node is currently opted into the Smoothing Pool (%s%s%s).\n",
Expand All @@ -279,14 +286,24 @@ func getStatus(c *cli.Context) error {
}
} else {
fmt.Printf("The node is not opted into the Smoothing Pool.\nTo learn more about the Smoothing Pool, please visit %s.\n", smoothingPoolLink)
}
// Count the number of 8 ETH, <10% commission minipools
poolsWithMissingCommission := 0
leb16wei := new(big.Int)
leb16wei.SetString("16000000000000000000", 10)
for _, minipool := range status.Minipools {
if minipool.Node.DepositBalance.Cmp(leb16wei) < 0 && minipool.Node.Fee*100 < 10 {
poolsWithMissingCommission++
}
}
if poolsWithMissingCommission == 1 {
fmt.Printf("%sYou have %d minipool that would earn extra commission if you opted into the smoothing pool!%s\n", colorYellow, poolsWithMissingCommission, colorReset)
fmt.Println("See https://rpips.rocketpool.net/RPIPs/RPIP-62 for more information about bonus commission, or run `rocketpool node join-smoothing-pool` to opt in.")
}
if poolsWithMissingCommission > 1 {
fmt.Printf("%sYou have %d minipools that would earn extra commission if you opted into the smoothing pool!%s\n", colorYellow, poolsWithMissingCommission, colorReset)
fmt.Println("See https://rpips.rocketpool.net/RPIPs/RPIP-62 for more information about bonus commission, or run `rocketpool node join-smoothing-pool` to opt in.")
}

fmt.Printf("The node's fee distributor %s%s%s has a balance of %.6f ETH.\n", colorBlue, status.FeeRecipientInfo.FeeDistributorAddress.Hex(), colorReset, math.RoundDown(eth.WeiToEth(status.FeeDistributorBalance), 6))
if cfg.IsNativeMode && !status.FeeRecipientInfo.IsInSmoothingPool && !status.FeeRecipientInfo.IsInOptOutCooldown {
fmt.Printf("%sNOTE: You are in Native Mode; you MUST ensure that your Validator Client is using this address as its fee recipient!%s\n", colorYellow, colorReset)
}
if !status.IsFeeDistributorInitialized {
fmt.Printf("\n%sThe fee distributor hasn't been initialized yet. When you are able, please initialize it with `rocketpool node initialize-fee-distributor`.%s\n", colorYellow, colorReset)
}

fmt.Println()
Expand Down
2 changes: 1 addition & 1 deletion rocketpool/api/minipool/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func getStatus(c *cli.Context) (*api.MinipoolStatusResponse, error) {
if err != nil {
return nil, err
}
details, err := getNodeMinipoolDetails(rp, bc, nodeAccount.Address, &legacyMinipoolQueueAddress)
details, err := GetNodeMinipoolDetails(rp, bc, nodeAccount.Address, &legacyMinipoolQueueAddress)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion rocketpool/api/minipool/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func validateMinipoolOwner(mp minipool.Minipool, nodeAddress common.Address) err
}

// Get all node minipool details
func getNodeMinipoolDetails(rp *rocketpool.RocketPool, bc beacon.Client, nodeAddress common.Address, legacyMinipoolQueueAddress *common.Address) ([]api.MinipoolDetails, error) {
func GetNodeMinipoolDetails(rp *rocketpool.RocketPool, bc beacon.Client, nodeAddress common.Address, legacyMinipoolQueueAddress *common.Address) ([]api.MinipoolDetails, error) {

// Data
var wg1 errgroup.Group
Expand Down
24 changes: 24 additions & 0 deletions rocketpool/api/node/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/urfave/cli"
"golang.org/x/sync/errgroup"

mp "github.com/rocket-pool/smartnode/rocketpool/api/minipool"
"github.com/rocket-pool/smartnode/rocketpool/api/pdao"
"github.com/rocket-pool/smartnode/shared/services"
"github.com/rocket-pool/smartnode/shared/services/alerting"
Expand All @@ -41,6 +42,9 @@ func getStatus(c *cli.Context) (*api.NodeStatusResponse, error) {
if err := services.RequireRocketStorage(c); err != nil {
return nil, err
}
if err := services.RequireBeaconClientSynced(c); err != nil {
return nil, err
}
cfg, err := services.GetConfig(c)
if err != nil {
return nil, err
Expand Down Expand Up @@ -70,6 +74,9 @@ func getStatus(c *cli.Context) (*api.NodeStatusResponse, error) {
response.PenalizedMinipools = map[common.Address]uint64{}
response.NodeRPLLocked = big.NewInt(0)

// Get the legacy MinipoolQueue contract address
legacyMinipoolQueueAddress := cfg.Smartnode.GetV110MinipoolQueueAddress()

// Get node account
nodeAccount, err := w.GetNodeAccount()
if err != nil {
Expand All @@ -81,6 +88,23 @@ func getStatus(c *cli.Context) (*api.NodeStatusResponse, error) {
// Sync
var wg errgroup.Group

wg.Go(func() error {
mpDetails, err := mp.GetNodeMinipoolDetails(rp, bc, nodeAccount.Address, &legacyMinipoolQueueAddress)
if err == nil {
response.Minipools = mpDetails
}
return err
})

wg.Go(func() error {
delegate, err := rp.GetContract("rocketMinipoolDelegate", nil)
if err != nil {
return fmt.Errorf("Error getting latest minipool delegate contract: %w", err)
}
response.LatestDelegate = *delegate.Address
return err
})

// Get node trusted status
wg.Go(func() error {
trusted, err := trustednode.GetMemberExists(rp, nodeAccount.Address, nil)
Expand Down
8 changes: 5 additions & 3 deletions shared/types/api/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ type NodeStatusResponse struct {
ProposalVotes []SnapshotProposalVote `json:"proposalVotes"`
ActiveSnapshotProposals []SnapshotProposal `json:"activeSnapshotProposals"`
} `json:"snapshotResponse"`
Alerts []NodeAlert `json:"alerts"`
SignallingAddress common.Address `json:"signallingAddress"`
SignallingAddressFormatted string `json:"signallingAddressFormatted"`
Alerts []NodeAlert `json:"alerts"`
SignallingAddress common.Address `json:"signallingAddress"`
SignallingAddressFormatted string `json:"signallingAddressFormatted"`
Minipools []MinipoolDetails `json:"minipools"`
LatestDelegate common.Address `json:"latestDelegate"`
}

type NodeAlert struct {
Expand Down
Loading