From 98b0f1295e988a77bd2bb687e6cebd2685c6c825 Mon Sep 17 00:00:00 2001 From: Tarun Date: Mon, 2 Oct 2023 15:08:34 +0200 Subject: [PATCH 1/4] Enable additional metric to choose whether to download rewards from Lighthouse API or not --- pkg/db/metrics.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/db/metrics.go b/pkg/db/metrics.go index fa045bca..3b4b306a 100644 --- a/pkg/db/metrics.go +++ b/pkg/db/metrics.go @@ -9,6 +9,7 @@ type DBMetrics struct { Block bool Epoch bool ValidatorRewards bool + APIRewards bool Transactions bool } @@ -22,9 +23,13 @@ func NewMetrics(input string) (DBMetrics, error) { dbMetrics.Block = true case "epoch": dbMetrics.Epoch = true + dbMetrics.Block = true case "rewards": dbMetrics.ValidatorRewards = true dbMetrics.Epoch = true + dbMetrics.Block = true + case "api_rewards": + dbMetrics.APIRewards = true case "transactions": dbMetrics.Transactions = true dbMetrics.Block = true From cc935a5f405c847706f028c18f357e3df663a47a Mon Sep 17 00:00:00 2001 From: Tarun Date: Mon, 2 Oct 2023 15:08:50 +0200 Subject: [PATCH 2/4] Only download rewards from API if tag activated --- pkg/clientapi/block.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/clientapi/block.go b/pkg/clientapi/block.go index 0c9abafb..d25e4013 100644 --- a/pkg/clientapi/block.go +++ b/pkg/clientapi/block.go @@ -46,7 +46,7 @@ func (s APIClient) RequestBeaconBlock(slot phase0.Slot) (spec.AgnosticBlock, err customBlock.StateRoot = s.RequestStateRoot(slot) - if s.Metrics.ValidatorRewards { + if s.Metrics.APIRewards { reward, err := s.RequestBlockRewards(slot) if err != nil { log.Error("cannot request block reward: %s", err) From ee5fa0d1779de94e9fa85ed19d872a74f1de1055 Mon Sep 17 00:00:00 2001 From: Tarun Date: Mon, 2 Oct 2023 15:09:02 +0200 Subject: [PATCH 3/4] Update go.mod --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 5072a4ea..b2aac9ce 100644 --- a/go.mod +++ b/go.mod @@ -70,7 +70,7 @@ require ( github.com/mattn/go-isatty v0.0.18 // indirect github.com/minio/sha256-simd v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 // indirect + github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 github.com/r3labs/sse/v2 v2.10.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect golang.org/x/crypto v0.10.0 // indirect From fcc693a98873f35e49480976708652ae620d30c3 Mon Sep 17 00:00:00 2001 From: Tarun Date: Tue, 3 Oct 2023 08:44:44 +0200 Subject: [PATCH 4/4] Update metrics documentation --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6e907928..e4c41816 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ make install - block: downloads withdrawals, blocks and block rewards - epoch: download epoch metrics, proposer duties, validator last status, - rewards: persists validator rewards metrics to database (activates epoch metrics) +- api_rewards: block rewards are hard to calculate, but they can be downloaded from the Beacon API. However, keep in mind this takes a few seconds per block when not at the head. Without this, reward cannot be compared to max_reward when a validator is a proposer (32/900K validators in an epoch). - transactions: requests transaction receipts from the execution layer (activates block metrics) ### Running the tool