Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced validator details #182

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5719922
add tabs to validator details page
pk910 Oct 24, 2024
8ba38d6
commit
pk910 Oct 24, 2024
57d182f
Merge branch 'master' into pk910/per-validator-operations
pk910 Nov 27, 2024
669f797
remove activity bitfield from voting aggregations, bump up voting agg…
pk910 Nov 28, 2024
e8b4930
implement new validator cache
pk910 Nov 28, 2024
cb3e0fa
added simple debug page for cache insights
pk910 Nov 28, 2024
874ce59
track validator votking activity
pk910 Nov 28, 2024
06dac2e
added no-js friendly lazy loading for validator details tabs
pk910 Nov 28, 2024
1c12140
show recent attestations on validator details page
pk910 Nov 29, 2024
ea5f105
Merge branch 'master' into pk910/per-validator-operations
pk910 Nov 29, 2024
8a020ca
fix merge conflict
pk910 Nov 29, 2024
0f74f94
show deposits on validator details page
pk910 Nov 29, 2024
2d524c2
add withdrawal & consolidation request details to validator details page
pk910 Nov 29, 2024
db66236
add separate config setting for validator activity history length
pk910 Nov 30, 2024
5e45147
add pubkey filter to el_consolidations & el_withdrawals pages
pk910 Dec 2, 2024
ec01fbc
added central getters for combined consolidation & withdrawal requests
pk910 Dec 2, 2024
9317d19
change validator not found message
pk910 Dec 2, 2024
88297d9
various small fixes for validator details page
pk910 Dec 2, 2024
a2d149d
Merge branch 'master' into pk910/per-validator-operations
pk910 Dec 2, 2024
52fa299
fix parent fork id getter for finalized fork ids
pk910 Dec 2, 2024
6ae1da9
fix parent fork id getter for finalized fork ids
pk910 Dec 2, 2024
ab75463
add exit reason to validator details page
pk910 Dec 3, 2024
66cda22
small style fixes
pk910 Dec 3, 2024
2ad83f5
fix issue with out of order deposit request inclusion (possible durin…
pk910 Dec 3, 2024
6e70516
request balances for relevant pages (index, submit consolidations/wit…
pk910 Dec 3, 2024
78443c1
show withdrawal addresses for 0x02 credentials on validators list
pk910 Dec 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .hack/devnet/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ $(for node in $EXECUTION_NODES; do
done)
indexer:
inMemoryEpochs: 8
activityHistoryLength: 6
cachePersistenceDelay: 8
disableIndexWriter: false
syncEpochCooldown: 1
Expand Down
1 change: 1 addition & 0 deletions cmd/dora-explorer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ func startFrontend(webserver *http.Server) {
if utils.Config.Frontend.Pprof {
// add pprof handler
router.PathPrefix("/debug/pprof/").Handler(http.DefaultServeMux)
router.HandleFunc("/debug/cache", handlers.DebugCache).Methods("GET")
}

if utils.Config.Frontend.Debug {
Expand Down
3 changes: 3 additions & 0 deletions config/default.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ indexer:
# max number of epochs to keep in memory
inMemoryEpochs: 3

# number of epochs to keep validator activity history for (high memory usage for large validator sets)
activityHistoryLength: 6

# disable synchronizing historic data
disableSynchronizer: false

Expand Down
5 changes: 5 additions & 0 deletions db/consolidation_request_txs.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ func GetConsolidationRequestTxsFiltered(offset uint64, limit uint32, canonicalFo
fmt.Fprintf(&sql, " %v dequeue_block <= $%v", filterOp, len(args))
filterOp = "AND"
}
if len(filter.PublicKey) > 0 {
args = append(args, filter.PublicKey)
fmt.Fprintf(&sql, " %v (source_pubkey = $%v OR target_pubkey = $%v) ", filterOp, len(args), len(args))
filterOp = "AND"
}
if len(filter.SourceAddress) > 0 {
args = append(args, filter.SourceAddress)
fmt.Fprintf(&sql, " %v source_address = $%v", filterOp, len(args))
Expand Down
31 changes: 22 additions & 9 deletions db/consolidation_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func InsertConsolidationRequests(consolidations []*dbtypes.ConsolidationRequest,
return nil
}

func GetConsolidationRequestsFiltered(offset uint64, limit uint32, finalizedBlock uint64, filter *dbtypes.ConsolidationRequestFilter) ([]*dbtypes.ConsolidationRequest, uint64, error) {
func GetConsolidationRequestsFiltered(offset uint64, limit uint32, canonicalForkIds []uint64, filter *dbtypes.ConsolidationRequestFilter) ([]*dbtypes.ConsolidationRequest, uint64, error) {
var sql strings.Builder
args := []interface{}{}
fmt.Fprint(&sql, `
Expand Down Expand Up @@ -92,6 +92,11 @@ func GetConsolidationRequestsFiltered(offset uint64, limit uint32, finalizedBloc
fmt.Fprintf(&sql, " %v slot_number <= $%v", filterOp, len(args))
filterOp = "AND"
}
if len(filter.PublicKey) > 0 {
args = append(args, filter.PublicKey)
fmt.Fprintf(&sql, " %v (source_pubkey = $%v OR target_pubkey = $%v) ", filterOp, len(args), len(args))
filterOp = "AND"
}
if len(filter.SourceAddress) > 0 {
args = append(args, filter.SourceAddress)
fmt.Fprintf(&sql, " %v source_address = $%v", filterOp, len(args))
Expand Down Expand Up @@ -136,14 +141,22 @@ func GetConsolidationRequestsFiltered(offset uint64, limit uint32, finalizedBloc
filterOp = "AND"
}

if filter.WithOrphaned == 0 {
args = append(args, finalizedBlock)
fmt.Fprintf(&sql, " %v (slot_number > $%v OR orphaned = false)", filterOp, len(args))
filterOp = "AND"
} else if filter.WithOrphaned == 2 {
args = append(args, finalizedBlock)
fmt.Fprintf(&sql, " %v (slot_number > $%v OR orphaned = true)", filterOp, len(args))
filterOp = "AND"
if filter.WithOrphaned != 1 {
forkIdStr := make([]string, len(canonicalForkIds))
for i, forkId := range canonicalForkIds {
forkIdStr[i] = fmt.Sprintf("%v", forkId)
}
if len(forkIdStr) == 0 {
forkIdStr = append(forkIdStr, "0")
}

if filter.WithOrphaned == 0 {
fmt.Fprintf(&sql, " %v fork_id IN (%v)", filterOp, strings.Join(forkIdStr, ","))
filterOp = "AND"
} else if filter.WithOrphaned == 2 {
fmt.Fprintf(&sql, " %v fork_id NOT IN (%v)", filterOp, strings.Join(forkIdStr, ","))
filterOp = "AND"
}
}

args = append(args, limit)
Expand Down
10 changes: 10 additions & 0 deletions db/deposits.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@ func GetDepositTxsFiltered(offset uint64, limit uint32, finalizedBlock uint64, f
`)

filterOp := "WHERE"
if filter.MinIndex > 0 {
args = append(args, filter.MinIndex)
fmt.Fprintf(&sql, " %v deposit_index >= $%v", filterOp, len(args))
filterOp = "AND"
}
if filter.MaxIndex > 0 {
args = append(args, filter.MaxIndex)
fmt.Fprintf(&sql, " %v deposit_index <= $%v", filterOp, len(args))
filterOp = "AND"
}
if len(filter.Address) > 0 {
args = append(args, filter.Address)
fmt.Fprintf(&sql, " %v tx_sender = $%v", filterOp, len(args))
Expand Down
5 changes: 5 additions & 0 deletions db/withdrawal_request_txs.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ func GetWithdrawalRequestTxsFiltered(offset uint64, limit uint32, canonicalForkI
fmt.Fprintf(&sql, " %v dequeue_block <= $%v", filterOp, len(args))
filterOp = "AND"
}
if len(filter.PublicKey) > 0 {
args = append(args, filter.PublicKey)
fmt.Fprintf(&sql, " %v validator_pubkey = $%v ", filterOp, len(args))
filterOp = "AND"
}
if len(filter.SourceAddress) > 0 {
args = append(args, filter.SourceAddress)
fmt.Fprintf(&sql, " %v source_address = $%v", filterOp, len(args))
Expand Down
31 changes: 22 additions & 9 deletions db/withdrawal_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func InsertWithdrawalRequests(elRequests []*dbtypes.WithdrawalRequest, tx *sqlx.
return nil
}

func GetWithdrawalRequestsFiltered(offset uint64, limit uint32, finalizedBlock uint64, filter *dbtypes.WithdrawalRequestFilter) ([]*dbtypes.WithdrawalRequest, uint64, error) {
func GetWithdrawalRequestsFiltered(offset uint64, limit uint32, canonicalForkIds []uint64, filter *dbtypes.WithdrawalRequestFilter) ([]*dbtypes.WithdrawalRequest, uint64, error) {
var sql strings.Builder
args := []interface{}{}
fmt.Fprint(&sql, `
Expand All @@ -88,6 +88,11 @@ func GetWithdrawalRequestsFiltered(offset uint64, limit uint32, finalizedBlock u
fmt.Fprintf(&sql, " %v slot_number <= $%v", filterOp, len(args))
filterOp = "AND"
}
if len(filter.PublicKey) > 0 {
args = append(args, filter.PublicKey)
fmt.Fprintf(&sql, " %v validator_pubkey = $%v ", filterOp, len(args))
filterOp = "AND"
}
if len(filter.SourceAddress) > 0 {
args = append(args, filter.SourceAddress)
fmt.Fprintf(&sql, " %v source_address = $%v", filterOp, len(args))
Expand Down Expand Up @@ -123,14 +128,22 @@ func GetWithdrawalRequestsFiltered(offset uint64, limit uint32, finalizedBlock u
filterOp = "AND"
}

if filter.WithOrphaned == 0 {
args = append(args, finalizedBlock)
fmt.Fprintf(&sql, " %v (slot_number > $%v OR orphaned = false)", filterOp, len(args))
filterOp = "AND"
} else if filter.WithOrphaned == 2 {
args = append(args, finalizedBlock)
fmt.Fprintf(&sql, " %v (slot_number > $%v OR orphaned = true)", filterOp, len(args))
filterOp = "AND"
if filter.WithOrphaned != 1 {
forkIdStr := make([]string, len(canonicalForkIds))
for i, forkId := range canonicalForkIds {
forkIdStr[i] = fmt.Sprintf("%v", forkId)
}
if len(forkIdStr) == 0 {
forkIdStr = append(forkIdStr, "0")
}

if filter.WithOrphaned == 0 {
fmt.Fprintf(&sql, " %v fork_id IN (%v)", filterOp, strings.Join(forkIdStr, ","))
filterOp = "AND"
} else if filter.WithOrphaned == 2 {
fmt.Fprintf(&sql, " %v fork_id NOT IN (%v)", filterOp, strings.Join(forkIdStr, ","))
filterOp = "AND"
}
}

args = append(args, limit)
Expand Down
6 changes: 6 additions & 0 deletions dbtypes/other.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ type MevBlockFilter struct {
}

type DepositTxFilter struct {
MinIndex uint64
MaxIndex uint64
Address []byte
TargetAddress []byte
PublicKey []byte
Expand Down Expand Up @@ -96,6 +98,7 @@ type SlashingFilter struct {
type WithdrawalRequestFilter struct {
MinSlot uint64
MaxSlot uint64
PublicKey []byte
SourceAddress []byte
MinIndex uint64
MaxIndex uint64
Expand All @@ -108,6 +111,7 @@ type WithdrawalRequestFilter struct {
type WithdrawalRequestTxFilter struct {
MinDequeue uint64
MaxDequeue uint64
PublicKey []byte
SourceAddress []byte
MinIndex uint64
MaxIndex uint64
Expand All @@ -120,6 +124,7 @@ type WithdrawalRequestTxFilter struct {
type ConsolidationRequestFilter struct {
MinSlot uint64
MaxSlot uint64
PublicKey []byte
SourceAddress []byte
MinSrcIndex uint64
MaxSrcIndex uint64
Expand All @@ -133,6 +138,7 @@ type ConsolidationRequestFilter struct {
type ConsolidationRequestTxFilter struct {
MinDequeue uint64
MaxDequeue uint64
PublicKey []byte
SourceAddress []byte
MinSrcIndex uint64
MaxSrcIndex uint64
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ require (
)

require (
github.com/520MianXiangDuiXiang520/MapSize v0.0.0-20230414174449-030467540731 // indirect
github.com/ipfs/go-cid v0.4.1 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/520MianXiangDuiXiang520/MapSize v0.0.0-20230414174449-030467540731 h1:ynhEKD+8g0G5Rk98HVqGeenoRBoHz0In6bAQ7bEzklQ=
github.com/520MianXiangDuiXiang520/MapSize v0.0.0-20230414174449-030467540731/go.mod h1:YGrfzOdPf4xnEhFGmxjVSw0xuu/PLmGsJZipIpp8+C0=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ=
github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
Expand Down
43 changes: 43 additions & 0 deletions handlers/debug_cache.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package handlers

import (
"encoding/json"
"errors"
"net/http"

"github.com/sirupsen/logrus"

"github.com/ethpandaops/dora/services"
"github.com/ethpandaops/dora/templates"
"github.com/ethpandaops/dora/utils"
)

// DebugCache will submit a consolidation request
func DebugCache(w http.ResponseWriter, r *http.Request) {
var debugCacheTemplateFiles = append(layoutTemplateFiles,
"debug_cache/debug_cache.html",
)
var pageTemplate = templates.GetTemplate(debugCacheTemplateFiles...)

if !utils.Config.Frontend.Pprof {
handlePageError(w, r, errors.New("debug pages are not enabled"))
return
}

pageData := buildDebugCachePageData()
data := InitPageData(w, r, "blockchain", "/debug_cache", "Debug Cache", debugCacheTemplateFiles)
data.Data = pageData
w.Header().Set("Content-Type", "text/html")
if handleTemplateError(w, r, "debug_cache.go", "Debug Cache", "", pageTemplate.ExecuteTemplate(w, "layout", data)) != nil {
return // an error has occurred and was processed
}
}

func buildDebugCachePageData() string {
logrus.Debugf("debug cache page called")

cacheStats := services.GlobalBeaconService.GetBeaconIndexer().GetCacheDebugStats()
jsonStats, _ := json.MarshalIndent(cacheStats, "", " ")

return string(jsonStats)
}
21 changes: 10 additions & 11 deletions handlers/deposits.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ func buildDepositsPageData(firstEpoch uint64, pageSize uint64) (*models.Deposits
}

chainState := services.GlobalBeaconService.GetChainState()
validatorSetRsp := services.GlobalBeaconService.GetCachedValidatorPubkeyMap()
validatorActivityMap, validatorActivityMax := services.GlobalBeaconService.GetValidatorActivity(3, false)

// load initiated deposits
dbDepositTxs := db.GetDepositTxs(0, 20)
Expand All @@ -97,14 +95,14 @@ func buildDepositsPageData(firstEpoch uint64, pageSize uint64) (*models.Deposits
Valid: depositTx.ValidSignature,
}

validator := validatorSetRsp[phase0.BLSPubKey(depositTx.PublicKey)]
if validator == nil {
validatorIndex, found := services.GlobalBeaconService.GetValidatorIndexByPubkey(phase0.BLSPubKey(depositTx.PublicKey))
if !found {
depositTxData.ValidatorStatus = "Deposited"
} else {
validator := services.GlobalBeaconService.GetValidatorByIndex(validatorIndex, false)
if strings.HasPrefix(validator.Status.String(), "pending") {
depositTxData.ValidatorStatus = "Pending"
} else if validator.Status == v1.ValidatorStateActiveOngoing {
depositTxData.ValidatorStatus = "Active"
depositTxData.ShowUpcheck = true
} else if validator.Status == v1.ValidatorStateActiveExiting {
depositTxData.ValidatorStatus = "Exiting"
Expand All @@ -121,8 +119,8 @@ func buildDepositsPageData(firstEpoch uint64, pageSize uint64) (*models.Deposits
}

if depositTxData.ShowUpcheck {
depositTxData.UpcheckActivity = validatorActivityMap[validator.Index]
depositTxData.UpcheckMaximum = uint8(validatorActivityMax)
depositTxData.UpcheckActivity = uint8(services.GlobalBeaconService.GetValidatorLiveness(validator.Index, 3))
depositTxData.UpcheckMaximum = uint8(3)
}
}

Expand All @@ -148,10 +146,11 @@ func buildDepositsPageData(firstEpoch uint64, pageSize uint64) (*models.Deposits
depositData.Index = *deposit.Index
}

validator := validatorSetRsp[phase0.BLSPubKey(deposit.PublicKey)]
if validator == nil {
validatorIndex, found := services.GlobalBeaconService.GetValidatorIndexByPubkey(phase0.BLSPubKey(deposit.PublicKey))
if !found {
depositData.ValidatorStatus = "Deposited"
} else {
validator := services.GlobalBeaconService.GetValidatorByIndex(validatorIndex, false)
if strings.HasPrefix(validator.Status.String(), "pending") {
depositData.ValidatorStatus = "Pending"
} else if validator.Status == v1.ValidatorStateActiveOngoing {
Expand All @@ -172,8 +171,8 @@ func buildDepositsPageData(firstEpoch uint64, pageSize uint64) (*models.Deposits
}

if depositData.ShowUpcheck {
depositData.UpcheckActivity = validatorActivityMap[validator.Index]
depositData.UpcheckMaximum = uint8(validatorActivityMax)
depositData.UpcheckActivity = uint8(services.GlobalBeaconService.GetValidatorLiveness(validator.Index, 3))
depositData.UpcheckMaximum = uint8(3)
}
}

Expand Down
Loading