Skip to content

Commit d1ae172

Browse files
authored
Merge pull request #17912 from MinaProtocol/cjjdespres/root-backing-detection-fix
Fix epoch snapshot loading when first booting with ledger sync enabled
2 parents 8de4e2c + 5d193b9 commit d1ae172

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

src/lib/consensus/proof_of_stake.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ module Make_str (A : Wire_types.Concrete) = struct
461461
let create_epoch_ledger ~config ~context:(module Context : CONTEXT)
462462
~genesis_epoch_ledger =
463463
let open Context in
464-
if Mina_ledger.Ledger.Root.Config.exists_backing config then (
464+
if Mina_ledger.Ledger.Root.Config.exists_any_backing config then (
465465
[%log info]
466466
~metadata:
467467
[ ("config", Mina_ledger.Ledger.Root.Config.to_yojson config) ]

src/lib/mina_ledger/root.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ struct
8686
| Converting_db_config { primary_directory; converting_directory } ->
8787
file_exists primary_directory && file_exists converting_directory
8888

89+
let exists_any_backing = function
90+
| Stable_db_config path ->
91+
file_exists path
92+
| Converting_db_config { primary_directory; converting_directory = _ } ->
93+
file_exists primary_directory
94+
8995
let with_directory ~backing_type ~directory_name =
9096
match backing_type with
9197
| Stable_db ->

src/lib/mina_ledger/root.mli

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ module Make
9090
(** Test if a root ledger backing already exists with this config *)
9191
val exists_backing : t -> bool
9292

93+
(** Test if a root ledger backing already exists with this config, ignoring
94+
the specific backing type of the root *)
95+
val exists_any_backing : t -> bool
96+
9397
(** Delete a backing of any type that might exist with this config, if
9498
present. this function will try any backing type even if it didn't match
9599
up with one provided in the config *)

src/lib/mina_ledger/test/test_mina_ledger.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ module Root_test = struct
115115
in
116116
L.Root.Config.move_backing_exn ~src:config ~dst:config_moved ;
117117
assert (
118-
(not (L.Root.Config.exists_backing config))
118+
(not (L.Root.Config.exists_any_backing config))
119119
&& L.Root.Config.exists_backing config_moved
120120
|| failwith "Config is not moved" ) ;
121121
let root_moved =

0 commit comments

Comments
 (0)