new prometheus metrics for client-stats metrics (#8834)

This commit is contained in:
kasey
2021-04-30 15:37:38 -05:00
committed by GitHub
parent 2fdfda2804
commit 7be6fc1780
18 changed files with 625 additions and 215 deletions

View File

@@ -14,6 +14,13 @@ func NewDB(ctx context.Context, dirPath string, config *kv.Config) (Database, er
return kv.NewKVStore(ctx, dirPath, config) return kv.NewKVStore(ctx, dirPath, config)
} }
// NewDBFilename uses the KVStoreDatafilePath so that if this layer of
// indirection between db.NewDB->kv.NewKVStore ever changes, it will be easy to remember
// to also change this filename indirection at the same time.
func NewDBFilename(dirPath string) string {
return kv.KVStoreDatafilePath(dirPath)
}
// NewSlasherDB initializes a new DB for slasher. // NewSlasherDB initializes a new DB for slasher.
func NewSlasherDB(ctx context.Context, dirPath string, config *slasherkv.Config) (SlasherDatabase, error) { func NewSlasherDB(ctx context.Context, dirPath string, config *slasherkv.Config) (SlasherDatabase, error) {
return slasherkv.NewKVStore(ctx, dirPath, config) return slasherkv.NewKVStore(ctx, dirPath, config)

View File

@@ -64,6 +64,13 @@ type Store struct {
ctx context.Context ctx context.Context
} }
// KVStoreDatafilePath is the canonical construction of a full
// database file path from the directory path, so that code outside
// this package can find the full path in a consistent way.
func KVStoreDatafilePath(dirPath string) string {
return path.Join(dirPath, DatabaseFileName)
}
// NewKVStore initializes a new boltDB key-value store at the directory // NewKVStore initializes a new boltDB key-value store at the directory
// path specified, creates the kv-buckets based on the schema, and stores // path specified, creates the kv-buckets based on the schema, and stores
// an open connection db object as a property of the Store struct. // an open connection db object as a property of the Store struct.
@@ -77,7 +84,7 @@ func NewKVStore(ctx context.Context, dirPath string, config *Config) (*Store, er
return nil, err return nil, err
} }
} }
datafile := path.Join(dirPath, DatabaseFileName) datafile := KVStoreDatafilePath(dirPath)
boltDB, err := bolt.Open( boltDB, err := bolt.Open(
datafile, datafile,
params.BeaconIoConfig().ReadWritePermissions, params.BeaconIoConfig().ReadWritePermissions,

View File

@@ -7,6 +7,7 @@ go_library(
"config.go", "config.go",
"log.go", "log.go",
"node.go", "node.go",
"prometheus.go",
], ],
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/node", importpath = "github.com/prysmaticlabs/prysm/beacon-chain/node",
visibility = [ visibility = [
@@ -48,6 +49,7 @@ go_library(
"//shared/version:go_default_library", "//shared/version:go_default_library",
"@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library",
"@com_github_pkg_errors//:go_default_library", "@com_github_pkg_errors//:go_default_library",
"@com_github_prometheus_client_golang//prometheus:go_default_library",
"@com_github_prysmaticlabs_eth2_types//:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library",
"@com_github_urfave_cli_v2//:go_default_library", "@com_github_urfave_cli_v2//:go_default_library",

View File

@@ -73,6 +73,7 @@ type BeaconNode struct {
opFeed *event.Feed opFeed *event.Feed
forkChoiceStore forkchoice.ForkChoicer forkChoiceStore forkchoice.ForkChoicer
stateGen *stategen.State stateGen *stategen.State
collector *bcnodeCollector
} }
// New creates a new node instance, sets up configuration options, and registers // New creates a new node instance, sets up configuration options, and registers
@@ -162,6 +163,15 @@ func New(cliCtx *cli.Context) (*BeaconNode, error) {
} }
} }
// db.DatabasePath is the path to the containing directory
// db.NewDBFilename expands that to the canonical full path using
// the same constuction as NewDB()
c, err := newBeaconNodePromCollector(db.NewDBFilename(beacon.db.DatabasePath()))
if err != nil {
return nil, err
}
beacon.collector = c
return beacon, nil return beacon, nil
} }
@@ -224,6 +234,7 @@ func (b *BeaconNode) Close() {
if err := b.db.Close(); err != nil { if err := b.db.Close(); err != nil {
log.Errorf("Failed to close database: %v", err) log.Errorf("Failed to close database: %v", err)
} }
b.collector.unregister()
b.cancel() b.cancel()
close(b.stop) close(b.stop)
} }
@@ -435,15 +446,22 @@ func (b *BeaconNode) registerPOWChainService() error {
return err return err
} }
cfg := &powchain.Web3ServiceConfig{ bs, err := powchain.NewPowchainCollector(b.ctx)
HttpEndpoints: endpoints, if err != nil {
DepositContract: common.HexToAddress(depAddress), return err
BeaconDB: b.db,
DepositCache: b.depositCache,
StateNotifier: b,
StateGen: b.stateGen,
Eth1HeaderReqLimit: b.cliCtx.Uint64(flags.Eth1HeaderReqLimit.Name),
} }
cfg := &powchain.Web3ServiceConfig{
HttpEndpoints: endpoints,
DepositContract: common.HexToAddress(depAddress),
BeaconDB: b.db,
DepositCache: b.depositCache,
StateNotifier: b,
StateGen: b.stateGen,
Eth1HeaderReqLimit: b.cliCtx.Uint64(flags.Eth1HeaderReqLimit.Name),
BeaconNodeStatsUpdater: bs,
}
web3Service, err := powchain.NewService(b.ctx, cfg) web3Service, err := powchain.NewService(b.ctx, cfg)
if err != nil { if err != nil {
return errors.Wrap(err, "could not register proof-of-work chain web3Service") return errors.Wrap(err, "could not register proof-of-work chain web3Service")

View File

@@ -0,0 +1,61 @@
package node
import (
"fmt"
"os"
"github.com/prometheus/client_golang/prometheus"
)
type bcnodeCollector struct {
DiskBeaconchainBytesTotal *prometheus.Desc
dbPath string
}
func newBeaconNodePromCollector(dbPath string) (*bcnodeCollector, error) {
namespace := "bcnode"
c := &bcnodeCollector{
DiskBeaconchainBytesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "disk_beaconchain_bytes_total"),
"Total hard disk space used by the beaconchain database, in bytes.",
nil,
nil,
),
dbPath: dbPath,
}
_, err := c.getCurrentDbBytes()
if err != nil {
return nil, err
}
return c, prometheus.Register(c)
}
func (bc *bcnodeCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- bc.DiskBeaconchainBytesTotal
}
func (bc *bcnodeCollector) Collect(ch chan<- prometheus.Metric) {
dbBytes, err := bc.getCurrentDbBytes()
if err != nil {
log.Warn(err)
return
}
ch <- prometheus.MustNewConstMetric(
bc.DiskBeaconchainBytesTotal,
prometheus.GaugeValue,
dbBytes,
)
}
func (bc *bcnodeCollector) getCurrentDbBytes() (float64, error) {
fs, err := os.Stat(bc.dbPath)
if err != nil {
return 0, fmt.Errorf("could not collect database file size for prometheus, path=%s, err=%s", bc.dbPath, err)
}
return float64(fs.Size()), nil
}
func (bc *bcnodeCollector) unregister() {
prometheus.Unregister(bc)
}

View File

