Skip to content

fix(refactor): Clean up handle_finalized_block and add E2E test coverage#3559

Open
radhika-kapoor wants to merge 5 commits intotempoxyz:mainfrom
radhika-kapoor:fix/cleanup-handle-finalized-block-2697
Open

fix(refactor): Clean up handle_finalized_block and add E2E test coverage#3559
radhika-kapoor wants to merge 5 commits intotempoxyz:mainfrom
radhika-kapoor:fix/cleanup-handle-finalized-block-2697

Conversation

@radhika-kapoor
Copy link
Copy Markdown
Contributor

Closes #2697

###Summary
The handle_finalized_block function in the DKG manager actor was a single large function. This PR resolves refactoring the function and adding E2E test coverage.

###Solution

  • Introduced FinalizedBlockContext struct -> groups the 7 individual arguments of handle_finalized_block into a single context struct, removing the clippy::too_many_arguments suppression and fulfilling the TODO comment.
  • Extracted 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.
  • Extracted 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 epoch

  • early_phase_dealer_distributes_shares -> Dealers distribute shares during the early phase

  • midpoint_and_late_phase_dealer_finalization -> Dealers finalize state in midpoint and late phases

  • restarted_node_ignores_prior_epoch_blocks -> Restarted node silently ignores blocks from prior epochs

  • boundary_block_resolves_epoch_outcome_and_advances_state -> Boundary block resolves DKG outcome, advances epoch, populates next players, keeps group public key stable

  • resolve_epoch_outcome_single_signer -> Same boundary block invariants with a single-signer setup

  • dealer_log_in_block_extra_data_is_stored -> Dealer logs written into block extra data are stored and used to complete the ceremony

  • own_dealer_log_in_block_is_cleared_from_state -> A dealer's own log is cleared from state after it appears in a finalized block

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.

Clean up overlong function handle_finalized_block in DKG actor

1 participant