From fd340302cb53bad323f5ece6b72f650322cc8c17 Mon Sep 17 00:00:00 2001 From: Sasha Zezulinsky <188990923+sasha-bitfly@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:18:08 +0000 Subject: [PATCH] use validator_proposal_rewards_slot for all the networks --- backend/pkg/api/data_access/vdb_blocks.go | 45 ++++++++--------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/backend/pkg/api/data_access/vdb_blocks.go b/backend/pkg/api/data_access/vdb_blocks.go index 7fda00911..0427bee94 100644 --- a/backend/pkg/api/data_access/vdb_blocks.go +++ b/backend/pkg/api/data_access/vdb_blocks.go @@ -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