Skip to content

Commit 44a4039

Browse files
authored
Merge pull request #17793 from MinaProtocol/cjjdespres/use-hard-fork-account
Use Hardfork account type in Root ledger
2 parents 77db665 + a12f498 commit 44a4039

File tree

4 files changed

+27
-30
lines changed

4 files changed

+27
-30
lines changed

src/lib/mina_ledger/ledger.ml

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -283,21 +283,21 @@ module Ledger_inner = struct
283283
and type token_id_set := Token_id.Set.t
284284
and type account_id := Account_id.t
285285
and type account_id_set := Account_id.Set.t
286-
and type converted_account := Account.Unstable.t
286+
and type converted_account := Account.Hardfork.t
287287
and type primary_ledger = Db.t
288-
and type converting_ledger = Unstable_db.t =
288+
and type converting_ledger = Hardfork_db.t =
289289
Converting_merkle_tree.With_database
290290
(struct
291-
type converted_account = Account.Unstable.t
291+
type converted_account = Account.Hardfork.t
292292

293-
let convert = Account.Unstable.of_stable
293+
let convert = Account.Hardfork.of_stable
294294

295-
let converted_equal = Account.Unstable.equal
295+
let converted_equal = Account.Hardfork.equal
296296

297297
include Inputs
298298
end)
299299
(Db)
300-
(Unstable_db)
300+
(Hardfork_db)
301301

302302
let of_any_ledger ledger =
303303
let mask = Mask.create ~depth:(Any_ledger.M.depth ledger) () in
@@ -334,7 +334,7 @@ module Ledger_inner = struct
334334
, Converting_ledger.converting_ledger converting_ledger )
335335

336336
module Root = struct
337-
include Root.Make (Any_ledger) (Db) (Unstable_db) (Converting_ledger)
337+
include Root.Make (Any_ledger) (Db) (Hardfork_db) (Converting_ledger)
338338

