Verified Commit 06398944 authored by Romain's avatar Romain

Mempool: handle endorsements which arrive too soon

Co-authored-by: Benjamin Canou's avatarBenjamin Canou <[email protected]>
Co-authored-by: Pierre Boutillier's avatarPierre Boutillier <[email protected]>
Co-authored-by: vbot's avatarvbot <[email protected]>
parent 9498d2cc
Pipeline #118477410 passed with stages
in 27 minutes and 1 second
......@@ -371,6 +371,15 @@ module Make (Filter : Prevalidator_filters.FILTER) (Arg : ARG) : T = struct
let config = filter_config w pv in
Filter.post_filter config (op, receipt)
let handle_branch_refused pv op oph errors =
notify_operation pv `Branch_refused op ;
Option.iter (Ring.add_and_return_erased pv.branch_refused oph) ~f:(fun e ->
pv.branch_refusals <- Operation_hash.Map.remove e pv.branch_refusals ;
pv.in_mempool <- Operation_hash.Set.remove e pv.in_mempool) ;
pv.in_mempool <- Operation_hash.Set.add oph pv.in_mempool ;
pv.branch_refusals <-
Operation_hash.Map.add oph (op, errors) pv.branch_refusals
let handle_unprocessed w pv =
( match pv.validation_state with
| Error err ->
......@@ -484,7 +493,6 @@ module Make (Filter : Prevalidator_filters.FILTER) (Arg : ARG) : T = struct
pv.branch_delays ;
Lwt.return (acc_validation_state, new_mempool)
| Branch_refused errors ->
notify_operation pv `Branch_refused op.raw ;
let new_mempool =
if is_endorsement op then
Mempool.
......@@ -497,20 +505,7 @@ module Make (Filter : Prevalidator_filters.FILTER) (Arg : ARG) : T = struct
}
else acc_mempool
in
Option.iter
(Ring.add_and_return_erased pv.branch_refused op.hash)
~f:(fun e ->
pv.branch_refusals <-
Operation_hash.Map.remove e pv.branch_refusals ;
pv.in_mempool <-
Operation_hash.Set.remove e pv.in_mempool) ;
pv.in_mempool <-
Operation_hash.Set.add op.hash pv.in_mempool ;
pv.branch_refusals <-
Operation_hash.Map.add
op.hash
(op.raw, errors)
pv.branch_refusals ;
handle_branch_refused pv op.raw op.hash errors ;
Lwt.return (acc_validation_state, new_mempool)
| Refused errors ->
refused op.hash op.raw errors
......@@ -791,7 +786,8 @@ module Make (Filter : Prevalidator_filters.FILTER) (Arg : ARG) : T = struct
pv.fetching <- Operation_hash.Set.remove oph pv.fetching ;
if not (Block_hash.Set.mem op.Operation.shell.branch pv.live_blocks) then (
Distributed_db.Operation.clear_or_cancel pv.chain_db oph ;
(* TODO: put in a specific delayed map ? *)
let error = [Exn (Failure "Unknown branch operation")] in
handle_branch_refused pv op oph error ;
return_unit )
else if
not (already_handled pv oph) (* prevent double inclusion on flush *)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment