Documentation ¶
Index ¶
- func NewApprovalProcessingCore(headers storage.Headers, state protocol.State, sealsDB storage.Seals, ...) (*approvalProcessingCore, error)
- type AggregatedSignatures
- func (as *AggregatedSignatures) Collect() []flow.AggregatedSignature
- func (as *AggregatedSignatures) CollectChunksWithMissingApprovals() []uint64
- func (as *AggregatedSignatures) HasSignature(chunkIndex uint64) bool
- func (as *AggregatedSignatures) PutSignature(chunkIndex uint64, aggregatedSignature flow.AggregatedSignature) int
- type ApprovalCollector
- func (c *ApprovalCollector) CollectMissingVerifiers() map[uint64]flow.IdentifierList
- func (c *ApprovalCollector) IncorporatedBlock() *flow.Header
- func (c *ApprovalCollector) IncorporatedBlockID() flow.Identifier
- func (c *ApprovalCollector) ProcessApproval(approval *flow.ResultApproval) error
- func (c *ApprovalCollector) SealResult() error
- type AssignmentCollector
- func (ac *AssignmentCollector) BlockID() flow.Identifier
- func (ac *AssignmentCollector) CheckEmergencySealing(finalizedBlockHeight uint64) error
- func (ac *AssignmentCollector) ProcessApproval(approval *flow.ResultApproval) error
- func (ac *AssignmentCollector) ProcessIncorporatedResult(incorporatedResult *flow.IncorporatedResult) error
- func (ac *AssignmentCollector) RequestMissingApprovals(maxHeightForRequesting uint64) error
- type AssignmentCollectorTree
- func (t *AssignmentCollectorTree) FinalizeForkAtLevel(finalized *flow.Header, sealed *flow.Header)
- func (t *AssignmentCollectorTree) GetCollector(resultID flow.Identifier) (*AssignmentCollector, bool)
- func (t *AssignmentCollectorTree) GetCollectorsByInterval(from, to uint64) []*AssignmentCollector
- func (t *AssignmentCollectorTree) GetOrCreateCollector(result *flow.ExecutionResult) (*LazyInitCollector, error)
- func (t *AssignmentCollectorTree) PruneUpToHeight(limit uint64) ([]flow.Identifier, error)
- type BaseApprovalsTestSuite
- type Cache
- type ChunkApprovalCollector
- type GetCachedBlockHeight
- type IncorporatedResultSeals
- func (ir *IncorporatedResultSeals) Add(seal *flow.IncorporatedResultSeal) (bool, error)
- func (ir *IncorporatedResultSeals) All() []*flow.IncorporatedResultSeal
- func (ir *IncorporatedResultSeals) ByID(id flow.Identifier) (*flow.IncorporatedResultSeal, bool)
- func (ir *IncorporatedResultSeals) Clear()
- func (ir *IncorporatedResultSeals) RegisterEjectionCallbacks(callbacks ...mempool.OnEjection)
- func (ir *IncorporatedResultSeals) Rem(id flow.Identifier) bool
- type LazyInitCollector
- type LruCache
- type NewCollectorFactoryMethod
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewApprovalProcessingCore ¶
func NewApprovalProcessingCore(headers storage.Headers, state protocol.State, sealsDB storage.Seals, assigner module.ChunkAssigner, verifier module.Verifier, sealsMempool mempool.IncorporatedResultSeals, approvalConduit network.Conduit, requiredApprovalsForSealConstruction uint, emergencySealingActive bool) (*approvalProcessingCore, error)
Types ¶
type AggregatedSignatures ¶
type AggregatedSignatures struct {
// contains filtered or unexported fields
}
AggregatedSignatures is an utility struct that provides concurrency safe access to map of aggregated signatures indexed by chunk index
func NewAggregatedSignatures ¶
func NewAggregatedSignatures(chunks uint64) *AggregatedSignatures
func (*AggregatedSignatures) Collect ¶
func (as *AggregatedSignatures) Collect() []flow.AggregatedSignature
Collect returns array with aggregated signature for each chunk
func (*AggregatedSignatures) CollectChunksWithMissingApprovals ¶
func (as *AggregatedSignatures) CollectChunksWithMissingApprovals() []uint64
CollectChunksWithMissingApprovals returns indexes of chunks that don't have an aggregated signature
func (*AggregatedSignatures) HasSignature ¶
func (as *AggregatedSignatures) HasSignature(chunkIndex uint64) bool
HasSignature returns boolean depending if we have signature for particular chunk
func (*AggregatedSignatures) PutSignature ¶
func (as *AggregatedSignatures) PutSignature(chunkIndex uint64, aggregatedSignature flow.AggregatedSignature) int
PutSignature adds the AggregatedSignature from the collector to `aggregatedSignatures`. The returned int is the resulting number of approved chunks.
type ApprovalCollector ¶
type ApprovalCollector struct {
// contains filtered or unexported fields
}
ApprovalCollector is responsible for distributing work to chunk collectorTree, collecting aggregated signatures for chunks that reached seal construction threshold, creating and submitting seal candidates once signatures for every chunk are aggregated.
func NewApprovalCollector ¶
func NewApprovalCollector(result *flow.IncorporatedResult, incorporatedBlock *flow.Header, assignment *chunks.Assignment, seals mempool.IncorporatedResultSeals, requiredApprovalsForSealConstruction uint) *ApprovalCollector
func (*ApprovalCollector) CollectMissingVerifiers ¶
func (c *ApprovalCollector) CollectMissingVerifiers() map[uint64]flow.IdentifierList
CollectMissingVerifiers collects ids of verifiers who haven't provided an approval for particular chunk Returns: map { ChunkIndex -> []VerifierId }
func (*ApprovalCollector) IncorporatedBlock ¶
func (c *ApprovalCollector) IncorporatedBlock() *flow.Header
IncorporatedBlock returns the block which incorporates execution result
func (*ApprovalCollector) IncorporatedBlockID ¶
func (c *ApprovalCollector) IncorporatedBlockID() flow.Identifier
IncorporatedBlockID returns the ID of block which incorporates execution result
func (*ApprovalCollector) ProcessApproval ¶
func (c *ApprovalCollector) ProcessApproval(approval *flow.ResultApproval) error
ProcessApproval performs processing of result approvals and bookkeeping of aggregated signatures for every chunk. Triggers sealing of execution result when processed last result approval needed for sealing. Returns: - engine.InvalidInputError - result approval is invalid - exception in case of any other error, usually this is not expected - nil on success
func (*ApprovalCollector) SealResult ¶
func (c *ApprovalCollector) SealResult() error
type AssignmentCollector ¶
type AssignmentCollector struct { ResultID flow.Identifier // ID of execution result BlockHeight uint64 // height of block targeted by execution result // contains filtered or unexported fields }
AssignmentCollector is responsible collecting approvals that satisfy one assignment, meaning that we will have multiple collectorTree for one execution result as same result can be incorporated in multiple forks. AssignmentCollector has a strict ordering of processing, before processing approvals at least one incorporated result has to be processed. AssignmentCollector takes advantage of internal caching to speed up processing approvals for different assignments AssignmentCollector is responsible for validating approvals on result-level(checking signature, identity). TODO: currently AssignmentCollector doesn't cleanup collectorTree when blocks that incorporate results get orphaned For BFT milestone we need to ensure that this cleanup is properly implemented and all orphan collectorTree are pruned by height when fork gets orphaned
func NewAssignmentCollector ¶
func NewAssignmentCollector(result *flow.ExecutionResult, state protocol.State, headers storage.Headers, assigner module.ChunkAssigner, seals mempool.IncorporatedResultSeals, sigVerifier module.Verifier, approvalConduit network.Conduit, requestTracker *sealing.RequestTracker, requiredApprovalsForSealConstruction uint, ) (*AssignmentCollector, error)
func (*AssignmentCollector) BlockID ¶
func (ac *AssignmentCollector) BlockID() flow.Identifier
BlockID returns the ID of the executed block
func (*AssignmentCollector) CheckEmergencySealing ¶
func (ac *AssignmentCollector) CheckEmergencySealing(finalizedBlockHeight uint64) error
func (*AssignmentCollector) ProcessApproval ¶
func (ac *AssignmentCollector) ProcessApproval(approval *flow.ResultApproval) error
func (*AssignmentCollector) ProcessIncorporatedResult ¶
func (ac *AssignmentCollector) ProcessIncorporatedResult(incorporatedResult *flow.IncorporatedResult) error
func (*AssignmentCollector) RequestMissingApprovals ¶
func (ac *AssignmentCollector) RequestMissingApprovals(maxHeightForRequesting uint64) error
type AssignmentCollectorTree ¶
type AssignmentCollectorTree struct {
// contains filtered or unexported fields
}
AssignmentCollectorTree is a mempool holding assignment collectors, which is aware of the tree structure formed by the execution results. The mempool supports pruning by height: only collectors descending from the latest finalized block are relevant. Safe for concurrent access. Internally, the mempool utilizes the LevelledForrest.
func NewAssignmentCollectorTree ¶
func NewAssignmentCollectorTree(lastSealed *flow.Header, headers storage.Headers, onCreateCollector NewCollectorFactoryMethod) *AssignmentCollectorTree
func (*AssignmentCollectorTree) FinalizeForkAtLevel ¶
func (t *AssignmentCollectorTree) FinalizeForkAtLevel(finalized *flow.Header, sealed *flow.Header)
FinalizeForkAtLevel performs finalization of fork which is stored in leveled forest. When block is finalized we can mark other forks as orphan and stop processing approvals for it. Eventually all forks will be cleaned up by height
func (*AssignmentCollectorTree) GetCollector ¶
func (t *AssignmentCollectorTree) GetCollector(resultID flow.Identifier) (*AssignmentCollector, bool)
GetCollector returns collector by ID and whether it is processable or not
func (*AssignmentCollectorTree) GetCollectorsByInterval ¶
func (t *AssignmentCollectorTree) GetCollectorsByInterval(from, to uint64) []*AssignmentCollector
GetCollectorsByInterval returns processable collectors that satisfy interval [from; to)
func (*AssignmentCollectorTree) GetOrCreateCollector ¶
func (t *AssignmentCollectorTree) GetOrCreateCollector(result *flow.ExecutionResult) (*LazyInitCollector, error)
GetOrCreateCollector performs lazy initialization of AssignmentCollector using double checked locking Returns, (AssignmentCollector, true or false whenever it was created, error)
func (*AssignmentCollectorTree) PruneUpToHeight ¶
func (t *AssignmentCollectorTree) PruneUpToHeight(limit uint64) ([]flow.Identifier, error)
PruneUpToHeight prunes all results for all assignment collectors with height up to but NOT INCLUDING `limit`. Errors if limit is lower than the previous value (as we cannot recover previously pruned results). Returns list of resultIDs that were pruned
type BaseApprovalsTestSuite ¶
type BaseApprovalsTestSuite struct { suite.Suite ParentBlock flow.Header // parent of sealing candidate Block flow.Header // candidate for sealing IncorporatedBlock flow.Header // block that incorporated result VerID flow.Identifier // for convenience, node id of first verifier Chunks flow.ChunkList // list of chunks of execution result ChunksAssignment *chunks.Assignment AuthorizedVerifiers map[flow.Identifier]*flow.Identity // map of authorized verifier identities for execution result IncorporatedResult *flow.IncorporatedResult }
BaseApprovalsTestSuite is a base suite for testing approvals processing related functionality At nutshell generates mock data that can be used to create approvals and provides all needed data to validate those approvals for respected execution result.
func (*BaseApprovalsTestSuite) SetupTest ¶
func (s *BaseApprovalsTestSuite) SetupTest()
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a utility structure that encapsulates map that stores result approvals and provides concurrent access to it.
func NewApprovalsCache ¶
func (*Cache) Get ¶
func (c *Cache) Get(approvalID flow.Identifier) *flow.ResultApproval
Get returns approval that is saved in cache
func (*Cache) Put ¶
func (c *Cache) Put(approval *flow.ResultApproval)
Put saves approval into cache
type ChunkApprovalCollector ¶
type ChunkApprovalCollector struct {
// contains filtered or unexported fields
}
ChunkApprovalCollector implements logic for checking chunks against assignments as well as accumulating signatures of already checked approvals.
func NewChunkApprovalCollector ¶
func NewChunkApprovalCollector(assignment map[flow.Identifier]struct{}, requiredApprovalsForSealConstruction uint) *ChunkApprovalCollector
func (*ChunkApprovalCollector) GetMissingSigners ¶
func (c *ChunkApprovalCollector) GetMissingSigners() flow.IdentifierList
GetMissingSigners returns ids of approvers that are present in assignment but didn't provide approvals
func (*ChunkApprovalCollector) ProcessApproval ¶
func (c *ChunkApprovalCollector) ProcessApproval(approval *flow.ResultApproval) (flow.AggregatedSignature, bool)
ProcessApproval performs processing and bookkeeping of single approval
type GetCachedBlockHeight ¶
type GetCachedBlockHeight = func(blockID flow.Identifier) (uint64, error)
helper functor that can be used to retrieve cached block height
type IncorporatedResultSeals ¶
type IncorporatedResultSeals struct {
// contains filtered or unexported fields
}
IncorporatedResultSeals implements the incorporated result seals memory pool of the consensus nodes. ATTENTION: this is a temporary wrapper for `mempool.IncorporatedResultSeals` to support a condition that there must be at least 2 receipts from _different_ ENs committing to the same incorporated result. This wrapper should only be used with `approvalProcessingCore`.
func NewIncorporatedResultSeals ¶
func NewIncorporatedResultSeals(mempool mempool.IncorporatedResultSeals) *IncorporatedResultSeals
NewIncorporatedResults creates a mempool for the incorporated result seals
func (*IncorporatedResultSeals) Add ¶
func (ir *IncorporatedResultSeals) Add(seal *flow.IncorporatedResultSeal) (bool, error)
Add adds an IncorporatedResultSeal to the mempool
func (*IncorporatedResultSeals) All ¶
func (ir *IncorporatedResultSeals) All() []*flow.IncorporatedResultSeal
All returns all the items in the mempool
func (*IncorporatedResultSeals) ByID ¶
func (ir *IncorporatedResultSeals) ByID(id flow.Identifier) (*flow.IncorporatedResultSeal, bool)
ByID gets an IncorporatedResultSeal by IncorporatedResult ID
func (*IncorporatedResultSeals) Clear ¶
func (ir *IncorporatedResultSeals) Clear()
Clear removes all entities from the pool.
func (*IncorporatedResultSeals) RegisterEjectionCallbacks ¶
func (ir *IncorporatedResultSeals) RegisterEjectionCallbacks(callbacks ...mempool.OnEjection)
RegisterEjectionCallbacks adds the provided OnEjection callbacks
func (*IncorporatedResultSeals) Rem ¶
func (ir *IncorporatedResultSeals) Rem(id flow.Identifier) bool
Rem removes an IncorporatedResultSeal from the mempool
type LazyInitCollector ¶
type LazyInitCollector struct { Collector *AssignmentCollector Processable bool // whether collector is processable Created bool // whether collector was created or retrieved from cache }
LazyInitCollector is a helper structure that is used to return collector which is lazy initialized
type LruCache ¶
type LruCache struct {
// contains filtered or unexported fields
}
LruCache is a wrapper over `simplelru.LRUCache` that provides needed api for processing result approvals Extends functionality of `simplelru.LRUCache` by introducing additional index for quicker access.
func NewApprovalsLRUCache ¶
func (*LruCache) Get ¶
func (c *LruCache) Get(approvalID flow.Identifier) *flow.ResultApproval
func (*LruCache) Peek ¶
func (c *LruCache) Peek(approvalID flow.Identifier) *flow.ResultApproval
func (*LruCache) Put ¶
func (c *LruCache) Put(approval *flow.ResultApproval)
func (*LruCache) TakeByResultID ¶
func (c *LruCache) TakeByResultID(resultID flow.Identifier) []*flow.ResultApproval
type NewCollectorFactoryMethod ¶
type NewCollectorFactoryMethod = func(result *flow.ExecutionResult) (*AssignmentCollector, error)
NewCollector is a factory method to generate an AssignmentCollector for an execution result