diff --git a/backend/pkg/api/data_access/notifications.go b/backend/pkg/api/data_access/notifications.go index 91ad838f2..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 { @@ -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) } diff --git a/backend/pkg/api/data_access/vdb_blocks.go b/backend/pkg/api/data_access/vdb_blocks.go index 5749d77ee..17bfcec76 100644 --- a/backend/pkg/api/data_access/vdb_blocks.go +++ b/backend/pkg/api/data_access/vdb_blocks.go @@ -152,6 +152,10 @@ func (d *DataAccessService) GetValidatorDashboardBlocks(ctx context.Context, das ), ) + if dashboardId.Validators == nil { + blocksDs = blocksDs.Where(goqu.L("(blocks.proposer IN (SELECT validator_index FROM users_val_dashboards_validators WHERE dashboard_id = ?))", dashboardId.Id)) + } + // 2. Selects groupIdQ := goqu.C("group_id").(exp.Aliaseable) if dashboardId.Validators != nil { diff --git a/backend/pkg/api/enums/notifications_enums.go b/backend/pkg/api/enums/notifications_enums.go index 9470b8caa..e2a4c6976 100644 --- a/backend/pkg/api/enums/notifications_enums.go +++ b/backend/pkg/api/enums/notifications_enums.go @@ -117,7 +117,7 @@ func (c NotificationMachinesColumn) ToExpr() OrderableSortable { case NotificationMachineEventType: return goqu.C("event_type") case NotificationMachineTimestamp: - return goqu.C("epoch") + return goqu.C("ts") default: return nil } @@ -170,7 +170,7 @@ func (c NotificationClientsColumn) ToExpr() OrderableSortable { case NotificationClientName: return goqu.C("client") case NotificationClientTimestamp: - return goqu.C("epoch") + return goqu.C("ts") default: return nil } @@ -256,7 +256,7 @@ func (NotificationNetworksColumn) NewFromString(s string) NotificationNetworksCo func (c NotificationNetworksColumn) ToExpr() OrderableSortable { switch c { case NotificationNetworkTimestamp: - return goqu.C("epoch") + return goqu.C("ts") case NotificationNetworkNetwork: return goqu.C("network") case NotificationNetworkEventType: 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 { 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/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 } } 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) => {