Skip to content

Commit 4caa5af

Browse files
authored
Merge branch 'compatible' into georgeee/remove-transaction-valid-stable
2 parents 78f8148 + adbef16 commit 4caa5af

File tree

10 files changed

+82
-111
lines changed

10 files changed

+82
-111
lines changed

src/lib/mina_base/user_command.ml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,11 @@ module Zero_one_or_two = struct
138138
end
139139

140140
module Verifiable = struct
141-
[%%versioned
142-
module Stable = struct
143-
module V2 = struct
144-
type t =
145-
( Signed_command.Stable.V2.t
146-
, Zkapp_command.Verifiable.Stable.V1.t )
147-
Poly.Stable.V2.t
148-
[@@deriving sexp, compare, equal, hash, yojson]
149-
150-
let to_latest = Fn.id
151-
end
152-
end]
141+
type t =
142+
( Signed_command.Stable.Latest.t
143+
, Zkapp_command.Verifiable.t )
144+
Poly.Stable.Latest.t
145+
[@@deriving sexp, compare, equal, hash, yojson, bin_io_unversioned]
153146

154147
let fee_payer (t : t) =
155148
match t with

src/lib/mina_base/zkapp_command.ml

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -402,24 +402,14 @@ let check_authorization (p : Account_update.t) : unit Or_error.t =
402402
Error err
403403

404404
module Verifiable : sig
405-
[%%versioned:
406-
module Stable : sig
407-
module V1 : sig
408-
type t = private
409-
{ fee_payer : Account_update.Fee_payer.Stable.V1.t
410-
; account_updates :
411-
( Side_loaded_verification_key.Stable.V2.t
412-
, Zkapp_basic.F.Stable.V1.t )
413-
With_hash.Stable.V1.t
414-
option
415-
Call_forest.With_hashes_and_data.Stable.V1.t
416-
; memo : Signed_command_memo.Stable.V1.t
417-
}
418-
[@@deriving sexp, compare, equal, hash, yojson]
419-
420-
val to_latest : t -> t
421-
end
422-
end]
405+
type t = private
406+
{ fee_payer : Account_update.Fee_payer.t
407+
; account_updates :
408+
(Side_loaded_verification_key.t, Zkapp_basic.F.t) With_hash.t option
409+
Call_forest.With_hashes_and_data.t
410+
; memo : Signed_command_memo.t
411+
}
412+
[@@deriving sexp, compare, equal, hash, yojson, bin_io]
423413

424414
val load_vk_from_ledger :
425415
location_of_account:(Account_id.t -> 'loc option)
@@ -472,24 +462,17 @@ module Verifiable : sig
472462
with type 'a Command_wrapper.t = 'a With_status.t
473463
and type cache = Verification_key_wire.t Account_id.Map.t
474464
end = struct
475-
[%%versioned
476-
module Stable = struct
477-
module V1 = struct
478-
type t =
479-
{ fee_payer : Account_update.Fee_payer.Stable.V1.t
480-
; account_updates :
481-
( Side_loaded_verification_key.Stable.V2.t
482-
, Zkapp_basic.F.Stable.V1.t )
483-
With_hash.Stable.V1.t
484-
option
485-
Call_forest.With_hashes_and_data.Stable.V1.t
486-
; memo : Signed_command_memo.Stable.V1.t
487-
}
488-
[@@deriving sexp, compare, equal, hash, yojson]
489-
490-
let to_latest = Fn.id
491-
end
492-
end]
465+
type t =
466+
{ fee_payer : Account_update.Fee_payer.Stable.Latest.t
467+
; account_updates :
468+
( Side_loaded_verification_key.Stable.Latest.t
469+
, Zkapp_basic.F.Stable.Latest.t )
470+
With_hash.Stable.Latest.t
471+
option
472+
Call_forest.With_hashes_and_data.Stable.Latest.t
473+
; memo : Signed_command_memo.Stable.Latest.t
474+
}
475+
[@@deriving sexp, compare, equal, hash, yojson, bin_io_unversioned]
493476

494477
let ok_if_vk_hash_expected ~got ~expected =
495478
if not @@ Zkapp_basic.F.equal (With_hash.hash got) expected then

src/lib/mina_wire_types/mina_transaction.ml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,3 @@ end
1010
module V2 = struct
1111
type t = Mina_base.User_command.V2.t Poly.V2.t
1212
end
13-
14-
module Valid = struct
15-
module V2 = struct
16-
type t = Mina_base.User_command.Valid.V2.t Poly.V2.t
17-
end
18-
end

src/lib/mina_wire_types/test/type_equalities.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,6 @@ module Mina_transaction = struct
318318
module W = WT.Mina_transaction
319319
include Assert_equal1V2 (O.Poly.Stable) (W.Poly)
320320
include Assert_equal0V2 (O.Stable) (W)
321-
include Assert_equal0V2 (O.Valid.Stable) (W.Valid)
322321
end
323322

324323
module Mina_state = struct

src/lib/network_pool/indexed_pool.ml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ module For_tests = struct
199199
Set.iter data ~f:(check_fee key) ) ;
200200
Transaction_hash.Map.iteri pool.all_by_hash ~f:(fun ~key ~data ->
201201
[%test_eq: Transaction_hash.t]
202-
(Transaction_hash.User_command_with_valid_signature.hash data)
202+
(Transaction_hash.User_command_with_valid_signature.transaction_hash
203+
data )
203204
key )
204205
end
205206

