Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/BEDS-991/new-clickhouse-schema-c…
Browse files Browse the repository at this point in the history
…hanges' into publish-docker
  • Loading branch information
guybrush committed Dec 12, 2024
2 parents 47c05a6 + fd34030 commit 291ae61
Showing 1 changed file with 15 additions and 30 deletions.
45 changes: 15 additions & 30 deletions backend/pkg/api/data_access/vdb_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,37 +361,22 @@ func (d *DataAccessService) GetValidatorDashboardBlocks(ctx context.Context, das
Slot uint64 `db:"slot"`
ClReward decimal.NullDecimal `db:"cl_reward"`
}{}
if utils.Config.Chain.ClConfig.DepositChainID == 17000 {
clRewardsQuery := goqu.Dialect("postgres").
From(goqu.T("consensus_payloads")).
Select(
goqu.C("slot"),
goqu.L("cl_attestations_reward / 1e9 + cl_sync_aggregate_reward / 1e9 + cl_slashing_inclusion_reward / 1e9 AS cl_reward"),
).Where(goqu.C("slot").In(slots))
clRewardsQuerySql, args, err := clRewardsQuery.Prepared(true).ToSQL()
if err != nil {
return nil, nil, err
}
err = d.alloyReader.SelectContext(ctx, &clRewardsData, clRewardsQuerySql, args...)
if err != nil {
return nil, nil, err
}
} else {
clRewardsQuery := goqu.Dialect("postgres").
From(goqu.L("mainnet.validator_proposal_rewards_slot")).
Select(
goqu.C("slot"),
goqu.L("attestations_reward / 1e9 + sync_aggregate_reward / 1e9 + slasher_reward / 1e9 AS cl_reward"),
).Where(goqu.C("slot").In(slots))
clRewardsQuerySql, args, err := clRewardsQuery.Prepared(true).ToSQL()
if err != nil {
return nil, nil, err
}
err = d.clickhouseReader.SelectContext(ctx, &clRewardsData, clRewardsQuerySql, args...)
if err != nil {
return nil, nil, err
}

clRewardsQuery := goqu.Dialect("postgres").
From(goqu.L("validator_proposal_rewards_slot")).
Select(
goqu.C("slot"),
goqu.L("attestations_reward / 1e9 + sync_aggregate_reward / 1e9 + slasher_reward / 1e9 AS cl_reward"),
).Where(goqu.C("slot").In(slots))
clRewardsQuerySql, args, err := clRewardsQuery.Prepared(true).ToSQL()
if err != nil {
return nil, nil, err
}
err = d.clickhouseReader.SelectContext(ctx, &clRewardsData, clRewardsQuerySql, args...)
if err != nil {
return nil, nil, err
}

clRewards := make(map[uint64]decimal.NullDecimal)
for _, reward := range clRewardsData {
clRewards[reward.Slot] = reward.ClReward
Expand Down

0 comments on commit 291ae61

Please sign in to comment.