Approval Checking: Avoid redundant checks (#3306)
* node/approval-voting: Introduce LruCache for pending Approval work This commit adds an LruCache that is intended to track the approval work submitted as background tasks in order to ensure that the validator needn't launch duplicate approval work for the same candidate across multiple blocks. A simple state machine is also introduced in order to differentiate pending and completed tasks. In addition, this LruCache will retain ValidationResults from the completed approval work once the task has completed. As per LruCache implementation, the oldest tasks will get evicted as new approval work is submitted to this cache. * node/approval-voting: Revert changes to master This commit reverts changes from the previous commit in order to simplify addressing the architecture discussion raised in the PR. * node/approval-voting: remove background task mpsc construct This diff removes the mpsc construct for background tasks in preparation for a move to leveraging RemoteHandles to launch approvals, rather than passing ApprovalRequests to a mpsc channel and handling the ApprovalRequests in the main subsystem task. * node/approval-voting: Introduce LRU Cache This commit introduces an LRU Cache but does not yet make use of it. * node/approval-voting: Remove BackgroundTasksMap and memoize currently_checking This commit removes the BackgroundTasksMap in the main subsystem task and introduces a method to keep track of RemoteHandles in such a way that we can ensure that a task is spawned once for a CandidateHash and relay parent tuple. * node/approval-voting: Remove BackgroundTasksMap and memoize currently_checking This commit removes the BackgroundTasksMap in the main subsystem task and introduces a map of FuturesUnordered per BlockNumber. In addition, a FusedFuture is generated by iterating across all FuturesUnordered for the BlockNumbers for which at least one candidate has approvals work running in the subsystem. * node/approval-voting: Address Rob's comments This diff removes the prior HashMap<BlockNumber, FuturesUnordered> construction and instead moves to a simple FuturesUnordered where all the work is await with Timeout. * node/approval-voting: Update Cargo.lock Due to a mismatch in rustc versions * node/approval-voting: Make use of actions when issuing_approval This commit fixes a small oversight in the logic of the prior commit. * node/approval-voting: Address Rob's feedback * node/approval-voting: Introduce lazy launch_approval evaluation * node/approval-voting: Send DistibruteApproval message on every LaunchApproval In addition to fixed the DistributeApproval bug, this commit also increases the size of the approvals cache and ensures the StaleGuard is removed when the advantageous approval state is reached. * node/approval-voting: Address final comments This commit removes the CandidateIndex from the ApprovalVoteRequest. Instead, the launch_approval function will compute the candidate_index from the block entry. In addition, a comment has been added explaining the difficulty of issuing approvals in the handle_actions function. * node/approval-voting: Set timeout to be 120s rather than 2s * Update Cargo.lock
parent
e3340e44
Please register or sign in to comment