339339
let as_masked t = as_unmasked t |> of_any_ledger
340340
end
@@ -909,7 +909,7 @@ let%test_unit "user_command application on converting ledger" =
909909
L.with_converting_ledger_exn ~logger ~depth ~f:(fun (l, cl) ->
910910
Init_ledger.init (module L) init_ledger l ;
911911
let init_merkle_root = L.merkle_root l in
912-
let init_cl_merkle_root = Unstable_db.merkle_root cl in
912+
let init_cl_merkle_root = Hardfork_db.merkle_root cl in
913913
let () =
914914
iter_err cmds
915915
~f:
@@ -923,18 +923,15 @@ let%test_unit "user_command application on converting ledger" =
923923
assert (
924924
not
925925
(Ledger_hash.equal init_cl_merkle_root
926-
(Unstable_db.merkle_root cl) ) ) ;
927-
(* Assert that the converted ledger has the same accounts as the first one, up to the new field*)
926+
(Hardfork_db.merkle_root cl) ) ) ;
927+
(* Assert that the converted ledger has the same accounts as the first one, up to conversion *)
928928
L.iteri l ~f:(fun index account ->
929-
let account_converted = Unstable_db.get_at_index_exn cl index in
929+
let account_converted = Hardfork_db.get_at_index_exn cl index in
930930
assert (
931-
Mina_base.Account.Key.(
932-
equal account.public_key account_converted.public_key) ) ;
933-
assert (
934-
Mina_base.Account.Nonce.(
935-
equal account_converted.nonce account_converted.unstable_field) ) ) ;
931+
Mina_base.Account.Hardfork.(
932+
equal (of_stable account) account_converted) ) ) ;
936933
(* Assert that the converted ledger doesn't have anything "extra" compared to the primary ledger *)
937-
Unstable_db.iteri cl ~f:(fun index account_converted ->
934+
Hardfork_db.iteri cl ~f:(fun index account_converted ->
938935
let account = L.get_at_index_exn l index in
939936
assert (
940937
Mina_base.Account.Key.(

src/lib/mina_ledger/ledger.mli

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ module Converting_ledger :
9797
and type token_id_set := Token_id.Set.t
9898
and type account_id := Account_id.t
9999
and type account_id_set := Account_id.Set.t
100-
and type converted_account := Account.Unstable.t
100+
and type converted_account := Account.Hardfork.t
101101
and type primary_ledger = Db.t
102-
and type converting_ledger = Unstable_db.t
102+
and type converting_ledger = Hardfork_db.t
103103

104104
module Root : sig
105105
include module type of
106-
Root.Make (Any_ledger) (Db) (Unstable_db) (Converting_ledger)
106+
Root.Make (Any_ledger) (Db) (Hardfork_db) (Converting_ledger)
107107

108108
val as_masked : t -> Mask.Attached.t
109109
end

src/lib/mina_ledger/root.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ module type Stable_db_intf =
1212
and type hash := Ledger_hash.t
1313
and type root_hash := Ledger_hash.t
1414

15-
module type Unstable_db_intf =
15+
module type Migrated_db_intf =
1616
Merkle_ledger.Intf.Ledger.DATABASE
17-
with type account := Account.Unstable.t
17+
with type account := Account.Hardfork.t
1818
and type key := Signature_lib.Public_key.Compressed.t
1919
and type token_id := Token_id.t
2020
and type token_id_set := Token_id.Set.t
@@ -43,21 +43,21 @@ module type Converting_ledger_intf =
4343
and type token_id_set := Token_id.Set.t
4444
and type account_id := Account_id.t
4545
and type account_id_set := Account_id.Set.t
46-
and type converted_account := Account.Unstable.t
46+
and type converted_account := Account.Hardfork.t
4747

4848
module Make
4949
(Any_ledger : Any_ledger_intf)
5050
(Stable_db : Stable_db_intf
5151
with module Location = Any_ledger.M.Location
5252
and module Addr = Any_ledger.M.Addr)
53-
(Unstable_db : Unstable_db_intf
53+
(Migrated_db : Migrated_db_intf
5454
with module Location = Any_ledger.M.Location
5555
and module Addr = Any_ledger.M.Addr)
5656
(Converting_ledger : Converting_ledger_intf
5757
with module Location = Any_ledger.M.Location
5858
and module Addr = Any_ledger.M.Addr
5959
with type primary_ledger = Stable_db.t
60-
and type converting_ledger = Unstable_db.t) =
60+
and type converting_ledger = Migrated_db.t) =
6161
struct
6262
module Config = struct
6363
type backing_type = Stable_db | Converting_db [@@deriving equal, yojson]

src/lib/mina_ledger/root.mli

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ module type Stable_db_intf =
1111
and type hash := Ledger_hash.t
1212
and type root_hash := Ledger_hash.t
1313

14-
module type Unstable_db_intf =
14+
module type Migrated_db_intf =
1515
Merkle_ledger.Intf.Ledger.DATABASE
16-
with type account := Account.Unstable.t
16+
with type account := Account.Hardfork.t
1717
and type key := Signature_lib.Public_key.Compressed.t
1818
and type token_id := Token_id.t
1919
and type token_id_set := Token_id.Set.t
@@ -42,7 +42,7 @@ module type Converting_ledger_intf =
4242
and type token_id_set := Token_id.Set.t
4343
and type account_id := Account_id.t
4444
and type account_id_set := Account_id.Set.t
45-
and type converted_account := Account.Unstable.t
45+
and type converted_account := Account.Hardfork.t
4646

4747
(** Make a root ledger. A root ledger is a database-backed, unmasked ledger used
4848
at the root of a mina ledger mask tree. Currently only a single stable
@@ -55,14 +55,14 @@ module Make
5555
(Stable_db : Stable_db_intf
5656
with module Location = Any_ledger.M.Location
5757
and module Addr = Any_ledger.M.Addr)
58-
(Unstable_db : Unstable_db_intf
58+
(Migrated_db : Migrated_db_intf
5959
with module Location = Any_ledger.M.Location
6060
and module Addr = Any_ledger.M.Addr)
6161
(Converting_ledger : Converting_ledger_intf
6262
with module Location = Any_ledger.M.Location
6363
and module Addr = Any_ledger.M.Addr
6464
with type primary_ledger = Stable_db.t
65-
and type converting_ledger = Unstable_db.t) : sig
65+
and type converting_ledger = Migrated_db.t) : sig
6666
type t
6767

6868
type root_hash = Ledger_hash.t

0 commit comments

Comments
 (0)