Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle expired transactions in transaction pool #6198

Merged
merged 14 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/block_time/block_time.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module Time = struct
[%%if
time_offsets]

type t = Time.Span.t Lazy.t
type t = Time.Span.t Lazy.t [@@deriving sexp]

let create offset = offset

Expand All @@ -54,7 +54,7 @@ module Time = struct

[%%else]

type t = unit
type t = unit [@@deriving sexp]

let create () = ()

Expand Down
2 changes: 1 addition & 1 deletion src/lib/block_time/block_time.mli
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Time : sig
include Hashable.S with type t := t

module Controller : sig
type t
type t [@@deriving sexp]

val create : t -> t

Expand Down
7 changes: 7 additions & 0 deletions src/lib/coda_base/user_command.ml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ let fee_token (t : t) =
| Snapp_command x ->
Snapp_command.fee_token x

let valid_until (t : t) =
match t with
| Signed_command x ->
Signed_command.valid_until x
| Snapp_command _ ->
Coda_numbers.Global_slot.max_value

let forget_check (t : Valid.t) : t = (t :> t)

let to_valid_unsafe (t : t) =
Expand Down
6 changes: 4 additions & 2 deletions src/lib/coda_lib/coda_lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,8 @@ let create (config : Config.t) =
in
let transaction_pool =
Network_pool.Transaction_pool.create ~config:txn_pool_config
~constraint_constants ~logger:config.logger
~constraint_constants ~consensus_constants
~time_controller:config.time_controller ~logger:config.logger
~incoming_diffs:(Coda_networking.transaction_pool_diffs net)
~local_diffs:local_txns_reader
~frontier_broadcast_pipe:frontier_broadcast_pipe_r
Expand Down Expand Up @@ -1191,7 +1192,8 @@ let create (config : Config.t) =
in
let%bind snark_pool =
Network_pool.Snark_pool.load ~config:snark_pool_config
~constraint_constants ~logger:config.logger
~constraint_constants ~consensus_constants
~time_controller:config.time_controller ~logger:config.logger
~disk_location:config.snark_pool_disk_location
~incoming_diffs:(Coda_networking.snark_pool_diffs net)
~local_diffs:local_snark_work_reader
Expand Down
2 changes: 2 additions & 0 deletions src/lib/consensus/intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ module type S = sig
val start_time : constants:Constants.t -> t -> Block_time.t

val end_time : constants:Constants.t -> t -> Block_time.t

val to_global_slot : t -> Coda_numbers.Global_slot.t
end

module Consensus_state : sig
Expand Down
2 changes: 2 additions & 0 deletions src/lib/consensus/proof_of_stake.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,8 @@ module Data = struct
Global_slot.diff ~constants t (gc_width_epoch, gc_width_slot)

let to_uint32 t = Global_slot.slot_number t

let to_global_slot = slot_number
end

[%%if
Expand Down
2 changes: 1 addition & 1 deletion src/lib/network_pool/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(public_name network_pool)
(inline_tests)
(library_flags -linkall)
(libraries async core one_or_two pipe_lib quickcheck_lib verifier coda_base ledger_proof transaction_snark transition_frontier)
(libraries async core one_or_two pipe_lib quickcheck_lib verifier coda_base ledger_proof transaction_snark transition_frontier consensus coda_numbers)
(preprocessor_deps "../../config.mlh")
(preprocess (pps ppx_base ppx_coda ppx_version ppx_let ppx_assert ppx_pipebang ppx_deriving.std ppx_sexp_conv ppx_bin_prot ppx_custom_printf ppx_inline_test ppx_optcomp ppx_snarky ppx_deriving_yojson ppx_fields_conv bisect_ppx --conditional))
(synopsis
Expand Down
4 changes: 3 additions & 1 deletion src/lib/network_pool/f_sequence.ml
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,8 @@ let length = C.length

let iter = C.iter

let find = C.find

let to_seq : 'e t -> 'e Sequence.t = fun t -> Sequence.unfold ~init:t ~f:uncons

let sexp_of_t : ('e -> Sexp.t) -> 'e t -> Sexp.t =
Expand All @@ -546,7 +548,7 @@ let rec equal : ('e -> 'e -> bool) -> 'e t -> 'e t -> bool =
| _ ->
false

let to_list : 'e t -> 'e list = Fn.compose Sequence.to_list to_seq
let to_list : 'e t -> 'e list = fun fseq -> Sequence.to_list (to_seq fseq)

let of_list : 'e list -> 'e t = List.fold_left ~init:empty ~f:snoc

Expand Down
4 changes: 4 additions & 0 deletions src/lib/network_pool/f_sequence.mli
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ val iter : 'e t -> f:('e -> unit) -> unit

val to_seq : 'e t -> 'e Sequence.t

val to_list : 'e t -> 'e list

val sexp_of_t : ('e -> Sexp.t) -> 'e t -> Sexp.t

val equal : ('e -> 'e -> bool) -> 'e t -> 'e t -> bool
Expand All @@ -58,3 +60,5 @@ val snoc : 'e t -> 'e -> 'e t
be a sequence containing all elements with index < i, the second will
contain all elements with index >= i *)
val split_at : 'e t -> int -> 'e t * 'e t

val find : 'e t -> f:('e -> sexp_bool) -> 'e sexp_option
Loading