@@ -9,6 +9,7 @@ go_library(
"deposit.go", "deposit.go",
"log.go", "log.go",
"log_processing.go", "log_processing.go",
"prometheus.go",
"provider.go", "provider.go",
"service.go", "service.go",
], ],
@@ -32,6 +33,7 @@ go_library(
"//contracts/deposit-contract:go_default_library", "//contracts/deposit-contract:go_default_library",
"//proto/beacon/db:go_default_library", "//proto/beacon/db:go_default_library",
"//shared/bytesutil:go_default_library", "//shared/bytesutil:go_default_library",
"//shared/clientstats:go_default_library",
"//shared/hashutil:go_default_library", "//shared/hashutil:go_default_library",
"//shared/httputils:go_default_library", "//shared/httputils:go_default_library",
"//shared/httputils/authorizationmethod:go_default_library", "//shared/httputils/authorizationmethod:go_default_library",
@@ -67,6 +69,7 @@ go_test(
"init_test.go", "init_test.go",
"log_processing_test.go", "log_processing_test.go",
"powchain_test.go", "powchain_test.go",
"prometheus_test.go",
"provider_test.go", "provider_test.go",
"service_test.go", "service_test.go",
], ],
@@ -84,6 +87,7 @@ go_test(
"//proto/beacon/db:go_default_library", "//proto/beacon/db:go_default_library",
"//shared/bls:go_default_library", "//shared/bls:go_default_library",
"//shared/bytesutil:go_default_library", "//shared/bytesutil:go_default_library",
"//shared/clientstats:go_default_library",
"//shared/event:go_default_library", "//shared/event:go_default_library",
"//shared/httputils:go_default_library", "//shared/httputils:go_default_library",
"//shared/httputils/authorizationmethod:go_default_library", "//shared/httputils/authorizationmethod:go_default_library",
@@ -98,6 +102,7 @@ go_test(
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
"@com_github_ethereum_go_ethereum//core/types:go_default_library", "@com_github_ethereum_go_ethereum//core/types:go_default_library",
"@com_github_ethereum_go_ethereum//trie:go_default_library", "@com_github_ethereum_go_ethereum//trie:go_default_library",
"@com_github_prometheus_client_golang//prometheus:go_default_library",
"@com_github_prysmaticlabs_eth2_types//:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library", "@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library",

View File

@@ -0,0 +1,153 @@
package powchain
import (
"context"
"sync"
"github.com/prometheus/client_golang/prometheus"
"github.com/prysmaticlabs/prysm/shared/clientstats"
)
type BeaconNodeStatsUpdater interface {
Update(stats clientstats.BeaconNodeStats)
}
type PowchainCollector struct {
SyncEth1Connected *prometheus.Desc
SyncEth1FallbackConnected *prometheus.Desc
SyncEth1FallbackConfigured *prometheus.Desc // true if flag specified: --fallback-web3provider
updateChan chan clientstats.BeaconNodeStats
latestStats clientstats.BeaconNodeStats
sync.Mutex
ctx context.Context
finishChan chan struct{}
}
var _ BeaconNodeStatsUpdater = &PowchainCollector{}
var _ prometheus.Collector = &PowchainCollector{}
// Update satisfies the BeaconNodeStatsUpdater
func (pc *PowchainCollector) Update(update clientstats.BeaconNodeStats) {
pc.updateChan <- update
}
// Describe is invoked by the prometheus collection loop.
// It returns a set of metric Descriptor references which
// are also used in Collect to group collected metrics into
// a family. Describe and Collect together satisfy the
// prometheus.Collector interface.
func (pc *PowchainCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- pc.SyncEth1Connected
ch <- pc.SyncEth1FallbackConfigured
ch <- pc.SyncEth1FallbackConnected
}
// Collect is invoked by the prometheus collection loop.
// It returns a set of Metrics representing the observation
// for the current collection period. In the case of this
// collector, we use values from the latest BeaconNodeStats
// value sent by the powchain Service, which updates this value
// whenever an internal event could change the state of one of
// the metrics.
// Describe and Collect together satisfy the
// prometheus.Collector interface.
func (pc *PowchainCollector) Collect(ch chan<- prometheus.Metric) {
bs := pc.getLatestStats()
var syncEth1FallbackConfigured float64 = 0
if bs.SyncEth1FallbackConfigured {
syncEth1FallbackConfigured = 1
}
ch <- prometheus.MustNewConstMetric(
pc.SyncEth1FallbackConfigured,
prometheus.GaugeValue,
syncEth1FallbackConfigured,
)
var syncEth1FallbackConnected float64 = 0
if bs.SyncEth1FallbackConnected {
syncEth1FallbackConnected = 1
}
ch <- prometheus.MustNewConstMetric(
pc.SyncEth1FallbackConnected,
prometheus.GaugeValue,
syncEth1FallbackConnected,
)
var syncEth1Connected float64 = 0
if bs.SyncEth1Connected {
syncEth1Connected = 1
}
ch <- prometheus.MustNewConstMetric(
pc.SyncEth1Connected,
prometheus.GaugeValue,
syncEth1Connected,
)
}
func (pc *PowchainCollector) getLatestStats() clientstats.BeaconNodeStats {
pc.Lock()
defer pc.Unlock()
return pc.latestStats
}
func (pc *PowchainCollector) setLatestStats(bs clientstats.BeaconNodeStats) {
pc.Lock()
pc.latestStats = bs
pc.Unlock()
}
// unregister returns true if the prometheus DefaultRegistry
// confirms that it was removed.
func (pc *PowchainCollector) unregister() bool {
return prometheus.Unregister(pc)
}
func (pc *PowchainCollector) latestStatsUpdateLoop() {
for {
select {
case <-pc.ctx.Done():
pc.unregister()
pc.finishChan <- struct{}{}
return
case bs := <-pc.updateChan:
pc.setLatestStats(bs)
}
}
}
func NewPowchainCollector(ctx context.Context) (*PowchainCollector, error) {
namespace := "powchain"
updateChan := make(chan clientstats.BeaconNodeStats, 2)
c := &PowchainCollector{
SyncEth1FallbackConfigured: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "sync_eth1_fallback_configured"),
"Boolean recording whether a fallback eth1 endpoint was configured: 0=false, 1=true.",
nil,
nil,
),
SyncEth1FallbackConnected: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "sync_eth1_fallback_connected"),
"Boolean indicating whether a fallback eth1 endpoint is currently connected: 0=false, 1=true.",
nil,
nil,
),
SyncEth1Connected: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "sync_eth1_connected"),
"Boolean indicating whether a fallback eth1 endpoint is currently connected: 0=false, 1=true.",
nil,
nil,
),
updateChan: updateChan,
ctx: ctx,
finishChan: make(chan struct{}, 1),
}
go c.latestStatsUpdateLoop()
return c, prometheus.Register(c)
}
type NopBeaconNodeStatsUpdater struct{}
func (nop *NopBeaconNodeStatsUpdater) Update(stats clientstats.BeaconNodeStats) {}
var _ BeaconNodeStatsUpdater = &NopBeaconNodeStatsUpdater{}

View File

@@ -0,0 +1,53 @@
package powchain
import (
"context"
"testing"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
)
// TestCleanup ensures that the cleanup function unregisters the prometheus.Collection
// also tests the interchangability of the explicit prometheus Register/Unregister
// and the implicit methods within the collector implementation
func TestCleanup(t *testing.T) {
ctx := context.Background()
pc, err := NewPowchainCollector(ctx)
assert.NoError(t, err, "Uxpected error caling NewPowchainCollector")
unregistered := pc.unregister()
assert.Equal(t, true, unregistered, "PowchainCollector.unregister did not return true (via prometheus.DefaultRegistry)")
// PowchainCollector is a prometheus.Collector, so we should be able to register it again
err = prometheus.Register(pc)
assert.NoError(t, err, "Got error from prometheus.Register after unregistering PowchainCollector")
// even if it somehow gets registered somewhere else, unregister should work
unregistered = pc.unregister()
assert.Equal(t, true, unregistered, "PowchainCollector.unregister failed on the second attempt")
// and so we should be able to register it again
err = prometheus.Register(pc)
assert.NoError(t, err, "Got error from prometheus.Register on the second attempt")
// ok clean it up one last time for real :)
unregistered = prometheus.Unregister(pc)
assert.Equal(t, true, unregistered, "prometheus.Unregister failed to unregister PowchainCollector on final cleanup")
}
// TestCancelation tests that canceling the context passed into
// NewPowchainCollector cleans everything up as expected. This
// does come at the cost of an extra channel cluttering up
// PowchainCollector, just for this test.
func TestCancelation(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
pc, err := NewPowchainCollector(ctx)
assert.NoError(t, err, "Uxpected error caling NewPowchainCollector")
ticker := time.NewTicker(10 * time.Second)
cancel()
select {
case <-ticker.C:
t.Error("Hit timeout waiting for cancel() to cleanup PowchainCollector")
case <-pc.finishChan:
break
}
err = prometheus.Register(pc)
assert.NoError(t, err, "Got error from prometheus.Register after unregistering PowchainCollector through canceled context")
}

