Skip to content

Commit f04cf58

Browse files
authored
Merge pull request #466 from rocket-pool/dev_v2
Move dev into v2
2 parents 1517f11 + b3718ea commit f04cf58

24 files changed

Lines changed: 249 additions & 241 deletions

install/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ install() {
361361
{ cp -r "$PACKAGE_FILES_PATH/override" "$RP_SHARE_PATH" || fail "Could not copy override folder to the Rocket Pool system directory."; } >&2
362362
{ cp -r "$PACKAGE_FILES_PATH/scripts" "$RP_SHARE_PATH" || fail "Could not copy scripts folder to the Rocket Pool system directory."; } >&2
363363
{ cp -r "$PACKAGE_FILES_PATH/templates" "$RP_SHARE_PATH" || fail "Could not copy templates folder to the Rocket Pool system directory."; } >&2
364-
{ find "$HD_SHARE_PATH/scripts" -name "*.sh" -exec chmod +x {} \; 2>/dev/null || fail "Could not set executable permissions on package files."; } >&2
364+
{ find "$RP_SHARE_PATH/scripts" -name "*.sh" -exec chmod +x {} \; 2>/dev/null || fail "Could not set executable permissions on package files."; } >&2
365365

366366

367367
# Clean up unnecessary files from old installations

src/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
github.com/prometheus/client_golang v1.18.0
2929
github.com/prysmaticlabs/prysm/v4 v4.2.1
3030
github.com/rivo/tview v0.0.0-20230208211350-7dfff1ce7854
31-
github.com/rocket-pool/node-manager-core v0.1.1-0.20240324201808-55b9188c549b
31+
github.com/rocket-pool/node-manager-core v0.1.1-0.20240325035720-824357e2dad7
3232
github.com/rocket-pool/rocketpool-go v1.8.3-0.20240324192746-e467edda77d1
3333
github.com/shirou/gopsutil/v3 v3.24.2
3434
github.com/tyler-smith/go-bip39 v1.1.0

src/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,8 @@ github.com/rocket-pool/batch-query v1.0.0 h1:5HejmT1n1fIdLIqUhTNwbkG2PGOPl3IVjCp
577577
github.com/rocket-pool/batch-query v1.0.0/go.mod h1:d1CmxShzk0fioJ4yX0eFGhz2an1odnW/LZ2cp3eDGIQ=
578578
github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd h1:p9KuetSKB9nte9I/MkkiM3pwKFVQgqxxPTQ0y56Ff6s=
579579
github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd/go.mod h1:UE9fof8P7iESVtLn1K9CTSkNRYVFHZHlf96RKbU33kA=
580-
github.com/rocket-pool/node-manager-core v0.1.1-0.20240324201808-55b9188c549b h1:YGc9XdzpxvmGPAF38wPdOZcZFhKHxGoP4Uq6M5+vh1A=
581-
github.com/rocket-pool/node-manager-core v0.1.1-0.20240324201808-55b9188c549b/go.mod h1:mUIsrmHwbpBwYo1Gp8nPmQ6SeNGxxgXMssT83eicDso=
580+
github.com/rocket-pool/node-manager-core v0.1.1-0.20240325035720-824357e2dad7 h1:u/SGtrPcGDKZmH+wS9XEP5+T/UrwtrwIwqTV7CXS/aE=
581+
github.com/rocket-pool/node-manager-core v0.1.1-0.20240325035720-824357e2dad7/go.mod h1:mUIsrmHwbpBwYo1Gp8nPmQ6SeNGxxgXMssT83eicDso=
582582
github.com/rocket-pool/rocketpool-go v1.8.3-0.20240324192746-e467edda77d1 h1:tl639aAfFraUVH33mCEth/oLyHiLGyW/sVm9NOb1FBs=
583583
github.com/rocket-pool/rocketpool-go v1.8.3-0.20240324192746-e467edda77d1/go.mod h1:NOI4fBev5mMwZejmAWVOl/ysYLzfHne3b/sAXb2Dy1w=
584584
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=

src/rocketpool-cli/rocketpool-cli.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ func validateFlags(c *cli.Context) error {
200200
return fmt.Errorf("Invalid nonce: %s\n", customNonce)
201201
}
202202
snCtx.Nonce = nonce
203+
} else {
204+
snCtx.Nonce = big.NewInt(0)
203205
}
204206

205207
// Make sure the config directory exists

src/rocketpool-daemon/node/defend-pdao-props.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,29 @@ type DefendPdaoProps struct {
5151
}
5252

