@@ -2884,24 +2884,39 @@ module Hardfork_config = struct
28842884 in
28852885 Option. value ~default: block_global_slot configured_slot
28862886
2887- (* * Helper to convert a global slot since hard fork to a global slot since genesis *)
2888- let global_slot_since_hard_fork_to_genesis
2889- ~(constraint_constants : Genesis_constants.Constraint_constants.t )
2890- global_slot =
2891- (* Convert the global slot to a span of slots since the current hard fork *)
2892- let global_slot_span =
2893- global_slot |> Mina_numbers.Global_slot_since_hard_fork. to_uint32
2894- |> Mina_numbers.Global_slot_span. of_uint32
2887+ (* * We schedule the hard fork genesis to occur at a particular
2888+ [Mina_numbers.Global_slot_since_hard_fork.t], but need a
2889+ [Mina_numbers.Global_slot_since_genesis.t] for the hard fork config. This
2890+ method does this conversion by taking the hard fork block's consensus data
2891+ applying the same slot update as [Consensus.Data.Consensus_state.update]
2892+ to the hard fork block's global slots (since hard fork and since genesis),
2893+ then returning the resulting global slot since genesis.
2894+
2895+ This method requires that the desired hard fork genesis slot occur after
2896+ the hard fork block's slot. This property is guaranteed by
2897+ [hard_fork_global_slot] (which determines the scheduled genesis slot) and
2898+ [breadcrumb] (which retrieves the hard fork block). *)
2899+ let move_hard_fork_consensus_to_scheduled_genesis ~hard_fork_consensus_data
2900+ next_genesis_global_slot =
2901+ let block_global_slot =
2902+ Consensus.Data.Consensus_state. curr_global_slot hard_fork_consensus_data
28952903 in
2896- (* Retrieve the global slot since genesis of the genesis of the current
2897- chain *)
2898- let current_genesis_global_slot =
2899- constraint_constants.fork
2900- |> Option. value_map ~default: Mina_numbers.Global_slot_since_genesis. zero
2901- ~f: (fun fork -> fork.global_slot_since_genesis)
2904+ let block_global_slot_since_genesis =
2905+ Consensus.Data.Consensus_state. global_slot_since_genesis
2906+ hard_fork_consensus_data
2907+ in
2908+ (* We pretend that the consensus moved forward from the hard fork block's
2909+ slot to the scheduled genesis slot, and get that slot difference *)
2910+ let global_slot_span =
2911+ Mina_numbers.Global_slot_since_hard_fork. diff next_genesis_global_slot
2912+ block_global_slot
2913+ |> Option. value_exn ~here: [% here]
2914+ ~message:
2915+ " Invariant: hard fork genesis cannot be scheduled before the hard \
2916+ fork block"
29022917 in
2903- (* Add the slot span to the current chain 's genesis slot to get the desired quantity *)
2904- Mina_numbers.Global_slot_since_genesis. add current_genesis_global_slot
2918+ (* Now apply that difference to the hard fork block 's slot since genesis *)
2919+ Mina_numbers.Global_slot_since_genesis. add block_global_slot_since_genesis
29052920 global_slot_span
29062921
29072922 let prepare_inputs ~breadcrumb_spec mina =
@@ -2913,9 +2928,8 @@ module Hardfork_config = struct
29132928 hard_fork_global_slot ~breadcrumb_spec ~block mina
29142929 in
29152930 let global_slot_since_genesis =
2916- global_slot_since_hard_fork_to_genesis
2917- ~constraint_constants:
2918- mina.config.precomputed_values.constraint_constants
2931+ move_hard_fork_consensus_to_scheduled_genesis
2932+ ~hard_fork_consensus_data: (Mina_block. consensus_state block)
29192933 global_slot_since_hard_fork
29202934 in
29212935 let genesis_state_timestamp =
0 commit comments