Skip to content

Commit c4f3177

Browse files
apollo_node_config: made validation only node hold full state
1 parent 3973cd0 commit c4f3177

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

crates/apollo_node_config/src/config_test.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,13 @@ fn monitoring_config(
115115
assert_eq!(component_exe_config.validate().is_ok(), expected_successful_validation);
116116
}
117117

118-
fn state_sync_config_with_state_only() -> StateSyncConfig {
118+
fn state_sync_config_with_full_archive() -> StateSyncConfig {
119119
StateSyncConfig {
120120
static_config: StateSyncStaticConfig {
121-
storage_config: StorageConfig { scope: StorageScope::StateOnly, ..Default::default() },
121+
storage_config: StorageConfig {
122+
scope: StorageScope::FullArchive,
123+
..Default::default()
124+
},
122125
..Default::default()
123126
},
124127
..Default::default()
@@ -136,7 +139,7 @@ fn validation_only_with_gateway_enabled_fails() {
136139
mempool_p2p: ReactiveComponentExecutionConfig::default(),
137140
..Default::default()
138141
},
139-
state_sync_config: Some(state_sync_config_with_state_only()),
142+
state_sync_config: Some(state_sync_config_with_full_archive()),
140143
..Default::default()
141144
};
142145
let err = config.validate_node_config().unwrap_err();
@@ -156,7 +159,7 @@ fn validation_only_with_http_server_enabled_fails() {
156159
..Default::default()
157160
},
158161
gateway_config: None,
159-
state_sync_config: Some(state_sync_config_with_state_only()),
162+
state_sync_config: Some(state_sync_config_with_full_archive()),
160163
..Default::default()
161164
};
162165
let err = config.validate_node_config().unwrap_err();
@@ -177,7 +180,7 @@ fn validation_only_with_mempool_enabled_fails() {
177180
},
178181
gateway_config: None,
179182
http_server_config: None,
180-
state_sync_config: Some(state_sync_config_with_state_only()),
183+
state_sync_config: Some(state_sync_config_with_full_archive()),
181184
..Default::default()
182185
};
183186
let err = config.validate_node_config().unwrap_err();
@@ -199,7 +202,7 @@ fn validation_only_with_mempool_p2p_enabled_fails() {
199202
gateway_config: None,
200203
http_server_config: None,
201204
mempool_config: None,
202-
state_sync_config: Some(state_sync_config_with_state_only()),
205+
state_sync_config: Some(state_sync_config_with_full_archive()),
203206
..Default::default()
204207
};
205208
let err = config.validate_node_config().unwrap_err();
@@ -221,14 +224,14 @@ fn validation_only_with_tx_ingestion_disabled_succeeds() {
221224
http_server_config: None,
222225
mempool_config: None,
223226
mempool_p2p_config: None,
224-
state_sync_config: Some(state_sync_config_with_state_only()),
227+
state_sync_config: Some(state_sync_config_with_full_archive()),
225228
..Default::default()
226229
};
227230
assert!(config.validate_node_config().is_ok());
228231
}
229232

230233
#[test]
231-
fn validation_only_with_full_archive_state_sync_fails() {
234+
fn validation_only_with_state_only_state_sync_fails() {
232235
let config = SequencerNodeConfig {
233236
validation_only: true,
234237
components: ComponentConfig {
@@ -245,7 +248,7 @@ fn validation_only_with_full_archive_state_sync_fails() {
245248
state_sync_config: Some(StateSyncConfig {
246249
static_config: StateSyncStaticConfig {
247250
storage_config: StorageConfig {
248-
scope: StorageScope::FullArchive,
251+
scope: StorageScope::StateOnly,
249252
..Default::default()
250253
},
251254
..Default::default()
@@ -255,5 +258,5 @@ fn validation_only_with_full_archive_state_sync_fails() {
255258
..Default::default()
256259
};
257260
let err = config.validate_node_config().unwrap_err();
258-
assert!(format!("{err:?}").contains("StateOnly"), "Unexpected error: {err:?}");
261+
assert!(format!("{err:?}").contains("FullArchive"), "Unexpected error: {err:?}");
259262
}

crates/apollo_node_config/src/node_config.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,10 +604,16 @@ impl SequencerNodeConfig {
604604
}
605605
other => other,
606606
})?;
607+
// TODO(AndrewL): validation-only nodes should ideally use StorageScope::StateOnly to
608+
// save disk and write traffic, but the SNIP-35 fee_proposals bootstrap calls
609+
// state_sync.get_block(), which reads transaction_metadata - a table excluded from
610+
// StateOnly (see apollo_storage::StorageScope). Find a way to either (a) make
611+
// get_block work without transaction_metadata or (b) skip the bootstrap call on
612+
// validation-only nodes, then flip this back to requiring StateOnly.
607613
if let Some(state_sync_config) = &self.state_sync_config {
608-
if state_sync_config.static_config.storage_config.scope != StorageScope::StateOnly {
614+
if state_sync_config.static_config.storage_config.scope != StorageScope::FullArchive {
609615
return Err(ConfigError::ComponentConfigMismatch {
610-
component_config_mismatch: "state_sync storage scope must be StateOnly when \
616+
component_config_mismatch: "state_sync storage scope must be FullArchive when \
611617
validation_only is true"
612618
.to_string(),
613619
});

0 commit comments

Comments
 (0)