@@ -327,7 +328,9 @@ let remove_all_by_fee_and_hash_and_expiration_exn :
327328
Transaction_hash.User_command_with_valid_signature.command cmd
328329
|> User_command.fee_per_wu
329330
in
330-
let cmd_hash = Transaction_hash.User_command_with_valid_signature.hash cmd in
331+
let cmd_hash =
332+
Transaction_hash.User_command_with_valid_signature.transaction_hash cmd
333+
in
331334
{ t with
332335
all_by_fee = Map_set.remove_exn t.all_by_fee fee_per_wu cmd
333336
; all_by_hash = Map.remove t.all_by_hash cmd_hash
@@ -412,7 +415,8 @@ module Update = struct
412415
else acc
413416
in
414417
let cmd_hash =
415-
Transaction_hash.User_command_with_valid_signature.hash cmd
418+
Transaction_hash.User_command_with_valid_signature.transaction_hash
419+
cmd
416420
in
417421
( match Transaction_hash.User_command_with_valid_signature.data cmd with
418422
| Zkapp_command p ->
@@ -515,8 +519,10 @@ let transactions ~logger t =
515519
in
516520
if
517521
Transaction_hash.equal
518-
(Transaction_hash.User_command_with_valid_signature.hash txn)
519-
(Transaction_hash.User_command_with_valid_signature.hash head_txn)
522+
(Transaction_hash.User_command_with_valid_signature
523+
.transaction_hash txn )
524+
(Transaction_hash.User_command_with_valid_signature
525+
.transaction_hash head_txn )
520526
then
521527
match F_sequence.uncons sender_queue' with
522528
| Some (next_txn, _) ->
@@ -1177,7 +1183,9 @@ let add_from_backtrack :
11771183
let%map () = check_expiry t.config unchecked in
11781184
let fee_payer = User_command.fee_payer unchecked in
11791185
let fee_per_wu = User_command.fee_per_wu unchecked in
1180-
let cmd_hash = Transaction_hash.User_command_with_valid_signature.hash cmd in
1186+
let cmd_hash =
1187+
Transaction_hash.User_command_with_valid_signature.transaction_hash cmd
1188+
in
11811189
let consumed = Option.value_exn (currency_consumed cmd) in
11821190
match Map.find t.all_by_sender fee_payer with
11831191
| None ->
@@ -1229,7 +1237,9 @@ let add_from_backtrack :
12291237
t'.all_by_fee fee_per_wu cmd
12301238
; all_by_hash =
12311239
Map.set t.all_by_hash
1232-
~key:(Transaction_hash.User_command_with_valid_signature.hash cmd)
1240+
~key:
1241+
(Transaction_hash.User_command_with_valid_signature
1242+
.transaction_hash cmd )
12331243
~data:cmd
12341244
; all_by_sender =
12351245
Map.set t'.all_by_sender ~key:fee_payer

src/lib/network_pool/test/indexed_pool_tests.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,8 @@ let commit_to_pool ledger pool cmd expected_drops =
494494
(Mina_ledger.Ledger.get ledger loc) )
495495
in
496496
let lower =
497-
List.map ~f:Transaction_hash.User_command_with_valid_signature.hash
497+
List.map
498+
~f:Transaction_hash.User_command_with_valid_signature.transaction_hash
498499
in
499500
[%test_eq: Transaction_hash.t list]
500501
(lower (Sequence.to_list dropped))
@@ -772,7 +773,8 @@ let apply_transactions txns accounts =
772773
in
773774
{ a with nonce; balance } ) )
774775

