From 25cc3e4da396e8f3bea6e932fc00b8dda25ec7b2 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Wed, 27 Jan 2021 20:02:30 +0000 Subject: [PATCH 1/3] Don't crash when expired transactions are in the pool --- src/lib/network_pool/indexed_pool.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/network_pool/indexed_pool.ml b/src/lib/network_pool/indexed_pool.ml index 66c51d92fbe..ec7c5e5fc0c 100644 --- a/src/lib/network_pool/indexed_pool.ml +++ b/src/lib/network_pool/indexed_pool.ml @@ -905,7 +905,7 @@ let rec add_from_gossip_exn : (* We've already removed them, so this should always be empty. *) assert (Sequence.is_empty dropped') ; Result.Ok (v, t'', dropped) - | Error ((Insufficient_funds _ | Overflow) as err) -> + | Error ((Insufficient_funds _ | Overflow | Expired _) as err) -> Error err (* C2 *) (* C4 *) @@ -949,7 +949,7 @@ let rec add_from_gossip_exn : | Ok (_v, t', dropped_) -> assert (Sequence.is_empty dropped_) ; go t' increment dropped' None current_nonce - | Error (Insufficient_funds _) -> + | Error (Insufficient_funds _ | Expired _) -> (* Re-evaluate with the same [dropped] to calculate the new fee increment. *) From 9623b58dfef06d98945909c4a2c70bef84b0240a Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Wed, 27 Jan 2021 20:33:06 +0000 Subject: [PATCH 2/3] Catch all of the transaction pool recursion errors --- src/lib/network_pool/indexed_pool.ml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/lib/network_pool/indexed_pool.ml b/src/lib/network_pool/indexed_pool.ml index ec7c5e5fc0c..e2119893126 100644 --- a/src/lib/network_pool/indexed_pool.ml +++ b/src/lib/network_pool/indexed_pool.ml @@ -905,12 +905,8 @@ let rec add_from_gossip_exn : (* We've already removed them, so this should always be empty. *) assert (Sequence.is_empty dropped') ; Result.Ok (v, t'', dropped) - | Error ((Insufficient_funds _ | Overflow | Expired _) as err) -> - Error err - (* C2 *) - (* C4 *) | Error err -> - raise (Command_error err) + Error err in let drop_head, drop_tail = Option.value_exn (Sequence.next dropped) in let increment = @@ -949,13 +945,11 @@ let rec add_from_gossip_exn : | Ok (_v, t', dropped_) -> assert (Sequence.is_empty dropped_) ; go t' increment dropped' None current_nonce - | Error (Insufficient_funds _ | Expired _) -> + | Error _err -> (* Re-evaluate with the same [dropped] to calculate the new fee increment. *) - go t' increment dropped (Some dropped') current_nonce - | Error err -> - raise (Command_error err) ) + go t' increment dropped (Some dropped') current_nonce ) in go t'' increment drop_tail None current_nonce in From d788aba7cf58b092516852137613db6c83850a81 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Wed, 27 Jan 2021 20:34:20 +0000 Subject: [PATCH 3/3] Remove Command_error --- src/lib/network_pool/indexed_pool.ml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/lib/network_pool/indexed_pool.ml b/src/lib/network_pool/indexed_pool.ml index e2119893126..3ad697cb37c 100644 --- a/src/lib/network_pool/indexed_pool.ml +++ b/src/lib/network_pool/indexed_pool.ml @@ -77,17 +77,6 @@ module Command_error = struct [@@deriving sexp_of, to_yojson] end -exception Command_error of Command_error.t - -let () = - Sexplib.Conv.Exn_converter.add [%extension_constructor Command_error] - (function - | Command_error t -> - Sexp.List [Sexp.Atom "Command_error"; Command_error.sexp_of_t t] - | _ -> - (* Reaching this branch indicates a bug in sexplib. *) - assert false ) - (* Compute the total currency required from the sender to execute a command. Returns None in case of overflow. *)