-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Send correct state root with finalization event #13842
Conversation
e := notifier.ReceivedEvents()[0] | ||
assert.Equal(t, statefeed.FinalizedCheckpoint, int(e.Type)) | ||
fc, ok := e.Data.(*ethpbv1.EventFinalizedCheckpoint) | ||
require.Equal(t, true, ok, "event has wrong data type") |
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.
If it's true then it should be okay, why do you have what seems like an error message here as well?
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.
In the require.Equal
fails during tests execution, then "event has wrong data type"
is displayed. It helps for test debugging.
@@ -443,16 +443,25 @@ func (s *Service) updateFinalizationOnBlock(ctx context.Context, preState, postS | |||
|
|||
// sendNewFinalizedEvent sends a new finalization checkpoint event over the | |||
// event feed. It needs to be called on the background | |||
func (s *Service) sendNewFinalizedEvent(signed interfaces.ReadOnlySignedBeaconBlock, postState state.BeaconState) { | |||
func (s *Service) sendNewFinalizedEvent(ctx context.Context, postState state.BeaconState) { | |||
isValidPayload := false | |||
s.headLock.RLock() | |||
if s.head != nil { | |||
isValidPayload = s.head.optimistic |
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 know this line has not be modified in this PR, but this case is not tested, and I guess it's quite an important case to test.
isValidPayload := false | ||
s.headLock.RLock() | ||
if s.head != nil { | ||
isValidPayload = s.head.optimistic | ||
} | ||
s.headLock.RUnlock() | ||
|
||
blk, err := s.cfg.BeaconDB.Block(ctx, bytesutil.ToBytes32(postState.FinalizedCheckpoint().Root)) | ||
if err != nil { | ||
log.WithError(err).Error("Could not retrieve block for finalized checkpoint root. Finalized event will not be emitted") |
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.
(Not tested.)
return | ||
} | ||
if blk == nil || blk.IsNil() || blk.Block() == nil || blk.Block().IsNil() { | ||
log.WithError(err).Error("Block retrieved for finalized checkpoint root is nil. Finalized event will not be emitted") |
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.
(Not tested.)
What type of PR is this?
Bug fix
What does this PR do? Why is it needed?
When sending the finalized event to the event feed we send the root of the received block's state as the finalized state root, but it should be the root of the finalized block's state.
Which issues(s) does this PR fix?
Fixes #13752