775-
let txn_hash = Transaction_hash.User_command_with_valid_signature.hash
776+
let txn_hash =
777+
Transaction_hash.User_command_with_valid_signature.transaction_hash
776778

777779
let application_invalidates_applied_transactions () =
778780
Quickcheck.test ~trials:1000

src/lib/network_pool/transaction_pool.ml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -681,14 +681,16 @@ struct
681681
let cmd_hash =
682682
With_status.data cmd
683683
|> Transaction_hash.User_command_with_valid_signature.create
684-
|> Transaction_hash.User_command_with_valid_signature.hash
684+
|> Transaction_hash.User_command_with_valid_signature
685+
.transaction_hash
685686
in
686687
Set.add set cmd_hash )
687688
in
688689
Sequence.to_list dropped_commands
689690
|> List.partition_tf ~f:(fun cmd ->
690691
Set.mem command_hashes
691-
(Transaction_hash.User_command_with_valid_signature.hash cmd) )
692+
(Transaction_hash.User_command_with_valid_signature
693+
.transaction_hash cmd ) )
692694
in
693695
List.iter committed_commands ~f:(fun cmd ->
694696
vk_table_lift_hashed vk_table_dec cmd ;
@@ -826,12 +828,10 @@ struct
826828
~time_controller ~slot_tx_end:config.Config.slot_tx_end
827829
; locally_generated_uncommitted =
828830
Hashtbl.create
829-
( module Transaction_hash.User_command_with_valid_signature.Stable
830-
.Latest )
831+
(module Transaction_hash.User_command_with_valid_signature)
831832
; locally_generated_committed =
832833
Hashtbl.create
833-
( module Transaction_hash.User_command_with_valid_signature.Stable
834-
.Latest )
834+
(module Transaction_hash.User_command_with_valid_signature)
835835
; current_batch = 0
836836
; remaining_in_batch = max_per_15_seconds
837837
; config
@@ -1376,12 +1376,16 @@ struct
13761376
in
13771377
let dropped_for_add_hashes =
13781378
List.map dropped_for_add
1379-
~f:Transaction_hash.User_command_with_valid_signature.hash
1379+
~f:
1380+
Transaction_hash.User_command_with_valid_signature
1381+
.transaction_hash
13801382
|> Transaction_hash.Set.of_list
13811383
in
13821384
let dropped_for_size_hashes =
13831385
List.map dropped_for_size
1384-
~f:Transaction_hash.User_command_with_valid_signature.hash
1386+
~f:
1387+
Transaction_hash.User_command_with_valid_signature
1388+
.transaction_hash
13851389
|> Transaction_hash.Set.of_list
13861390
in
13871391
let all_dropped_cmd_hashes =
@@ -1419,8 +1423,8 @@ struct
14191423
if
14201424
not
14211425
(Set.mem all_dropped_cmd_hashes
1422-
(Transaction_hash.User_command_with_valid_signature.hash
1423-
cmd ) )
1426+
(Transaction_hash.User_command_with_valid_signature
1427+
.transaction_hash cmd ) )
14241428
then register_locally_generated t cmd
14251429
| Error _ ->
14261430
() ) ;
@@ -1443,7 +1447,8 @@ struct
14431447
*)
14441448
if
14451449
Set.mem all_dropped_cmd_hashes
1446-
(Transaction_hash.User_command_with_valid_signature.hash cmd)
1450+
(Transaction_hash.User_command_with_valid_signature
1451+
.transaction_hash cmd )
14471452
then `Trd cmd
14481453
else `Fst cmd
14491454
| Error (cmd, error) ->
@@ -1577,7 +1582,8 @@ struct
15771582
->
15781583
let cmp = compare batch1 batch2 in
15791584
let get_hash =
1580-
Transaction_hash.User_command_with_valid_signature.hash
1585+
Transaction_hash.User_command_with_valid_signature
1586+
.transaction_hash
15811587
in
15821588
let get_nonce txn =
15831589
Transaction_hash.User_command_with_valid_signature.command txn

