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

PR 736: suggestions pt4 #774

Conversation

AlexHentschel
Copy link
Member

  • minor revisions of goDoc and inline comments
  • renamed method AggregatedSignatures.CollectChunksWithMissingApprovals to ChunksWithoutAggregatedSignature()
  • shifted the location of a few lines of code
  • renamed internal variable in matching.Core to be more specific: the executed block is now called executedBlock
  • AssignmentCollector now checks first whether an approval is already cached and drops duplicates, before doing expensive crypto verifications
  • ApprovalCollector
    • added logic for sealing right away if no approvals are required
    • 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
    • removed struct field requiredApprovalsForSealConstruction as the value is only needed at construction time

Alexander Hentschel added 4 commits June 1, 2021 15:50
• renamed method `AggregatedSignatures.CollectChunksWithMissingApprovals` to `ChunksWithoutAggregatedSignature()`
• shifted the location of a few lines of code
• renamed internal variable
…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;
Comment on lines +68 to +72
// 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)
}
Copy link
Member Author

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) {
Copy link
Member Author

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 the AssignmentCollector.
  • As this method is now not part of AssignmentCollector, I moved it to the end of the file

Comment on lines +269 to +274
// 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
}

Copy link
Member Author

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
Copy link
Member Author

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

Comment on lines +96 to +101
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)
Copy link
Member Author

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

@durkmurder durkmurder merged commit 2d5f120 into yurii/5417-approval-processing-engine Jun 2, 2021
@durkmurder durkmurder deleted the alex/5417-approval-processing-engine_-_suggestions_pt4 branch June 2, 2021 10:20
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.

2 participants