Skip to content

Commit 8f71335

Browse files
committed
Minor adjustments
1 parent 07d3ea4 commit 8f71335

File tree

7 files changed

+76
-103
lines changed

7 files changed

+76
-103
lines changed

bindings/node/deposit.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import (
1515
)
1616

1717
type NodeDeposit struct {
18-
BondAmount *big.Int `json:"bondAmount"`
19-
UseExpressTicket bool `json:"useExpressTicket"`
20-
ValidatorPubkey []byte `json:"validatorPubkey"`
21-
ValidatorSignature []byte `json:"validatorSignature"`
22-
DepositDataRoot common.Hash `json:"depositDataRoot"`
18+
BondAmount *big.Int `json:"bondAmount"`
19+
UseExpressTicket bool `json:"useExpressTicket"`
20+
ValidatorPubkey []byte `json:"validatorPubkey"`
21+
ValidatorSignature []byte `json:"validatorSignature"`
22+
DepositDataRoot common.Hash `json:"depositDataRoot"`
2323
}
2424

2525
type Deposits []NodeDeposit

rocketpool-cli/megapool/commands.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ func RegisterCommands(app *cli.App, name string, aliases []string) {
4545
},
4646
cli.UintFlag{
4747
Name: "count, c",
48-
Usage: "Number of deposits to make (default: 1)",
49-
Value: 1,
48+
Usage: "Number of deposits to make",
49+
Value: 0,
5050
},
5151
},
5252
Action: func(c *cli.Context) error {
@@ -57,13 +57,12 @@ func RegisterCommands(app *cli.App, name string, aliases []string) {
5757
}
5858

5959
// Validate count
60-
count := c.Uint("count")
61-
if count == 0 {
60+
if c.Uint("count") == 0 {
6261
return fmt.Errorf("Count must be greater than 0")
6362
}
6463

6564
// Run
66-
return nodeMegapoolDeposit(c, uint64(count))
65+
return nodeMegapoolDeposit(c)
6766

6867
},
6968
},

rocketpool-cli/megapool/deposit.go