src/lib/transaction/transaction_hash.ml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -168,23 +168,8 @@ module User_command_with_valid_signature = struct
168168

169169
let hash_of_yojson = of_yojson
170170

171-
[%%versioned
172-
module Stable = struct
173-
module V2 = struct
174-
type t =
175-
( (User_command.Valid.Stable.V2.t[@hash.ignore])
176-
, (T.Stable.V1.t[@to_yojson hash_to_yojson]) )
177-
With_hash.Stable.V1.t
178-
[@@deriving sexp, hash, to_yojson]
179-
180-
let to_latest = Fn.id
181-
182-
(* Compare only on hashes, comparing on the data too would be slower and
183-
add no value.
184-
*)
185-
let compare (x : t) (y : t) = T.compare x.hash y.hash
186-
end
187-
end]
171+
type t = (User_command.Valid.t, hash) With_hash.t
172+
[@@deriving hash, sexp, compare, to_yojson]
188173

189174
let create (c : User_command.Valid.t) : t =
190175
{ data = c; hash = hash_command (User_command.forget_check c) }
@@ -193,12 +178,23 @@ module User_command_with_valid_signature = struct
193178

194179
let command ({ data; _ } : t) = User_command.forget_check data
195180

196-
let hash ({ hash; _ } : t) = hash
181+
let transaction_hash ({ hash; _ } : t) = hash
197182

198183
let forget_check ({ data; hash } : t) =
199184
{ With_hash.data = User_command.forget_check data; hash }
200185

201-
include Comparable.Make (Stable.Latest)
186+
include Comparable.Make (struct
187+
type nonrec t = t
188+
189+
let sexp_of_t = sexp_of_t
190+
191+
let t_of_sexp = t_of_sexp
192+
193+
(* Compare only on hashes, comparing on the data too would be slower and
194+
add no value.
195+
*)
196+
let compare (x : t) (y : t) = T.compare x.hash y.hash
197+
end)
202198

203199
let make data hash : t = { data; hash }
204200
end

src/lib/transaction/transaction_hash.mli

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,16 @@ include Comparable.S with type t := t
5151
module User_command_with_valid_signature : sig
5252
type hash = t [@@deriving sexp, compare, hash, yojson]
5353

54-
[%%versioned:
55-
module Stable : sig
56-
[@@@no_toplevel_latest_type]
57-
58-
module V2 : sig
59-
type t =
60-
private
61-
(User_command.Valid.Stable.V2.t, hash) With_hash.Stable.V1.t
62-
[@@deriving sexp, compare, hash, to_yojson]
63-
end
64-
end]
65-
66-
type t = Stable.Latest.t [@@deriving sexp, compare, to_yojson]
54+
type t = private (User_command.Valid.t, hash) With_hash.t
55+
[@@deriving hash, sexp, compare, to_yojson]
6756

6857
val create : User_command.Valid.t -> t
6958

7059
val data : t -> User_command.Valid.t
7160

7261
val command : t -> User_command.t
7362

74-
val hash : t -> hash
63+
val transaction_hash : t -> hash
7564

7665
val forget_check : t -> (User_command.t, hash) With_hash.t
7766

src/lib/verifier/prod.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,7 @@ module Worker = struct
319319
; verify_commands =
320320
f
321321
( [%bin_type_class:
322-
User_command.Verifiable.Stable.Latest.t
323-
With_status.Stable.Latest.t
322+
User_command.Verifiable.t With_status.Stable.Latest.t
324323
With_id_tag.t
325324
list]
326325
, [%bin_type_class:

0 commit comments

Comments
 (0)