Baker: make anonymous operations applied after endorsements

This commit is contained in:
Vincent Botbol 2018-08-06 15:09:08 +02:00 committed by Grégoire Henry
parent 7f07c6badb
commit b8e78c4229
No known key found for this signature in database
GPG Key ID: 50D984F20BD445D2

View File

@ -687,11 +687,13 @@ let filter_and_apply_operations
let accepted_managers = List.sort Proto_alpha.compare_operations accepted_managers in
(* Make sure we only keep valid operations *)
filter_valid_operations initial_inc votes >>=? fun (inc, votes) ->
filter_valid_operations inc anonymous >>=? fun (inc, anonymous) ->
filter_valid_operations inc accepted_managers >>=? fun (inc, accepted_managers) ->
filter_map_s (is_valid_endorsement inc) endorsements >>=? fun endorsements ->
(* Endorsements won't fail now *)
fold_left_s add_operation inc endorsements >>=? fun final_inc ->
fold_left_s add_operation inc endorsements >>=? fun inc ->
(* Endorsement and double baking/endorsement evidence do not commute:
we apply anonymous operations after endorsements. *)
filter_valid_operations inc anonymous >>=? fun (final_inc, anonymous) ->
let operations = List.map List.rev [ endorsements ; votes ; anonymous ; accepted_managers ] in
finalize_construction final_inc >>=? fun (validation_result, metadata) ->
return @@ (final_inc, (validation_result, metadata), operations)