approvals

package
v0.17.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2021 License: AGPL-3.0 Imports: 23 Imported by: 2

Documentation

Index

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

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 NewApprovalsCache(capacity uint) *Cache

func (*Cache) All

func (c *Cache) All() []*flow.ResultApproval

All returns all stored approvals

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

Add adds an IncorporatedResultSeal to the mempool

func (*IncorporatedResultSeals) All

All returns all the items in the mempool

func (*IncorporatedResultSeals) ByID

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

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 NewApprovalsLRUCache(limit uint) *LruCache

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL