Skip to content

Commit c14616d

Browse files
committed
move sync ledger constants back to compile time
1 parent a27d3cc commit c14616d

File tree

31 files changed

+105
-66
lines changed

31 files changed

+105
-66
lines changed

src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ let setup_daemon logger ~itn_features =
10061006
let module Context = struct
10071007
let logger = logger
10081008

1009-
let genesis_constants = precomputed_values.genesis_constants
1009+
let compile_config = precomputed_values.compile_config
10101010

10111011
let constraint_constants = precomputed_values.constraint_constants
10121012

src/config/dev.mlh

+4
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,7 @@
8383
[%%undef compaction_interval]
8484
[%%define vrf_poll_interval 0]
8585
[%%undef zkapp_cmd_limit]
86+
87+
(* Sync ledger query/response size*)
88+
[%%define sync_ledger_max_subtree_depth 4]
89+
[%%define sync_ledger_default_subtree_depth 3]

src/config/devnet.mlh

+4
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,7 @@
7878
[%%define vrf_poll_interval 5000]
7979
[%%define zkapp_cmd_limit 24]
8080
[%%undef scan_state_transaction_capacity_log_2]
81+
82+
(* Constants determining sync ledger query/response size*)
83+
[%%define sync_ledger_max_subtree_depth 8]
84+
[%%define sync_ledger_default_subtree_depth 6]

src/config/lightnet.mlh

+4
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@
7777
[%%define compaction_interval 360000]
7878
[%%define vrf_poll_interval 5000]
7979
[%%undef zkapp_cmd_limit]
80+
81+
(* Constants determining sync ledger query/response size*)
82+
[%%define sync_ledger_max_subtree_depth 8]
83+
[%%define sync_ledger_default_subtree_depth 6]

src/config/mainnet.mlh

+4
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,7 @@
7878
[%%define vrf_poll_interval 5000]
7979
[%%define zkapp_cmd_limit 24]
8080
[%%undef scan_state_transaction_capacity_log_2]
81+
82+
(* Constants determining sync ledger query/response size*)
83+
[%%define sync_ledger_max_subtree_depth 8]
84+
[%%define sync_ledger_default_subtree_depth 6]

src/lib/block_producer/block_producer.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ let produce ~genesis_breadcrumb ~context:(module Context : CONTEXT) ~prover
821821
let module Consensus_context = struct
822822
include Context
823823

824-
let genesis_constants = precomputed_values.genesis_constants
824+
let compile_config = precomputed_values.compile_config
825825
end in
826826
Internal_tracing.with_state_hash protocol_state_hashes.state_hash
827827
@@ fun () ->
@@ -1419,7 +1419,7 @@ let run_precomputed ~context:(module Context : CONTEXT) ~verifier ~trust_system
14191419
let module Consensus_context = struct
14201420
include Context
14211421

