Skip to content

Commit

Permalink
(NOBIDS) wrap withdrawalcount with coalesce in all queries
Browse files Browse the repository at this point in the history
  • Loading branch information
guybrush committed May 16, 2024
1 parent 874ff7e commit 633e9ac
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ func SaveEpoch(epoch uint64, validators []*types.Validator, client rpc.Client, t
attesterslashingscount,
attestationscount,
depositscount,
withdrawalcount,
COALESCEwithdrawalcount,
voluntaryexitscount,
validatorscount,
averagevalidatorbalance,
Expand Down
6 changes: 3 additions & 3 deletions handlers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func ApiEpoch(w http.ResponseWriter, r *http.Request) {
return
}

rows, err := db.ReaderDb.Query(`SELECT attestationscount, attesterslashingscount, averagevalidatorbalance, blockscount, depositscount, eligibleether, epoch, (epoch <= $2) AS finalized, globalparticipationrate, proposerslashingscount, rewards_exported, totalvalidatorbalance, validatorscount, voluntaryexitscount, votedether, withdrawalcount,
rows, err := db.ReaderDb.Query(`SELECT attestationscount, attesterslashingscount, averagevalidatorbalance, blockscount, depositscount, eligibleether, epoch, (epoch <= $2) AS finalized, globalparticipationrate, proposerslashingscount, rewards_exported, totalvalidatorbalance, validatorscount, voluntaryexitscount, votedether, COALESCE(withdrawalcount,0),
(SELECT COUNT(*) FROM blocks WHERE epoch = $1 AND status = '0') as scheduledblocks,
(SELECT COUNT(*) FROM blocks WHERE epoch = $1 AND status = '1') as proposedblocks,
(SELECT COUNT(*) FROM blocks WHERE epoch = $1 AND status = '2') as missedblocks,
Expand Down Expand Up @@ -355,7 +355,7 @@ func ApiEpochSlots(w http.ResponseWriter, r *http.Request) {
return
}

rows, err := db.ReaderDb.Query("SELECT attestationscount, attesterslashingscount, blockroot, depositscount, epoch, eth1data_blockhash, eth1data_depositcount, eth1data_depositroot, exec_base_fee_per_gas, exec_block_hash, exec_block_number, exec_extra_data, exec_fee_recipient, exec_gas_limit, exec_gas_used, exec_logs_bloom, exec_parent_hash, exec_random, exec_receipts_root, exec_state_root, exec_timestamp, exec_transactions_count, graffiti, graffiti_text, parentroot, proposer, proposerslashingscount, randaoreveal, signature, slot, stateroot, status, syncaggregate_bits, syncaggregate_participation, syncaggregate_signature, voluntaryexitscount, withdrawalcount FROM blocks WHERE epoch = $1 ORDER BY slot", epoch)
rows, err := db.ReaderDb.Query("SELECT attestationscount, attesterslashingscount, blockroot, depositscount, epoch, eth1data_blockhash, eth1data_depositcount, eth1data_depositroot, exec_base_fee_per_gas, exec_block_hash, exec_block_number, exec_extra_data, exec_fee_recipient, exec_gas_limit, exec_gas_used, exec_logs_bloom, exec_parent_hash, exec_random, exec_receipts_root, exec_state_root, exec_timestamp, COALESCE(exec_transactions_count,0), graffiti, graffiti_text, parentroot, proposer, proposerslashingscount, randaoreveal, signature, slot, stateroot, status, syncaggregate_bits, syncaggregate_participation, syncaggregate_signature, voluntaryexitscount, COALESCE(withdrawalcount,0) FROM blocks WHERE epoch = $1 ORDER BY slot", epoch)
if err != nil {
sendServerErrorResponse(w, r.URL.String(), "could not retrieve db results")
return
Expand Down Expand Up @@ -434,7 +434,7 @@ func ApiSlots(w http.ResponseWriter, r *http.Request) {
blocks.attesterslashingscount,
blocks.attestationscount,
blocks.depositscount,
blocks.withdrawalcount,
COALESCE(blocks.withdrawalcount,0),
blocks.voluntaryexitscount,
blocks.proposer,
blocks.status,
Expand Down
2 changes: 1 addition & 1 deletion handlers/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func Epoch(w http.ResponseWriter, r *http.Request) {
blocks.parentroot,
blocks.attestationscount,
blocks.depositscount,
blocks.withdrawalcount,
COALESCE(blocks.withdrawalcount,0),
blocks.voluntaryexitscount,
blocks.proposerslashingscount,
blocks.attesterslashingscount,
Expand Down
2 changes: 1 addition & 1 deletion handlers/epochs.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func EpochsData(w http.ResponseWriter, r *http.Request) {
attesterslashingscount,
attestationscount,
depositscount,
withdrawalcount,
COALESCE(withdrawalcount,0),
voluntaryexitscount,
validatorscount,
averagevalidatorbalance,
Expand Down
2 changes: 1 addition & 1 deletion handlers/slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func GetSlotPageData(blockSlot uint64) (*types.BlockPageData, error) {
blocks.attesterslashingscount,
blocks.attestationscount,
blocks.depositscount,
blocks.withdrawalcount,
COALESCE(blocks.withdrawalcount,0),
blocks.voluntaryexitscount,
blocks.proposer,
blocks.status,
Expand Down
4 changes: 2 additions & 2 deletions handlers/slots.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func GetSlotsTableData(draw, start, length uint64, search string, searchForEmpty
blocks.parentroot,
blocks.attestationscount,
blocks.depositscount,
blocks.withdrawalcount,
COALESCE(blocks.withdrawalcount,0),
blocks.voluntaryexitscount,
blocks.proposerslashingscount,
blocks.attesterslashingscount,
Expand Down Expand Up @@ -215,7 +215,7 @@ func GetSlotsTableData(draw, start, length uint64, search string, searchForEmpty
blocks.parentroot,
blocks.attestationscount,
blocks.depositscount,
blocks.withdrawalcount,
COALESCE(blocks.withdrawalcount,0),
blocks.voluntaryexitscount,
blocks.proposerslashingscount,
blocks.attesterslashingscount,
Expand Down
2 changes: 1 addition & 1 deletion handlers/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ func ValidatorProposedBlocks(w http.ResponseWriter, r *http.Request) {
parentroot,
attestationscount,
depositscount,
withdrawalcount,
COALESCE(withdrawalcount,0),
voluntaryexitscount,
proposerslashingscount,
attesterslashingscount,
Expand Down
2 changes: 1 addition & 1 deletion services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ func getIndexPageData() (*types.IndexPageData, error) {
blocks.parentroot,
blocks.attestationscount,
blocks.depositscount,
blocks.withdrawalcount,
COALESCE(blocks.withdrawalcount,0),
blocks.voluntaryexitscount,
blocks.proposerslashingscount,
blocks.attesterslashingscount,
Expand Down

0 comments on commit 633e9ac

Please sign in to comment.