Skip to content

Commit a3dddb1

Browse files
apollo_gateway: move get_latest_block_info to be async
1 parent ad481c7 commit a3dddb1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

crates/apollo_gateway/src/stateful_transaction_validator.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ impl StatefulTransactionValidatorFactoryTrait for StatefulTransactionValidatorFa
5858
) -> StatefulTransactionValidatorResult<Box<dyn StatefulTransactionValidatorTrait>> {
5959
// TODO(yael 6/5/2024): consider storing the block_info as part of the
6060
// StatefulTransactionValidator and update it only once a new block is created.
61-
let state_reader = tokio::runtime::Handle::current()
61+
let current_runtime = tokio::runtime::Handle::current();
62+
let state_reader = current_runtime
6263
.block_on(state_reader_factory.get_state_reader_from_latest_block())
6364
.map_err(|err| GatewaySpecError::UnexpectedError {
6465
data: format!("Internal server error: {err}"),
@@ -69,7 +70,7 @@ impl StatefulTransactionValidatorFactoryTrait for StatefulTransactionValidatorFa
6970
e,
7071
)
7172
})?;
72-
let latest_block_info = get_latest_block_info(&state_reader)?;
73+
let latest_block_info = current_runtime.block_on(get_latest_block_info(&state_reader))?;
7374

7475
let state = CachedState::new(state_reader);
7576
let mut versioned_constants = VersionedConstants::get_versioned_constants(
@@ -330,10 +331,11 @@ fn skip_stateful_validations(
330331
Ok(false)
331332
}
332333

333-
pub fn get_latest_block_info(
334+
pub async fn get_latest_block_info(
334335
state_reader: &dyn MempoolStateReader,
335336
) -> StatefulTransactionValidatorResult<BlockInfo> {
336-
tokio::runtime::Handle::current()
337-
.block_on(state_reader.get_block_info())
337+
state_reader
338+
.get_block_info()
339+
.await
338340
.map_err(|e| StarknetError::internal_with_logging("Failed to get latest block info", e))
339341
}

0 commit comments

Comments
 (0)