Skip to content

Commit

Permalink
Decouple Transaction_snark_work types
Browse files Browse the repository at this point in the history
Remove `Stable.Latest.t = t` from interfaces. This is a preparation step
for removing the equality in the implementation as well.
  • Loading branch information
georgeee committed Jan 21, 2025
1 parent 54e24e4 commit f535126
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
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 @@ -1579,7 +1579,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 @@ -112,7 +112,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
2 changes: 1 addition & 1 deletion src/lib/mina_networking/rpcs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ 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 unwrap forget)
|> Option.some |> return
| _, _ ->
return None
Expand Down
12 changes: 8 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,11 @@ 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 generate : Stable.Latest.t -> t = Fn.id
let generate : Stable.Latest.t -> t =
Pre_diff_two.map ~f1:Transaction_snark_work.generate ~f2:Fn.id

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

module Pre_diff_with_at_most_one_coinbase = struct
Expand All @@ -202,9 +204,11 @@ 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 generate : Stable.Latest.t -> t = Fn.id
let generate : Stable.Latest.t -> t =
Pre_diff_one.map ~f1:Transaction_snark_work.generate ~f2:Fn.id

let unwrap : t -> Stable.Latest.t = Fn.id
let unwrap : t -> Stable.Latest.t =
Pre_diff_one.map ~f1:Transaction_snark_work.unwrap ~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 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 generate = Fn.id

let unwrap = 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, 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 @@ -93,3 +99,7 @@ module Checked : sig
end

val forget : Checked.t -> t

val generate : Stable.Latest.t -> t

val unwrap : t -> Stable.Latest.t

0 comments on commit f535126

Please sign in to comment.