diff --git a/api/src/context.rs b/api/src/context.rs index 939276891d81c..4cea588b9906a 100644 --- a/api/src/context.rs +++ b/api/src/context.rs @@ -259,12 +259,12 @@ impl Context { } pub fn get_latest_ledger_info(&self) -> Result { - if self.indexer_reader.is_some() { - let ledger_info = self.get_latest_internal_indexer_ledger_version_and_ledger_info()?; - Ok(ledger_info) - } else { - self.get_latest_storage_ledger_info() + if let Some(indexer_reader) = self.indexer_reader.as_ref() { + if indexer_reader.is_internal_indexer_enabled() { + return self.get_latest_internal_indexer_ledger_info(); + } } + self.get_latest_storage_ledger_info() } pub fn get_latest_ledger_info_and_verify_lookup_version( @@ -292,9 +292,7 @@ impl Context { Ok((latest_ledger_info, requested_ledger_version)) } - pub fn get_latest_internal_indexer_ledger_version_and_ledger_info< - E: ServiceUnavailableError, - >( + pub fn get_latest_internal_indexer_ledger_info( &self, ) -> Result { if let Some(indexer_reader) = self.indexer_reader.as_ref() { diff --git a/crates/aptos/src/node/local_testnet/node.rs b/crates/aptos/src/node/local_testnet/node.rs index e40974a6ba78e..e51a63a73fe1f 100644 --- a/crates/aptos/src/node/local_testnet/node.rs +++ b/crates/aptos/src/node/local_testnet/node.rs @@ -153,9 +153,11 @@ impl NodeManager { node_config.indexer_grpc.use_data_service_interface = run_txn_stream; node_config.indexer_grpc.address.set_port(txn_stream_port); - // So long as the indexer relies on storage indexing tables, this must be set - // for the indexer GRPC stream on the node to work. - node_config.storage.enable_indexer = run_txn_stream; + node_config.indexer_table_info.table_info_service_mode = match run_txn_stream { + // Localnet should be responsible for backup or restore of table info tables. + true => aptos_config::config::TableInfoServiceMode::IndexingOnly, + false => aptos_config::config::TableInfoServiceMode::Disabled, + }; // Bind to the requested address. node_config.api.address.set_ip(IpAddr::V4(bind_to)); diff --git a/storage/indexer/src/indexer_reader.rs b/storage/indexer/src/indexer_reader.rs index 0368d80c612a5..535d043d50119 100644 --- a/storage/indexer/src/indexer_reader.rs +++ b/storage/indexer/src/indexer_reader.rs @@ -40,6 +40,10 @@ impl IndexerReaders { } impl IndexerReader for IndexerReaders { + fn is_internal_indexer_enabled(&self) -> bool { + self.db_indexer_reader.is_some() + } + fn get_table_info(&self, handle: TableHandle) -> anyhow::Result> { if let Some(table_info_reader) = &self.table_info_reader { return Ok(table_info_reader.get_table_info_with_retry(handle)?); diff --git a/types/src/indexer/indexer_db_reader.rs b/types/src/indexer/indexer_db_reader.rs index 016524dc5bb67..164b927de37dc 100644 --- a/types/src/indexer/indexer_db_reader.rs +++ b/types/src/indexer/indexer_db_reader.rs @@ -21,6 +21,8 @@ pub enum Order { } pub trait IndexerReader: Send + Sync { + fn is_internal_indexer_enabled(&self) -> bool; + fn get_table_info(&self, handle: TableHandle) -> Result>; fn get_events(