You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: backend/pkg/commons/db/statistics.go
+89-34Lines changed: 89 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -831,54 +831,109 @@ func gatherValidatorDepositWithdrawals(day uint64, data []*types.ValidatorStatsT
831
831
DepositsAmountuint64`db:"deposits_amount"`
832
832
}
833
833
resDeposits:=make([]*resRowDeposits, 0, 1024)
834
+
// In this query we are collecting all deposits per validator and sum them up. We need to consider that all deposits after the first valid deposits are valid. Note that there are currently only valid requests in the deposit_requests table.
834
835
depositsQry:=`
835
-
with first_valid_deposits as (
836
-
select
837
-
distinct on (publickey)
836
+
with
837
+
first_valid_deposits as (
838
+
select distinct on (publickey)
838
839
publickey,
839
840
block_slot,
840
841
block_index
841
842
from
842
843
blocks_deposits
843
844
where
844
845
valid_signature
845
-
and publickey in ( -- doesnt need to be 100% accurate, we only filter for performance reasons
846
-
select
847
-
publickey
848
-
from
849
-
blocks_deposits
850
-
where
851
-
blocks_deposits.block_slot >= $1
852
-
and blocks_deposits.block_slot <= $2
853
-
)
846
+
and publickey in (select bd.publickey from blocks_deposits bd where bd.valid_signature and bd.block_slot >= $1 and bd.block_slot <= $2)
854
847
order by
855
848
publickey,
856
849
block_slot,
857
850
block_index
851
+
),
852
+
first_valid_deposit_requests as (
853
+
select
854
+
distinct on (pubkey)
855
+
pubkey,
856
+
block_slot,
857
+
request_index
858
+
from
859
+
blocks_deposit_requests
860
+
where
861
+
pubkey in (select bdr.pubkey from blocks_deposit_requests bdr where bdr.block_slot >= $1 and bdr.block_slot <= $2)
0 commit comments