1422-
let genesis_constants = precomputed_values.genesis_constants
1422+
let compile_config = precomputed_values.compile_config
14231423
end in
14241424
Debug_assert.debug_assert (fun () ->
14251425
[%test_result: [ `Take | `Keep ]]

src/lib/bootstrap_controller/bootstrap_controller.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ let time_deferred deferred =
6464
(Time.diff end_time start_time, result)
6565

6666
let worth_getting_root ({ context = (module Context); _ } as t) candidate =
67-
let module Context = struct
67+
let module Consensus_context = struct
6868
include Context
6969

70-
let genesis_constants = precomputed_values.genesis_constants
70+
let compile_config = precomputed_values.compile_config
7171

7272
let logger =
7373
Logger.extend logger
@@ -77,7 +77,7 @@ let worth_getting_root ({ context = (module Context); _ } as t) candidate =
7777
end in
7878
Consensus.Hooks.equal_select_status `Take
7979
@@ Consensus.Hooks.select
80-
~context:(module Context)
80+
~context:(module Consensus_context)
8181
~existing:
8282
( t.best_seen_transition |> Mina_block.Validation.block_with_hash
8383
|> With_hash.map ~f:Mina_block.consensus_state )
@@ -240,7 +240,7 @@ let external_transition_compare ~context:(module Context : CONTEXT) =
240240
let module Consensus_context = struct
241241
include Context
242242

243-
let genesis_constants = precomputed_values.genesis_constants
243+
let compile_config = precomputed_values.compile_config
244244
end in
245245
let get_consensus_state =
246246
Fn.compose Protocol_state.consensus_state Mina_block.Header.protocol_state
@@ -337,7 +337,7 @@ let run ~context:(module Context : CONTEXT) ~trust_system ~verifier ~network
337337
let module Consensus_context = struct
338338
include Context
339339

340-
let genesis_constants = precomputed_values.genesis_constants
340+
let compile_config = precomputed_values.compile_config
341341
end in
342342
let%bind sync_ledger_time, (hash, sender, expected_staged_ledger_hash) =
343343
time_deferred
@@ -823,7 +823,7 @@ let%test_module "Bootstrap_controller tests" =
823823
let module Consensus_context = struct
824824
include Context
825825

826-
let genesis_constants = precomputed_values.genesis_constants
826+
let compile_config = precomputed_values.compile_config
827827
end in
828828
let root_sync_ledger =
829829
Sync_ledger.Db.create

src/lib/consensus/intf.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module type CONTEXT = sig
1212

1313
val consensus_constants : Constants.t
1414

15-
val genesis_constants : Genesis_constants.t
15+
val compile_config : Mina_compile_config.t
1616
end
1717

1818
module type Constants = sig

src/lib/consensus/proof_of_stake.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module Make_str (A : Wire_types.Concrete) = struct
3131

3232
val consensus_constants : Constants.t
3333

34-
val genesis_constants : Genesis_constants.t
34+
val compile_config : Mina_compile_config.t
3535
end
3636

3737
let make_checked t = Snark_params.Tick.Run.make_checked t
@@ -3111,7 +3111,7 @@ module Make_str (A : Wire_types.Concrete) = struct
31113111

31123112
let consensus_constants = Lazy.force Constants.for_unit_tests
31133113

3114-
let genesis_constants = Genesis_constants.For_unit_tests.t
3114+
let compile_config = Mina_compile_config.For_unit_tests.t
31153115
end in
31163116
(* Even when consensus constants are of prod sizes, candidate should still trigger a bootstrap *)
31173117
should_bootstrap_len
@@ -3439,7 +3439,7 @@ module Make_str (A : Wire_types.Concrete) = struct
34393439

34403440
let consensus_constants = constants
34413441

3442-
let genesis_constants = Genesis_constants.For_unit_tests.t
3442+
let compile_config = Mina_compile_config.For_unit_tests.t
34433443
end
34443444

34453445
let test_update constraint_constants =

src/lib/fake_network/fake_network.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ module Generator = struct
216216
let module Consensus_context = struct
217217
include Context
218218

219-
let genesis_constants = precomputed_values.genesis_constants
219+
let compile_config = precomputed_values.compile_config
220220
end in
221221
let open Context in
222222
let epoch_ledger_location =
@@ -263,7 +263,7 @@ module Generator = struct
263263
let module Consensus_context = struct
264264
include Context
265265

266-
let genesis_constants = precomputed_values.genesis_constants
266+
let compile_config = precomputed_values.compile_config
267267
end in
268268
let open Context in
269269
let epoch_ledger_location =

src/lib/genesis_constants/genesis_constants.ml

-4
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,6 @@ module T = struct
223223
; max_action_elements : int
224224
; zkapp_cmd_limit_hardcap : int
225225
; minimum_user_command_fee : Currency.Fee.Stable.Latest.t
226-
; sync_ledger_default_subtree_depth : int
227-
; sync_ledger_max_subtree_depth : int
228226
}
229227
[@@deriving to_yojson, sexp_of, bin_io_unversioned]
230228

@@ -436,8 +434,6 @@ module Make (Node_config : Node_config_intf.S) : S = struct
436434
; zkapp_cmd_limit_hardcap = 128
437435
; minimum_user_command_fee =
438436
Currency.Fee.of_mina_string_exn Node_config.minimum_user_command_fee
439-
; sync_ledger_max_subtree_depth = 8
440-
; sync_ledger_default_subtree_depth = 6
441437
}
442438
end
443439

src/lib/genesis_ledger_helper/lib/genesis_ledger_helper_lib.ml

-6
Original file line numberDiff line numberDiff line change
@@ -577,12 +577,6 @@ let make_genesis_constants ~logger ~(default : Genesis_constants.t)
577577
; minimum_user_command_fee =
578578
Option.value ~default:default.minimum_user_command_fee
579579
(config.daemon >>= fun cfg -> cfg.minimum_user_command_fee)
580-
; sync_ledger_default_subtree_depth =
581-
Option.value ~default:default.sync_ledger_default_subtree_depth
582-
(config.daemon >>= fun cfg -> cfg.sync_ledger_default_subtree_depth)
583-
; sync_ledger_max_subtree_depth =
584-
Option.value ~default:default.sync_ledger_max_subtree_depth
585-
(config.daemon >>= fun cfg -> cfg.sync_ledger_max_subtree_depth)
586580
}
587581

588582
let%test_module "Runtime config" =

src/lib/ledger_catchup/super_catchup.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ let pick ~context:(module Context : CONTEXT)
769769
let module Context = struct
770770
include Context
771771

772-
let genesis_constants = precomputed_values.genesis_constants
772+
let compile_config = precomputed_values.compile_config
773773
end in
774774
match
775775
Consensus.Hooks.select

src/lib/mina_block/validation.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module type CONTEXT = sig
1919

2020
val consensus_constants : Consensus.Constants.t
2121

22-
val genesis_constants : Genesis_constants.t
22+
val compile_config : Mina_compile_config.t
2323
end
2424

2525
let validation (_, v) = v

src/lib/mina_block/validation.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module type CONTEXT = sig
2020

2121
val consensus_constants : Consensus.Constants.t
2222

23-
val genesis_constants : Genesis_constants.t
23+
val compile_config : Mina_compile_config.t
2424
end
2525

2626
val validation :

src/lib/mina_compile_config/mina_compile_config.ml

+20-3
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ module Inputs = struct
2121
; rpc_heartbeat_timeout_sec : float
2222
; rpc_heartbeat_send_every_sec : float
2323
; zkapps_disabled : bool
24+
; sync_ledger_max_subtree_depth : int
25+
; sync_ledger_default_subtree_depth : int
2426
}
2527
[@@deriving yojson, bin_io_unversioned]
2628
end
2729

2830
type t =
2931
{ curve_size : int
30-
; default_snark_worker_fee : Currency.Fee.t
31-
; minimum_user_command_fee : Currency.Fee.t
32+
; default_snark_worker_fee : Currency.Fee.Stable.Latest.t
33+
; minimum_user_command_fee : Currency.Fee.Stable.Latest.t
3234
; itn_features : bool
3335
; compaction_interval : Time.Span.t option
3436
; block_window_duration : Time.Span.t
@@ -39,8 +41,10 @@ type t =
3941
; rpc_heartbeat_timeout : Time_ns.Span.t
4042
; rpc_heartbeat_send_every : Time_ns.Span.t
4143
; zkapps_disabled : bool
44+
; sync_ledger_max_subtree_depth : int
45+
; sync_ledger_default_subtree_depth : int
4246
}
43-
[@@deriving sexp_of]
47+
[@@deriving sexp_of, bin_io_unversioned]
4448

4549
let make (inputs : Inputs.t) =
4650
{ curve_size = inputs.curve_size
@@ -64,6 +68,8 @@ let make (inputs : Inputs.t) =
6468
; network_id = inputs.network_id
6569
; zkapp_cmd_limit = inputs.zkapp_cmd_limit
6670
; zkapps_disabled = inputs.zkapps_disabled
71+
; sync_ledger_max_subtree_depth = inputs.sync_ledger_max_subtree_depth
72+
; sync_ledger_default_subtree_depth = inputs.sync_ledger_default_subtree_depth
6773
}
6874

6975
let to_yojson t =
@@ -91,6 +97,9 @@ let to_yojson t =
9197
, Option.value_map ~default:`Null ~f:(fun x -> `Int x) t.zkapp_cmd_limit
9298
)
9399
; ("zkapps_disabled", `Bool t.zkapps_disabled)
100+
; ("sync_ledger_max_subtree_depth", `Int t.sync_ledger_max_subtree_depth)
101+
; ( "sync_ledger_default_subtree_depth"
102+
, `Int t.sync_ledger_default_subtree_depth )
94103
]
95104

