diff --git a/handlers/el_consolidations.go b/handlers/el_consolidations.go index 5dc8aa18..854887f4 100644 --- a/handlers/el_consolidations.go +++ b/handlers/el_consolidations.go @@ -50,7 +50,8 @@ func ElConsolidations(w http.ResponseWriter, r *http.Request) { var minTgtIndex uint64 var maxTgtIndex uint64 var tgtVName string - var withOrphaned uint64 + var withOrphaned uint64 = 1 + var pubkey string if urlArgs.Has("f") { if urlArgs.Has("f.mins") { @@ -83,13 +84,14 @@ func ElConsolidations(w http.ResponseWriter, r *http.Request) { if urlArgs.Has("f.orphaned") { withOrphaned, _ = strconv.ParseUint(urlArgs.Get("f.orphaned"), 10, 64) } - } else { - withOrphaned = 1 + if urlArgs.Has("f.pubkey") { + pubkey = urlArgs.Get("f.pubkey") + } } var pageError error pageError = services.GlobalCallRateLimiter.CheckCallLimit(r, 2) if pageError == nil { - data.Data, pageError = getFilteredElConsolidationsPageData(pageIdx, pageSize, minSlot, maxSlot, sourceAddr, minSrcIndex, maxSrcIndex, srcVName, minTgtIndex, maxTgtIndex, tgtVName, uint8(withOrphaned)) + data.Data, pageError = getFilteredElConsolidationsPageData(pageIdx, pageSize, minSlot, maxSlot, sourceAddr, minSrcIndex, maxSrcIndex, srcVName, minTgtIndex, maxTgtIndex, tgtVName, uint8(withOrphaned), pubkey) } if pageError != nil { handlePageError(w, r, pageError) @@ -101,11 +103,11 @@ func ElConsolidations(w http.ResponseWriter, r *http.Request) { } } -func getFilteredElConsolidationsPageData(pageIdx uint64, pageSize uint64, minSlot uint64, maxSlot uint64, sourceAddr string, minSrcIndex uint64, maxSrcIndex uint64, srcVName string, minTgtIndex uint64, maxTgtIndex uint64, tgtVName string, withOrphaned uint8) (*models.ElConsolidationsPageData, error) { +func getFilteredElConsolidationsPageData(pageIdx uint64, pageSize uint64, minSlot uint64, maxSlot uint64, sourceAddr string, minSrcIndex uint64, maxSrcIndex uint64, srcVName string, minTgtIndex uint64, maxTgtIndex uint64, tgtVName string, withOrphaned uint8, pubkey string) (*models.ElConsolidationsPageData, error) { pageData := &models.ElConsolidationsPageData{} - pageCacheKey := fmt.Sprintf("el_consolidations:%v:%v:%v:%v:%v:%v:%v:%v:%v:%v:%v:%v", pageIdx, pageSize, minSlot, maxSlot, sourceAddr, minSrcIndex, maxSrcIndex, srcVName, minTgtIndex, maxTgtIndex, tgtVName, withOrphaned) + pageCacheKey := fmt.Sprintf("el_consolidations:%v:%v:%v:%v:%v:%v:%v:%v:%v:%v:%v:%v:%v", pageIdx, pageSize, minSlot, maxSlot, sourceAddr, minSrcIndex, maxSrcIndex, srcVName, minTgtIndex, maxTgtIndex, tgtVName, withOrphaned, pubkey) pageRes, pageErr := services.GlobalFrontendCache.ProcessCachedPage(pageCacheKey, true, pageData, func(_ *services.FrontendCacheProcessingPage) interface{} { - return buildFilteredElConsolidationsPageData(pageIdx, pageSize, minSlot, maxSlot, sourceAddr, minSrcIndex, maxSrcIndex, srcVName, minTgtIndex, maxTgtIndex, tgtVName, withOrphaned) + return buildFilteredElConsolidationsPageData(pageIdx, pageSize, minSlot, maxSlot, sourceAddr, minSrcIndex, maxSrcIndex, srcVName, minTgtIndex, maxTgtIndex, tgtVName, withOrphaned, pubkey) }) if pageErr == nil && pageRes != nil { resData, resOk := pageRes.(*models.ElConsolidationsPageData) @@ -117,7 +119,7 @@ func getFilteredElConsolidationsPageData(pageIdx uint64, pageSize uint64, minSlo return pageData, pageErr } -func buildFilteredElConsolidationsPageData(pageIdx uint64, pageSize uint64, minSlot uint64, maxSlot uint64, sourceAddr string, minSrcIndex uint64, maxSrcIndex uint64, srcVName string, minTgtIndex uint64, maxTgtIndex uint64, tgtVName string, withOrphaned uint8) *models.ElConsolidationsPageData { +func buildFilteredElConsolidationsPageData(pageIdx uint64, pageSize uint64, minSlot uint64, maxSlot uint64, sourceAddr string, minSrcIndex uint64, maxSrcIndex uint64, srcVName string, minTgtIndex uint64, maxTgtIndex uint64, tgtVName string, withOrphaned uint8, pubkey string) *models.ElConsolidationsPageData { filterArgs := url.Values{} if minSlot != 0 { filterArgs.Add("f.mins", fmt.Sprintf("%v", minSlot)) @@ -149,6 +151,9 @@ func buildFilteredElConsolidationsPageData(pageIdx uint64, pageSize uint64, minS if withOrphaned != 0 { filterArgs.Add("f.orphaned", fmt.Sprintf("%v", withOrphaned)) } + if pubkey != "" { + filterArgs.Add("f.pubkey", pubkey) + } pageData := &models.ElConsolidationsPageData{ FilterAddress: sourceAddr, @@ -161,6 +166,7 @@ func buildFilteredElConsolidationsPageData(pageIdx uint64, pageSize uint64, minS FilterMaxTgtIndex: maxTgtIndex, FilterTgtValidatorName: tgtVName, FilterWithOrphaned: withOrphaned, + FilterPublicKey: pubkey, } logrus.Debugf("el_consolidations page called: %v:%v [%v,%v,%v,%v,%v,%v,%v,%v]", pageIdx, pageSize, minSlot, maxSlot, minSrcIndex, maxSrcIndex, srcVName, minTgtIndex, maxTgtIndex, tgtVName) if pageIdx == 1 { @@ -189,6 +195,7 @@ func buildFilteredElConsolidationsPageData(pageIdx uint64, pageSize uint64, minS MaxTgtIndex: maxTgtIndex, TgtValidatorName: tgtVName, WithOrphaned: withOrphaned, + PublicKey: common.FromHex(pubkey), } dbElConsolidations, totalRows := services.GlobalBeaconService.GetConsolidationRequestsByFilter(consolidationRequestFilter, pageIdx-1, uint32(pageSize)) diff --git a/handlers/el_withdrawals.go b/handlers/el_withdrawals.go index 818fadf3..6a74abf2 100644 --- a/handlers/el_withdrawals.go +++ b/handlers/el_withdrawals.go @@ -49,6 +49,7 @@ func ElWithdrawals(w http.ResponseWriter, r *http.Request) { var vname string var withOrphaned uint64 var withType uint64 + var pubkey string if urlArgs.Has("f") { if urlArgs.Has("f.mins") { @@ -75,13 +76,16 @@ func ElWithdrawals(w http.ResponseWriter, r *http.Request) { if urlArgs.Has("f.type") { withType, _ = strconv.ParseUint(urlArgs.Get("f.type"), 10, 64) } + if urlArgs.Has("f.pubkey") { + pubkey = urlArgs.Get("f.pubkey") + } } else { withOrphaned = 1 } var pageError error pageError = services.GlobalCallRateLimiter.CheckCallLimit(r, 2) if pageError == nil { - data.Data, pageError = getFilteredElWithdrawalsPageData(pageIdx, pageSize, minSlot, maxSlot, sourceAddr, minIndex, maxIndex, vname, uint8(withOrphaned), uint8(withType)) + data.Data, pageError = getFilteredElWithdrawalsPageData(pageIdx, pageSize, minSlot, maxSlot, sourceAddr, minIndex, maxIndex, vname, uint8(withOrphaned), uint8(withType), pubkey) } if pageError != nil { handlePageError(w, r, pageError) @@ -93,11 +97,11 @@ func ElWithdrawals(w http.ResponseWriter, r *http.Request) { } } -func getFilteredElWithdrawalsPageData(pageIdx uint64, pageSize uint64, minSlot uint64, maxSlot uint64, sourceAddr string, minIndex uint64, maxIndex uint64, vname string, withOrphaned uint8, withType uint8) (*models.ElWithdrawalsPageData, error) { +func getFilteredElWithdrawalsPageData(pageIdx uint64, pageSize uint64, minSlot uint64, maxSlot uint64, sourceAddr string, minIndex uint64, maxIndex uint64, vname string, withOrphaned uint8, withType uint8, pubkey string) (*models.ElWithdrawalsPageData, error) { pageData := &models.ElWithdrawalsPageData{} - pageCacheKey := fmt.Sprintf("el_withdrawals:%v:%v:%v:%v:%v:%v:%v:%v:%v:%v", pageIdx, pageSize, minSlot, maxSlot, sourceAddr, minIndex, maxIndex, vname, withOrphaned, withType) + pageCacheKey := fmt.Sprintf("el_withdrawals:%v:%v:%v:%v:%v:%v:%v:%v:%v:%v:%v", pageIdx, pageSize, minSlot, maxSlot, sourceAddr, minIndex, maxIndex, vname, withOrphaned, withType, pubkey) pageRes, pageErr := services.GlobalFrontendCache.ProcessCachedPage(pageCacheKey, true, pageData, func(_ *services.FrontendCacheProcessingPage) interface{} { - return buildFilteredElWithdrawalsPageData(pageIdx, pageSize, minSlot, maxSlot, sourceAddr, minIndex, maxIndex, vname, withOrphaned, withType) + return buildFilteredElWithdrawalsPageData(pageIdx, pageSize, minSlot, maxSlot, sourceAddr, minIndex, maxIndex, vname, withOrphaned, withType, pubkey) }) if pageErr == nil && pageRes != nil { resData, resOk := pageRes.(*models.ElWithdrawalsPageData) @@ -109,7 +113,7 @@ func getFilteredElWithdrawalsPageData(pageIdx uint64, pageSize uint64, minSlot u return pageData, pageErr } -func buildFilteredElWithdrawalsPageData(pageIdx uint64, pageSize uint64, minSlot uint64, maxSlot uint64, sourceAddr string, minIndex uint64, maxIndex uint64, vname string, withOrphaned uint8, withType uint8) *models.ElWithdrawalsPageData { +func buildFilteredElWithdrawalsPageData(pageIdx uint64, pageSize uint64, minSlot uint64, maxSlot uint64, sourceAddr string, minIndex uint64, maxIndex uint64, vname string, withOrphaned uint8, withType uint8, pubkey string) *models.ElWithdrawalsPageData { filterArgs := url.Values{} if minSlot != 0 { filterArgs.Add("f.mins", fmt.Sprintf("%v", minSlot)) @@ -135,6 +139,9 @@ func buildFilteredElWithdrawalsPageData(pageIdx uint64, pageSize uint64, minSlot if withType != 0 { filterArgs.Add("f.type", fmt.Sprintf("%v", withType)) } + if pubkey != "" { + filterArgs.Add("f.pubkey", pubkey) + } pageData := &models.ElWithdrawalsPageData{ FilterAddress: sourceAddr, @@ -145,6 +152,7 @@ func buildFilteredElWithdrawalsPageData(pageIdx uint64, pageSize uint64, minSlot FilterValidatorName: vname, FilterWithOrphaned: withOrphaned, FilterWithType: withType, + FilterPublicKey: pubkey, } logrus.Debugf("el_withdrawals page called: %v:%v [%v,%v,%v,%v,%v]", pageIdx, pageSize, minSlot, maxSlot, minIndex, maxIndex, vname) if pageIdx == 1 { @@ -170,6 +178,7 @@ func buildFilteredElWithdrawalsPageData(pageIdx uint64, pageSize uint64, minSlot MaxIndex: maxIndex, ValidatorName: vname, WithOrphaned: withOrphaned, + PublicKey: common.FromHex(pubkey), } switch withType { diff --git a/templates/el_consolidations/el_consolidations.html b/templates/el_consolidations/el_consolidations.html index 8c9a40e0..c8938876 100644 --- a/templates/el_consolidations/el_consolidations.html +++ b/templates/el_consolidations/el_consolidations.html @@ -72,6 +72,15 @@

+
+
+ Public Key + +
+
+ +
+
diff --git a/templates/el_withdrawals/el_withdrawals.html b/templates/el_withdrawals/el_withdrawals.html index 4d153613..7a69ec88 100644 --- a/templates/el_withdrawals/el_withdrawals.html +++ b/templates/el_withdrawals/el_withdrawals.html @@ -72,6 +72,14 @@

+
+
+ Public Key +
+
+ +
+
diff --git a/types/models/el_consolidations.go b/types/models/el_consolidations.go index 0df3e13c..9cef7b49 100644 --- a/types/models/el_consolidations.go +++ b/types/models/el_consolidations.go @@ -9,6 +9,7 @@ type ElConsolidationsPageData struct { FilterMinSlot uint64 `json:"filter_mins"` FilterMaxSlot uint64 `json:"filter_maxs"` FilterAddress string `json:"filter_address"` + FilterPublicKey string `json:"filter_pubkey"` FilterMinSrcIndex uint64 `json:"filter_minsi"` FilterMaxSrcIndex uint64 `json:"filter_maxsi"` FilterSrcValidatorName string `json:"filter_svname"` diff --git a/types/models/el_withdrawals.go b/types/models/el_withdrawals.go index fcf6aea1..e2121d9a 100644 --- a/types/models/el_withdrawals.go +++ b/types/models/el_withdrawals.go @@ -14,6 +14,7 @@ type ElWithdrawalsPageData struct { FilterValidatorName string `json:"filter_vname"` FilterWithOrphaned uint8 `json:"filter_orphaned"` FilterWithType uint8 `json:"filter_type"` + FilterPublicKey string `json:"filter_pubkey"` ElRequests []*ElWithdrawalsPageDataWithdrawal `json:"withdrawals"` RequestCount uint64 `json:"request_count"`