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

Change proposer cache overwrite logic #11191

Merged
merged 9 commits into from
Aug 10, 2022
Merged

Conversation

rkapka
Copy link
Contributor

@rkapka rkapka commented Aug 9, 2022

What type of PR is this?

Bug fix

What does this PR do? Why is it needed?

Comment in ProposerPayloadIDsCache.SetProposerAndPayloadIDs says:

Ok to overwrite if the slot is already set but the payload ID is not set.

The mentioned payload ID refers to the cached ID, not the new one. The current comparison verifies the new ID.

@rkapka rkapka requested a review from a team as a code owner August 9, 2022 11:40
// Ok to overwrite if the slot is already set but the payload ID is not set.
ids, ok := f.slotToProposerAndPayloadIDs[slot]
// Ok to overwrite if the slot is already set but the cached payload ID is not set.
// Ok to overwrite if the slot is already set but the cached payload ID is not set.
// This combats the re-org case where payload assignment could change the epoch of.
Copy link
Contributor Author

@rkapka rkapka Aug 9, 2022

Choose a reason for hiding this comment

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

This combats the re-org case where payload assignment could change the epoch of

There is something missing at the end of the sentence @terencechain. What should it say?

Comment on lines 57 to 58
// Ok to overwrite if the slot is already set but the cached payload ID is not set.
// Ok to overwrite if the slot is already set but the cached payload ID is not set.
Copy link
Member

Choose a reason for hiding this comment

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

Duplicate lines?

Suggested change
// Ok to overwrite if the slot is already set but the cached payload ID is not set.
// Ok to overwrite if the slot is already set but the cached payload ID is not set.
// Ok to overwrite if the slot is already set but the cached payload ID is not set.

if !ok || (ok && pId != [pIdLength]byte{}) {
f.slotToProposerAndPayloadIDs[slot] = bytes
byte8 := [8]byte{}
if !ok || (ok && bytes.Equal(ids[vIdLength:], byte8[:])) {
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a unit test for condition bytes.Equal(ids[vIdLength:], byte8[:]) if it's not already covered? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was already covered. I improved a comment in dc553ac

ids, ok := f.slotToProposerAndPayloadIDs[slot]
// Ok to overwrite if the slot is already set but the cached payload ID is not set.
// This combats the re-org case where payload assignment could change at the start of the epoch.
byte8 := [8]byte{}
Copy link
Member

Choose a reason for hiding this comment

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

Why do we hardcode 8 here but use vpIdsLength on line 54?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@prylabs-bulldozer prylabs-bulldozer bot merged commit 0f19beb into develop Aug 10, 2022
@delete-merged-branch delete-merged-branch bot deleted the set-proposer-cache branch August 10, 2022 22:49
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