From 0fb79ec9c4c386805223c70451dd569a80866f92 Mon Sep 17 00:00:00 2001 From: bexan Date: Wed, 22 May 2024 14:52:43 +0200 Subject: [PATCH] starknet: add call to verify_invoke_tx_before_pool --- .../katana/rpc/rpc-types/src/error/starknet.rs | 3 +++ crates/katana/rpc/rpc/src/starknet.rs | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/crates/katana/rpc/rpc-types/src/error/starknet.rs b/crates/katana/rpc/rpc-types/src/error/starknet.rs index a4aacae381..a77b1f8e95 100644 --- a/crates/katana/rpc/rpc-types/src/error/starknet.rs +++ b/crates/katana/rpc/rpc-types/src/error/starknet.rs @@ -75,6 +75,8 @@ pub enum StarknetApiError { TooManyKeysInFilter, #[error("Failed to fetch pending transactions")] FailedToFetchPendingTransactions, + #[error("Solis: Assets are invalid on L2")] + SolisAssetFault, } impl StarknetApiError { @@ -110,6 +112,7 @@ impl StarknetApiError { StarknetApiError::UnsupportedContractClassVersion => 62, StarknetApiError::UnexpectedError { .. } => 63, StarknetApiError::ProofLimitExceeded => 10000, + StarknetApiError::SolisAssetFault => 7777, } } diff --git a/crates/katana/rpc/rpc/src/starknet.rs b/crates/katana/rpc/rpc/src/starknet.rs index a02ed30c48..797084da55 100644 --- a/crates/katana/rpc/rpc/src/starknet.rs +++ b/crates/katana/rpc/rpc/src/starknet.rs @@ -36,7 +36,7 @@ use katana_rpc_types::{ use katana_rpc_types_builder::ReceiptBuilder; use katana_tasks::{BlockingTaskPool, TokioTaskSpawner}; use starknet::core::types::{ - BlockTag, DeclareTransactionTrace, DeployAccountTransactionTrace, ExecuteInvocation, + BlockTag, BroadcastedInvokeTransaction, DeclareTransactionTrace, DeployAccountTransactionTrace, ExecuteInvocation, InvokeTransactionTrace, L1HandlerTransactionTrace, RevertedInvocation, SimulatedTransaction, TransactionExecutionStatus, TransactionStatus, TransactionTrace, }; @@ -675,6 +675,20 @@ impl StarknetApiServer for StarknetApi { &self, invoke_transaction: BroadcastedInvokeTx, ) -> RpcResult { + + if let Some(hooker) = &self.inner.sequencer.hooker { + let tx_clone = invoke_transaction.0.clone(); + match tx_clone { + BroadcastedInvokeTransaction::V3(tx) => { + if !hooker.read().await.verify_invoke_tx_before_pool(tx).await { + return Err(StarknetApiError::SolisAssetFault.into()); + } + }, + BroadcastedInvokeTransaction::V1(_tx) => { + return Err(StarknetApiError::UnsupportedTransactionVersion.into()); + } + } + } self.on_io_blocking_task(move |this| { if invoke_transaction.is_query() { return Err(StarknetApiError::UnsupportedTransactionVersion.into());