-
Notifications
You must be signed in to change notification settings - Fork 640
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
Conversation
@@ -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) { |
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.
This change allows us to create the metrics in a non-jank way.
// 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. |
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.
This is a (very minor) bug fix.
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 | ||
} |
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.
Moving the Processing
check before getBlock
avoids calling VM.GetBlock
when getProcessingAncestor
is called with a processing block.
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 | ||
} | ||
} |
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.
This test was previously pretty broken because the engine assumes that blocks that have been Verify
ed are GetBlock
able. So once we issue
ed 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) { |
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.
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.
Why this should be merged
GetBlock
during the normal case of bubbling votes (when the voted item is provided).getProcessingAncestor
behavior.How this works
Just moves code around slightly.
How this was tested