View File

@@ -36,6 +36,7 @@ import (
contracts "github.com/prysmaticlabs/prysm/contracts/deposit-contract" contracts "github.com/prysmaticlabs/prysm/contracts/deposit-contract"
protodb "github.com/prysmaticlabs/prysm/proto/beacon/db" protodb "github.com/prysmaticlabs/prysm/proto/beacon/db"
"github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/clientstats"
"github.com/prysmaticlabs/prysm/shared/httputils" "github.com/prysmaticlabs/prysm/shared/httputils"
"github.com/prysmaticlabs/prysm/shared/httputils/authorizationmethod" "github.com/prysmaticlabs/prysm/shared/httputils/authorizationmethod"
"github.com/prysmaticlabs/prysm/shared/logutil" "github.com/prysmaticlabs/prysm/shared/logutil"
@@ -146,17 +147,19 @@ type Service struct {
lastReceivedMerkleIndex int64 // Keeps track of the last received index to prevent log spam. lastReceivedMerkleIndex int64 // Keeps track of the last received index to prevent log spam.
runError error runError error
preGenesisState iface.BeaconState preGenesisState iface.BeaconState
bsUpdater BeaconNodeStatsUpdater
} }
// Web3ServiceConfig defines a config struct for web3 service to use through its life cycle. // Web3ServiceConfig defines a config struct for web3 service to use through its life cycle.
type Web3ServiceConfig struct { type Web3ServiceConfig struct {
HttpEndpoints []string HttpEndpoints []string
DepositContract common.Address DepositContract common.Address
BeaconDB db.HeadAccessDatabase BeaconDB db.HeadAccessDatabase
DepositCache *depositcache.DepositCache DepositCache *depositcache.DepositCache
StateNotifier statefeed.Notifier StateNotifier statefeed.Notifier
StateGen *stategen.State StateGen *stategen.State
Eth1HeaderReqLimit uint64 Eth1HeaderReqLimit uint64
BeaconNodeStatsUpdater BeaconNodeStatsUpdater
} }
// NewService sets up a new instance with an ethclient when // NewService sets up a new instance with an ethclient when
@@ -210,6 +213,12 @@ func NewService(ctx context.Context, config *Web3ServiceConfig) (*Service, error
lastReceivedMerkleIndex: -1, lastReceivedMerkleIndex: -1,
preGenesisState: genState, preGenesisState: genState,
headTicker: time.NewTicker(time.Duration(params.BeaconConfig().SecondsPerETH1Block) * time.Second), headTicker: time.NewTicker(time.Duration(params.BeaconConfig().SecondsPerETH1Block) * time.Second),
// use the nop updater by default, rely on upstream set up to pass in an appropriate impl
bsUpdater: config.BeaconNodeStatsUpdater,
}
if config.BeaconNodeStatsUpdater == nil {
s.bsUpdater = &NopBeaconNodeStatsUpdater{}
} }
if err := s.ensureValidPowchainData(ctx); err != nil { if err := s.ensureValidPowchainData(ctx); err != nil {
@@ -223,6 +232,7 @@ func NewService(ctx context.Context, config *Web3ServiceConfig) (*Service, error
if err := s.initializeEth1Data(ctx, eth1Data); err != nil { if err := s.initializeEth1Data(ctx, eth1Data); err != nil {
return nil, err return nil, err
} }
return s, nil return s, nil
} }
@@ -302,6 +312,31 @@ func (s *Service) Status() error {
return nil return nil
} }
func (s *Service) updateBeaconnodeStats() {
bs := clientstats.BeaconNodeStats{}
if len(s.httpEndpoints) > 1 {
bs.SyncEth1FallbackConfigured = true
}
if s.IsConnectedToETH1() {
if s.primaryConnected() {
bs.SyncEth1Connected = true
} else {
bs.SyncEth1FallbackConnected = true
}
}
s.bsUpdater.Update(bs)
}
func (s *Service) updateCurrHttpEndpoint(endpoint httputils.Endpoint) {
s.currHttpEndpoint = endpoint
s.updateBeaconnodeStats()
}
func (s *Service) updateConnectedETH1(state bool) {
s.connectedETH1 = state
s.updateBeaconnodeStats()
}
// IsConnectedToETH1 checks if the beacon node is connected to a ETH1 Node. // IsConnectedToETH1 checks if the beacon node is connected to a ETH1 Node.
func (s *Service) IsConnectedToETH1() bool { func (s *Service) IsConnectedToETH1() bool {
return s.connectedETH1 return s.connectedETH1
@@ -455,7 +490,7 @@ func (s *Service) waitForConnection() {
synced, errSynced := s.isEth1NodeSynced() synced, errSynced := s.isEth1NodeSynced()
// Resume if eth1 node is synced. // Resume if eth1 node is synced.
if synced { if synced {
s.connectedETH1 = true s.updateConnectedETH1(true)
s.runError = nil s.runError = nil
log.WithFields(logrus.Fields{ log.WithFields(logrus.Fields{
"endpoint": logutil.MaskCredentialsLogging(s.currHttpEndpoint.Url), "endpoint": logutil.MaskCredentialsLogging(s.currHttpEndpoint.Url),
@@ -503,7 +538,7 @@ func (s *Service) waitForConnection() {
continue continue
} }
if synced { if synced {
s.connectedETH1 = true s.updateConnectedETH1(true)
s.runError = nil s.runError = nil
log.WithFields(logrus.Fields{ log.WithFields(logrus.Fields{
"endpoint": logutil.MaskCredentialsLogging(s.currHttpEndpoint.Url), "endpoint": logutil.MaskCredentialsLogging(s.currHttpEndpoint.Url),
@@ -539,7 +574,7 @@ func (s *Service) isEth1NodeSynced() (bool, error) {
// Reconnect to eth1 node in case of any failure. // Reconnect to eth1 node in case of any failure.
func (s *Service) retryETH1Node(err error) { func (s *Service) retryETH1Node(err error) {
s.runError = err s.runError = err
s.connectedETH1 = false s.updateConnectedETH1(false)
// Back off for a while before // Back off for a while before
// resuming dialing the eth1 node. // resuming dialing the eth1 node.
time.Sleep(backOffPeriod) time.Sleep(backOffPeriod)
@@ -765,7 +800,7 @@ func (s *Service) run(done <-chan struct{}) {
case <-done: case <-done:
s.isRunning = false s.isRunning = false
s.runError = nil s.runError = nil
s.connectedETH1 = false s.updateConnectedETH1(false)
log.Debug("Context closed, exiting goroutine") log.Debug("Context closed, exiting goroutine")
return return
case <-s.headTicker.C: case <-s.headTicker.C:
@@ -895,7 +930,7 @@ func (s *Service) checkDefaultEndpoint() {
// Switch back to primary endpoint and try connecting // Switch back to primary endpoint and try connecting
// to it again. // to it again.
s.currHttpEndpoint = primaryEndpoint s.updateCurrHttpEndpoint(primaryEndpoint)
s.retryETH1Node(nil) s.retryETH1Node(nil)
} }
@@ -916,12 +951,10 @@ func (s *Service) fallbackToNextEndpoint() {
if nextIndex >= totalEndpoints { if nextIndex >= totalEndpoints {
nextIndex = 0 nextIndex = 0
} }
// Exit early if we have the same index. if nextIndex != currIndex {
if nextIndex == currIndex { log.Infof("Falling back to alternative endpoint: %s", logutil.MaskCredentialsLogging(s.currHttpEndpoint.Url))
return
} }
s.currHttpEndpoint = s.httpEndpoints[nextIndex] s.updateCurrHttpEndpoint(s.httpEndpoints[nextIndex])
log.Infof("Falling back to alternative endpoint: %s", logutil.MaskCredentialsLogging(s.currHttpEndpoint.Url))
} }
// initializes our service from the provided eth1data object by initializing all the relevant // initializes our service from the provided eth1data object by initializing all the relevant
@@ -1032,3 +1065,7 @@ func eth1HeadIsBehind(timestamp uint64) bool {
// check that web3 client is syncing // check that web3 client is syncing
return time.Unix(int64(timestamp), 0).Before(timeout) return time.Unix(int64(timestamp), 0).Before(timeout)
} }
func (s *Service) primaryConnected() bool {
return s.currHttpEndpoint.Equals(s.httpEndpoints[0])
}

View File

@@ -21,6 +21,7 @@ import (
mockPOW "github.com/prysmaticlabs/prysm/beacon-chain/powchain/testing" mockPOW "github.com/prysmaticlabs/prysm/beacon-chain/powchain/testing"
contracts "github.com/prysmaticlabs/prysm/contracts/deposit-contract" contracts "github.com/prysmaticlabs/prysm/contracts/deposit-contract"
protodb "github.com/prysmaticlabs/prysm/proto/beacon/db" protodb "github.com/prysmaticlabs/prysm/proto/beacon/db"
"github.com/prysmaticlabs/prysm/shared/clientstats"
"github.com/prysmaticlabs/prysm/shared/event" "github.com/prysmaticlabs/prysm/shared/event"
"github.com/prysmaticlabs/prysm/shared/httputils" "github.com/prysmaticlabs/prysm/shared/httputils"
"github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/params"
@@ -535,6 +536,16 @@ func TestNewService_Eth1HeaderRequLimit(t *testing.T) {
assert.Equal(t, uint64(150), s2.cfg.Eth1HeaderReqLimit, "unable to set eth1HeaderRequestLimit") assert.Equal(t, uint64(150), s2.cfg.Eth1HeaderReqLimit, "unable to set eth1HeaderRequestLimit")
} }
type mockBSUpdater struct {
lastBS clientstats.BeaconNodeStats
}
func (mbs *mockBSUpdater) Update(bs clientstats.BeaconNodeStats) {
mbs.lastBS = bs
}
var _ BeaconNodeStatsUpdater = &mockBSUpdater{}
func TestServiceFallbackCorrectly(t *testing.T) { func TestServiceFallbackCorrectly(t *testing.T) {
firstEndpoint := "A" firstEndpoint := "A"
secondEndpoint := "B" secondEndpoint := "B"
@@ -543,22 +554,27 @@ func TestServiceFallbackCorrectly(t *testing.T) {
require.NoError(t, err, "Unable to set up simulated backend") require.NoError(t, err, "Unable to set up simulated backend")
beaconDB := dbutil.SetupDB(t) beaconDB := dbutil.SetupDB(t)
mbs := &mockBSUpdater{}
s1, err := NewService(context.Background(), &Web3ServiceConfig{ s1, err := NewService(context.Background(), &Web3ServiceConfig{
HttpEndpoints: []string{firstEndpoint}, HttpEndpoints: []string{firstEndpoint},
DepositContract: testAcc.ContractAddr, DepositContract: testAcc.ContractAddr,
BeaconDB: beaconDB, BeaconDB: beaconDB,
BeaconNodeStatsUpdater: mbs,
}) })
s1.bsUpdater = mbs
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, firstEndpoint, s1.currHttpEndpoint.Url, "Unexpected http endpoint") assert.Equal(t, firstEndpoint, s1.currHttpEndpoint.Url, "Unexpected http endpoint")
// Stay at the first endpoint. // Stay at the first endpoint.
s1.fallbackToNextEndpoint() s1.fallbackToNextEndpoint()
assert.Equal(t, firstEndpoint, s1.currHttpEndpoint.Url, "Unexpected http endpoint") assert.Equal(t, firstEndpoint, s1.currHttpEndpoint.Url, "Unexpected http endpoint")
assert.Equal(t, false, mbs.lastBS.SyncEth1FallbackConfigured, "SyncEth1FallbackConfigured in clientstats update should be false when only 1 endpoint is configured")
s1.httpEndpoints = append(s1.httpEndpoints, httputils.Endpoint{Url: secondEndpoint}) s1.httpEndpoints = append(s1.httpEndpoints, httputils.Endpoint{Url: secondEndpoint})
s1.fallbackToNextEndpoint() s1.fallbackToNextEndpoint()
assert.Equal(t, secondEndpoint, s1.currHttpEndpoint.Url, "Unexpected http endpoint") assert.Equal(t, secondEndpoint, s1.currHttpEndpoint.Url, "Unexpected http endpoint")
assert.Equal(t, true, mbs.lastBS.SyncEth1FallbackConfigured, "SyncEth1FallbackConfigured in clientstats update should be true when > 1 endpoint is configured")
thirdEndpoint := "C" thirdEndpoint := "C"
fourthEndpoint := "D" fourthEndpoint := "D"

334
deps.bzl
View File

@@ -189,6 +189,54 @@ def prysm_deps():
version = "v1.2.0", version = "v1.2.0",
) )
go_repository(
name = "com_github_aws_aws_sdk_go_v2_config",
importpath = "github.com/aws/aws-sdk-go-v2/config",
sum = "h1:ZAoq32boMzcaTW9bcUacBswAmHTbvlvDJICgHFZuECo=",
version = "v1.1.1",
)
go_repository(
name = "com_github_aws_aws_sdk_go_v2_credentials",
importpath = "github.com/aws/aws-sdk-go-v2/credentials",
sum = "h1:NbvWIM1Mx6sNPTxowHgS2ewXCRp+NGTzUYb/96FZJbY=",
version = "v1.1.1",
)
go_repository(
name = "com_github_aws_aws_sdk_go_v2_feature_ec2_imds",
importpath = "github.com/aws/aws-sdk-go-v2/feature/ec2/imds",
sum = "h1:EtEU7WRaWliitZh2nmuxEXrN0Cb8EgPUFGIoTMeqbzI=",
version = "v1.0.2",
)
go_repository(
name = "com_github_aws_aws_sdk_go_v2_service_internal_presigned_url",
importpath = "github.com/aws/aws-sdk-go-v2/service/internal/presigned-url",
sum = "h1:4AH9fFjUlVktQMznF+YN33aWNXaR4VgDXyP28qokJC0=",
version = "v1.0.2",
)
go_repository(
name = "com_github_aws_aws_sdk_go_v2_service_route53",
importpath = "github.com/aws/aws-sdk-go-v2/service/route53",
sum = "h1:cKr6St+CtC3/dl/rEBJvlk7A/IN5D5F02GNkGzfbtVU=",
version = "v1.1.1",
)
go_repository(
name = "com_github_aws_aws_sdk_go_v2_service_sso",
importpath = "github.com/aws/aws-sdk-go-v2/service/sso",
sum = "h1:37QubsarExl5ZuCBlnRP+7l1tNwZPBSTqpTBrPH98RU=",
version = "v1.1.1",
)
go_repository(
name = "com_github_aws_aws_sdk_go_v2_service_sts",
importpath = "github.com/aws/aws-sdk-go-v2/service/sts",
sum = "h1:TJoIfnIFubCX0ACVeJ0w46HEH5MwjwYN4iFhuYIhfIY=",
version = "v1.1.1",
)
go_repository(
name = "com_github_aws_smithy_go",
importpath = "github.com/aws/smithy-go",
sum = "h1:D6CSsM3gdxaGaqXnPgOBCeL6Mophqzu7KJOu7zW78sU=",
version = "v1.1.0",
)
go_repository( go_repository(
name = "com_github_azure_azure_pipeline_go", name = "com_github_azure_azure_pipeline_go",
importpath = "github.com/Azure/azure-pipeline-go", importpath = "github.com/Azure/azure-pipeline-go",
@@ -263,6 +311,12 @@ def prysm_deps():
version = "v0.1.0", version = "v0.1.0",
) )
go_repository(
name = "com_github_bketelsen_crypt",
importpath = "github.com/bketelsen/crypt",
sum = "h1:+0HFd5KSZ/mm3JmhmrDukiId5iR6w4+BdFtfSy4yWIc=",
version = "v0.0.3-0.20200106085610-5cbc8cc4026c",
)
go_repository( go_repository(
name = "com_github_bmizerany_pat", name = "com_github_bmizerany_pat",
importpath = "github.com/bmizerany/pat", importpath = "github.com/bmizerany/pat",
@@ -456,6 +510,31 @@ def prysm_deps():
sum = "h1:13EK9RTujF7lVkvHQ5Hbu6bM+Yfrq8L0MkJNnjHSd4Q=", sum = "h1:13EK9RTujF7lVkvHQ5Hbu6bM+Yfrq8L0MkJNnjHSd4Q=",
version = "v1.4.2", version = "v1.4.2",
) )
go_repository(
name = "com_github_consensys_bavard",
importpath = "github.com/consensys/bavard",
sum = "h1:Ulx+x6FcZnw25LXxuohvLeu7B1xGQIGrOy12Z+QCAjU=",
version = "v0.1.8-0.20210105233146-c16790d2aa8b",
)
go_repository(
name = "com_github_consensys_goff",
importpath = "github.com/consensys/goff",
sum = "h1:eatQPk1I/aVec+F5qs47id17bWZsQFIjxu7C9MsrIHY=",
version = "v0.3.10",
)
go_repository(
name = "com_github_consensys_gurvy",
importpath = "github.com/consensys/gurvy",
sum = "h1:H2hvjvT2OFMgdMn5ZbhXqHt+F8DJ2clZW7Vmc0kFFxc=",
version = "v0.3.8",
)
go_repository(
name = "com_github_coreos_bbolt",
importpath = "github.com/coreos/bbolt",
sum = "h1:wZwiHHUieZCquLkDL0B8UhzreNWsPHooDAG3q34zk0s=",
version = "v1.3.2",
)
go_repository( go_repository(
name = "com_github_coreos_etcd", name = "com_github_coreos_etcd",
importpath = "github.com/coreos/etcd", importpath = "github.com/coreos/etcd",
@@ -594,8 +673,8 @@ def prysm_deps():
go_repository( go_repository(
name = "com_github_dlclark_regexp2", name = "com_github_dlclark_regexp2",
importpath = "github.com/dlclark/regexp2", importpath = "github.com/dlclark/regexp2",
sum = "h1:8sAhBGEM0dRWogWqWyQeIJnxjWO6oIjl8FKqREDsGfk=", sum = "h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E=",
version = "v1.2.0", version = "v1.4.0",
) )
go_repository( go_repository(
@@ -624,12 +703,6 @@ def prysm_deps():
version = "v1.0.0", version = "v1.0.0",
) )
go_repository(
name = "com_github_dvyukov_go_fuzz",
importpath = "github.com/dvyukov/go-fuzz",
sum = "h1:NgO45/5mBLRVfiXerEFzH6ikcZ7DNRPS639xFg3ENzU=",
version = "v0.0.0-20200318091601-be3528f3a813",
)
go_repository( go_repository(
name = "com_github_eapache_go_resiliency", name = "com_github_eapache_go_resiliency",
importpath = "github.com/eapache/go-resiliency", importpath = "github.com/eapache/go-resiliency",
@@ -856,8 +929,8 @@ def prysm_deps():
go_repository( go_repository(
name = "com_github_go_ole_go_ole", name = "com_github_go_ole_go_ole",
importpath = "github.com/go-ole/go-ole", importpath = "github.com/go-ole/go-ole",
sum = "h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E=", sum = "h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY=",
version = "v1.2.1", version = "v1.2.5",
) )
go_repository( go_repository(
name = "com_github_go_openapi_jsonpointer", name = "com_github_go_openapi_jsonpointer",
@@ -886,8 +959,8 @@ def prysm_deps():
go_repository( go_repository(
name = "com_github_go_sourcemap_sourcemap", name = "com_github_go_sourcemap_sourcemap",
importpath = "github.com/go-sourcemap/sourcemap", importpath = "github.com/go-sourcemap/sourcemap",
sum = "h1:0b/xya7BKGhXuqFESKM4oIiRo9WOt2ebz7KxfreD6ug=", sum = "h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=",
version = "v2.1.2+incompatible", version = "v2.1.3+incompatible",
) )
go_repository( go_repository(
name = "com_github_go_sql_driver_mysql", name = "com_github_go_sql_driver_mysql",
@@ -908,6 +981,13 @@ def prysm_deps():
sum = "h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwnTLB6vQiq+o=", sum = "h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwnTLB6vQiq+o=",
version = "v2.1.0+incompatible", version = "v2.1.0+incompatible",
) )
go_repository(
name = "com_github_gofrs_uuid",
importpath = "github.com/gofrs/uuid",
sum = "h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84=",
version = "v3.3.0+incompatible",
)
go_repository( go_repository(
name = "com_github_gogo_googleapis", name = "com_github_gogo_googleapis",
importpath = "github.com/gogo/googleapis", importpath = "github.com/gogo/googleapis",
@@ -1260,6 +1340,12 @@ def prysm_deps():
version = "v0.0.0-20210130185500-57372fb27371", version = "v0.0.0-20210130185500-57372fb27371",
) )
go_repository(
name = "com_github_holiman_bloomfilter_v2",
importpath = "github.com/holiman/bloomfilter/v2",
sum = "h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=",
version = "v2.0.3",
)
go_repository( go_repository(
name = "com_github_holiman_uint256", name = "com_github_holiman_uint256",
importpath = "github.com/holiman/uint256", importpath = "github.com/holiman/uint256",
@@ -1485,6 +1571,12 @@ def prysm_deps():
version = "v1.0.0", version = "v1.0.0",
) )
go_repository(
name = "com_github_jedisct1_go_minisign",
importpath = "github.com/jedisct1/go-minisign",
sum = "h1:UvSe12bq+Uj2hWd8aOlwPmoZ+CITRFrdit+sDGfAg8U=",
version = "v0.0.0-20190909160543-45766022959e",
)
go_repository( go_repository(
name = "com_github_jessevdk_go_flags", name = "com_github_jessevdk_go_flags",
importpath = "github.com/jessevdk/go-flags", importpath = "github.com/jessevdk/go-flags",
@@ -1497,6 +1589,13 @@ def prysm_deps():
sum = "h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=", sum = "h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=",
version = "v0.4.0", version = "v0.4.0",
) )
go_repository(
name = "com_github_jmespath_go_jmespath_internal_testify",
importpath = "github.com/jmespath/go-jmespath/internal/testify",
sum = "h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=",
version = "v1.5.1",
)
go_repository( go_repository(
name = "com_github_jonboulle_clockwork", name = "com_github_jonboulle_clockwork",
importpath = "github.com/jonboulle/clockwork", importpath = "github.com/jonboulle/clockwork",
@@ -1602,6 +1701,13 @@ def prysm_deps():
sum = "h1:qNtd6alRqd3qOdPrKXMZImV192ngQ0WSh1briEO33Tk=", sum = "h1:qNtd6alRqd3qOdPrKXMZImV192ngQ0WSh1briEO33Tk=",
version = "v0.0.0-20200115003610-082473db97ca", version = "v0.0.0-20200115003610-082473db97ca",
) )
go_repository(
name = "com_github_kilic_bls12_381",
importpath = "github.com/kilic/bls12-381",
sum = "h1:eZB80d/IKkIPjCTLUBT6+Imzn2zLpXtJFzY986jlHV4=",
version = "v0.0.0-20201226121925-69dacb279461",
)
go_repository( go_repository(
name = "com_github_kisielk_errcheck", name = "com_github_kisielk_errcheck",
importpath = "github.com/kisielk/errcheck", importpath = "github.com/kisielk/errcheck",
@@ -1707,6 +1813,12 @@ def prysm_deps():
version = "v1.1.0", version = "v1.1.0",
) )
go_repository(
name = "com_github_leanovate_gopter",
importpath = "github.com/leanovate/gopter",
sum = "h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=",
version = "v0.2.9",
)
go_repository( go_repository(
name = "com_github_lib_pq", name = "com_github_lib_pq",
importpath = "github.com/lib/pq", importpath = "github.com/lib/pq",
@@ -2273,12 +2385,6 @@ def prysm_deps():
version = "v0.0.0-20140419014527-cca7078d478f", version = "v0.0.0-20140419014527-cca7078d478f",
) )
go_repository(
name = "com_github_naoina_go_stringutil",
importpath = "github.com/naoina/go-stringutil",
sum = "h1:rCUeRUHjBjGTSHl0VC00jUPLz8/F9dDzYI70Hzifhks=",
version = "v0.1.0",
)
go_repository( go_repository(
name = "com_github_naoina_toml", name = "com_github_naoina_toml",
importpath = "github.com/naoina/toml", importpath = "github.com/naoina/toml",
@@ -2645,12 +2751,7 @@ def prysm_deps():
sum = "h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=", sum = "h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=",
version = "v1.7.0", version = "v1.7.0",
) )
go_repository(
name = "com_github_rs_xhandler",
importpath = "github.com/rs/xhandler",
sum = "h1:3hxavr+IHMsQBrYUPQM5v0CgENFktkkbg1sfpgM3h20=",
version = "v0.0.0-20160618193221-ed27b6fd6521",
)
go_repository( go_repository(
name = "com_github_russross_blackfriday", name = "com_github_russross_blackfriday",
importpath = "github.com/russross/blackfriday", importpath = "github.com/russross/blackfriday",
@@ -2680,8 +2781,8 @@ def prysm_deps():
go_repository( go_repository(
name = "com_github_satori_go_uuid", name = "com_github_satori_go_uuid",
importpath = "github.com/satori/go.uuid", importpath = "github.com/satori/go.uuid",
sum = "h1:gQZ0qzfKHQIybLANtM3mBXNUtOfsCFXeTsnBqCsx1KM=", sum = "h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=",
version = "v1.2.1-0.20181028125025-b2ce2384e17b", version = "v1.2.0",
) )
go_repository( go_repository(
@@ -2840,8 +2941,8 @@ def prysm_deps():
go_repository( go_repository(
name = "com_github_stackexchange_wmi", name = "com_github_stackexchange_wmi",
importpath = "github.com/StackExchange/wmi", importpath = "github.com/StackExchange/wmi",
sum = "h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8=", sum = "h1:5sXbqlSomvdjlRbWyNqkPsJ3Fg+tQZCbgeX1VGljbQY=",
version = "v0.0.0-20180116203802-5d049714c4a6", version = "v0.0.0-20210224194228-fe8f1750fd46",
) )
go_repository( go_repository(
name = "com_github_status_im_keycard_go", name = "com_github_status_im_keycard_go",
@@ -2849,18 +2950,6 @@ def prysm_deps():
sum = "h1:Oo2KZNP70KE0+IUJSidPj/BFS/RXNHmKIJOdckzml2E=", sum = "h1:Oo2KZNP70KE0+IUJSidPj/BFS/RXNHmKIJOdckzml2E=",
version = "v0.0.0-20200402102358-957c09536969", version = "v0.0.0-20200402102358-957c09536969",
) )
go_repository(
name = "com_github_steakknife_bloomfilter",
importpath = "github.com/steakknife/bloomfilter",
sum = "h1:gIlAHnH1vJb5vwEjIp5kBj/eu99p/bl0Ay2goiPe5xE=",
version = "v0.0.0-20180922174646-6819c0d2a570",
)
go_repository(
name = "com_github_steakknife_hamming",
importpath = "github.com/steakknife/hamming",
sum = "h1:njlZPzLwU639dk2kqnCPPv+wNjq7Xb6EfUxe/oX0/NM=",
version = "v0.0.0-20180906055917-c99c65617cd3",
)
go_repository( go_repository(
name = "com_github_streadway_amqp", name = "com_github_streadway_amqp",
@@ -2887,6 +2976,13 @@ def prysm_deps():
sum = "h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=", sum = "h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=",
version = "v1.7.0", version = "v1.7.0",
) )
go_repository(
name = "com_github_subosito_gotenv",
importpath = "github.com/subosito/gotenv",
sum = "h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=",
version = "v1.2.0",
)
http_archive( http_archive(
name = "com_github_supranational_blst", name = "com_github_supranational_blst",
urls = [ urls = [
@@ -3075,12 +3171,6 @@ def prysm_deps():
sum = "h1:ekJIKh6+YbUIVt9DfNbkR5d6aFcFTLDRyJNAACURBg8=", sum = "h1:ekJIKh6+YbUIVt9DfNbkR5d6aFcFTLDRyJNAACURBg8=",
version = "v1.1.3", version = "v1.1.3",
) )
go_repository(
name = "com_github_wsddn_go_ecdh",
importpath = "github.com/wsddn/go-ecdh",
sum = "h1:1cngl9mPEoITZG8s8cVcUy5CeIBYhEESkOB7m6Gmkrk=",
version = "v0.0.0-20161211032359-48726bab9208",
)
go_repository( go_repository(
name = "com_github_x_cray_logrus_prefixed_formatter", name = "com_github_x_cray_logrus_prefixed_formatter",
@@ -3163,6 +3253,13 @@ def prysm_deps():
sum = "h1:/May9ojXjRkPBNVrq+oWLqmWCkr4OU5uRY29bu0mRyQ=", sum = "h1:/May9ojXjRkPBNVrq+oWLqmWCkr4OU5uRY29bu0mRyQ=",
version = "v1.1.0", version = "v1.1.0",
) )
go_repository(
name = "com_google_cloud_go_firestore",
importpath = "cloud.google.com/go/firestore",
sum = "h1:9x7Bx0A9R5/M9jibeJeZWqjeVEIxYW9fZYqB9a70/bY=",
version = "v1.1.0",
)
go_repository( go_repository(
name = "com_google_cloud_go_pubsub", name = "com_google_cloud_go_pubsub",
importpath = "cloud.google.com/go/pubsub", importpath = "cloud.google.com/go/pubsub",
@@ -3262,6 +3359,13 @@ def prysm_deps():
sum = "h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=", sum = "h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=",
version = "v0.9.1", version = "v0.9.1",
) )
go_repository(
name = "in_gopkg_ini_v1",
importpath = "gopkg.in/ini.v1",
sum = "h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=",
version = "v1.51.0",
)
go_repository( go_repository(
name = "in_gopkg_jcmturner_aescts_v1", name = "in_gopkg_jcmturner_aescts_v1",
importpath = "gopkg.in/jcmturner/aescts.v1", importpath = "gopkg.in/jcmturner/aescts.v1",
@@ -3678,141 +3782,3 @@ def prysm_deps():
sum = "h1:uFRZXykJGK9lLY4HtgSw44DnIcAM+kRBP7x5m+NpAOM=", sum = "h1:uFRZXykJGK9lLY4HtgSw44DnIcAM+kRBP7x5m+NpAOM=",
version = "v1.16.0", version = "v1.16.0",
) )
go_repository(
name = "tools_gotest",
importpath = "gotest.tools",
sum = "h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=",
version = "v2.2.0+incompatible",
)
go_repository(
name = "com_github_aws_aws_sdk_go_v2_config",
importpath = "github.com/aws/aws-sdk-go-v2/config",
sum = "h1:ZAoq32boMzcaTW9bcUacBswAmHTbvlvDJICgHFZuECo=",
version = "v1.1.1",
)
go_repository(
name = "com_github_aws_aws_sdk_go_v2_credentials",
importpath = "github.com/aws/aws-sdk-go-v2/credentials",
sum = "h1:NbvWIM1Mx6sNPTxowHgS2ewXCRp+NGTzUYb/96FZJbY=",
version = "v1.1.1",
)
go_repository(
name = "com_github_aws_aws_sdk_go_v2_feature_ec2_imds",
importpath = "github.com/aws/aws-sdk-go-v2/feature/ec2/imds",
sum = "h1:EtEU7WRaWliitZh2nmuxEXrN0Cb8EgPUFGIoTMeqbzI=",
version = "v1.0.2",
)
go_repository(
name = "com_github_aws_aws_sdk_go_v2_service_internal_presigned_url",
importpath = "github.com/aws/aws-sdk-go-v2/service/internal/presigned-url",
sum = "h1:4AH9fFjUlVktQMznF+YN33aWNXaR4VgDXyP28qokJC0=",
version = "v1.0.2",
)
go_repository(
name = "com_github_aws_aws_sdk_go_v2_service_route53",
importpath = "github.com/aws/aws-sdk-go-v2/service/route53",
sum = "h1:cKr6St+CtC3/dl/rEBJvlk7A/IN5D5F02GNkGzfbtVU=",
version = "v1.1.1",
)
go_repository(
name = "com_github_aws_aws_sdk_go_v2_service_sso",
importpath = "github.com/aws/aws-sdk-go-v2/service/sso",
sum = "h1:37QubsarExl5ZuCBlnRP+7l1tNwZPBSTqpTBrPH98RU=",
version = "v1.1.1",
)
go_repository(
name = "com_github_aws_aws_sdk_go_v2_service_sts",
importpath = "github.com/aws/aws-sdk-go-v2/service/sts",
sum = "h1:TJoIfnIFubCX0ACVeJ0w46HEH5MwjwYN4iFhuYIhfIY=",
version = "v1.1.1",
)
go_repository(
name = "com_github_aws_smithy_go",
importpath = "github.com/aws/smithy-go",
sum = "h1:D6CSsM3gdxaGaqXnPgOBCeL6Mophqzu7KJOu7zW78sU=",
version = "v1.1.0",
)
go_repository(
name = "com_github_bketelsen_crypt",
importpath = "github.com/bketelsen/crypt",
sum = "h1:+0HFd5KSZ/mm3JmhmrDukiId5iR6w4+BdFtfSy4yWIc=",
version = "v0.0.3-0.20200106085610-5cbc8cc4026c",
)
go_repository(
name = "com_github_consensys_bavard",
importpath = "github.com/consensys/bavard",
sum = "h1:Ulx+x6FcZnw25LXxuohvLeu7B1xGQIGrOy12Z+QCAjU=",
version = "v0.1.8-0.20210105233146-c16790d2aa8b",
)
go_repository(
name = "com_github_consensys_goff",
importpath = "github.com/consensys/goff",
sum = "h1:eatQPk1I/aVec+F5qs47id17bWZsQFIjxu7C9MsrIHY=",
version = "v0.3.10",
)
go_repository(
name = "com_github_consensys_gurvy",
importpath = "github.com/consensys/gurvy",
sum = "h1:H2hvjvT2OFMgdMn5ZbhXqHt+F8DJ2clZW7Vmc0kFFxc=",
version = "v0.3.8",
)
go_repository(
name = "com_github_coreos_bbolt",
importpath = "github.com/coreos/bbolt",
sum = "h1:wZwiHHUieZCquLkDL0B8UhzreNWsPHooDAG3q34zk0s=",
version = "v1.3.2",
)
go_repository(
name = "com_github_gofrs_uuid",
importpath = "github.com/gofrs/uuid",
sum = "h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84=",
version = "v3.3.0+incompatible",
)
go_repository(
name = "com_github_holiman_bloomfilter_v2",
importpath = "github.com/holiman/bloomfilter/v2",
sum = "h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=",
version = "v2.0.3",
)
go_repository(
name = "com_github_jedisct1_go_minisign",
importpath = "github.com/jedisct1/go-minisign",
sum = "h1:UvSe12bq+Uj2hWd8aOlwPmoZ+CITRFrdit+sDGfAg8U=",
version = "v0.0.0-20190909160543-45766022959e",
)
go_repository(
name = "com_github_jmespath_go_jmespath_internal_testify",
importpath = "github.com/jmespath/go-jmespath/internal/testify",
sum = "h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=",
version = "v1.5.1",
)
go_repository(
name = "com_github_kilic_bls12_381",
importpath = "github.com/kilic/bls12-381",
sum = "h1:eZB80d/IKkIPjCTLUBT6+Imzn2zLpXtJFzY986jlHV4=",
version = "v0.0.0-20201226121925-69dacb279461",
)
go_repository(
name = "com_github_leanovate_gopter",
importpath = "github.com/leanovate/gopter",
sum = "h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=",
version = "v0.2.9",
)
go_repository(
name = "com_github_subosito_gotenv",
importpath = "github.com/subosito/gotenv",
sum = "h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=",
version = "v1.2.0",
)
go_repository(
name = "com_google_cloud_go_firestore",
importpath = "cloud.google.com/go/firestore",
sum = "h1:9x7Bx0A9R5/M9jibeJeZWqjeVEIxYW9fZYqB9a70/bY=",
version = "v1.1.0",
)
go_repository(
name = "in_gopkg_ini_v1",
importpath = "gopkg.in/ini.v1",
sum = "h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=",
version = "v1.51.0",
)

6
go.sum
View File

@@ -46,7 +46,10 @@ github.com/Azure/azure-storage-blob-go v0.7.0/go.mod h1:f9YQKtsG1nMisotuTPpO0tjN
github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI=
github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0=
github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA=
github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA=
github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc=
github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk=
@@ -171,6 +174,7 @@ github.com/consensys/goff v0.3.10/go.mod h1:xTldOBEHmFiYS0gPXd3NsaEqZWlnmeWcRLWg
github.com/consensys/gurvy v0.3.8/go.mod h1:sN75xnsiD593XnhbhvG2PkOy194pZBzqShWF/kwuW/g= github.com/consensys/gurvy v0.3.8/go.mod h1:sN75xnsiD593XnhbhvG2PkOy194pZBzqShWF/kwuW/g=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
@@ -427,6 +431,7 @@ github.com/gxed/hashland/keccakpg v0.0.1/go.mod h1:kRzw3HkwxFU1mpmPP8v1WyQzwdGfm
github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmvhST0bie/0lS48= github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmvhST0bie/0lS48=
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE=
github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE=
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
@@ -475,6 +480,7 @@ github.com/influxdata/flux v0.65.1/go.mod h1:J754/zds0vvpfwuq7Gc2wRdVwEodfpCFM7m
github.com/influxdata/influxdb v1.8.3 h1:WEypI1BQFTT4teLM+1qkEcvUi0dAvopAI/ir0vAiBg8= github.com/influxdata/influxdb v1.8.3 h1:WEypI1BQFTT4teLM+1qkEcvUi0dAvopAI/ir0vAiBg8=
github.com/influxdata/influxdb v1.8.3/go.mod h1:JugdFhsvvI8gadxOI6noqNeeBHvWNTbfYGtiAn+2jhI= github.com/influxdata/influxdb v1.8.3/go.mod h1:JugdFhsvvI8gadxOI6noqNeeBHvWNTbfYGtiAn+2jhI=
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/influxdata/influxql v1.1.1-0.20200828144457-65d3ef77d385/go.mod h1:gHp9y86a/pxhjJ+zMjNXiQAA197Xk9wLxaz+fGG+kWk= github.com/influxdata/influxql v1.1.1-0.20200828144457-65d3ef77d385/go.mod h1:gHp9y86a/pxhjJ+zMjNXiQAA197Xk9wLxaz+fGG+kWk=
github.com/influxdata/line-protocol v0.0.0-20180522152040-32c6aa80de5e/go.mod h1:4kt73NQhadE3daL3WhR5EJ/J2ocX0PZzwxQ0gXJ7oFE= github.com/influxdata/line-protocol v0.0.0-20180522152040-32c6aa80de5e/go.mod h1:4kt73NQhadE3daL3WhR5EJ/J2ocX0PZzwxQ0gXJ7oFE=
github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19ybifQhZoQNF5D8= github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19ybifQhZoQNF5D8=

View File

@@ -4,5 +4,6 @@
echo STABLE_GIT_COMMIT "$(git rev-parse HEAD)" echo STABLE_GIT_COMMIT "$(git rev-parse HEAD)"
echo DATE "$(date --rfc-3339=seconds --utc)" echo DATE "$(date --rfc-3339=seconds --utc)"
echo DATE_UNIX "$(date --utc +%s)"
echo DOCKER_TAG "$(git rev-parse --abbrev-ref HEAD)-$(git rev-parse --short=6 HEAD)" echo DOCKER_TAG "$(git rev-parse --abbrev-ref HEAD)-$(git rev-parse --short=6 HEAD)"
echo STABLE_GIT_TAG "$(git describe --tags "$(git rev-list --tags --max-count=1)")" echo STABLE_GIT_TAG "$(git describe --tags "$(git rev-list --tags --max-count=1)")"

View File

@@ -0,0 +1,8 @@
load("@prysm//tools/go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["types.go"],
importpath = "github.com/prysmaticlabs/prysm/shared/clientstats",
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,61 @@
package clientstats
// CommonStats represent generic metrics that are expected on both
// beaconnode and validator metric types. This type is used for
// marshaling metrics to the POST body sent to the metrics collcetor.
// Note that some metrics are labeled NA because they are expected
// to be present with their zero-value when not supported by a client.
type CommonStats struct {
CPUProcessSecondsTotal int64 `json:"cpu_process_seconds_total"`
MemoryProcessBytes int64 `json:"memory_process_bytes"`
ClientName string `json:"client_name"`
ClientVersion string `json:"client_version"`
ClientBuild int64 `json:"client_build"`
// TODO(#8849): parse the grpc connection string to determine
// if multiple addresses are present
SyncEth2FallbackConfigured bool `json:"sync_eth2_fallback_configured"`
// N/A -- when multiple addresses are provided to grpc, requests are
// load-balanced between the provided endpoints.
// This is different from a "fallback" configuration where
// the second address is treated as a failover.
SyncEth2FallbackConnected bool `json:"sync_eth2_fallback_connected"`
}
// BeaconNodeStats embeds CommonStats and represents metrics specific to
// the beacon-node process. This type is used to marshal metrics data
// to the POST body sent to the metrics collcetor. To make the connection
// to client-stats clear, BeaconNodeStats is also used by prometheus
// collection code introduced to support client-stats.
// Note that some metrics are labeled NA because they are expected
// to be present with their zero-value when not supported by a client.
type BeaconNodeStats struct {
// TODO(#8850): add support for this after slasher refactor is merged
SlasherActive bool `json:"slasher_active"`
SyncEth1FallbackConfigured bool `json:"sync_eth1_fallback_configured"`
SyncEth1FallbackConnected bool `json:"sync_eth1_fallback_connected"`
SyncEth1Connected bool `json:"sync_eth1_connected"`
SyncEth2Synced bool `json:"sync_eth2_synced"`
DiskBeaconchainBytesTotal int64 `json:"disk_beaconchain_bytes_total"`
// N/A -- would require significant network code changes at this time
NetworkLibp2pBytesTotalReceive int64 `json:"network_libp2p_bytes_total_receive"`
// N/A -- would require significant network code changes at this time
NetworkLibp2pBytesTotalTransmit int64 `json:"network_libp2p_bytes_total_transmit"`
// p2p_peer_count where label "state" == "Connected"
NetworkPeersConnected int64 `json:"network_peers_connected"`
// beacon_head_slot
SyncBeaconHeadSlot int64 `json:"sync_beacon_head_slot"`
CommonStats `json:",inline"`
}
// ValidatorStats embeds CommonStats and represents metrics specific to
// the validator process. This type is used to marshal metrics data
// to the POST body sent to the metrics collcetor.
// Note that some metrics are labeled NA because they are expected
// to be present with their zero-value when not supported by a client.
type ValidatorStats struct {
// N/A -- TODO(#8848): verify whether we can obtain this metric from the validator process
ValidatorTotal int64 `json:"validator_total"`
// N/A -- TODO(#8848): verify whether we can obtain this metric from the validator process
ValidatorActive int64 `json:"validator_active"`
CommonStats `json:",inline"`
}

View File

@@ -11,6 +11,7 @@ go_library(
x_defs = { x_defs = {
"gitCommit": "{STABLE_GIT_COMMIT}", "gitCommit": "{STABLE_GIT_COMMIT}",
"buildDate": "{DATE}", "buildDate": "{DATE}",
"buildDateUnix": "{DATE_UNIX}",
"gitTag": "{STABLE_GIT_TAG}", "gitTag": "{STABLE_GIT_TAG}",
}, },
deps = [ deps = [

View File

@@ -6,8 +6,11 @@ import (
) )
var prysmInfo = promauto.NewGauge(prometheus.GaugeOpts{ var prysmInfo = promauto.NewGauge(prometheus.GaugeOpts{
Name: "prysm_version", Name: "prysm_version",
ConstLabels: prometheus.Labels{"version": gitTag, "commit": gitCommit}, ConstLabels: prometheus.Labels{
"version": gitTag,
"commit": gitCommit,
"buildDate": buildDateUnix},
}) })
func init() { func init() {

View File

@@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"log" "log"
"os/exec" "os/exec"
"strconv"
"strings" "strings"
"time" "time"
) )
@@ -13,6 +14,7 @@ import (
// The value of these vars are set through linker options. // The value of these vars are set through linker options.
var gitCommit = "Local build" var gitCommit = "Local build"
var buildDate = "Moments ago" var buildDate = "Moments ago"
var buildDateUnix = "0"
var gitTag = "Unknown" var gitTag = "Unknown"
// Version returns the version string of this build. // Version returns the version string of this build.
@@ -21,6 +23,9 @@ func Version() string {
now := time.Now().Format(time.RFC3339) now := time.Now().Format(time.RFC3339)
buildDate = now buildDate = now
} }
if buildDateUnix == "{DATE_UNIX}" {
buildDateUnix = strconv.Itoa(int(time.Now().Unix()))
}
return fmt.Sprintf("%s. Built at: %s", BuildData(), buildDate) return fmt.Sprintf("%s. Built at: %s", BuildData(), buildDate)
} }