diff --git a/CHANGES.rst b/CHANGES.rst index 41911f4d984918196ea8bb684ee5397d93e1e0a2..04b6cc13306280abe546f240af951d159aa15a61 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -86,6 +86,10 @@ Baker states in order to avoid unexpected crashes when the baker gets updated, or when a new protocol's baker starts. (MR :gl:`!7640`) +- Restored previous behaviour from :gl:`!7490` for blocks at round + greater than 0. Application-dependent checks are re-enabled for + re-proposal and fresh blocks at round greater than 0. + Accuser ------- diff --git a/src/proto_016_PtMumbai/lib_delegate/baking_actions.ml b/src/proto_016_PtMumbai/lib_delegate/baking_actions.ml index e05821d643bce2bc756ee10fcb8fccd7de84e15f..b24a54100308732896aa299a3ba105985c87bcb7 100644 --- a/src/proto_016_PtMumbai/lib_delegate/baking_actions.ml +++ b/src/proto_016_PtMumbai/lib_delegate/baking_actions.ml @@ -119,6 +119,7 @@ type block_to_bake = { round : Round.t; delegate : Baking_state.consensus_key_and_delegate; kind : block_kind; + force_apply : bool; } type action = @@ -214,7 +215,13 @@ let sign_block_header state proposer unsigned_block_header = return {Block_header.shell; protocol_data = {contents; signature}} let inject_block ~state_recorder state block_to_bake ~updated_state = - let {predecessor; round; delegate = (consensus_key, _) as delegate; kind} = + let { + predecessor; + round; + delegate = (consensus_key, _) as delegate; + kind; + force_apply; + } = block_to_bake in Events.( @@ -311,7 +318,7 @@ let inject_block ~state_recorder state block_to_bake ~updated_state = ~payload_round ~liquidity_baking_toggle_vote ~user_activated_upgrades - ~force_apply:state.global_state.config.force_apply + ~force_apply state.global_state.config.fees simulation_mode simulation_kind diff --git a/src/proto_016_PtMumbai/lib_delegate/baking_actions.mli b/src/proto_016_PtMumbai/lib_delegate/baking_actions.mli index 91b9bf7729157864c0258c476ae56aeeb30c54ef..5b9715905497978525327f0f8e57e14593936e88 100644 --- a/src/proto_016_PtMumbai/lib_delegate/baking_actions.mli +++ b/src/proto_016_PtMumbai/lib_delegate/baking_actions.mli @@ -41,6 +41,11 @@ type block_to_bake = { round : Round.t; delegate : consensus_key_and_delegate; kind : block_kind; + force_apply : bool; + (** if true, while baking the block, try and apply the block and its + operations instead of only validating them. this can be permanently + set using the [--force-apply] flag (see [force_apply_switch_arg] in + [baking_commands.ml]). *) } type action = diff --git a/src/proto_016_PtMumbai/lib_delegate/baking_lib.ml b/src/proto_016_PtMumbai/lib_delegate/baking_lib.ml index 5adbda789e44c39f1c44b0ef3e94acce5ce6ec05..ebb2cd35fc0c934559c28b6254c2625aa71bcedf 100644 --- a/src/proto_016_PtMumbai/lib_delegate/baking_lib.ml +++ b/src/proto_016_PtMumbai/lib_delegate/baking_lib.ml @@ -235,6 +235,7 @@ let propose_at_next_level ~minimal_timestamp state = round = minimal_round; delegate; kind; + force_apply = state.global_state.config.force_apply; } in let state_recorder ~new_state = @@ -476,6 +477,7 @@ let baking_minimal_timestamp state = round = minimal_round; delegate; kind; + force_apply = state.global_state.config.force_apply; } in let state_recorder ~new_state = diff --git a/src/proto_016_PtMumbai/lib_delegate/state_transitions.ml b/src/proto_016_PtMumbai/lib_delegate/state_transitions.ml index d39c05dbc8cdd858a589a671db6b74db8b78ebb7..5cc55044263d47599f57bbc3de3d3f1a4106c9ab 100644 --- a/src/proto_016_PtMumbai/lib_delegate/state_transitions.ml +++ b/src/proto_016_PtMumbai/lib_delegate/state_transitions.ml @@ -413,7 +413,12 @@ let propose_fresh_block_action ~endorsements ?last_proposal in let kind = Fresh operation_pool in Events.(emit proposing_fresh_block (delegate, round)) >>= fun () -> - let block_to_bake = {predecessor; round; delegate; kind} in + let force_apply = + state.global_state.config.force_apply || Round.(round <> zero) + (* This is used as a safety net by applying blocks on round > 0, in case + validation-only did not produce a correct round-0 block. *) + in + let block_to_bake = {predecessor; round; delegate; kind; force_apply} in let updated_state = update_current_phase state Idle in Lwt.return @@ Inject_block {block_to_bake; updated_state} @@ -498,8 +503,13 @@ let propose_block_action state delegate round (proposal : proposal) = let kind = Reproposal {consensus_operations; payload_hash; payload_round; payload} in + let force_apply = + true + (* This is used as a safety net by applying blocks on round > 0, in case + validation-only did not produce a correct round-0 block. *) + in let block_to_bake = - {predecessor = proposal.predecessor; round; delegate; kind} + {predecessor = proposal.predecessor; round; delegate; kind; force_apply} in let updated_state = update_current_phase state Idle in Lwt.return @@ Inject_block {block_to_bake; updated_state} diff --git a/src/proto_alpha/lib_delegate/baking_actions.ml b/src/proto_alpha/lib_delegate/baking_actions.ml index 42153493a602d3982b94f3796abb07a916c89b9f..3b78c068e85dc865dd0510eaa255490b8722a549 100644 --- a/src/proto_alpha/lib_delegate/baking_actions.ml +++ b/src/proto_alpha/lib_delegate/baking_actions.ml @@ -119,6 +119,7 @@ type block_to_bake = { round : Round.t; delegate : Baking_state.consensus_key_and_delegate; kind : block_kind; + force_apply : bool; } type action = @@ -214,7 +215,13 @@ let sign_block_header state proposer unsigned_block_header = return {Block_header.shell; protocol_data = {contents; signature}} let inject_block ~state_recorder state block_to_bake ~updated_state = - let {predecessor; round; delegate = (consensus_key, _) as delegate; kind} = + let { + predecessor; + round; + delegate = (consensus_key, _) as delegate; + kind; + force_apply; + } = block_to_bake in Events.( @@ -311,7 +318,7 @@ let inject_block ~state_recorder state block_to_bake ~updated_state = ~payload_round ~liquidity_baking_toggle_vote ~user_activated_upgrades - ~force_apply:state.global_state.config.force_apply + ~force_apply state.global_state.config.fees simulation_mode simulation_kind diff --git a/src/proto_alpha/lib_delegate/baking_actions.mli b/src/proto_alpha/lib_delegate/baking_actions.mli index 07665261acea2a7be09334c4f9d64e5c0d99313f..360f1f761e27eae0213a55ee22ba568b5940c8d8 100644 --- a/src/proto_alpha/lib_delegate/baking_actions.mli +++ b/src/proto_alpha/lib_delegate/baking_actions.mli @@ -41,6 +41,11 @@ type block_to_bake = { round : Round.t; delegate : consensus_key_and_delegate; kind : block_kind; + force_apply : bool; + (** if true, while baking the block, try and apply the block and its + operations instead of only validating them. this can be permanently + set using the [--force-apply] flag (see [force_apply_switch_arg] in + [baking_commands.ml]). *) } type action = diff --git a/src/proto_alpha/lib_delegate/baking_lib.ml b/src/proto_alpha/lib_delegate/baking_lib.ml index 113cab5a0a571df5f65fceb30cabe1959021ab64..8ce23bda6549ea1e4619b341f962e87ec151e3ca 100644 --- a/src/proto_alpha/lib_delegate/baking_lib.ml +++ b/src/proto_alpha/lib_delegate/baking_lib.ml @@ -235,6 +235,7 @@ let propose_at_next_level ~minimal_timestamp state = round = minimal_round; delegate; kind; + force_apply = state.global_state.config.force_apply; } in let state_recorder ~new_state = @@ -488,6 +489,7 @@ let baking_minimal_timestamp state = round = minimal_round; delegate; kind; + force_apply = state.global_state.config.force_apply; } in let state_recorder ~new_state = diff --git a/src/proto_alpha/lib_delegate/state_transitions.ml b/src/proto_alpha/lib_delegate/state_transitions.ml index d39c05dbc8cdd858a589a671db6b74db8b78ebb7..5cc55044263d47599f57bbc3de3d3f1a4106c9ab 100644 --- a/src/proto_alpha/lib_delegate/state_transitions.ml +++ b/src/proto_alpha/lib_delegate/state_transitions.ml @@ -413,7 +413,12 @@ let propose_fresh_block_action ~endorsements ?last_proposal in let kind = Fresh operation_pool in Events.(emit proposing_fresh_block (delegate, round)) >>= fun () -> - let block_to_bake = {predecessor; round; delegate; kind} in + let force_apply = + state.global_state.config.force_apply || Round.(round <> zero) + (* This is used as a safety net by applying blocks on round > 0, in case + validation-only did not produce a correct round-0 block. *) + in + let block_to_bake = {predecessor; round; delegate; kind; force_apply} in let updated_state = update_current_phase state Idle in Lwt.return @@ Inject_block {block_to_bake; updated_state} @@ -498,8 +503,13 @@ let propose_block_action state delegate round (proposal : proposal) = let kind = Reproposal {consensus_operations; payload_hash; payload_round; payload} in + let force_apply = + true + (* This is used as a safety net by applying blocks on round > 0, in case + validation-only did not produce a correct round-0 block. *) + in let block_to_bake = - {predecessor = proposal.predecessor; round; delegate; kind} + {predecessor = proposal.predecessor; round; delegate; kind; force_apply} in let updated_state = update_current_phase state Idle in Lwt.return @@ Inject_block {block_to_bake; updated_state}