Skip to content
Draft
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ require (
github.com/sethvargo/go-password v0.2.0
github.com/shirou/gopsutil/v3 v3.23.1
github.com/tyler-smith/go-bip39 v1.1.0
github.com/umbracle/go-eth-consensus v0.1.2
github.com/urfave/cli v1.22.12
github.com/wealdtech/go-ens/v3 v3.5.5
github.com/wealdtech/go-eth2-types/v2 v2.8.1-0.20230131115251-b93cf60cee26
Expand Down Expand Up @@ -148,7 +149,7 @@ require (
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344 // indirect
github.com/supranational/blst v0.3.10 // indirect
github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1527,8 +1527,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stvp/go-udp-testing v0.0.0-20201019212854-469649b16807/go.mod h1:7jxmlfBCDBXRzr0eAQJ48XC1hBu1np4CS5+cHEYfwpc=
github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344 h1:m+8fKfQwCAy1QjzINvKe/pYtLjo2dl59x2w9YSEJxuY=
github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/supranational/blst v0.3.10 h1:CMciDZ/h4pXDDXQASe8ZGTNKUiVNxVVA5hpci2Uuhuk=
github.com/supranational/blst v0.3.10/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs=
Expand Down Expand Up @@ -1560,6 +1560,8 @@ github.com/ugorji/go/codec v1.1.13/go.mod h1:oNVt3Dq+FO91WNQ/9JnHKQP2QJxTzoN7wCB
github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw=
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
github.com/umbracle/go-eth-consensus v0.1.2 h1:oRAZwURW3u6kWPBCYYp2WpknSy5rAKf5OwMJahdPK3c=
github.com/umbracle/go-eth-consensus v0.1.2/go.mod h1:FutcwopvmyWSPl3FQRT9Oru83/tJeGMxy4k0OfJ0sdY=
github.com/umbracle/gohashtree v0.0.2-alpha.0.20230207094856-5b775a815c10 h1:CQh33pStIp/E30b7TxDlXfM0145bn2e8boI30IxAhTg=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
Expand Down
16 changes: 13 additions & 3 deletions rocketpool/watchtower/generate-rewards-tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/rocket-pool/rocketpool-go/rocketpool"
"github.com/rocket-pool/smartnode/shared/services"
"github.com/rocket-pool/smartnode/shared/services/beacon"
"github.com/rocket-pool/smartnode/shared/services/beacon/client"
"github.com/rocket-pool/smartnode/shared/services/config"
rprewards "github.com/rocket-pool/smartnode/shared/services/rewards"
"github.com/rocket-pool/smartnode/shared/services/state"
Expand Down Expand Up @@ -52,9 +53,18 @@ func newGenerateRewardsTree(c *cli.Context, logger log.ColorLogger, errorLogger
if err != nil {
return nil, err
}
bc, err := services.GetBeaconClient(c)
if err != nil {
return nil, err
var bc beacon.Client
// Override the beacon client, if requested
if beaconOverride := os.Getenv("TREEGEN_BEACON_CLIENT_ENDPOINT"); beaconOverride != "" {
logger.Printlnf("Using %s as the Beacon Node for GenerateRewardsTree", beaconOverride)
bc = client.NewStandardHttpClient(beaconOverride)
} else {
var err error

bc, err = services.GetBeaconClient(c)
if err != nil {
return nil, err
}
}
rp, err := services.GetRocketPool(c)
if err != nil {
Expand Down
21 changes: 17 additions & 4 deletions rocketpool/watchtower/submit-rewards-tree-stateless.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/rocket-pool/smartnode/rocketpool/watchtower/utils"
"github.com/rocket-pool/smartnode/shared/services"
"github.com/rocket-pool/smartnode/shared/services/beacon"
"github.com/rocket-pool/smartnode/shared/services/beacon/client"
"github.com/rocket-pool/smartnode/shared/services/config"
rprewards "github.com/rocket-pool/smartnode/shared/services/rewards"
"github.com/rocket-pool/smartnode/shared/services/state"
Expand Down Expand Up @@ -68,10 +69,21 @@ func newSubmitRewardsTree_Stateless(c *cli.Context, logger log.ColorLogger, erro
if err != nil {
return nil, err
}
bc, err := services.GetBeaconClient(c)
if err != nil {
return nil, err

var bc beacon.Client
// Override the beacon client, if requested
if beaconOverride := os.Getenv("TREEGEN_BEACON_CLIENT_ENDPOINT"); beaconOverride != "" {
logger.Printlnf("Using %s as the Beacon Node for SubmitRewardsTree", beaconOverride)
bc = client.NewStandardHttpClient(beaconOverride)
} else {
var err error

bc, err = services.GetBeaconClient(c)
if err != nil {
return nil, err
}
}

rp, err := services.GetRocketPool(c)
if err != nil {
return nil, err
Expand Down Expand Up @@ -566,7 +578,8 @@ func (t *submitRewardsTree_Stateless) getSnapshotConsensusBlock(endTime time.Tim
targetSlot := uint64(math.Ceil(totalTimespan.Seconds() / float64(eth2Config.SecondsPerSlot)))
targetSlotEpoch := targetSlot / eth2Config.SlotsPerEpoch
targetSlot = targetSlotEpoch*eth2Config.SlotsPerEpoch + (eth2Config.SlotsPerEpoch - 1) // The target slot becomes the last one in the Epoch
requiredEpoch := targetSlotEpoch + 1 // The smoothing pool requires 1 epoch beyond the target to be finalized, to check for late attestations
// XXX Jacob, you changed this from targetSlotEpoch + 1 so we start generating when the subsequent epoch justifies instead
requiredEpoch := targetSlotEpoch // The smoothing pool requires 1 epoch beyond the target to be finalized, to check for late attestations

// Check if the required epoch is finalized yet
if beaconHead.FinalizedEpoch < requiredEpoch {
Expand Down
20 changes: 16 additions & 4 deletions rocketpool/watchtower/watchtower.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math/big"
"math/rand"
"net/http"
"os"
"sync"
"time"

Expand All @@ -18,6 +19,7 @@ import (
"github.com/rocket-pool/smartnode/rocketpool/watchtower/collectors"
"github.com/rocket-pool/smartnode/shared/services"
"github.com/rocket-pool/smartnode/shared/services/beacon"
"github.com/rocket-pool/smartnode/shared/services/beacon/client"
"github.com/rocket-pool/smartnode/shared/services/state"
"github.com/rocket-pool/smartnode/shared/utils/log"
)
Expand Down Expand Up @@ -82,10 +84,6 @@ func run(c *cli.Context) error {
if err != nil {
return err
}
bc, err := services.GetBeaconClient(c)
if err != nil {
return err
}

// Print the current mode
if cfg.IsNativeMode {
Expand All @@ -109,6 +107,20 @@ func run(c *cli.Context) error {
errorLog := log.NewColorLogger(ErrorColor)
updateLog := log.NewColorLogger(UpdateColor)

var bc beacon.Client
// Override the beacon client, if requested
if beaconOverride := os.Getenv("TREEGEN_BEACON_CLIENT_ENDPOINT"); beaconOverride != "" {
updateLog.Printlnf("Overriding the Beacon Node URL to %s", beaconOverride)
bc = client.NewStandardHttpClient(beaconOverride)
} else {
var err error

bc, err = services.GetBeaconClient(c)
if err != nil {
return err
}
}

// Create the state manager
m, err := state.NewNetworkStateManager(rp, cfg, rp.Client, bc, &updateLog)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion shared/services/beacon/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ type Committees interface {
Slot(int) uint64
// Validators returns the list of validators of the committee at
// the provided offset
Validators(int) []string
Validators(int) []uint64
// Count returns the number of committees in the response
Count() int
// Release returns the reused validators slice buffer to the pool for
Expand Down
Loading