Skip to content

Commit

Permalink
Merge pull request #81 from migalabs/feat/optional-api-rewards
Browse files Browse the repository at this point in the history
Feat/optional api rewards
  • Loading branch information
tdahar authored Oct 18, 2023
2 parents bd55e13 + fcc693a commit 1295d1f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/clientapi/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions pkg/db/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type DBMetrics struct {
Block bool
Epoch bool
ValidatorRewards bool
APIRewards bool
Transactions bool
}

Expand All @@ -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
Expand Down

0 comments on commit 1295d1f

Please sign in to comment.