96105
(*TODO: Delete this module and read in a value from the environment*)
@@ -110,6 +119,10 @@ module Compiled = struct
110119
; rpc_heartbeat_timeout_sec = 60.0
111120
; rpc_heartbeat_send_every_sec = 10.0
112121
; zkapps_disabled = false
122+
; sync_ledger_max_subtree_depth =
123+
Node_config.sync_ledger_max_subtree_depth
124+
; sync_ledger_default_subtree_depth =
125+
Node_config.sync_ledger_default_subtree_depth
113126
}
114127
in
115128
make inputs
@@ -137,6 +150,10 @@ module For_unit_tests = struct
137150
; network_id = Node_config_for_unit_tests.network
138151
; zkapp_cmd_limit = Node_config_for_unit_tests.zkapp_cmd_limit
139152
; zkapps_disabled = Node_config_for_unit_tests.zkapps_disabled
153+
; sync_ledger_max_subtree_depth =
154+
Node_config_for_unit_tests.sync_ledger_max_subtree_depth
155+
; sync_ledger_default_subtree_depth =
156+
Node_config_for_unit_tests.sync_ledger_default_subtree_depth
140157
}
141158
in
142159
make inputs

src/lib/mina_lib/mina_lib.ml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,8 @@ let context ~commit_id (config : Config.t) : (module CONTEXT) =
12691269

