From 7205765e46437c74aa4a7fb32e9e2b3db3d7948d Mon Sep 17 00:00:00 2001 From: Nimrod Weiss Date: Wed, 17 Jun 2026 12:41:28 +0300 Subject: [PATCH] apollo_deployments: derive state_sync optional sync-clients from env presence --- .../jsonnet/lib/applicative_config.libsonnet | 68 ++++++++++++++++++- .../jsonnet/testing/overrides.libsonnet | 19 +++--- 2 files changed, 73 insertions(+), 14 deletions(-) diff --git a/crates/apollo_deployments/jsonnet/lib/applicative_config.libsonnet b/crates/apollo_deployments/jsonnet/lib/applicative_config.libsonnet index b3ec5b68f7b..017e13ab8c2 100644 --- a/crates/apollo_deployments/jsonnet/lib/applicative_config.libsonnet +++ b/crates/apollo_deployments/jsonnet/lib/applicative_config.libsonnet @@ -20,6 +20,68 @@ function(overrides) local revertConfig = { revert_up_to_and_including: 18446744073709551615, should_revert: false }; local behaviorMode = 'starknet'; local validationOnly = false; + // `state_sync` optional sub-configs. The env supplies each one as `null` (the `#is_none:true` + // option ⇒ None) or as an object (active, possibly carrying only the sparse sub-field overrides); + // an active option is `default` deep-merged with those overrides. Secret/pointer fields use the + // same placeholders as the other network configs (`secret_key`/`http_headers` → '' filled by + // secrets.json; `chain_id`/`starknet_url` → the pointer locals). + local optionalStateSyncSubConfig(value, default) = + if value == null then null else std.mergePatch(default, value); + local defaultCentralSyncClientConfig = { + central_source_config: { + class_cache_size: 128, + concurrent_requests: 20, + http_headers: '', + max_classes_to_download: 20, + max_state_updates_to_download: 20, + max_state_updates_to_store_in_memory: 20, + retry_config: { max_retries: 10, retry_base_millis: 30, retry_max_delay_millis: 30000 }, + starknet_url: starknetUrl, + }, + sync_config: { + base_layer_propagation_sleep_duration: 10, + blocks_before_tip_to_disable_batching: 100, + blocks_max_stream_size: 1000, + collect_pending_data: false, + latest_block_poll_interval_millis: 500, + recoverable_error_sleep_duration: 3, + state_updates_max_stream_size: 1000, + store_sierras_and_casms_block_threshold: 0, + verify_blocks: false, + }, + }; + local defaultStateSyncNetworkConfig = { + advertised_multiaddr: null, + bootstrap_peer_multiaddr: null, + broadcasted_message_metadata_buffer_size: 100000, + chain_id: chainId, + discovery_config: { + bootstrap_dial_retry_config: { + base_delay_millis: 2, + factor: 5, + max_delay_seconds: 5, + new_connection_stabilization_millis: 2000, + }, + heartbeat_interval: 100, + }, + idle_connection_timeout: 120, + peer_manager_config: { malicious_timeout_seconds: 1, unstable_timeout_millis: 1000 }, + port: 53140, + prune_dead_connections_ping_interval: 15, + prune_dead_connections_ping_timeout: 20, + reported_peer_ids_buffer_size: 100000, + secret_key: '', + session_timeout: 120, + }; + local defaultP2pSyncClientConfig = { + buffer_size: 100000, + num_block_classes_per_query: 100, + num_block_state_diffs_per_query: 100, + num_block_transactions_per_query: 100, + num_headers_per_query: 10000, + wait_period_for_new_data: 50, + wait_period_for_other_protocol: 50, + }; { base_layer_config: { bpo1_start_block_number: overrides.base_layer_config.bpo1_start_block_number, @@ -530,9 +592,9 @@ function(overrides) }, }, static_config: { - central_sync_client_config: overrides.state_sync_config.static_config.central_sync_client_config, - network_config: overrides.state_sync_config.static_config.network_config, - p2p_sync_client_config: overrides.state_sync_config.static_config.p2p_sync_client_config, + central_sync_client_config: optionalStateSyncSubConfig(overrides.state_sync_config.static_config.central_sync_client_config, defaultCentralSyncClientConfig), + network_config: optionalStateSyncSubConfig(overrides.state_sync_config.static_config.network_config, defaultStateSyncNetworkConfig), + p2p_sync_client_config: optionalStateSyncSubConfig(overrides.state_sync_config.static_config.p2p_sync_client_config, defaultP2pSyncClientConfig), revert_config: revertConfig, rpc_config: { apollo_gateway_retry_config: { diff --git a/crates/apollo_deployments/jsonnet/testing/overrides.libsonnet b/crates/apollo_deployments/jsonnet/testing/overrides.libsonnet index ce00ef71723..f7945c223a8 100644 --- a/crates/apollo_deployments/jsonnet/testing/overrides.libsonnet +++ b/crates/apollo_deployments/jsonnet/testing/overrides.libsonnet @@ -5,7 +5,7 @@ eth_fee_token_address: '0x1', strk_fee_token_address: '0x2', recorder_url: 'https://recorder_url', - starknet_url: 'https://starknet_url', + starknet_url: 'https://starknet_url/', native_classes_whitelist: '[]', validator_id: '0x64', versioned_constants_overrides: null, @@ -127,17 +127,14 @@ }, state_sync_config: { static_config: { - central_sync_client_config: null, - network_config: null, - p2p_sync_client_config: { - num_headers_per_query: 10000, - num_block_state_diffs_per_query: 100, - num_block_transactions_per_query: 100, - num_block_classes_per_query: 100, - wait_period_for_new_data: 50, - wait_period_for_other_protocol: 50, - buffer_size: 100000, + // Matches the real sepolia-alpha envs: central-sync active (a sparse override exercises the + // deep-merge onto the applicative default), p2p and network None. `null` = None; an object = + // active (default merged with the object). + central_sync_client_config: { + sync_config: { store_sierras_and_casms_block_threshold: 0 }, }, + network_config: null, + p2p_sync_client_config: null, rpc_config: { port: 8083, },