fix(refactor): Clean up handle_finalized_block and add E2E test coverage#3559
Open
radhika-kapoor wants to merge 5 commits intotempoxyz:mainfrom
Open
fix(refactor): Clean up handle_finalized_block and add E2E test coverage#3559radhika-kapoor wants to merge 5 commits intotempoxyz:mainfrom
radhika-kapoor wants to merge 5 commits intotempoxyz:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2697
###Summary
The
handle_finalized_blockfunction in the DKG manager actor was a single large function. This PR resolves refactoring the function and adding E2E test coverage.###Solution
FinalizedBlockContextstruct -> groups the 7 individual arguments ofhandle_finalized_blockinto a single context struct, removing theclippy::too_many_argumentssuppression and fulfilling the TODO comment.process_mid_epoch_block-> the mid-epoch path (reading dealer logs from block extra data, persisting them to the journal, clearing own log from state) is now a standalone method.resolve_epoch_outcome-> the boundary block path (reading the on-chain DKG outcome, computing local output, updating metrics, reading the validator contract) is now a standalone method.###Tests Added
8 new E2E tests covering the per-block processing logic:
mid_epoch_blocks_do_not_advance_epoch-> Epoch counter only advances on the last block of each epochearly_phase_dealer_distributes_shares-> Dealers distribute shares during the early phasemidpoint_and_late_phase_dealer_finalization-> Dealers finalize state in midpoint and late phasesrestarted_node_ignores_prior_epoch_blocks-> Restarted node silently ignores blocks from prior epochsboundary_block_resolves_epoch_outcome_and_advances_state-> Boundary block resolves DKG outcome, advances epoch, populates next players, keeps group public key stableresolve_epoch_outcome_single_signer-> Same boundary block invariants with a single-signer setupdealer_log_in_block_extra_data_is_stored-> Dealer logs written into block extra data are stored and used to complete the ceremonyown_dealer_log_in_block_is_cleared_from_state-> A dealer's own log is cleared from state after it appears in a finalized block