12701270
let compaction_interval = config.compile_config.compaction_interval
12711271

1272+
(*Same as config.precomputed_values.compile_config.
1273+
TODO: Remove redundant fields *)
12721274
let compile_config = config.compile_config
12731275
end )
12741276

@@ -1618,8 +1620,8 @@ let create ~commit_id ?wallets (config : Config.t) =
16181620
~pids:config.pids ~logger:config.logger
16191621
~conf_dir:config.conf_dir ~consensus_constants
16201622
~keypairs:config.block_production_keypairs
1621-
~genesis_constants:
1622-
config.precomputed_values.genesis_constants ) )
1623+
~compile_config:config.precomputed_values.compile_config )
1624+
)
16231625
>>| Result.ok_exn
16241626
in
16251627
let snark_worker =

src/lib/node_config/for_unit_tests/node_config_for_unit_tests.ml

+4
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,7 @@ let rpc_handshake_timeout_sec = 60.0
9696
let rpc_heartbeat_timeout_sec = 60.0
9797

9898
let rpc_heartbeat_send_every_sec = 10.0 (*same as the default*)
99+
100+
let sync_ledger_max_subtree_depth = 4
101+
102+
let sync_ledger_default_subtree_depth = 3

src/lib/node_config/for_unit_tests/node_config_for_unit_tests.mli

+4
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ val rpc_handshake_timeout_sec : float
2121
val rpc_heartbeat_timeout_sec : float
2222

2323
val rpc_heartbeat_send_every_sec : float
24+
25+
val sync_ledger_max_subtree_depth : int
26+
27+
val sync_ledger_default_subtree_depth : int

src/lib/node_config/intf/node_config_intf.mli

+4
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,8 @@ module type S = sig
6262
val zkapp_cmd_limit : int option
6363

6464
val scan_state_tps_goal_x10 : int option
65+
66+
val sync_ledger_max_subtree_depth : int
67+
68+
val sync_ledger_default_subtree_depth : int
6569
end

src/lib/node_config/node_config.ml

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ include Node_config_version
2828

2929
[%%inject "scan_state_with_tps_goal", scan_state_with_tps_goal]
3030

31+
[%%inject "sync_ledger_max_subtree_depth", sync_ledger_max_subtree_depth]
32+
33+
[%%inject
34+
"sync_ledger_default_subtree_depth", sync_ledger_default_subtree_depth]
35+
3136
[%%ifndef scan_state_transaction_capacity_log_2]
3237

3338
let scan_state_transaction_capacity_log_2 : int option = None

src/lib/runtime_config/runtime_config.ml

+7-8
Original file line numberDiff line numberDiff line change
@@ -1892,14 +1892,6 @@ module Constants : Constants_intf = struct
18921892
; minimum_user_command_fee =
18931893
Option.value ~default:a.genesis_constants.minimum_user_command_fee
18941894
Option.(b.daemon >>= fun d -> d.minimum_user_command_fee)
1895-
; sync_ledger_default_subtree_depth =
1896-
Option.value
1897-
~default:a.genesis_constants.sync_ledger_default_subtree_depth
1898-
Option.(b.daemon >>= fun d -> d.sync_ledger_default_subtree_depth)
1899-
; sync_ledger_max_subtree_depth =
1900-
Option.value
1901-
~default:a.genesis_constants.sync_ledger_max_subtree_depth
1902-
Option.(b.daemon >>= fun d -> d.sync_ledger_max_subtree_depth)
19031895
}
19041896
in
19051897
let constraint_constants =
@@ -1975,6 +1967,13 @@ module Constants : Constants_intf = struct
19751967
; network_id =
19761968
Option.value ~default:a.compile_config.network_id
19771969
Option.(b.daemon >>= fun d -> d.network_id)
1970+
; sync_ledger_max_subtree_depth =
1971+
Option.value ~default:a.compile_config.sync_ledger_max_subtree_depth
1972+
Option.(b.daemon >>= fun d -> d.sync_ledger_max_subtree_depth)
1973+
; sync_ledger_default_subtree_depth =
1974+
Option.value
1975+
~default:a.compile_config.sync_ledger_default_subtree_depth
1976+
Option.(b.daemon >>= fun d -> d.sync_ledger_default_subtree_depth)
19781977
}
19791978
in
19801979
{ genesis_constants; constraint_constants; proof_level; compile_config }

0 commit comments

Comments
 (0)