Skip to content

Commit 1c0070a

Browse files
apollo_state_sync: remove reconstruction of proccesed txs metrics (#10490)
1 parent cda9289 commit 1c0070a

File tree

9 files changed

+5
-83
lines changed

9 files changed

+5
-83
lines changed

Cargo.lock

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/apollo_deployments/resources/app_configs/replacer_state_sync_config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"state_sync_config.rpc_config.ip": "0.0.0.0",
4848
"state_sync_config.rpc_config.max_events_chunk_size": 1000,
4949
"state_sync_config.rpc_config.max_events_keys": 100,
50-
"state_sync_config.should_replay_processed_txs_metric": false,
5150
"state_sync_config.storage_config.db_config.enforce_file_exists": false,
5251
"state_sync_config.storage_config.db_config.growth_step": 67108864,
5352
"state_sync_config.storage_config.db_config.max_readers": 8192,

crates/apollo_deployments/resources/app_configs/state_sync_config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"state_sync_config.rpc_config.max_events_chunk_size": 1000,
4848
"state_sync_config.rpc_config.max_events_keys": 100,
4949
"state_sync_config.rpc_config.ip": "0.0.0.0",
50-
"state_sync_config.should_replay_processed_txs_metric": false,
5150
"state_sync_config.storage_config.db_config.enforce_file_exists": false,
5251
"state_sync_config.storage_config.db_config.growth_step": 67108864,
5352
"state_sync_config.storage_config.db_config.max_readers": 8192,

crates/apollo_integration_tests/src/utils.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,6 @@ pub fn create_state_sync_configs(
717717
port: rpc_ports.remove(0),
718718
..Default::default()
719719
},
720-
should_replay_processed_txs_metric: true,
721720
..Default::default()
722721
})
723722
.collect()

crates/apollo_node/resources/config_schema.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3164,11 +3164,6 @@
31643164
"pointer_target": "starknet_url",
31653165
"privacy": "Public"
31663166
},
3167-
"state_sync_config.should_replay_processed_txs_metric": {
3168-
"description": "Whether to replay processed transactions.",
3169-
"privacy": "Public",
3170-
"value": false
3171-
},
31723167
"state_sync_config.storage_config.db_config.chain_id": {
31733168
"description": "The chain to follow. For more details see https://docs.starknet.io/documentation/architecture_and_concepts/Blocks/transactions/#chain-id.",
31743169
"pointer_target": "chain_id",

crates/apollo_state_sync/src/runner/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ impl StateSyncRunner {
133133
network_config,
134134
revert_config,
135135
rpc_config,
136-
should_replay_processed_txs_metric,
137136
} = config;
138137

139138
let StateSyncResources {
@@ -144,8 +143,7 @@ impl StateSyncRunner {
144143
pending_classes,
145144
} = StateSyncResources::new(&storage_config);
146145

147-
let register_metrics_future =
148-
register_metrics(should_replay_processed_txs_metric, storage_reader.clone()).boxed();
146+
let register_metrics_future = register_metrics(storage_reader.clone()).boxed();
149147

150148
// Creating the JSON-RPC server future
151149
// Located above the revert if block since we would like to be able to query the RPC server

crates/apollo_state_sync_config/src/config.rs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@ use std::path::PathBuf;
33
use std::result;
44

55
use apollo_central_sync_config::config::{CentralSourceConfig, SyncConfig};
6-
use apollo_config::dumping::{
7-
prepend_sub_config_name,
8-
ser_optional_sub_config,
9-
ser_param,
10-
SerializeConfig,
11-
};
12-
use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam};
6+
use apollo_config::dumping::{prepend_sub_config_name, ser_optional_sub_config, SerializeConfig};
7+
use apollo_config::{ParamPath, SerializedParam};
138
use apollo_network::NetworkConfig;
149
use apollo_p2p_sync_config::config::P2pSyncClientConfig;
1510
use apollo_reverts::RevertConfig;
@@ -37,20 +32,11 @@ pub struct StateSyncConfig {
3732
pub revert_config: RevertConfig,
3833
#[validate(nested)]
3934
pub rpc_config: RpcConfig,
40-
// TODO(noamsp): Remove this after fixing the replay procedure.
41-
// This is a temporary solution by disabling the replay procedure in production and enabling it
42-
// in integration tests.
43-
pub should_replay_processed_txs_metric: bool,
4435
}
4536

4637
impl SerializeConfig for StateSyncConfig {
4738
fn dump(&self) -> BTreeMap<ParamPath, SerializedParam> {
48-
let mut config = BTreeMap::from_iter([ser_param(
49-
"should_replay_processed_txs_metric",
50-
&self.should_replay_processed_txs_metric,
51-
"Whether to replay processed transactions.",
52-
ParamPrivacyInput::Public,
53-
)]);
39+
let mut config = BTreeMap::new();
5440
config.extend(prepend_sub_config_name(self.storage_config.dump(), "storage_config"));
5541
config.extend(ser_optional_sub_config(&self.network_config, "network_config"));
5642
config.extend(prepend_sub_config_name(self.revert_config.dump(), "revert_config"));
@@ -94,7 +80,6 @@ impl Default for StateSyncConfig {
9480
network_config: Some(NetworkConfig { port: STATE_SYNC_PORT, ..Default::default() }),
9581
revert_config: RevertConfig::default(),
9682
rpc_config: RpcConfig::default(),
97-
should_replay_processed_txs_metric: false,
9883
}
9984
}
10085
}

crates/apollo_state_sync_metrics/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,3 @@ apollo_infra.workspace = true
1616
apollo_metrics.workspace = true
1717
apollo_state_sync_types.workspace = true
1818
apollo_storage.workspace = true
19-
starknet_api.workspace = true
20-
tokio.workspace = true
21-
tracing.workspace = true

crates/apollo_state_sync_metrics/src/metrics.rs

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use apollo_infra::metrics::{
55
RemoteClientMetrics,
66
RemoteServerMetrics,
77
};
8-
use apollo_metrics::metrics::MetricDetails;
98
use apollo_metrics::{define_infra_metrics, define_metrics};
109
use apollo_state_sync_types::communication::STATE_SYNC_REQUEST_LABELS;
1110
use apollo_storage::body::BodyStorageReader;
@@ -15,9 +14,6 @@ use apollo_storage::db::TransactionKind;
1514
use apollo_storage::header::HeaderStorageReader;
1615
use apollo_storage::state::StateStorageReader;
1716
use apollo_storage::{StorageReader, StorageTxn};
18-
use starknet_api::block::BlockNumber;
19-
use tracing::debug;
20-
2117
define_infra_metrics!(state_sync);
2218

2319
define_metrics!(
@@ -45,10 +41,7 @@ define_metrics!(
4541
},
4642
);
4743

48-
pub async fn register_metrics(
49-
should_replay_processed_txs_metric: bool,
50-
storage_reader: StorageReader,
51-
) {
44+
pub async fn register_metrics(storage_reader: StorageReader) {
5245
STATE_SYNC_HEADER_MARKER.register();
5346
STATE_SYNC_BODY_MARKER.register();
5447
STATE_SYNC_STATE_MARKER.register();
@@ -61,14 +54,6 @@ pub async fn register_metrics(
6154
STATE_SYNC_REVERTED_UP_TO_AND_INCLUDING.register();
6255
let txn = storage_reader.begin_ro_txn().unwrap();
6356
update_marker_metrics(&txn);
64-
if should_replay_processed_txs_metric {
65-
let storage_reader = storage_reader.clone();
66-
let _ = tokio::task::spawn_blocking(move || {
67-
let txn = storage_reader.begin_ro_txn().unwrap();
68-
reconstruct_processed_transactions_metric(&txn);
69-
})
70-
.await;
71-
}
7257
}
7358

7459
pub fn update_marker_metrics<Mode: TransactionKind>(txn: &StorageTxn<'_, Mode>) {
@@ -83,35 +68,3 @@ pub fn update_marker_metrics<Mode: TransactionKind>(txn: &StorageTxn<'_, Mode>)
8368
STATE_SYNC_COMPILED_CLASS_MARKER
8469
.set_lossy(txn.get_compiled_class_marker().expect("Should have a compiled class marker").0);
8570
}
86-
87-
// TODO(noamsp): Fix replay procedure by adding the value to the storage, this way we wont need to
88-
// replay all the transactions.
89-
fn reconstruct_processed_transactions_metric(txn: &StorageTxn<'_, impl TransactionKind>) {
90-
let block_marker = txn.get_body_marker().expect("Should have a body marker");
91-
92-
debug!("Starting to count all transactions in the storage");
93-
// Early return if no blocks to process
94-
if block_marker.0 == 0 {
95-
return;
96-
}
97-
98-
let mut total_transactions = 0;
99-
100-
// Process all blocks efficiently
101-
for block_number in 0..block_marker.0 {
102-
if let Ok(Some(transaction_hashes)) =
103-
txn.get_block_transaction_hashes(BlockNumber(block_number))
104-
{
105-
total_transactions += transaction_hashes.len();
106-
}
107-
}
108-
109-
debug!(
110-
"Finished counting all transactions in the storage. Incrementing {} metric with value: \
111-
{total_transactions}",
112-
STATE_SYNC_PROCESSED_TRANSACTIONS.get_name(),
113-
);
114-
// Set the metric once with the total count
115-
STATE_SYNC_PROCESSED_TRANSACTIONS
116-
.increment(total_transactions.try_into().expect("Failed to convert usize to u64"));
117-
}

0 commit comments

Comments
 (0)