Skip to content

Commit f6c72b3

Browse files
authored
Merge pull request #14381 from MinaProtocol/merge-back-to-develop-2023-10-18
Merge back to develop
2 parents 962234d + 6ad0b78 commit f6c72b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+532
-128
lines changed

automation/terraform/modules/testnet-alerts/templates/testnet-alert-rules.yml.tpl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,24 @@ groups:
255255
description: "{{ $value }} blocks have been validated on network {{ $labels.testnet }} in the last hour (according to some node)."
256256
runbook: "https://www.notion.so/minaprotocol/FewBlocksPerHour-47a6356f093242d988b0d9527ce23478"
257257

258+
- alert: StuckInBootstrap
259+
expr: count by (testnet) (increase(Coda_Runtime_process_uptime_ms_total{syncStatus = "BOOTSTRAP"}[2h]) >= 7200000) > 0
260+
for: ${alert_evaluation_duration}
261+
labels:
262+
testnet: "{{ $labels.testnet }}"
263+
severity: critical
264+
annotations:
265+
summary: "One or more {{ $labels.testnet }} nodes are stuck at bootstrap for more than 2 hours"
266+
267+
- alert: StuckInCatchup
268+
expr: count by (testnet) (increase(Coda_Runtime_process_uptime_ms_total{syncStatus = "CATCHUP"}[2h]) >= 7200000) > 0
269+
for: ${alert_evaluation_duration}
270+
labels:
271+
testnet: "{{ $labels.testnet }}"
272+
severity: critical
273+
annotations:
274+
summary: "One or more {{ $labels.testnet }} nodes are stuck at catchup for more than 2 hours"
275+
258276

259277
- name: Warnings
260278
rules:

buildkite/scripts/rosetta-integration-tests.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ ROSETTA_CLI_CONFIG_FILES=${ROSETTA_CLI_CONFIG_FILES:="config.json mina.ros"}
9393
ROSETTA_CLI_MAIN_CONFIG_FILE=${ROSETTA_CLI_MAIN_CONFIG_FILE:="config.json"}
9494

9595
# Frequency (in seconds) at which payment operations will be sent
96-
TRANSACTION_FREQUENCY=60
96+
TRANSACTION_FREQUENCY=10
9797

9898
# Fetch zkApps
9999
curl -Ls https://github.com/MinaProtocol/rosetta-integration-test-zkapps/tarball/$ROSETTA_INT_TEST_ZKAPPS_VERSION | tar xz -C /tmp
@@ -122,8 +122,8 @@ cat <<EOF >"$MINA_CONFIG_FILE"
122122
"ledger": {
123123
"name": "${MINA_NETWORK}",
124124
"accounts": [
125-
{ "pk": "${BLOCK_PRODUCER_PK}", "balance": "1000", "delegate": null, "sk": null },
126-
{ "pk": "${SNARK_PRODUCER_PK}", "balance": "2000", "delegate": "${BLOCK_PRODUCER_PK}", "sk": null }
125+
{ "pk": "${BLOCK_PRODUCER_PK}", "balance": "1000000", "delegate": null, "sk": null },
126+
{ "pk": "${SNARK_PRODUCER_PK}", "balance": "2000000", "delegate": "${BLOCK_PRODUCER_PK}", "sk": null }
127127
]
128128
}
129129
}

buildkite/scripts/run-snark-transaction-profiler.sh

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@ export DEBIAN_FRONTEND=noninteractive
88
apt-get update
99
apt-get install -y git apt-transport-https ca-certificates tzdata curl python3
1010

11-
case "$BUILDKITE_PULL_REQUEST_BASE_BRANCH" in
12-
rampup|berkeley|release/2.0.0|develop)
13-
TESTNET_NAME="berkeley"
14-
;;
15-
*)
16-
TESTNET_NAME="mainnet"
17-
esac
11+
TESTNET_NAME="berkeley"
1812

1913
git config --global --add safe.directory /workdir
2014

@@ -30,4 +24,4 @@ MAX_NUM_UPDATES=4
3024
MIN_NUM_UPDATES=2
3125

3226
echo "--- Run Snark Transaction Profiler with parameters: --zkapps --k ${K} --max-num-updates ${MAX_NUM_UPDATES} --min-num-updates ${MIN_NUM_UPDATES}"
33-
python3 ./scripts/snark_transaction_profiler.py ${K} ${MAX_NUM_UPDATES} ${MIN_NUM_UPDATES}
27+
python3 ./scripts/snark_transaction_profiler.py ${K} ${MAX_NUM_UPDATES} ${MIN_NUM_UPDATES}

buildkite/src/Constants/DebianVersions.dhall

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ let minimalDirtyWhen = [
6666
S.strictlyStart (S.contains "dockerfiles/stages"),
6767
S.exactly "scripts/rebuild-deb" "sh",
6868
S.exactly "scripts/release-docker" "sh",
69-
S.exactly "buildkite/scripts/build-artifact" "sh"
69+
S.exactly "buildkite/scripts/build-artifact" "sh",
70+
-- Snark profiler dirtyWhen
71+
S.exactly "buildkite/src/Jobs/Test/RunSnarkProfiler" "dhall",
72+
S.exactly "buildkite/scripts/run-snark-transaction-profiler" "sh",
73+
S.exactly "scripts/snark_transaction_profiler" "py"
7074
]
7175

7276
-- The default debian version (Bullseye) is used in all downstream CI jobs

buildkite/src/Jobs/Test/FuzzyZkappTest.dhall

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ Pipeline.build
5151
mode = PipelineMode.Type.Stable
5252
},
5353
steps = [
54-
buildTestCmd "dev" "src/lib/transaction_snark/test/zkapp_fuzzy/zkapp_fuzzy.exe" 3600 150 Size.Small
54+
buildTestCmd "dev" "src/lib/transaction_snark/test/zkapp_fuzzy/zkapp_fuzzy.exe" 4200 150 Size.Small
5555
]
5656
}

scripts/version-linter.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22

33
# version-linter.py -- makes sure serializations of versioned types don't change
44

5+
"""
6+
For the PR branch, PR base branch, and release branch, download the
7+
type shapes file from Google storage There should be a type shape file
8+
available for every commit in a PR branch.
9+
10+
For each branch, store the type shape information in a Python dictionary, truncating
11+
the shapes at a maximum depth.
12+
13+
For each type, compare the type shapes of each branch. If the shapes don't match, print an
14+
error message. The exact comparison rules are given in RFC 0047 (with some embellishments
15+
mentioned below).
16+
17+
The maximum depth should be set high enough so that all differences are caught
18+
(no false negatives).
19+
20+
There may be some false positives, where a difference is reported for
21+
type t1 due to a change to a type t2 contained in t1. The
22+
difference will always also be reported for t2 directly. The maximum
23+
depth should be set low enough to minimize such false positives.
24+
25+
There are some special rules for the types associated with signed commands and zkApp commands.
26+
See `check_command_types` below.
27+
"""
28+
529
import subprocess
630
import os
731
import io

src/app/archive/create_schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ CREATE TABLE protocol_versions
135135
, transaction int NOT NULL
136136
, network int NOT NULL
137137
, patch int NOT NULL
138-
, UNIQUE (transaction,network)
138+
, UNIQUE (transaction,network,patch)
139139
);
140140

141141
CREATE TYPE chain_status_type AS ENUM ('canonical', 'orphaned', 'pending');

src/app/archive/lib/load_data.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
(* load_data.ml -- load archive db data to "native" OCaml data *)
22

3+
(* these functions are used by the replayer and `extract_blocks` to load particular pieces
4+
of archive db data
5+
*)
6+
37
open Core_kernel
48
open Async
59
open Mina_base

src/app/archive/lib/processor.ml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
(* processor.ml -- database processing for archive node *)
22

3+
(* For each table in the archive database schema, a
4+
corresponding module contains code to read from and write to
5+
that table. The module defines a type `t`, a record with fields
6+
corresponding to columns in the table; typically, the `id` column
7+
that does not have an associated field.
8+
9+
The more recently written modules use the Mina_caqti library to
10+
construct the SQL for those queries. For consistency and
11+
simplicity, the older modules should probably be refactored to use
12+
Mina_caqti.
13+
14+
Module `Account_identifiers` is a good example of how Mina_caqti
15+
can be used.
16+
17+
After these table-related modules, there are functions related to
18+
running the archive process and archive-related apps.
19+
*)
20+
321
module Archive_rpc = Rpc
422
open Async
523
open Core
@@ -51,6 +69,7 @@ module Public_key = struct
5169
public_key
5270
end
5371

72+
(* Unlike other modules here, `Token_owners` does not correspond with a database table *)
5473
module Token_owners = struct
5574
(* hash table of token owners, updated for each block *)
5675
let owner_tbl : Account_id.t Token_id.Table.t = Token_id.Table.create ()
@@ -3755,6 +3774,7 @@ let add_block_aux ?(retries = 3) ~logger ~pool ~add_block ~hash
37553774
in
37563775
retry ~f:add ~logger ~error_str:"add_block_aux" retries
37573776

3777+
(* used by `archive_blocks` app *)
37583778
let add_block_aux_precomputed ~constraint_constants ~logger ?retries ~pool
37593779
~delete_older_than block =
37603780
add_block_aux ~logger ?retries ~pool ~delete_older_than
@@ -3765,6 +3785,7 @@ let add_block_aux_precomputed ~constraint_constants ~logger ?retries ~pool
37653785
~accounts_created:block.Precomputed.accounts_created
37663786
~tokens_used:block.Precomputed.tokens_used block
37673787

3788+
(* used by `archive_blocks` app *)
37683789
let add_block_aux_extensional ~logger ?retries ~pool ~delete_older_than block =
37693790
add_block_aux ~logger ?retries ~pool ~delete_older_than
37703791
~add_block:Block.add_from_extensional
@@ -3773,6 +3794,7 @@ let add_block_aux_extensional ~logger ?retries ~pool ~delete_older_than block =
37733794
~accounts_created:block.Extensional.Block.accounts_created
37743795
~tokens_used:block.Extensional.Block.tokens_used block
37753796

3797+
(* receive blocks from a daemon, write them to the database *)
37763798
let run pool reader ~constraint_constants ~logger ~delete_older_than :
37773799
unit Deferred.t =
37783800
Strict_pipe.Reader.iter reader ~f:(function
@@ -3799,6 +3821,7 @@ let run pool reader ~constraint_constants ~logger ~delete_older_than :
37993821
| Transition_frontier _ ->
38003822
Deferred.unit )
38013823

3824+
(* [add_genesis_accounts] is called when starting the archive process *)
38023825
let add_genesis_accounts ~logger ~(runtime_config_opt : Runtime_config.t option)
38033826
pool =
38043827
match runtime_config_opt with
@@ -3976,6 +3999,7 @@ let create_metrics_server ~logger ~metrics_server_port ~missing_blocks_width
39763999
in
39774000
go ()
39784001

4002+
(* for running the archive process *)
39794003
let setup_server ~metrics_server_port ~constraint_constants ~logger
39804004
~postgres_address ~server_port ~delete_older_than ~runtime_config_opt
39814005
~missing_blocks_width =

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/pickles/proof_cache.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,10 @@ let set_wrap_proof t ~keypair ~public_input proof =
250250
in
251251
let proof_json = Backend.Tock.Proof.to_yojson proof in
252252
set_proof t ~verification_key ~public_input proof_json
253+
254+
let is_env_var_set_requesting_error_for_proofs () =
255+
match Sys.getenv_opt "ERROR_ON_PROOF" with
256+
| Some ("true" | "t" (* insert whatever value is okay here *)) ->
257+
true
258+
| None | Some _ ->
259+
false

src/lib/pickles/proof_cache.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,5 @@ val set_wrap_proof :
5252
-> public_input:Kimchi_bindings.FieldVectors.Fq.t
5353
-> Backend.Tock.Proof.t
5454
-> unit
55+
56+
val is_env_var_set_requesting_error_for_proofs : unit -> bool

src/lib/pickles/step.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,10 @@ struct
827827
~public_input:public_inputs
828828
with
829829
| None ->
830+
if
831+
Proof_cache
832+
.is_env_var_set_requesting_error_for_proofs ()
833+
then failwith "Regenerated proof" ;
830834
let%map.Promise proof = create_proof () in
831835
Proof_cache.set_step_proof proof_cache ~keypair:pk
832836
~public_input:public_inputs proof.proof ;

src/lib/pickles/wrap.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,10 @@ let wrap
876876
~public_input:public_inputs
877877
with
878878
| None ->
879+
if
880+
Proof_cache.is_env_var_set_requesting_error_for_proofs
881+
()
882+
then failwith "Regenerated proof" ;
879883
let%map.Promise proof = create_proof () in
880884
Proof_cache.set_wrap_proof proof_cache ~keypair:pk
881885
~public_input:public_inputs proof.proof ;

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"

0 commit comments

Comments
 (0)