Skip to content

Commit

Permalink
starknet: add call to verify_invoke_tx_before_pool
Browse files Browse the repository at this point in the history
  • Loading branch information
ybensacq committed May 22, 2024
1 parent b219de6 commit 0fb79ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions crates/katana/rpc/rpc-types/src/error/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -110,6 +112,7 @@ impl StarknetApiError {
StarknetApiError::UnsupportedContractClassVersion => 62,
StarknetApiError::UnexpectedError { .. } => 63,
StarknetApiError::ProofLimitExceeded => 10000,
StarknetApiError::SolisAssetFault => 7777,
}
}

Expand Down
16 changes: 15 additions & 1 deletion crates/katana/rpc/rpc/src/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -675,6 +675,20 @@ impl<EF: ExecutorFactory> StarknetApiServer for StarknetApi<EF> {
&self,
invoke_transaction: BroadcastedInvokeTx,
) -> RpcResult<InvokeTxResult> {

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());
Expand Down

0 comments on commit 0fb79ec

Please sign in to comment.