-
Notifications
You must be signed in to change notification settings - Fork 177
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
PR 736: suggestions pt4 #774
PR 736: suggestions pt4 #774
Conversation
• renamed method `AggregatedSignatures.CollectChunksWithMissingApprovals` to `ChunksWithoutAggregatedSignature()` • shifted the location of a few lines of code
• renamed internal variable
…ve crypto verifications
…ls are required; • ApprovalCollector: using consistently uint64 to refer to chunk indices and related quantities; • sealing.Engine: separated logic for creating inbound queues for trusted inputs from message handler for untrusted inputs;
// pre-select all authorized verifiers at the block that is being sealed | ||
authorizedApprovers, err := authorizedVerifiersAtBlock(state, result.BlockID) | ||
if err != nil { | ||
return nil, engine.NewInvalidInputErrorf("could not determine authorized verifiers for sealing candidate: %w", err) | ||
} |
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 just shifted this code up. Thereby, we are initializing the dependencies of AssignmentCollector
first and subsequently the struct itself.
// * have the Verification role and | ||
// * have _positive_ weight and | ||
// * are not ejected | ||
func (ac *AssignmentCollector) authorizedVerifiersAtBlock(blockID flow.Identifier) (map[flow.Identifier]*flow.Identity, 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.
- I removed the pointer receiver, which allows to compute
authorizedVerifiersAtBlock
before initializing theAssignmentCollector
. - As this method is now not part of
AssignmentCollector
, I moved it to the end of the file
// we have this approval cached already, no need to process it again | ||
approvalCacheID := approval.Body.PartialID() | ||
if cached := ac.verifiedApprovalsCache.Get(approvalCacheID); cached != nil { | ||
return nil | ||
} | ||
|
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.
checks first whether an approval is already cached and drops duplicates, before doing expensive crypto verifications
pendingIncorporatedResults *fifoqueue.FifoQueue | ||
notifier engine.Notifier | ||
messageHandler *engine.MessageHandler | ||
requiredApprovalsForSealConstruction uint |
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.
removed struct field requiredApprovalsForSealConstruction
as the value is only needed at construction time
err = e.setupTrustedInboundQueues() | ||
if err != nil { | ||
return nil, fmt.Errorf("could not initialize message handler: %w", err) | ||
return nil, fmt.Errorf("initialization of inbound queues for trusted inputs failed: %w", err) | ||
} | ||
|
||
err = e.setupMessageHandler(options.RequiredApprovalsForSealConstruction) |
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.
separated logic for creating inbound queues for trusted inputs from message handler for untrusted inputs
AggregatedSignatures.CollectChunksWithMissingApprovals
toChunksWithoutAggregatedSignature()
matching.Core
to be more specific: the executed block is now calledexecutedBlock
AssignmentCollector
now checks first whether an approval is already cached and drops duplicates, before doing expensive crypto verificationsApprovalCollector
uint64
to refer to chunk indices and related quantities;sealing.Engine
:requiredApprovalsForSealConstruction
as the value is only needed at construction time