Module Tezos_baking_025_PsUshuai.Baking_scheduling

create_global_state ?dal_node_rpc_ctxt ?constants ~chain context baking_configuration consensus_keys creates a Baking_state.global_state: round_durations are created from constants, and a forge worker is started. If constants is not provided, an RPC is called to recover them from context.

val create_initial_state : ?canceler:Lwt_canceler.t -> Tezos_client_025_PsUshuai.Protocol_client_context.full -> ?synchronize:bool -> ?monitor_node_operations:bool -> multi_node_setup:bool -> global_state:Baking_state.global_state -> current_proposal:Baking_state_types.proposal -> Baking_state_types.Key.t list -> Baking_state.state Tezos_base.TzPervasives.tzresult Lwt.t

create_initial_state ?canceler context ?synchronize ?monitor_node_operations ~global_state current_proposal consensus_keys creates an initial Baking_state.t for a single node connection by initializing a Baking_state.automaton_state, a Baking_state.level_state and a Baking_state.round_state from an existing global_state.

  • For the automaton_state initialization, a validation mode is set based on the baking configuration and an operation worker is started. If canceler is provided, cancelling it will also trigger a shutdown of the operation worker. See Baking_automaton.create_automaton_state.
  • For the level_state initialization, information regarding the current and next levels is retrieved (the current level being that of the current_proposal) and delegate slots are computed for the given consensus_keys at both levels. The DAL included attestations cache committees are also initialized for both levels.
  • For the round_state initialization, current round is computed by calling Baking_actions.compute_round with current_proposal information if synchronize is set to true (which is the default).

run context ?canceler ?stop_on_event ?on_error ?constants chain baking_configuration consensus_keys is the entry point of the baker automaton. This function performs the following tasks:

  • perform a sanity check that check the location of the baking files, nonces, highwatermarks and state files, also verifying that the files are loadable
  • create the streams for valid blocks, new heads, and operations from the node's mempool's
  • create an initial state, see Baking_automaton.create_initial_state
  • register dal profiles by calling the register_dal_profiles node RPC