5353
func NewDefendPdaoProps(ctx context.Context, sp *services.ServiceProvider, logger log.ColorLogger) *DefendPdaoProps {
54+
cfg := sp.GetConfig()
55+
log := &logger
56+
maxFee, maxPriorityFee := getAutoTxInfo(cfg, log)
5457
return &DefendPdaoProps{
5558
ctx: ctx,
5659
sp: sp,
57-
log: &logger,
60+
log: log,
61+
cfg: cfg,
62+
w: sp.GetWallet(),
63+
rp: sp.GetRocketPool(),
64+
bc: sp.GetBeaconClient(),
65+
rs: cfg.GetRocketPoolResources(),
66+
gasThreshold: cfg.AutoTxGasThreshold.Value,
67+
maxFee: maxFee,
68+
maxPriorityFee: maxPriorityFee,
5869
lastScannedBlock: nil,
70+
intervalSize: big.NewInt(int64(config.EventLogInterval)),
5971
}
6072
}
6173

6274
// Defend pDAO proposals
6375
func (t *DefendPdaoProps) Run(state *state.NetworkState) error {
64-
// Get services
65-
t.cfg = t.sp.GetConfig()
66-
t.w = t.sp.GetWallet()
67-
t.rp = t.sp.GetRocketPool()
68-
t.w = t.sp.GetWallet()
6976
t.nodeAddress, _ = t.w.GetAddress()
70-
t.maxFee, t.maxPriorityFee = getAutoTxInfo(t.cfg, t.log)
71-
t.gasThreshold = t.cfg.AutoTxGasThreshold.Value
72-
t.intervalSize = big.NewInt(int64(config.EventLogInterval))
73-
t.rs = t.cfg.GetRocketPoolResources()
7477

7578
// Bindings
7679
propMgr, err := proposals.NewProposalManager(t.ctx, t.log, t.cfg, t.rp, t.bc)

src/rocketpool-daemon/node/distribute-minipools.go

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
// Distribute minipools task
2727
type DistributeMinipools struct {
2828
sp *services.ServiceProvider
29-
log log.ColorLogger
29+
log *log.ColorLogger
3030
cfg *config.SmartNodeConfig
3131
w *wallet.Wallet
3232
rp *rocketpool.RocketPool
@@ -42,46 +42,54 @@ type DistributeMinipools struct {
4242

4343
// Create distribute minipools task
4444
func NewDistributeMinipools(sp *services.ServiceProvider, logger log.ColorLogger) *DistributeMinipools {
45+
cfg := sp.GetConfig()
46+
log := &logger
47+
maxFee, maxPriorityFee := getAutoTxInfo(cfg, log)
48+
gasThreshold := cfg.AutoTxGasThreshold.Value
49+
50+
if gasThreshold == 0 {
51+
log.Println("Automatic tx gas threshold is 0, disabling auto-distribute.")
52+
}
53+
54+
distributeThresholdFloat := cfg.DistributeThreshold.Value
55+
// Safety clamp
56+
if distributeThresholdFloat >= 8 {
57+
log.Printlnf("WARNING: Auto-distribute threshold is more than 8 ETH (%.6f ETH), reducing to 7.5 ETH for safety", distributeThresholdFloat)
58+
distributeThresholdFloat = 7.5
59+
} else if distributeThresholdFloat == 0 {
60+
log.Println("Auto-distribute threshold is 0, disabling auto-distribute.")
61+
return nil
62+
}
63+
distributeThreshold := eth.EthToWei(distributeThresholdFloat)
64+
4565
return &DistributeMinipools{
46-
sp: sp,
47-
log: logger,
48-
eight: eth.EthToWei(8),
66+
sp: sp,
67+
log: log,
68+
cfg: cfg,
69+
w: sp.GetWallet(),
70+
rp: sp.GetRocketPool(),
71+
bc: sp.GetBeaconClient(),
72+
d: sp.GetDocker(),
73+
gasThreshold: gasThreshold,
74+
distributeThreshold: distributeThreshold,
75+
maxFee: maxFee,
76+
maxPriorityFee: maxPriorityFee,
77+
eight: eth.EthToWei(8),
4978
}
5079
}
5180

5281
// Distribute minipools
5382
func (t *DistributeMinipools) Run(state *state.NetworkState) error {
54-
// Get services
55-
t.cfg = t.sp.GetConfig()
56-
t.w = t.sp.GetWallet()
57-
t.rp = t.sp.GetRocketPool()
58-
t.bc = t.sp.GetBeaconClient()
59-
t.d = t.sp.GetDocker()
60-
t.w = t.sp.GetWallet()
61-
nodeAddress, _ := t.w.GetAddress()
62-
t.maxFee, t.maxPriorityFee = getAutoTxInfo(t.cfg, &t.log)
63-
t.gasThreshold = t.cfg.AutoTxGasThreshold.Value
64-
6583
// Check if auto-distributing is disabled
6684
if t.gasThreshold == 0 {
67-
t.log.Println("Automatic tx gas threshold is 0, disabling auto-distribute.")
68-
return nil
69-
}
70-
distributeThreshold := t.cfg.DistributeThreshold.Value
71-
// Safety clamp
72-
if distributeThreshold >= 8 {
73-
t.log.Printlnf("WARNING: Auto-distribute threshold is more than 8 ETH (%.6f ETH), reducing to 7.5 ETH for safety", distributeThreshold)
74-
distributeThreshold = 7.5
75-
} else if distributeThreshold == 0 {
76-
t.log.Println("Auto-distribute threshold is 0, disabling auto-distribute.")
7785
return nil
7886
}
79-
t.distributeThreshold = eth.EthToWei(distributeThreshold)
8087

8188
// Log
8289
t.log.Println("Checking for minipools to distribute...")
8390

8491
// Get prelaunch minipools
92+
nodeAddress, _ := t.w.GetAddress()
8593
minipools, err := t.getDistributableMinipools(nodeAddress, state)
8694
if err != nil {
8795
return err
@@ -191,7 +199,7 @@ func (t *DistributeMinipools) distributeMinipools(submissions []*eth.Transaction
191199
// Get the max fee
192200
maxFee := t.maxFee
193201
if maxFee == nil || maxFee.Uint64() == 0 {
194-
maxFee, err = gas.GetMaxFeeWeiForDaemon(&t.log)
202+
maxFee, err = gas.GetMaxFeeWeiForDaemon(t.log)
195203
if err != nil {
196204
return err
197205
}
@@ -200,7 +208,7 @@ func (t *DistributeMinipools) distributeMinipools(submissions []*eth.Transaction
200208
opts.GasTipCap = t.maxPriorityFee
201209

202210
// Print the gas info
203-
if !gas.PrintAndCheckGasInfoForBatch(submissions, true, t.gasThreshold, &t.log, maxFee) {
211+
if !gas.PrintAndCheckGasInfoForBatch(submissions, true, t.gasThreshold, t.log, maxFee) {
204212
return nil
205213
}
206214

@@ -213,7 +221,7 @@ func (t *DistributeMinipools) distributeMinipools(submissions []*eth.Transaction
213221
}
214222

215223
// Print TX info and wait for them to be included in a block
216-
err = tx.PrintAndWaitForTransactionBatch(t.cfg, t.rp, &t.log, submissions, callbacks, opts)
224+
err = tx.PrintAndWaitForTransactionBatch(t.cfg, t.rp, t.log, submissions, callbacks, opts)
217225
if err != nil {
218226
return err
219227
}

src/rocketpool-daemon/node/download-reward-trees.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os"
66

77
"github.com/rocket-pool/node-manager-core/utils/log"
8+
"github.com/rocket-pool/rocketpool-go/rocketpool"
89
rprewards "github.com/rocket-pool/smartnode/rocketpool-daemon/common/rewards"
910
"github.com/rocket-pool/smartnode/rocketpool-daemon/common/services"
1011
"github.com/rocket-pool/smartnode/rocketpool-daemon/common/state"
@@ -14,26 +15,25 @@ import (
1415
// Manage download rewards trees task
1516
type DownloadRewardsTrees struct {
1617
sp *services.ServiceProvider
17-
log log.ColorLogger
18+
log *log.ColorLogger
19+
cfg *config.SmartNodeConfig
20+
rp *rocketpool.RocketPool
1821
}
1922

2023
// Create manage fee recipient task
2124
func NewDownloadRewardsTrees(sp *services.ServiceProvider, logger log.ColorLogger) *DownloadRewardsTrees {
2225
return &DownloadRewardsTrees{
2326
sp: sp,
24-
log: logger,
27+
log: &logger,
28+
cfg: sp.GetConfig(),
29+
rp: sp.GetRocketPool(),
2530
}
2631
}
2732

2833
// Manage fee recipient
2934
func (t *DownloadRewardsTrees) Run(state *state.NetworkState) error {
30-
// Get services
31-
cfg := t.sp.GetConfig()
32-
rp := t.sp.GetRocketPool()
33-
nodeAddress, _ := t.sp.GetWallet().GetAddress()
34-
3535
// Check if the user opted into downloading rewards files
36-
if cfg.RewardsTreeMode.Value != config.RewardsMode_Download {
36+
if t.cfg.RewardsTreeMode.Value != config.RewardsMode_Download {
3737
return nil
3838
}
3939

@@ -42,12 +42,13 @@ func (t *DownloadRewardsTrees) Run(state *state.NetworkState) error {
4242

4343
// Get the current interval
4444
currentIndex := state.NetworkDetails.RewardIndex
45+
nodeAddress, _ := t.sp.GetWallet().GetAddress()
4546

4647
// Check for missing intervals
4748
missingIntervals := []uint64{}
4849
for i := uint64(0); i < currentIndex; i++ {
4950
// Check if the tree file exists
50-
treeFilePath := cfg.GetRewardsTreePath(i)
51+
treeFilePath := t.cfg.GetRewardsTreePath(i)
5152
_, err := os.Stat(treeFilePath)
5253
if os.IsNotExist(err) {
5354
t.log.Printlnf("You are missing the rewards tree file for interval %d.", i)
@@ -64,11 +65,11 @@ func (t *DownloadRewardsTrees) Run(state *state.NetworkState) error {
6465
// Download missing intervals
6566
for _, missingInterval := range missingIntervals {
6667
fmt.Printf("Downloading interval %d file... ", missingInterval)
67-
intervalInfo, err := rprewards.GetIntervalInfo(rp, cfg, nodeAddress, missingInterval, nil)
68+
intervalInfo, err := rprewards.GetIntervalInfo(t.rp, t.cfg, nodeAddress, missingInterval, nil)
6869
if err != nil {
6970
return fmt.Errorf("error getting interval %d info: %w", missingInterval, err)
7071
}
71-
err = rprewards.DownloadRewardsFile(cfg, &intervalInfo)
72+
err = rprewards.DownloadRewardsFile(t.cfg, &intervalInfo)
7273
if err != nil {
7374
fmt.Println()
7475
return err

src/rocketpool-daemon/node/manage-fee-recipient.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88
"time"
99

10+
"github.com/docker/docker/client"
1011
"github.com/ethereum/go-ethereum/common"
1112

1213
"github.com/rocket-pool/node-manager-core/beacon"
@@ -29,31 +30,30 @@ type ManageFeeRecipient struct {
2930
ctx context.Context
3031
sp *services.ServiceProvider
3132
cfg *config.SmartNodeConfig
32-
log log.ColorLogger
33+
log *log.ColorLogger
3334
bc beacon.IBeaconClient
35+
d *client.Client
3436
}
3537

3638
// Create manage fee recipient task
3739
func NewManageFeeRecipient(ctx context.Context, sp *services.ServiceProvider, logger log.ColorLogger) *ManageFeeRecipient {
3840
return &ManageFeeRecipient{
3941
ctx: ctx,
4042
sp: sp,
41-
log: logger,
43+
log: &logger,
44+
cfg: sp.GetConfig(),
45+
bc: sp.GetBeaconClient(),
46+
d: sp.GetDocker(),
4247
}
4348
}
4449

4550
// Manage fee recipient
4651
func (t *ManageFeeRecipient) Run(state *state.NetworkState) error {
47-
// Get services
48-
t.cfg = t.sp.GetConfig()
49-
t.bc = t.sp.GetBeaconClient()
50-
d := t.sp.GetDocker()
51-
nodeAddress, _ := t.sp.GetWallet().GetAddress()
52-
5352
// Log
5453
t.log.Println("Checking for correct fee recipient...")
5554

5655
// Get the fee recipient info for the node
56+
nodeAddress, _ := t.sp.GetWallet().GetAddress()
5757
feeRecipientInfo, err := t.getFeeRecipientInfo(nodeAddress, state)
5858
if err != nil {
5959
return fmt.Errorf("error getting fee recipient info: %w", err)
@@ -90,7 +90,7 @@ func (t *ManageFeeRecipient) Run(state *state.NetworkState) error {
9090
t.log.Printlnf("Error updating fee recipient files: %s", err.Error())
9191
t.log.Println("Shutting down the validator client for safety to prevent you from being penalized...")
9292

93-
err = validator.StopValidator(t.cfg, t.bc, &t.log, d, false)
93+
err = validator.StopValidator(t.cfg, t.bc, t.log, t.d, false)
9494
if err != nil {
9595
return fmt.Errorf("error stopping validator client: %w", err)
9696
}
@@ -99,7 +99,7 @@ func (t *ManageFeeRecipient) Run(state *state.NetworkState) error {
9999

100100
// Restart the VC
101101
t.log.Println("Fee recipient files updated successfully! Restarting validator client...")
102-
err = validator.StopValidator(t.cfg, t.bc, &t.log, d, true)
102+
err = validator.StopValidator(t.cfg, t.bc, t.log, t.d, true)
103103
if err != nil {
104104
return fmt.Errorf("error restarting validator client: %w", err)
105105
}
@@ -132,7 +132,7 @@ func (t *ManageFeeRecipient) getFeeRecipientInfo(nodeAddress common.Address, sta
132132
beaconConfig := state.BeaconConfig
133133
beaconHead, err := t.bc.GetBeaconHead(t.ctx)
134134
if err != nil {
135-
return nil, fmt.Errorf("Error getting Beacon head: %w", err)
135+
return nil, fmt.Errorf("error getting Beacon head: %w", err)
136136
}
137137

138138
// Check if the user just opted out

0 commit comments

Comments
 (0)