-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: added notifications for validators opted in #598
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for testing, we can follow the same approach as we did for the relay-emulator. We can add the APIs to the relay emulator or create a new beacon emulator and always return validators that are opted in. One additional thing would be that we might need to deploy the middleware contract and register some dummy public keys. The keys we register should be the ones returned from our API.
nextEpoch := currentEpoch + 1 | ||
nextEpochStart := s.genesisTime.Add(time.Duration(nextEpoch) * EpochDuration) | ||
fetchTime := nextEpochStart.Add(-FetchOffset) | ||
delay := time.Until(fetchTime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
map[string]any{ | ||
"epoch": epoch, | ||
"slot": slot, | ||
"bls_key": info.BLSKey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for the clients it would be better to give the execution block number in the notification as they will bid on that. Can we somehow compute this? Or maybe some API which can provide this?
|
||
func (s *Service) scheduleNotificationForSlot(epoch uint64, slot uint64, info *validatorapiv1.SlotInfo) { | ||
slotStartTime := s.genesisTime.Add(time.Duration(slot) * SlotDuration) | ||
notificationTime := slotStartTime.Add(-NotifyOffset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think we need this delay. We already have the delay to query the duties. I think we can send this as soon as we get the info. In case of the notifications, users will be always subscribed ideally. So sooner they get it, sooner they can decide to bid.
If they miss this, they should be able to query the get validators endpoint right?
Describe your changes
This PR introduces scheduling notifications for validator opt-ins, and running periodic epoch-based processing.
1. Notifications Module Minor Update
Topic Update
In
p2p/pkg/notifications/notifications.go
, a small addition was made (e.g., to support additional notification topics such asTopicValidatorOptedIn
).2. Validator Service Enhancements
Service Initialization
In
p2p/pkg/rpc/validator/service.go
, theNewService
function has been refactored to:notifier
parameter to manage notifications.Genesis Time Fetching
The service now fetches the genesis time from the Beacon API (
/eth/v1/beacon/genesis
). This timestamp is crucial for calculating slot start times.Notification Scheduling
A new method,
scheduleNotificationForSlot
, has been implemented. It:Epoch Processing & Cron Job
processEpoch
method now processes proposer duties, checks each validator’s opt-in status, and schedules notifications accordingly.Start
method runs a background cron job that:Checklist before requesting a review