Lines changed: 31 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package megapool
33
import (
44
"fmt"
55
"math/big"
6+
"strconv"
67

78
"github.com/rocket-pool/smartnode/bindings/utils/eth"
89
"github.com/urfave/cli"
@@ -27,7 +28,7 @@ const (
2728
maxAlertItems int = 3
2829
)
2930

30-
func nodeMegapoolDeposit(c *cli.Context, count uint64) error {
31+
func nodeMegapoolDeposit(c *cli.Context) error {
3132

3233
// Get RP client
3334
rp, err := rocketpool.NewClientFromCtx(c).WithReady()
@@ -64,24 +65,6 @@ func nodeMegapoolDeposit(c *cli.Context, count uint64) error {
6465
return nil
6566
}
6667

67-
/*
68-
// Check if the fee distributor has been initialized
69-
isInitializedResponse, err := rp.IsFeeDistributorInitialized()
70-
if err != nil {
71-
return err
72-
}
73-
if !isInitializedResponse.IsInitialized {
74-
fmt.Println("Your fee distributor has not been initialized yet so you cannot create a new validator.\nPlease run `rocketpool node initialize-fee-distributor` to initialize it first.")
75-
return nil
76-
}
77-
78-
// Post a warning about fee distribution
79-
if !(c.Bool("yes") || prompt.Confirm(fmt.Sprintf("%sNOTE: By creating a new validator, your node will automatically claim and distribute any balance you have in your fee distributor contract. If you don't want to claim your balance at this time, you should not create a new minipool.%s\nWould you like to continue?", colorYellow, colorReset))) {
80-
fmt.Println("Cancelled.")
81-
return nil
82-
}
83-
*/
84-
8568
useExpressTicket := false
8669

8770
var wg errgroup.Group
@@ -118,16 +101,22 @@ func nodeMegapoolDeposit(c *cli.Context, count uint64) error {
118101
return err
119102
}
120103

121-
if count > 1 {
122-
if !(c.Bool("yes") || prompt.Confirm(fmt.Sprintf("%sNOTE: You are about to create %d new megapool validators, each with a %.0f ETH deposit (total: %.0f ETH).%s\nWould you like to continue?", colorYellow, count, amount, amount*float64(count), colorReset))) {
123-
fmt.Println("Cancelled.")
124-
return nil
125-
}
126-
} else {
127-
if !(c.Bool("yes") || prompt.Confirm(fmt.Sprintf("%sNOTE: You are about to create a new megapool validator with a %.0f ETH deposit.%s\nWould you like to continue?", colorYellow, amount, colorReset))) {
128-
fmt.Println("Cancelled.")
129-
return nil
104+
count := c.Uint64("count")
105+
106+
// If the count was not provided, prompt the user for the number of deposits
107+
for count == 0 {
108+
countStr := prompt.Prompt("How many validators would you like to create?", "^\\d+$", "Invalid number.")
109+
count, err = strconv.ParseUint(countStr, 10, 64)
110+
if err != nil {
111+
fmt.Println("Invalid number. Please try again.")
112+
continue
130113
}
114+
break
115+
}
116+
117+
if !(c.Bool("yes") || prompt.Confirm(fmt.Sprintf("%sNOTE: You are about to create %d new megapool validators, each with a %.0f ETH deposit (total: %.0f ETH).%s\nWould you like to continue?", colorYellow, count, amount, amount*float64(count), colorReset))) {
118+
fmt.Println("Cancelled.")
119+
return nil
131120
}
132121

133122
fmt.Printf("There are %d validator(s) on the express queue.\n", queueDetails.ExpressLength)
@@ -146,7 +135,7 @@ func nodeMegapoolDeposit(c *cli.Context, count uint64) error {
146135
fmt.Printf("You have %d express tickets available.", expressTicketCount)
147136
fmt.Println()
148137
// Prompt for confirmation
149-
if c.Bool("yes") || prompt.Confirm("Would you like to use an express ticket?") {
138+
if c.Bool("yes") || prompt.Confirm("Would you like to use your express tickets?") {
150139
useExpressTicket = true
151140
}
152141
}
@@ -166,11 +155,8 @@ func nodeMegapoolDeposit(c *cli.Context, count uint64) error {
166155
return err
167156
}
168157
if !canDeposit.CanDeposit {
169-
if count > 1 {
170-
fmt.Printf("Cannot make %d node deposits:\n", count)
171-
} else {
172-
fmt.Println("Cannot make node deposit:")
173-
}
158+
fmt.Printf("Cannot make %d node deposits:\n", count)
159+
174160
if canDeposit.InsufficientBalanceWithoutCredit {
175161
nodeBalance := eth.WeiToEth(canDeposit.NodeBalance)
176162
fmt.Printf("There is not enough ETH in the staking pool to use your credit balance (it needs at least 1 ETH but only has %.2f ETH) and you don't have enough ETH in your wallet (%.6f ETH) to cover the deposit amount yourself. If you want to continue creating a minipool, you will either need to wait for the staking pool to have more ETH deposited or add more ETH to your node wallet.", eth.WeiToEth(canDeposit.DepositBalance), nodeBalance)
@@ -246,28 +232,17 @@ func nodeMegapoolDeposit(c *cli.Context, count uint64) error {
246232
}
247233

248234
// Prompt for confirmation
249-
if count > 1 {
250-
if !(c.Bool("yes") || prompt.Confirm(fmt.Sprintf(
251-
"You are about to deposit %.6f ETH to create %d new megapool validators (%.6f ETH total).\n"+
252-
"%sARE YOU SURE YOU WANT TO DO THIS? Exiting these validators and retrieving your capital cannot be done until each validator has been *active* on the Beacon Chain for 256 epochs (approx. 27 hours).%s\n",
253-
math.RoundDown(eth.WeiToEth(amountWei), 6),
254-
count,
255-
math.RoundDown(eth.WeiToEth(amountWei), 6)*float64(count),
256-
colorYellow,
257-
colorReset))) {
258-
fmt.Println("Cancelled.")
259-
return nil
260-
}
261-
} else {
262-
if !(c.Bool("yes") || prompt.Confirm(fmt.Sprintf(
263-
"You are about to deposit %.6f ETH to create a new megapool validator.\n"+
264-
"%sARE YOU SURE YOU WANT TO DO THIS? Exiting this validator and retrieving your capital cannot be done until the validator has been *active* on the Beacon Chain for 256 epochs (approx. 27 hours).%s\n",
265-
math.RoundDown(eth.WeiToEth(amountWei), 6),
266-
colorYellow,
267-
colorReset))) {
268-
fmt.Println("Cancelled.")
269-
return nil
270-
}
235+
236+
if !(c.Bool("yes") || prompt.Confirm(fmt.Sprintf(
237+
"You are about to deposit %.6f ETH to create %d new megapool validators (%.6f ETH total).\n"+
238+
"%sARE YOU SURE YOU WANT TO DO THIS? Exiting these validators and retrieving your capital cannot be done until each validator has been *active* on the Beacon Chain for 256 epochs (approx. 27 hours).%s\n",
239+
math.RoundDown(eth.WeiToEth(amountWei), 6),
240+
count,
241+
math.RoundDown(eth.WeiToEth(amountWei), 6)*float64(count),
242+
colorYellow,
243+
colorReset))) {
244+
fmt.Println("Cancelled.")
245+
return nil
271246
}
272247

273248
// Make deposit(s)

rocketpool-cli/megapool/dissolve-validator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func dissolveValidator(c *cli.Context) error {
3838
// Get Megapool status
3939
status, err := rp.MegapoolStatus(false)
4040
if err != nil {
41-
return err
41+
return err
4242
}
4343

4444
validatorsInPrestake := []api.MegapoolValidatorDetails{}

shared/services/rocketpool/node.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,6 @@ func (c *Client) CanNodeDeposits(count uint64, amountWei *big.Int, minFee float6
729729
return response, nil
730730
}
731731

732-
733732
// Make a node deposit
734733
func (c *Client) NodeDeposit(amountWei *big.Int, minFee float64, salt *big.Int, useCreditBalance bool, useExpressTicket bool, submit bool) (api.NodeDepositResponse, error) {
735734
responseBytes, err := c.callAPI(fmt.Sprintf("node deposit %s %f %s %t %t %t", amountWei.String(), minFee, salt.String(), useCreditBalance, useExpressTicket, submit))

shared/services/state/network-state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ func (m *NetworkStateManager) createNetworkState(slotNumber uint64) (*NetworkSta
301301
if err != nil {
302302
return err
303303
}
304-
megapoolDetails, err := rpstate.GetNodeMegapoolDetails(m.rp, nodeAddress, opts)
304+
megapoolDetails, err := rpstate.GetNodeMegapoolDetails(m.rp, nodeAddress, opts)
305305
if err != nil {
306306
return err
307307
}

shared/types/api/node.go

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -428,22 +428,22 @@ type CanNodeWithdrawRplv1_3_1Response struct {
428428
}
429429

430430
type CanNodeDepositResponse struct {
431-
Status string `json:"status"`
432-
Error string `json:"error"`
433-
CanDeposit bool `json:"canDeposit"`
434-
CreditBalance *big.Int `json:"creditBalance"`
435-
DepositBalance *big.Int `json:"depositBalance"`
436-
CanUseCredit bool `json:"canUseCredit"`
437-
NodeBalance *big.Int `json:"nodeBalance"`
438-
InsufficientBalance bool `json:"insufficientBalance"`
439-
InsufficientBalanceWithoutCredit bool `json:"insufficientBalanceWithoutCredit"`
440-
InvalidAmount bool `json:"invalidAmount"`
441-
DepositDisabled bool `json:"depositDisabled"`
442-
InConsensus bool `json:"inConsensus"`
443-
MinipoolAddress common.Address `json:"minipoolAddress"`
444-
MegapoolAddress common.Address `json:"megapoolAddress"`
431+
Status string `json:"status"`
432+
Error string `json:"error"`
433+
CanDeposit bool `json:"canDeposit"`
434+
CreditBalance *big.Int `json:"creditBalance"`
435+
DepositBalance *big.Int `json:"depositBalance"`
436+
CanUseCredit bool `json:"canUseCredit"`
437+
NodeBalance *big.Int `json:"nodeBalance"`
438+
InsufficientBalance bool `json:"insufficientBalance"`
439+
InsufficientBalanceWithoutCredit bool `json:"insufficientBalanceWithoutCredit"`
440+
InvalidAmount bool `json:"invalidAmount"`
441+
DepositDisabled bool `json:"depositDisabled"`
442+
InConsensus bool `json:"inConsensus"`
443+
MinipoolAddress common.Address `json:"minipoolAddress"`
444+
MegapoolAddress common.Address `json:"megapoolAddress"`
445445
ValidatorPubkeys []rptypes.ValidatorPubkey `json:"validatorPubkeys"`
446-
GasInfo rocketpool.GasInfo `json:"gasInfo"`
446+
GasInfo rocketpool.GasInfo `json:"gasInfo"`
447447
}
448448
type NodeDepositResponse struct {
449449
Status string `json:"status"`
@@ -455,30 +455,30 @@ type NodeDepositResponse struct {
455455
}
456456

457457
type CanNodeDepositsResponse struct {
458-
Status string `json:"status"`
459-
Error string `json:"error"`
460-
CanDeposit bool `json:"canDeposit"`
461-
CreditBalance *big.Int `json:"creditBalance"`
462-
DepositBalance *big.Int `json:"depositBalance"`
463-
CanUseCredit bool `json:"canUseCredit"`
464-
NodeBalance *big.Int `json:"nodeBalance"`
465-
InsufficientBalance bool `json:"insufficientBalance"`
466-
InsufficientBalanceWithoutCredit bool `json:"insufficientBalanceWithoutCredit"`
467-
InvalidAmount bool `json:"invalidAmount"`
468-
DepositDisabled bool `json:"depositDisabled"`
469-
InConsensus bool `json:"inConsensus"`
470-
MinipoolAddress common.Address `json:"minipoolAddress"`
471-
MegapoolAddress common.Address `json:"megapoolAddress"`
458+
Status string `json:"status"`
459+
Error string `json:"error"`
460+
CanDeposit bool `json:"canDeposit"`
461+
CreditBalance *big.Int `json:"creditBalance"`
462+
DepositBalance *big.Int `json:"depositBalance"`
463+
CanUseCredit bool `json:"canUseCredit"`
464+
NodeBalance *big.Int `json:"nodeBalance"`
465+
InsufficientBalance bool `json:"insufficientBalance"`
466+
InsufficientBalanceWithoutCredit bool `json:"insufficientBalanceWithoutCredit"`
467+
InvalidAmount bool `json:"invalidAmount"`
468+
DepositDisabled bool `json:"depositDisabled"`
469+
InConsensus bool `json:"inConsensus"`
470+
MinipoolAddress common.Address `json:"minipoolAddress"`
471+
MegapoolAddress common.Address `json:"megapoolAddress"`
472472
ValidatorPubkeys []rptypes.ValidatorPubkey `json:"validatorPubkeys"`
473-
GasInfo rocketpool.GasInfo `json:"gasInfo"`
473+
GasInfo rocketpool.GasInfo `json:"gasInfo"`
474474
}
475475

476476
type NodeDepositsResponse struct {
477-
Status string `json:"status"`
478-
Error string `json:"error"`
479-
TxHash common.Hash `json:"txHash"`
477+
Status string `json:"status"`
478+
Error string `json:"error"`
479+
TxHash common.Hash `json:"txHash"`
480480
ValidatorPubkeys []rptypes.ValidatorPubkey `json:"validatorPubkeys"`
481-
ScrubPeriod time.Duration `json:"scrubPeriod"`
481+
ScrubPeriod time.Duration `json:"scrubPeriod"`
482482
}
483483

484484
type CanCreateVacantMinipoolResponse struct {

0 commit comments

Comments
 (0)