Skip to content
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

Validator: Safer pending attestation records flushing #8433

Merged
merged 16 commits into from
Feb 12, 2021

Conversation

prestonvanloon
Copy link
Member

What type of PR is this?

Other

What does this PR do? Why is it needed?

Better locking and flushing of this slice can help prevent dropped saves, in the event that there is already some batch save in progress.

Which issues(s) does this PR fix?

N/A

Other notes for review

@@ -26,6 +27,37 @@ type AttestationRecord struct {
SigningRoot [32]byte
}

func NewPendingAttestationRecords() *PendingAttestationRecords {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conflicts with PendingAttestation used as part of prysm's core package. Throughout our code base, they refer to attestations that are queued to enter the chain, but perhaps we could choose a different name

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I will rename

@@ -258,13 +294,28 @@ func (s *Store) batchAttestationWrites(ctx context.Context) {
// and resets the list of batched attestations for future writes.
// This function notifies all subscribers for flushed attestations
// of the result of the save operation.
func (s *Store) flushAttestationRecords(ctx context.Context) {
func (s *Store) flushAttestationRecords(ctx context.Context, records []*AttestationRecord) {
if s.batchedAttestationsFlushInProgress {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Atomic bool could be better here, we have it in the shared/ package

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abool

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely, thanks!

@prestonvanloon prestonvanloon marked this pull request as ready for review February 12, 2021 16:30
@prestonvanloon prestonvanloon requested a review from a team as a code owner February 12, 2021 16:30
func (s *Store) flushAttestationRecords(ctx context.Context) {
func (s *Store) flushAttestationRecords(ctx context.Context, records []*AttestationRecord) {
if s.batchedAttestationsFlushInProgress.IsSet() {
log.Error("Attempted to flush attestation records when already in progress")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be at error level? maybe debug is appropriate. We should only have error logs when they are actionable to the user, and this is opaque from a user's perspective

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should never ever happen. If it is happening, then it's a development bug that was recently introduced. I will add a comment to reflect the significance

s.batchedAttestations = make([]*AttestationRecord, 0, attestationBatchCapacity)
} else {
// This should never happen.
log.WithError(err).Error("Failed to batch save attestation records, retrying in queue")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same ^

@prylabs-bulldozer prylabs-bulldozer bot merged commit e2c5ae5 into develop Feb 12, 2021
@delete-merged-branch delete-merged-branch bot deleted the check-in-progress branch February 12, 2021 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants