Skip to content

Commit ebecbcb

Browse files
Merge branch 'berkeley' into alert/catchup-and-bootstrap-got-stuck
2 parents a64807a + 2bbce00 commit ebecbcb

File tree

17 files changed

+197
-80
lines changed

17 files changed

+197
-80
lines changed

src/lib/mina_lib/mina_lib.ml

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,13 @@ let create_sync_status_observer ~logger ~is_seed ~demo_mode ~net
462462
let open Mina_incremental.Status in
463463
let restart_delay = Time.Span.of_min 5. in
464464
let offline_shutdown_delay = Time.Span.of_min 25. in
465+
let after_genesis =
466+
let genesis_timestamp =
467+
Genesis_constants.(
468+
genesis_timestamp_of_string genesis_state_timestamp_string)
469+
in
470+
fun () -> Time.(( >= ) (now ())) genesis_timestamp
471+
in
465472
let incremental_status =
466473
map4 online_status_incr transition_frontier_and_catchup_signal_incr
467474
first_connection_incr first_message_incr
@@ -471,29 +478,31 @@ let create_sync_status_observer ~logger ~is_seed ~demo_mode ~net
471478
else
472479
match online_status with
473480
| `Offline ->
474-
( match !next_helper_restart with
475-
| None ->
476-
next_helper_restart :=
477-
Some
478-
(Async.Clock.Event.run_after restart_delay
479-
(fun () ->
480-
[%log info]
481-
"Offline for too long; restarting libp2p_helper" ;
482-
Mina_networking.restart_helper net ;
483-
next_helper_restart := None ;
484-
match !offline_shutdown with
485-
| None ->
486-
offline_shutdown :=
487-
Some
488-
(Async.Clock.Event.run_after
489-
offline_shutdown_delay
490-
(fun () -> raise Offline_shutdown)
491-
() )
492-
| Some _ ->
493-
() )
494-
() )
495-
| Some _ ->
496-
() ) ;
481+
(* nothing to do if offline before genesis *)
482+
( if after_genesis () then
483+
match !next_helper_restart with
484+
| None ->
485+
next_helper_restart :=
486+
Some
487+
(Async.Clock.Event.run_after restart_delay
488+
(fun () ->
489+
[%log info]
490+
"Offline for too long; restarting libp2p_helper" ;
491+
Mina_networking.restart_helper net ;
492+
next_helper_restart := None ;
493+
match !offline_shutdown with
494+
| None ->
495+
offline_shutdown :=
496+
Some
497+
(Async.Clock.Event.run_after
498+
offline_shutdown_delay
499+
(fun () -> raise Offline_shutdown)
500+
() )
501+
| Some _ ->
502+
() )
503+
() )
504+
| Some _ ->
505+
() ) ;
497506
let is_empty = function `Empty -> true | _ -> false in
498507
if is_empty first_connection then (
499508
[%str_log info] Connecting ;
@@ -572,10 +581,12 @@ let create_sync_status_observer ~logger ~is_seed ~demo_mode ~net
572581
| Some _ ->
573582
()
574583
| None ->
575-
bootstrap_timeout :=
576-
Some
577-
(Timeout.create () bootstrap_timeout_duration
578-
~f:log_bootstrap_error_and_restart )
584+
(* don't check bootstrap timeout before genesis *)
585+
if after_genesis () then
586+
bootstrap_timeout :=
587+
Some
588+
(Timeout.create () bootstrap_timeout_duration
589+
~f:log_bootstrap_error_and_restart )
579590
in
580591
let stop_bootstrap_timeout () =
581592
match !bootstrap_timeout with
@@ -585,7 +596,7 @@ let create_sync_status_observer ~logger ~is_seed ~demo_mode ~net
585596
| None ->
586597
()
587598
in
588-
let handle_status_change sync_status =
599+
let handle_status_change (sync_status : Sync_status.t) =
589600
( match sync_status with
590601
| `Offline ->
591602
start_offline_timeout ()

src/lib/sync_status/sync_status.ml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
open Core_kernel
22

3-
(** Sync_status represent states interacting with peers in the coda protocol.
3+
(** Sync_status represent states interacting with peers in the Mina protocol.
44
When the protocol is starting, the node should be in the CONNECT state
55
trying to connect to a peer. Once it connects to a peer, the node should be
66
in the LISTENING state waiting for peers to send a message to them. When
77
the node receives a constant flow of messages, its state should be SYNCED.
88
However, when the node is bootstrapping, its state is BOOTSTRAPPING. If it
9-
hasn’t received messages for some time
10-
(Mina_compile_config.inactivity_secs), then it is OFFLINE. *)
9+
hasn’t received messages for some time (see [Mina_lib.offline_time]), then
10+
it is OFFLINE.
11+
*)
1112
let to_string = function
1213
| `Connecting ->
1314
"Connecting"

src/lib/transaction_snark/test/fee_payer/dune

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
yojson
1313
sexplib0
1414
integers
15+
ppx_deriving_yojson.runtime
16+
result
1517
;; local libraries
1618
mina_base.import
1719
pickles
@@ -35,7 +37,7 @@
3537
transaction_snark_tests
3638
)
3739
(library_flags -linkall)
38-
(inline_tests (flags -verbose -show-counts))
40+
(inline_tests (flags -verbose -show-counts) (deps proof_cache.json))
3941
(preprocess
4042
(pps ppx_snarky ppx_version ppx_jane))
4143
(instrumentation (backend bisect_ppx)))

src/lib/transaction_snark/test/fee_payer/fee_payer.ml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ open Mina_transaction
99

1010
let%test_module "Fee payer tests" =
1111
( module struct
12+
let proof_cache =
13+
Result.ok_or_failwith @@ Pickles.Proof_cache.of_yojson
14+
@@ Yojson.Safe.from_file "proof_cache.json"
15+
16+
let () = Transaction_snark.For_tests.set_proof_cache proof_cache
17+
1218
let `VK vk, `Prover zkapp_prover = Lazy.force U.trivial_zkapp
1319

1420
let memo = Signed_command_memo.create_from_string_exn "Fee payer tests"
@@ -316,4 +322,11 @@ let%test_module "Fee payer tests" =
316322
List.is_empty
317323
(Zkapp_command.account_updates_list zkapp_command) ) ;
318324
U.check_zkapp_command_with_merges_exn ledger [ zkapp_command ] ) ) )
325+
326+
let () =
327+
match Sys.getenv "PROOF_CACHE_OUT" with
328+
| Some path ->
329+
Yojson.Safe.to_file path @@ Pickles.Proof_cache.to_yojson proof_cache
330+
| None ->
331+
()
319332
end )

src/lib/transaction_snark/test/fee_payer/proof_cache.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)