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

Decouple Transaction_snark_work types #16499

Open
wants to merge 1 commit into
base: georgeee/proof-cache-tag-21-decouple-staged_ledger_diff-types
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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: 3 additions & 1 deletion src/lib/mina_lib/mina_lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,9 @@ let fetch_completed_snarks (module Context : CONTEXT) snark_pool network
let%bind () =
Deferred.List.iter completed_works ~f:(fun work ->
(* proofs should be verified in apply and broadcast *)
let statement = Transaction_snark_work.statement work in
let statement =
Transaction_snark_work.Stable.Latest.statement work
in
let snark =
Network_pool.Priced_proof.
{ proof = work.proofs
Expand Down
2 changes: 1 addition & 1 deletion src/lib/mina_networking/mina_networking.mli
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ module Rpcs : sig
module Get_completed_snarks : sig
type query = unit

type response = Transaction_snark_work.unchecked list option
type response = Transaction_snark_work.Stable.Latest.t list option
end

type ('query, 'response) rpc = ('query, 'response) Rpcs.rpc =
Expand Down
5 changes: 4 additions & 1 deletion src/lib/mina_networking/rpcs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,10 @@ module Get_completed_snarks = struct
| Some snark_pool, Some snark_state ->
Work_selector.completed_work_statements ~snark_pool snark_state
|> Fn.flip List.take limit
|> List.map ~f:Transaction_snark_work.forget
|> List.map
~f:
Transaction_snark_work.(
Fn.compose read_all_proofs_from_disk forget)
|> Option.some |> return
| _, _ ->
return None
Expand Down
16 changes: 12 additions & 4 deletions src/lib/staged_ledger_diff/diff.ml
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,13 @@ module Make_str (A : Wire_types.Concrete) = struct
type t =
(Transaction_snark_work.t, User_command.t With_status.t) Pre_diff_two.t

let write_all_proofs_to_disk : Stable.Latest.t -> t = Fn.id
let write_all_proofs_to_disk : Stable.Latest.t -> t =
Pre_diff_two.map ~f1:Transaction_snark_work.write_all_proofs_to_disk
~f2:Fn.id

let read_all_proofs_from_disk : t -> Stable.Latest.t = Fn.id
let read_all_proofs_from_disk : t -> Stable.Latest.t =
Pre_diff_two.map ~f1:Transaction_snark_work.read_all_proofs_from_disk
~f2:Fn.id
end

module Pre_diff_with_at_most_one_coinbase = struct
Expand All @@ -202,9 +206,13 @@ module Make_str (A : Wire_types.Concrete) = struct
type t =
(Transaction_snark_work.t, User_command.t With_status.t) Pre_diff_one.t

let write_all_proofs_to_disk : Stable.Latest.t -> t = Fn.id
let write_all_proofs_to_disk : Stable.Latest.t -> t =
Pre_diff_one.map ~f1:Transaction_snark_work.write_all_proofs_to_disk
~f2:Fn.id

let read_all_proofs_from_disk : t -> Stable.Latest.t = Fn.id
let read_all_proofs_from_disk : t -> Stable.Latest.t =
Pre_diff_one.map ~f1:Transaction_snark_work.read_all_proofs_from_disk
~f2:Fn.id
end

module Diff = struct
Expand Down
6 changes: 6 additions & 0 deletions src/lib/transaction_snark_work/transaction_snark_work.ml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ module T = struct
}
[@@deriving equal, sexp, yojson]

let statement t = One_or_two.map t.proofs ~f:Ledger_proof.statement

let to_latest = Fn.id
end
end]
Expand All @@ -117,6 +119,10 @@ module T = struct
; fee = t.fee
; prover = t.prover
}

let write_all_proofs_to_disk = Fn.id

let read_all_proofs_from_disk = Fn.id
end

include T
Expand Down
14 changes: 12 additions & 2 deletions src/lib/transaction_snark_work/transaction_snark_work.mli
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module type S = sig
val proofs : t -> Ledger_proof.t One_or_two.t
end

type t = Mina_wire_types.Transaction_snark_work.V2.t =
type t =
{ fee : Currency.Fee.t
; proofs : Ledger_proof.t One_or_two.t
; prover : Public_key.Compressed.t
Expand All @@ -76,9 +76,15 @@ val statement : t -> Statement.t
module Stable : sig
module V2 : sig
type t [@@deriving bin_io, equal, sexp, version, yojson]

val statement : t -> Statement.Stable.V2.t

val to_latest : t -> t
end

module Latest = V2
end
with type V2.t = t
with type V2.t = Mina_wire_types.Transaction_snark_work.V2.t

type unchecked = t

Expand All @@ -91,3 +97,7 @@ module Checked : sig
end

val forget : Checked.t -> t

val write_all_proofs_to_disk : Stable.Latest.t -> t

val read_all_proofs_from_disk : t -> Stable.Latest.t