Skip to content

Commit

Permalink
don't compute dummy vk hash at the top level
Browse files Browse the repository at this point in the history
  • Loading branch information
mitschabaude committed Aug 16, 2023
1 parent 8ee87dc commit d232a0d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/lib/genesis_ledger_helper/genesis_ledger_helper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ module Ledger = struct
; List.to_string balances ~f:(fun (i, balance) ->
sprintf "%i %s" i (Currency.Balance.to_string balance) )
; (* Distinguish ledgers when the hash function is different. *)
Snark_params.Tick.Field.to_string Mina_base.Account.empty_digest
Snark_params.Tick.Field.to_string
(Lazy.force Mina_base.Account.empty_digest)
; (* Distinguish ledgers when the account record layout has changed. *)
Bin_prot.Writer.to_string Mina_base.Account.Stable.Latest.bin_writer_t
Mina_base.Account.empty
Expand Down
2 changes: 1 addition & 1 deletion src/lib/mina_base/account.ml
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ let empty =
; zkapp = None
}

let empty_digest = digest empty
let empty_digest = lazy (digest empty)

let create account_id balance =
let public_key = Account_id.public_key account_id in
Expand Down
4 changes: 2 additions & 2 deletions src/lib/mina_base/zkapp_account.ml
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ let typ : (Checked.t, t) Typ.t =
let open Poly in
Typ.of_hlistable
[ Zkapp_state.typ Field.typ
; Flagged_option.option_typ
~default:{ With_hash.data = None; hash = dummy_vk_hash () }
; Flagged_option.lazy_option_typ
~default:(lazy { With_hash.data = None; hash = dummy_vk_hash () })
(Data_as_hash.typ ~hash:With_hash.hash)
|> Typ.transport
~there:(Option.map ~f:(With_hash.map ~f:Option.some))
Expand Down
5 changes: 5 additions & 0 deletions src/lib/mina_base/zkapp_basic.ml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ module Flagged_option = struct
let option_typ ~default t =
Typ.transport (typ t) ~there:(of_option ~default) ~back:to_option

let lazy_option_typ ~default t =
Typ.transport (typ t)
~there:(fun t -> of_option t ~default:(Lazy.force default))
~back:to_option

[%%endif]
end

Expand Down
3 changes: 2 additions & 1 deletion src/lib/mina_ledger/ledger.ml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ module Ledger_inner = struct

let hash_account = Fn.compose Ledger_hash.of_digest Account.digest

let empty_account = Ledger_hash.of_digest Account.empty_digest
let empty_account =
Ledger_hash.of_digest (Lazy.force Account.empty_digest)
end
end]
end
Expand Down
2 changes: 1 addition & 1 deletion src/lib/mina_ledger/sync_ledger.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Hash = struct

let hash_account = Fn.compose Ledger_hash.of_digest Account.digest

let empty_account = Ledger_hash.of_digest Account.empty_digest
let empty_account = Ledger_hash.of_digest (Lazy.force Account.empty_digest)
end

module Root_hash = struct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Hash = struct

let hash_account = Fn.compose Ledger_hash.of_digest Account.digest

let empty_account = Ledger_hash.of_digest Account.empty_digest
let empty_account = Ledger_hash.of_digest (Lazy.force Account.empty_digest)
end

let%test_module "transaction logic consistency" =
Expand Down

0 comments on commit d232a0d

Please sign in to comment.