Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor in Block producer #16181

Open
wants to merge 11 commits into
base: al/header
Choose a base branch
from
Open

Refactor in Block producer #16181

wants to merge 11 commits into from

Conversation

anne-laure-s
Copy link
Member

This PR updates old commits :

  • Split Block_producer.run into smaller functions (splitted in this PR) : 69561b9
  • Refactor block production control flow : 93f6457
  • Remove Interruptible usage from block production : 8ae33e5
  • Debugging block creation schedule : 2cd1275
  • Refactor genesis block creation : 8b0d8bb

@anne-laure-s anne-laure-s self-assigned this Oct 3, 2024
@anne-laure-s anne-laure-s requested a review from a team as a code owner October 3, 2024 17:22
@anne-laure-s
Copy link
Member Author

!ci-build-me

@svv232
Copy link
Member

svv232 commented Oct 3, 2024

!ci-nightly-me

@coveralls
Copy link

Coverage Status

coverage: 61.091%. first build
when pulling 38e78ff on al/block-producer
into 85f8bfb on al/header.

Committed separately for cleaner diff in Github interface.
(* Commented out because for large blocks it's an oversized log *)
(* ; ( "internal_transition"
, Internal_transition.to_yojson internal_transition ) *)
; ( "internal_transition"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was probably made by accident

@georgeee
Copy link
Member

Suggest splitting this PR: commits before Refactor block production control flow are extremely trivial movements of code and could be merged as such (we don't even need to test these).

Everything further actually changes control flow, so it's probably better to consider them separately.

@georgeee
Copy link
Member

Commit Debugging block creation schedule has to be removed from the PR

in
check_next_block_timing slot i () )
let%map () =
Broadcast_pipe.Reader.iter_until frontier_reader
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment: iterates until there is some frontier

x
in
let%map _ = Interruptible.force produce_intr in
(* TODO consider uncommenting below or removing interruptible usage completely *)
Copy link
Member

@georgeee georgeee Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forcing produce_intr makes sure that the next iteration won't start before the block is produced. Hence interruptible will not ever be actually interrupted.

It could make sense if we replaced the Interruptible.force above with Interruptible.don't_wait_for, but this wasn't the case in the original code.

handle_block_production_errors ~logger ~rejected_blocks_logger
~time_taken:span ~previous_protocol_state ~protocol_state res

let iteration ~schedule_next_check ~dispatch_now ~schedule_dispatch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename:

  • ~schedule_next_check to ~schedule_next_vrf_check
  • ~dispatch_now to ~produce_block_now
  • ~next_check_now to ~next_vrf_check_now
  • ~schedule_dispatch to ~schedule_block_production

~next_check_now ~context:(module Context : CONTEXT) ~vrf_evaluator
~time_controller ~coinbase_receiver ~set_next_producer_timing ~frontier
~vrf_evaluation_state ~epoch_data_for_vrf ~ledger_snapshot i slot =
O1trace.thread
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this O1trace.thread, it was introduced for debugging

@@ -1241,6 +1225,9 @@ let run ~context:(module Context : CONTEXT) ~vrf_evaluator ~prover ~verifier
let run_precomputed ~context:(module Context : CONTEXT) ~verifier ~trust_system
~time_controller ~frontier_reader ~transition_writer ~precomputed_blocks =
let open Context in
let log_bootstrap_mode () =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why it was re-introduced locally?

@georgeee
Copy link
Member

Last few commits are better be split to standalone PRs.

Point of commit Refactor block production control flow is that this is only a rewrite of previous code: singleton scheduler is only used to schedule one routine to happen strictly after previous scheduled routine was completed, and Singleton_supervisor's parts were accurately integrated into run's code directly.

Commit Remove Interruptible usage from block production removes the use of interruptible which becomes obviously redundant (interruptible will never get to be interrupted) after previous commit.

Finally, Refactor genesis block creation is the only change that modifies behavior (not just refactors the code): instead of trying to defer creation of genesis block to the latest possible point, it's always being executed at the beginning of run().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants