diff --git a/src/lib/genesis_ledger_helper/genesis_ledger_helper.ml b/src/lib/genesis_ledger_helper/genesis_ledger_helper.ml index f9cadb3e8c8..6111e0ebe18 100644 --- a/src/lib/genesis_ledger_helper/genesis_ledger_helper.ml +++ b/src/lib/genesis_ledger_helper/genesis_ledger_helper.ml @@ -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 diff --git a/src/lib/mina_base/account.ml b/src/lib/mina_base/account.ml index 7f7cece5802..51b46d25629 100644 --- a/src/lib/mina_base/account.ml +++ b/src/lib/mina_base/account.ml @@ -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 diff --git a/src/lib/mina_base/zkapp_account.ml b/src/lib/mina_base/zkapp_account.ml index 395aa049ba3..a53d1ce8f37 100644 --- a/src/lib/mina_base/zkapp_account.ml +++ b/src/lib/mina_base/zkapp_account.ml @@ -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)) diff --git a/src/lib/mina_base/zkapp_basic.ml b/src/lib/mina_base/zkapp_basic.ml index 1b14b041006..37d96cfb5a2 100644 --- a/src/lib/mina_base/zkapp_basic.ml +++ b/src/lib/mina_base/zkapp_basic.ml @@ -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 diff --git a/src/lib/mina_ledger/ledger.ml b/src/lib/mina_ledger/ledger.ml index 7e00c45d6c8..a84fcde5d27 100644 --- a/src/lib/mina_ledger/ledger.ml +++ b/src/lib/mina_ledger/ledger.ml @@ -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 diff --git a/src/lib/mina_ledger/sync_ledger.ml b/src/lib/mina_ledger/sync_ledger.ml index 7a2360dc91d..a0c1b125dda 100644 --- a/src/lib/mina_ledger/sync_ledger.ml +++ b/src/lib/mina_ledger/sync_ledger.ml @@ -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 diff --git a/src/lib/transaction_consistency_tests/transaction_consistency_tests.ml b/src/lib/transaction_consistency_tests/transaction_consistency_tests.ml index 813fd12487f..aa2af6d6224 100644 --- a/src/lib/transaction_consistency_tests/transaction_consistency_tests.ml +++ b/src/lib/transaction_consistency_tests/transaction_consistency_tests.ml @@ -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" =