From 355fa50542018d43be41ec587376eab52d3c4925 Mon Sep 17 00:00:00 2001 From: Stefan Pletka <124689083+Eisei24@users.noreply.github.com> Date: Wed, 6 Nov 2024 11:15:54 +0100 Subject: [PATCH 1/6] Fixed wrong type of EventType in the cursor --- backend/pkg/api/types/data_access.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/backend/pkg/api/types/data_access.go b/backend/pkg/api/types/data_access.go index c4326b1ed..333c7b3e5 100644 --- a/backend/pkg/api/types/data_access.go +++ b/backend/pkg/api/types/data_access.go @@ -5,6 +5,7 @@ import ( "time" "github.com/gobitfly/beaconchain/pkg/api/enums" + t "github.com/gobitfly/beaconchain/pkg/commons/types" "github.com/gobitfly/beaconchain/pkg/consapi/types" "github.com/gobitfly/beaconchain/pkg/monitoring/constants" "github.com/shopspring/decimal" @@ -139,20 +140,12 @@ type NotificationClientsCursor struct { Ts time.Time } -type NotificationRocketPoolsCursor struct { - GenericCursor - - NodeAddress []byte - EventType string - Epoch uint64 -} - type NotificationNetworksCursor struct { GenericCursor Network uint64 Ts time.Time - EventType string + EventType t.EventName } type UserCredentialInfo struct { From c86c2d4fb5d1c369577f3729a3a71efee1e92792 Mon Sep 17 00:00:00 2001 From: Stefan Pletka <124689083+Eisei24@users.noreply.github.com> Date: Wed, 6 Nov 2024 13:34:31 +0100 Subject: [PATCH 2/6] Removed the event type conversion --- backend/pkg/api/data_access/notifications.go | 23 ++++---------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/backend/pkg/api/data_access/notifications.go b/backend/pkg/api/data_access/notifications.go index 91ad838f2..bdc13ca67 100644 --- a/backend/pkg/api/data_access/notifications.go +++ b/backend/pkg/api/data_access/notifications.go @@ -777,24 +777,12 @@ func (d *DataAccessService) GetMachineNotifications(ctx context.Context, userId // Calculate the result cursorData := notificationHistory for _, notification := range notificationHistory { - resultEntry := t.NotificationMachinesTableRow{ + result = append(result, t.NotificationMachinesTableRow{ MachineName: notification.MachineName, Threshold: notification.EventThreshold, + EventType: string(notification.EventType), Timestamp: notification.Ts.Unix(), - } - switch notification.EventType { - case types.MonitoringMachineOfflineEventName: - resultEntry.EventType = "offline" - case types.MonitoringMachineDiskAlmostFullEventName: - resultEntry.EventType = "storage" - case types.MonitoringMachineCpuLoadEventName: - resultEntry.EventType = "cpu" - case types.MonitoringMachineMemoryUsageEventName: - resultEntry.EventType = "memory" - default: - return nil, nil, fmt.Errorf("invalid event name for machine notification: %v", notification.EventType) - } - result = append(result, resultEntry) + }) } // ------------------------------------- @@ -996,19 +984,16 @@ func (d *DataAccessService) GetNetworkNotifications(ctx context.Context, userId resultEntry := t.NotificationNetworksTableRow{ ChainId: notification.Network, Timestamp: notification.Ts.Unix(), + EventType: string(notification.EventType), } switch notification.EventType { case types.NetworkGasAboveThresholdEventName: - resultEntry.EventType = "gas_above" resultEntry.Threshold = decimal.NewFromFloat(notification.EventThreshold).Mul(decimal.NewFromInt(params.GWei)) case types.NetworkGasBelowThresholdEventName: - resultEntry.EventType = "gas_below" resultEntry.Threshold = decimal.NewFromFloat(notification.EventThreshold).Mul(decimal.NewFromInt(params.GWei)) case types.NetworkParticipationRateThresholdEventName: - resultEntry.EventType = "participation_rate" resultEntry.Threshold = decimal.NewFromFloat(notification.EventThreshold) case types.RocketpoolNewClaimRoundStartedEventName: - resultEntry.EventType = "new_reward_round" default: return nil, nil, fmt.Errorf("invalid event name for network notification: %v", notification.EventType) } From cc3667d9eb30e2cddebea3344a6881e33fdb2ee9 Mon Sep 17 00:00:00 2001 From: benji-bitfly Date: Wed, 6 Nov 2024 10:37:36 +0100 Subject: [PATCH 3/6] fix(DashboardValidatorManagmentModal): update `isSearchResultRestricted` to check if user has `bulk adding` permission See: BEDS-885 --- .../components/dashboard/DashboardValidatorManagementModal.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/components/dashboard/DashboardValidatorManagementModal.vue b/frontend/components/dashboard/DashboardValidatorManagementModal.vue index 206b5141e..a7590e8fd 100644 --- a/frontend/components/dashboard/DashboardValidatorManagementModal.vue +++ b/frontend/components/dashboard/DashboardValidatorManagementModal.vue @@ -211,7 +211,7 @@ function isSearchResultRestricted(result: ResultSuggestion): boolean { case ResultType.ValidatorsByPubkey: return false default: - return isPublic.value || !user.value?.premium_perks?.ad_free + return isPublic.value || !user.value?.premium_perks?.bulk_adding } } From 1061ac300061612fcc21bb88bdf11672cfc05963 Mon Sep 17 00:00:00 2001 From: Lucca Dukic <109136188+LuccaBitfly@users.noreply.github.com> Date: Thu, 7 Nov 2024 11:37:59 +0100 Subject: [PATCH 4/6] refactor: match dashboard notification detail to notification event name See: BEDS-935 --- backend/pkg/api/data_access/notifications.go | 38 +++++++++---------- backend/pkg/api/types/notifications.go | 16 ++++---- .../NotificationsDashboardDialogEntity.vue | 36 +++++++++--------- frontend/types/api/notifications.ts | 14 +++---- 4 files changed, 52 insertions(+), 52 deletions(-) diff --git a/backend/pkg/api/data_access/notifications.go b/backend/pkg/api/data_access/notifications.go index bdc13ca67..0a07f5b7c 100644 --- a/backend/pkg/api/data_access/notifications.go +++ b/backend/pkg/api/data_access/notifications.go @@ -405,16 +405,16 @@ func (d *DataAccessService) GetValidatorDashboardNotificationDetails(ctx context notificationDetails := t.NotificationValidatorDashboardDetail{ ValidatorOffline: []uint64{}, ProposalMissed: []t.IndexSlots{}, - ProposalDone: []t.IndexBlocks{}, - UpcomingProposals: []t.IndexSlots{}, + ProposalSuccess: []t.IndexBlocks{}, + ProposalUpcoming: []t.IndexSlots{}, Slashed: []uint64{}, - SyncCommittee: []uint64{}, + Sync: []uint64{}, AttestationMissed: []t.IndexEpoch{}, Withdrawal: []t.NotificationEventWithdrawal{}, ValidatorOfflineReminder: []uint64{}, - ValidatorBackOnline: []t.NotificationEventValidatorBackOnline{}, - MinimumCollateralReached: []t.Address{}, - MaximumCollateralReached: []t.Address{}, + ValidatorOnline: []t.NotificationEventValidatorBackOnline{}, + MinCollateral: []t.Address{}, + MaxCollateral: []t.Address{}, } var searchIndices []uint64 @@ -554,7 +554,7 @@ func (d *DataAccessService) GetValidatorDashboardNotificationDetails(ctx context if searchEnabled && !searchIndexSet[curNotification.ValidatorIndex] { continue } - notificationDetails.UpcomingProposals = append(notificationDetails.UpcomingProposals, t.IndexSlots{Index: curNotification.ValidatorIndex, Slots: []uint64{curNotification.Slot}}) + notificationDetails.ProposalUpcoming = append(notificationDetails.ProposalUpcoming, t.IndexSlots{Index: curNotification.ValidatorIndex, Slots: []uint64{curNotification.Slot}}) case types.ValidatorGotSlashedEventName: curNotification, ok := notification.(*n.ValidatorGotSlashedNotification) if !ok { @@ -583,7 +583,7 @@ func (d *DataAccessService) GetValidatorDashboardNotificationDetails(ctx context if searchEnabled && !searchIndexSet[curNotification.ValidatorIndex] { continue } - notificationDetails.ValidatorBackOnline = append(notificationDetails.ValidatorBackOnline, t.NotificationEventValidatorBackOnline{Index: curNotification.ValidatorIndex, EpochCount: curNotification.Epoch}) + notificationDetails.ValidatorOnline = append(notificationDetails.ValidatorOnline, t.NotificationEventValidatorBackOnline{Index: curNotification.ValidatorIndex, EpochCount: curNotification.Epoch}) case types.ValidatorReceivedWithdrawalEventName: curNotification, ok := notification.(*n.ValidatorWithdrawalNotification) if !ok { @@ -630,9 +630,9 @@ func (d *DataAccessService) GetValidatorDashboardNotificationDetails(ctx context addr := t.Address{Hash: t.Hash(nodeAddress), IsContract: true} addressMapping[nodeAddress] = &addr if notification.GetEventName() == types.RocketpoolCollateralMinReachedEventName { - notificationDetails.MinimumCollateralReached = append(notificationDetails.MinimumCollateralReached, addr) + notificationDetails.MinCollateral = append(notificationDetails.MinCollateral, addr) } else { - notificationDetails.MaximumCollateralReached = append(notificationDetails.MaximumCollateralReached, addr) + notificationDetails.MaxCollateral = append(notificationDetails.MaxCollateral, addr) } case types.SyncCommitteeSoonEventName: curNotification, ok := notification.(*n.SyncCommitteeSoonNotification) @@ -642,7 +642,7 @@ func (d *DataAccessService) GetValidatorDashboardNotificationDetails(ctx context if searchEnabled && !searchIndexSet[curNotification.ValidatorIndex] { continue } - notificationDetails.SyncCommittee = append(notificationDetails.SyncCommittee, curNotification.ValidatorIndex) + notificationDetails.Sync = append(notificationDetails.Sync, curNotification.ValidatorIndex) default: log.Debugf("Unhandled notification type: %s", notification.GetEventName()) } @@ -652,10 +652,10 @@ func (d *DataAccessService) GetValidatorDashboardNotificationDetails(ctx context // fill proposals for validatorIndex, proposalInfo := range proposalsInfo { if len(proposalInfo.Proposed) > 0 { - notificationDetails.ProposalDone = append(notificationDetails.ProposalDone, t.IndexBlocks{Index: validatorIndex, Blocks: proposalInfo.Proposed}) + notificationDetails.ProposalSuccess = append(notificationDetails.ProposalSuccess, t.IndexBlocks{Index: validatorIndex, Blocks: proposalInfo.Proposed}) } if len(proposalInfo.Scheduled) > 0 { - notificationDetails.UpcomingProposals = append(notificationDetails.UpcomingProposals, t.IndexSlots{Index: validatorIndex, Slots: proposalInfo.Scheduled}) + notificationDetails.ProposalUpcoming = append(notificationDetails.ProposalUpcoming, t.IndexSlots{Index: validatorIndex, Slots: proposalInfo.Scheduled}) } if len(proposalInfo.Missed) > 0 { notificationDetails.ProposalMissed = append(notificationDetails.ProposalMissed, t.IndexSlots{Index: validatorIndex, Slots: proposalInfo.Missed}) @@ -674,14 +674,14 @@ func (d *DataAccessService) GetValidatorDashboardNotificationDetails(ctx context for i, contractStatus := range contractStatusRequests { contractStatusPerAddress["0x"+contractStatus.Address] = i } - for i := range notificationDetails.MinimumCollateralReached { - if address, ok := addressMapping[string(notificationDetails.MinimumCollateralReached[i].Hash)]; ok { - notificationDetails.MinimumCollateralReached[i] = *address + for i := range notificationDetails.MinCollateral { + if address, ok := addressMapping[string(notificationDetails.MinCollateral[i].Hash)]; ok { + notificationDetails.MinCollateral[i] = *address } } - for i := range notificationDetails.MaximumCollateralReached { - if address, ok := addressMapping[string(notificationDetails.MaximumCollateralReached[i].Hash)]; ok { - notificationDetails.MaximumCollateralReached[i] = *address + for i := range notificationDetails.MaxCollateral { + if address, ok := addressMapping[string(notificationDetails.MaxCollateral[i].Hash)]; ok { + notificationDetails.MaxCollateral[i] = *address } } for i := range notificationDetails.Withdrawal { diff --git a/backend/pkg/api/types/notifications.go b/backend/pkg/api/types/notifications.go index 14ee217b0..d3616a7bc 100644 --- a/backend/pkg/api/types/notifications.go +++ b/backend/pkg/api/types/notifications.go @@ -63,19 +63,19 @@ type NotificationEventWithdrawal struct { type NotificationValidatorDashboardDetail struct { DashboardName string `db:"dashboard_name" json:"dashboard_name"` GroupName string `db:"group_name" json:"group_name"` - ValidatorOffline []uint64 `json:"validator_offline"` // validator indices + ValidatorOffline []uint64 `json:"validator_offline"` // validator indices + ValidatorOfflineReminder []uint64 `json:"validator_offline_reminder"` // validator indices; TODO not filled yet + ValidatorOnline []NotificationEventValidatorBackOnline `json:"validator_online"` GroupEfficiencyBelow float64 `json:"group_efficiency_below,omitempty"` // fill with the `group_efficiency_below` threshold if event is present ProposalMissed []IndexSlots `json:"proposal_missed"` - ProposalDone []IndexBlocks `json:"proposal_done"` - UpcomingProposals []IndexSlots `json:"upcoming_proposals"` + ProposalSuccess []IndexBlocks `json:"proposal_success"` + ProposalUpcoming []IndexSlots `json:"proposal_upcoming"` Slashed []uint64 `json:"slashed"` // validator indices - SyncCommittee []uint64 `json:"sync_committee"` // validator indices + Sync []uint64 `json:"sync"` // validator indices AttestationMissed []IndexEpoch `json:"attestation_missed"` // index (epoch) Withdrawal []NotificationEventWithdrawal `json:"withdrawal"` - ValidatorOfflineReminder []uint64 `json:"validator_offline_reminder"` // validator indices; TODO not filled yet - ValidatorBackOnline []NotificationEventValidatorBackOnline `json:"validator_back_online"` - MinimumCollateralReached []Address `json:"min_collateral_reached"` // node addresses - MaximumCollateralReached []Address `json:"max_collateral_reached"` // node addresses + MinCollateral []Address `json:"min_collateral"` // node addresses + MaxCollateral []Address `json:"max_collateral"` // node addresses } type InternalGetUserNotificationsValidatorDashboardResponse ApiDataResponse[NotificationValidatorDashboardDetail] diff --git a/frontend/components/notifications/NotificationsDashboardDialogEntity.vue b/frontend/components/notifications/NotificationsDashboardDialogEntity.vue index e000fb2f5..0d5c77c58 100644 --- a/frontend/components/notifications/NotificationsDashboardDialogEntity.vue +++ b/frontend/components/notifications/NotificationsDashboardDialogEntity.vue @@ -129,8 +129,8 @@ const formatValueWei = (value: string) => {