Skip to content

Commit

Permalink
Merge pull request #1007 from gobitfly/BEDS-397/add_upcoming_block_pr…
Browse files Browse the repository at this point in the history
…oposal_notification

Beds 397/add upcoming block proposal notification
  • Loading branch information
peterbitfly authored Oct 22, 2024
2 parents 34df501 + 537fc23 commit c8028a5
Show file tree
Hide file tree
Showing 8 changed files with 381 additions and 205 deletions.
14 changes: 13 additions & 1 deletion backend/cmd/exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,19 @@ func Run() {
go services.StartHistoricPriceService()
}

go modules.StartAll(context)
usedModules := []modules.ModuleInterface{}

if cfg.JustV2 {
usedModules = append(usedModules, modules.NewDashboardDataModule(context))
} else {
usedModules = append(usedModules,
modules.NewSlotExporter(context),
modules.NewExecutionDepositsExporter(context),
modules.NewExecutionPayloadsExporter(context),
)
}

go modules.StartAll(context, usedModules, cfg.JustV2)

// Keep the program alive until Ctrl+C is pressed
utils.WaitForCtrlC()
Expand Down
26 changes: 13 additions & 13 deletions backend/pkg/api/data_access/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/gobitfly/beaconchain/pkg/commons/log"
"github.com/gobitfly/beaconchain/pkg/commons/types"
"github.com/gobitfly/beaconchain/pkg/commons/utils"
"github.com/gobitfly/beaconchain/pkg/notification"
n "github.com/gobitfly/beaconchain/pkg/notification"
"github.com/lib/pq"
"github.com/shopspring/decimal"
Expand Down Expand Up @@ -62,18 +61,19 @@ type NotificationsRepository interface {
func (*DataAccessService) registerNotificationInterfaceTypes() {
var once sync.Once
once.Do(func() {
gob.Register(&notification.ValidatorProposalNotification{})
gob.Register(&notification.ValidatorAttestationNotification{})
gob.Register(&notification.ValidatorIsOfflineNotification{})
gob.Register(&notification.ValidatorIsOnlineNotification{})
gob.Register(&notification.ValidatorGotSlashedNotification{})
gob.Register(&notification.ValidatorWithdrawalNotification{})
gob.Register(&notification.NetworkNotification{})
gob.Register(&notification.RocketpoolNotification{})
gob.Register(&notification.MonitorMachineNotification{})
gob.Register(&notification.TaxReportNotification{})
gob.Register(&notification.EthClientNotification{})
gob.Register(&notification.SyncCommitteeSoonNotification{})
gob.Register(&n.ValidatorProposalNotification{})
gob.Register(&n.ValidatorUpcomingProposalNotification{})
gob.Register(&n.ValidatorAttestationNotification{})
gob.Register(&n.ValidatorIsOfflineNotification{})
gob.Register(&n.ValidatorIsOnlineNotification{})
gob.Register(&n.ValidatorGotSlashedNotification{})
gob.Register(&n.ValidatorWithdrawalNotification{})
gob.Register(&n.NetworkNotification{})
gob.Register(&n.RocketpoolNotification{})
gob.Register(&n.MonitorMachineNotification{})
gob.Register(&n.TaxReportNotification{})
gob.Register(&n.EthClientNotification{})
gob.Register(&n.SyncCommitteeSoonNotification{})
})
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- +goose Up
-- +goose StatementBegin
SELECT 'creating epochs_notified_head table';
CREATE TABLE IF NOT EXISTS epochs_notified_head (
epoch INTEGER NOT NULL,
event_name VARCHAR(255) NOT NULL,
senton TIMESTAMP WITHOUT TIME ZONE NOT NULL,
PRIMARY KEY (epoch, event_name)
);
-- +goose StatementEnd

-- +goose Down
-- +goose StatementBegin
SELECT 'dropping epochs_notified_head table';
DROP TABLE IF EXISTS epochs_notified_head;
-- +goose StatementEnd
3 changes: 3 additions & 0 deletions backend/pkg/commons/types/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const (
)

var EventSortOrder = []EventName{
ValidatorUpcomingProposalEventName,
ValidatorGotSlashedEventName,
ValidatorDidSlashEventName,
ValidatorMissedProposalEventName,
Expand Down Expand Up @@ -173,6 +174,7 @@ var MachineEventsMap = map[EventName]struct{}{
}

var LegacyEventLabel map[EventName]string = map[EventName]string{
ValidatorUpcomingProposalEventName: "Your validator(s) will soon propose a block",
ValidatorMissedProposalEventName: "Your validator(s) missed a proposal",
ValidatorExecutedProposalEventName: "Your validator(s) submitted a proposal",
ValidatorMissedAttestationEventName: "Your validator(s) missed an attestation",
Expand All @@ -196,6 +198,7 @@ var LegacyEventLabel map[EventName]string = map[EventName]string{
}

var EventLabel map[EventName]string = map[EventName]string{
ValidatorUpcomingProposalEventName: "Upcoming block proposal",
ValidatorMissedProposalEventName: "Block proposal missed",
ValidatorExecutedProposalEventName: "Block proposal submitted",
ValidatorMissedAttestationEventName: "Attestation missed",
Expand Down
17 changes: 2 additions & 15 deletions backend/pkg/exporter/modules/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ type ModuleInterface interface {
var Client *rpc.Client

// Start will start the export of data from rpc into the database
func StartAll(context ModuleContext) {
if !utils.Config.JustV2 {
func StartAll(context ModuleContext, modules []ModuleInterface, justV2 bool) {
if !justV2 {
go networkLivenessUpdater(context.ConsClient)
go genesisDepositsExporter(context.ConsClient)
go syncCommitteesExporter(context.ConsClient)
Expand Down Expand Up @@ -65,19 +65,6 @@ func StartAll(context ModuleContext) {
}

// start subscription modules

modules := []ModuleInterface{}

if utils.Config.JustV2 {
modules = append(modules, NewDashboardDataModule(context))
} else {
modules = append(modules,
NewSlotExporter(context),
NewExecutionDepositsExporter(context),
NewExecutionPayloadsExporter(context),
)
}

startSubscriptionModules(&context, modules)
}

Expand Down
Loading

0 comments on commit c8028a5

Please sign in to comment.