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

Improve and test getProcessingAncestor #2956

Merged
merged 13 commits into from
Apr 23, 2024
Merged

Conversation

StephenButtolph
Copy link
Contributor

Why this should be merged

  • This removes a call to GetBlock during the normal case of bubbling votes (when the voted item is provided).
  • This adds a test for getProcessingAncestor behavior.
  • This fixes a minor bug that could cause a node to issue a poll even though there were no processing blocks.

How this works

Just moves code around slightly.

How this was tested

  • Added unit test
  • Fixed broken unit test
  • CI

@StephenButtolph StephenButtolph added consensus This involves consensus testing This primarily focuses on testing labels Apr 19, 2024
@StephenButtolph StephenButtolph added this to the v1.11.5 milestone Apr 19, 2024
@StephenButtolph StephenButtolph self-assigned this Apr 19, 2024
@@ -38,104 +38,106 @@ type metrics struct {
issued *prometheus.CounterVec
}

func (m *metrics) Initialize(namespace string, reg prometheus.Registerer) error {
func newMetrics(namespace string, reg prometheus.Registerer) (*metrics, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change allows us to create the metrics in a non-jank way.

Comment on lines +1043 to +1045
// It's possible that the blocks we just added to consensus were decided
// immediately by votes that were pending their issuance. If this is the
// case, we should not be requesting any chits.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a (very minor) bug fix.

Comment on lines +1132 to +1143
if t.Consensus.Processing(bubbledVote) {
t.Ctx.Log.Verbo("applying vote",
zap.Stringer("initialVoteID", initialVote),
zap.Stringer("bubbledVoteID", bubbledVote),
)
if bubbledVote != initialVote {
t.numProcessingAncestorFetchesSucceeded.Inc()
} else {
t.numProcessingAncestorFetchesUnneeded.Inc()
}
return bubbledVote, true
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving the Processing check before getBlock avoids calling VM.GetBlock when getProcessingAncestor is called with a processing block.

Comment on lines +1151 to +1164
vm.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) {
switch blkID {
case GenesisID:
return Genesis, nil
case issuedBlk.ID():
return issuedBlk, nil
case missingBlk.ID():
return missingBlk, nil
case blockingBlk.ID():
return blockingBlk, nil
default:
return nil, errUnknownBlock
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test was previously pretty broken because the engine assumes that blocks that have been Verifyed are GetBlockable. So once we issueed missingBlk, the engine was in a weird state.

// processing in consensus. If no ancestor could be found, false is returned.
//
// Note: If [initialVote] is processing, then [initialVote] will be returned.
func (t *Transitive) getProcessingAncestor(ctx context.Context, initialVote ids.ID) (ids.ID, bool) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was moved into this file because all of the fields that are used on are this struct. I was considering moving this function off the structs entirely and just passing in the fields... But there are quite a few things that can be accessed... Especially because of the getBlock call.

Base automatically changed from cleanup-consensus-tests to master April 23, 2024 21:09
@StephenButtolph StephenButtolph added this pull request to the merge queue Apr 23, 2024
Merged via the queue into master with commit 162c916 Apr 23, 2024
19 checks passed
@StephenButtolph StephenButtolph deleted the remove-useless-db-read branch April 23, 2024 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus This involves consensus testing This primarily focuses on testing
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants