Skip to content

Commit 7d6071a

Browse files
Revert to 0.14.0 3 (#10504)
* Revert "apollo_infra: apply tcp_nodelay on remote connections (#10237)" This reverts commit 3a5aacd. * Revert "apollo_gateway: Add gatewaye cache ratio panel (#10189)" This reverts commit e961954. * Revert "apollo_gateway: Add cache metrics (#10191)" This reverts commit 4f46288. * Revert "apollo_gateway: make class cache configurable (#10188)" This reverts commit 4ced915. * Revert "apollo_gateway: Add naive class cache (#10190)" This reverts commit cfb096e.
1 parent 3a5aacd commit 7d6071a

File tree

13 files changed

+18
-135
lines changed

13 files changed

+18
-135
lines changed

crates/apollo_dashboard/resources/dev_grafana.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -630,17 +630,6 @@
630630
"histogram_quantile(0.95, sum by (le) (rate(gateway_validate_stateful_tx_storage_operations_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\"}[5m])))"
631631
],
632632
"extra_params": {}
633-
},
634-
{
635-
"title": "gateway_class_cache_miss_ratio",
636-
"description": "The ratio of cache misses when requesting compiled classes from the Gateway State Reader",
637-
"type": "timeseries",
638-
"exprs": [
639-
"(increase(gateway_class_cache_misses{cluster=~\"$cluster\", namespace=~\"$namespace\"}[5m]) / (increase(gateway_class_cache_misses{cluster=~\"$cluster\", namespace=~\"$namespace\"}[5m]) + increase(gateway_class_cache_hits{cluster=~\"$cluster\", namespace=~\"$namespace\"}[5m])))"
640-
],
641-
"extra_params": {
642-
"unit": "percentunit"
643-
}
644633
}
645634
],
646635
"collapsed": true

crates/apollo_dashboard/src/panels/gateway.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
use apollo_gateway::metrics::{
22
GATEWAY_ADD_TX_FAILURE,
33
GATEWAY_ADD_TX_LATENCY,
4-
GATEWAY_CLASS_CACHE_HITS,
5-
GATEWAY_CLASS_CACHE_MISSES,
6-
GATEWAY_METRIC_RATE_DURATION,
74
GATEWAY_TRANSACTIONS_FAILED,
85
GATEWAY_TRANSACTIONS_RECEIVED,
96
GATEWAY_TRANSACTIONS_SENT_TO_MEMPOOL,
@@ -135,17 +132,6 @@ fn get_panel_gateway_validate_stateful_tx_storage_operations() -> Panel {
135132
)
136133
}
137134

138-
// TODO(MatanL/Shahak): use clamp_min(X, 1) on denom to avoid division by zero.
139-
fn get_panel_gateway_class_cache_miss_ratio() -> Panel {
140-
Panel::ratio_time_series(
141-
"gateway_class_cache_miss_ratio",
142-
"The ratio of cache misses when requesting compiled classes from the Gateway State Reader",
143-
&GATEWAY_CLASS_CACHE_MISSES,
144-
&[&GATEWAY_CLASS_CACHE_MISSES, &GATEWAY_CLASS_CACHE_HITS],
145-
GATEWAY_METRIC_RATE_DURATION,
146-
)
147-
}
148-
149135
pub(crate) fn get_gateway_row() -> Row {
150136
Row::new(
151137
"Gateway",
@@ -160,7 +146,6 @@ pub(crate) fn get_gateway_row() -> Row {
160146
get_panel_gateway_transactions_sent_to_mempool(),
161147
get_panel_gateway_validate_stateful_tx_storage_time(),
162148
get_panel_gateway_validate_stateful_tx_storage_operations(),
163-
get_panel_gateway_class_cache_miss_ratio(),
164149
],
165150
)
166151
}

crates/apollo_deployments/resources/app_configs/gateway_config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"gateway_config.authorized_declarer_accounts": "",
33
"gateway_config.authorized_declarer_accounts.#is_none": true,
44
"gateway_config.block_declare": false,
5-
"gateway_config.class_cache_size": 250,
65
"gateway_config.stateful_tx_validator_config.max_allowed_nonce_gap": 200,
76
"gateway_config.stateful_tx_validator_config.max_nonce_for_validation_skip": "0x1",
87
"gateway_config.stateful_tx_validator_config.min_gas_price_percentage": 100,
@@ -19,4 +18,4 @@
1918
"gateway_config.stateless_tx_validator_config.min_sierra_version.major": 1,
2019
"gateway_config.stateless_tx_validator_config.min_sierra_version.minor": 1,
2120
"gateway_config.stateless_tx_validator_config.min_sierra_version.patch": 0
22-
}
21+
}

crates/apollo_gateway/src/config.rs

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,46 +19,24 @@ use crate::compiler_version::VersionId;
1919

2020
const JSON_RPC_VERSION: &str = "2.0";
2121

22-
#[derive(Clone, Debug, Serialize, Deserialize, Validate, PartialEq)]
22+
#[derive(Clone, Debug, Default, Serialize, Deserialize, Validate, PartialEq)]
2323
pub struct GatewayConfig {
2424
pub stateless_tx_validator_config: StatelessTransactionValidatorConfig,
2525
pub stateful_tx_validator_config: StatefulTransactionValidatorConfig,
2626
pub chain_info: ChainInfo,
2727
pub block_declare: bool,
2828
#[serde(default, deserialize_with = "deserialize_optional_contract_addresses")]
2929
pub authorized_declarer_accounts: Option<Vec<ContractAddress>>,
30-
pub class_cache_size: usize,
31-
}
32-
33-
impl Default for GatewayConfig {
34-
fn default() -> Self {
35-
Self {
36-
stateless_tx_validator_config: StatelessTransactionValidatorConfig::default(),
37-
stateful_tx_validator_config: StatefulTransactionValidatorConfig::default(),
38-
chain_info: ChainInfo::default(),
39-
block_declare: false,
40-
authorized_declarer_accounts: None,
41-
class_cache_size: 250,
42-
}
43-
}
4430
}
4531

4632
impl SerializeConfig for GatewayConfig {
4733
fn dump(&self) -> BTreeMap<ParamPath, SerializedParam> {
48-
let mut dump = BTreeMap::from_iter([
49-
ser_param(
50-
"block_declare",
51-
&self.block_declare,
52-
"If true, the gateway will block declare transactions.",
53-
ParamPrivacyInput::Public,
54-
),
55-
ser_param(
56-
"class_cache_size",
57-
&self.class_cache_size,
58-
"Maximum number of compiled contract classes to cache in memory.",
59-
ParamPrivacyInput::Public,
60-
),
61-
]);
34+
let mut dump = BTreeMap::from_iter([ser_param(
35+
"block_declare",
36+
&self.block_declare,
37+
"If true, the gateway will block declare transactions.",
38+
ParamPrivacyInput::Public,
39+
)]);
6240
dump.extend(prepend_sub_config_name(
6341
self.stateless_tx_validator_config.dump(),
6442
"stateless_tx_validator_config",

crates/apollo_gateway/src/gateway.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use apollo_proc_macros::sequencer_latency_histogram;
2525
use apollo_state_sync_types::communication::SharedStateSyncClient;
2626
use axum::async_trait;
2727
use blockifier::context::ChainInfo;
28-
use starknet_api::class_cache::GlobalContractCache;
2928
use starknet_api::rpc_transaction::{
3029
InternalRpcTransaction,
3130
InternalRpcTransactionWithoutTxHash,
@@ -280,12 +279,9 @@ pub fn create_gateway(
280279
class_manager_client: SharedClassManagerClient,
281280
runtime: tokio::runtime::Handle,
282281
) -> Gateway {
283-
let class_cache = GlobalContractCache::new(config.class_cache_size);
284-
285282
let state_reader_factory = Arc::new(SyncStateReaderFactory {
286283
shared_state_sync_client,
287284
class_manager_client: class_manager_client.clone(),
288-
class_cache,
289285
runtime,
290286
});
291287
let transaction_converter =

crates/apollo_gateway/src/gateway_test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ fn config() -> GatewayConfig {
9292
chain_info: ChainInfo::create_for_testing(),
9393
block_declare: false,
9494
authorized_declarer_accounts: None,
95-
class_cache_size: 1,
9695
}
9796
}
9897

crates/apollo_gateway/src/metrics.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ define_metrics!(
4747
MetricHistogram { GATEWAY_VALIDATE_TX_LATENCY, "gateway_validate_tx_latency", "Latency of gateway validate function in secs" },
4848
MetricHistogram { GATEWAY_VALIDATE_STATEFUL_TX_STORAGE_TIME, "gateway_validate_stateful_tx_storage_time", "Total time spent in storage operations in secs during stateful tx validation" },
4949
MetricHistogram { GATEWAY_VALIDATE_STATEFUL_TX_STORAGE_OPERATIONS, "gateway_validate_stateful_tx_storage_operations", "Total number of storage operations during stateful tx validation"},
50-
MetricCounter { GATEWAY_CLASS_CACHE_HITS, "gateway_class_cache_hits", "Counter of class cache hits", init=0 },
51-
MetricCounter { GATEWAY_CLASS_CACHE_MISSES, "gateway_class_cache_misses", "Counter of class cache misses", init=0 },
5250
},
5351
);
5452

@@ -245,8 +243,6 @@ impl Drop for GatewayMetricHandle {
245243
}
246244
}
247245

248-
pub const GATEWAY_METRIC_RATE_DURATION: &str = "5m";
249-
250246
pub(crate) fn register_metrics() {
251247
GATEWAY_TRANSACTIONS_RECEIVED.register();
252248
GATEWAY_TRANSACTIONS_FAILED.register();
@@ -256,6 +252,4 @@ pub(crate) fn register_metrics() {
256252
GATEWAY_VALIDATE_TX_LATENCY.register();
257253
GATEWAY_VALIDATE_STATEFUL_TX_STORAGE_TIME.register();
258254
GATEWAY_VALIDATE_STATEFUL_TX_STORAGE_OPERATIONS.register();
259-
GATEWAY_CLASS_CACHE_HITS.register();
260-
GATEWAY_CLASS_CACHE_MISSES.register();
261255
}

crates/apollo_gateway/src/sync_state_reader.rs

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use blockifier::state::state_api::{StateReader as BlockifierStateReader, StateRe
1919
use futures::executor::block_on;
2020
use lazy_static::lazy_static;
2121
use starknet_api::block::{BlockHash, BlockInfo, BlockNumber, GasPriceVector, GasPrices};
22-
use starknet_api::class_cache::GlobalContractCache;
2322
use starknet_api::contract_class::ContractClass;
2423
use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce};
2524
use starknet_api::data_availability::L1DataAvailabilityMode;
@@ -28,8 +27,6 @@ use starknet_api::state::StorageKey;
2827
use starknet_types_core::felt::Felt;
2928

3029
use crate::metrics::{
31-
GATEWAY_CLASS_CACHE_HITS,
32-
GATEWAY_CLASS_CACHE_MISSES,
3330
GATEWAY_VALIDATE_STATEFUL_TX_STORAGE_OPERATIONS,
3431
GATEWAY_VALIDATE_STATEFUL_TX_STORAGE_TIME,
3532
};
@@ -41,23 +38,20 @@ pub(crate) struct SyncStateReader {
4138
block_number: BlockNumber,
4239
state_sync_client: SharedStateSyncClientMetricWrapper,
4340
class_manager_client: SharedClassManagerClient,
44-
class_cache: GlobalContractCache<RunnableCompiledClass>,
4541
runtime: tokio::runtime::Handle,
4642
}
4743

4844
impl SyncStateReader {
4945
pub fn from_number(
5046
state_sync_client: SharedStateSyncClient,
5147
class_manager_client: SharedClassManagerClient,
52-
class_cache: GlobalContractCache<RunnableCompiledClass>,
5348
block_number: BlockNumber,
5449
runtime: tokio::runtime::Handle,
5550
) -> Self {
5651
Self {
5752
block_number,
5853
state_sync_client: SharedStateSyncClientMetricWrapper::new(state_sync_client),
5954
class_manager_client,
60-
class_cache,
6155
runtime,
6256
}
6357
}
@@ -131,19 +125,6 @@ impl BlockifierStateReader for SyncStateReader {
131125
}
132126

133127
fn get_compiled_class(&self, class_hash: ClassHash) -> StateResult<RunnableCompiledClass> {
134-
// Check cache first.
135-
// Note: GlobalContractCache uses std::sync::Mutex which blocks the thread.
136-
// This is safe here because get_compiled_class() is always called from
137-
// spawn_blocking contexts (see ProcessTxBlockingTask in gateway.rs), not
138-
// directly from async code. Cache operations are very fast (hash map lookups),
139-
// so the blocking time is minimal (microseconds).
140-
if let Some(cached_class) = self.class_cache.get(&class_hash) {
141-
GATEWAY_CLASS_CACHE_HITS.increment(1);
142-
return Ok(cached_class);
143-
}
144-
145-
GATEWAY_CLASS_CACHE_MISSES.increment(1);
146-
147128
let mut is_class_declared = self
148129
.runtime
149130
.block_on(self.state_sync_client.is_class_declared_at(self.block_number, class_hash))
@@ -167,18 +148,14 @@ impl BlockifierStateReader for SyncStateReader {
167148
was declared",
168149
);
169150

170-
let runnable_class = match contract_class {
151+
match contract_class {
171152
ContractClass::V1(casm_contract_class) => {
172-
RunnableCompiledClass::V1(casm_contract_class.try_into()?)
153+
Ok(RunnableCompiledClass::V1(casm_contract_class.try_into()?))
173154
}
174155
ContractClass::V0(deprecated_contract_class) => {
175-
RunnableCompiledClass::V0(deprecated_contract_class.try_into()?)
156+
Ok(RunnableCompiledClass::V0(deprecated_contract_class.try_into()?))
176157
}
177-
};
178-
179-
// Cache the compiled class before returning
180-
self.class_cache.set(class_hash, runnable_class.clone());
181-
Ok(runnable_class)
158+
}
182159
}
183160

184161
fn get_class_hash_at(&self, contract_address: ContractAddress) -> StateResult<ClassHash> {
@@ -304,16 +281,9 @@ impl Drop for SharedStateSyncClientMetricWrapper {
304281
}
305282
}
306283

307-
/// Factory for creating SyncStateReader instances with a shared class cache.
308-
///
309-
/// The class cache is shared across all state readers created by this factory,
310-
/// maximizing cache hit rates across transaction validations. The cache uses
311-
/// std::sync::Mutex internally, which is safe because state reader operations
312-
/// are always executed in spawn_blocking contexts (see ProcessTxBlockingTask).
313284
pub(crate) struct SyncStateReaderFactory {
314285
pub shared_state_sync_client: SharedStateSyncClient,
315286
pub class_manager_client: SharedClassManagerClient,
316-
pub class_cache: GlobalContractCache<RunnableCompiledClass>,
317287
pub runtime: tokio::runtime::Handle,
318288
}
319289

@@ -331,7 +301,6 @@ impl StateReaderFactory for SyncStateReaderFactory {
331301
Ok(Box::new(SyncStateReader::from_number(
332302
self.shared_state_sync_client.clone(),
333303
self.class_manager_client.clone(),
334-
self.class_cache.clone(),
335304
latest_block_number,
336305
self.runtime.clone(),
337306
)))

crates/apollo_gateway/src/sync_state_reader_test.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,13 @@ use starknet_api::block::{
2525
GasPrices,
2626
NonzeroGasPrice,
2727
};
28-
use starknet_api::class_cache::GlobalContractCache;
2928
use starknet_api::contract_class::{ContractClass, SierraVersion};
3029
use starknet_api::core::{ClassHash, SequencerContractAddress};
3130
use starknet_api::data_availability::L1DataAvailabilityMode;
3231
use starknet_api::{class_hash, contract_address, felt, nonce, storage_key};
3332

3433
use crate::state_reader::MempoolStateReader;
3534
use crate::sync_state_reader::{SyncStateReader, OLD_DEPLOY_CLASS_HASH_WHITELIST};
36-
37-
fn create_test_class_cache() -> GlobalContractCache<RunnableCompiledClass> {
38-
GlobalContractCache::new(1)
39-
}
4035
#[tokio::test]
4136
async fn test_get_block_info() {
4237
let mut mock_state_sync_client = MockStateSyncClient::new();
@@ -73,7 +68,6 @@ async fn test_get_block_info() {
7368
let state_sync_reader = SyncStateReader::from_number(
7469
Arc::new(mock_state_sync_client),
7570
Arc::new(mock_class_manager_client),
76-
create_test_class_cache(),
7771
block_number,
7872
tokio::runtime::Handle::current(),
7973
);
@@ -130,7 +124,6 @@ async fn test_get_storage_at() {
130124
let state_sync_reader = SyncStateReader::from_number(
131125
Arc::new(mock_state_sync_client),
132126
Arc::new(mock_class_manager_client),
133-
create_test_class_cache(),
134127
block_number,
135128
tokio::runtime::Handle::current(),
136129
);
@@ -161,7 +154,6 @@ async fn test_get_nonce_at() {
161154
let state_sync_reader = SyncStateReader::from_number(
162155
Arc::new(mock_state_sync_client),
163156
Arc::new(mock_class_manager_client),
164-
create_test_class_cache(),
165157
block_number,
166158
tokio::runtime::Handle::current(),
167159
);
@@ -191,7 +183,6 @@ async fn test_get_class_hash_at() {
191183
let state_sync_reader = SyncStateReader::from_number(
192184
Arc::new(mock_state_sync_client),
193185
Arc::new(mock_class_manager_client),
194-
create_test_class_cache(),
195186
block_number,
196187
tokio::runtime::Handle::current(),
197188
);
@@ -286,7 +277,6 @@ async fn test_get_compiled_class(
286277
let state_sync_reader = SyncStateReader::from_number(
287278
Arc::new(mock_state_sync_client),
288279
Arc::new(mock_class_manager_client),
289-
create_test_class_cache(),
290280
block_number,
291281
tokio::runtime::Handle::current(),
292282
);

crates/apollo_infra/src/component_client/remote_component_client.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,12 @@ where
130130
metrics: &'static RemoteClientMetrics,
131131
) -> Self {
132132
let uri = format!("http://{url}:{port}/").parse().unwrap();
133-
let mut connector = hyper::client::connect::HttpConnector::new();
134-
connector.set_nodelay(true);
135133
let client = Client::builder()
136134
.http2_only(true)
137135
.pool_max_idle_per_host(config.idle_connections)
138136
.pool_idle_timeout(Duration::from_millis(config.idle_timeout_ms))
139-
.build(connector);
140-
137+
.build_http();
141138
debug!("RemoteComponentClient created with URI: {uri:?}");
142-
143139
Self { uri, client, config, metrics, _req: PhantomData, _res: PhantomData }
144140
}
145141

0 commit comments

Comments
 (0)