From 4db8ae0c89ebbb750f75c0425e78e378363a37e0 Mon Sep 17 00:00:00 2001 From: Ammar Arif Date: Wed, 19 Jun 2024 16:36:39 -0400 Subject: [PATCH] fix(katana-rpc): only include successful transactions in pending block (#2082) Only include successful transactions in pending block --- crates/katana/rpc/rpc/src/starknet.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/katana/rpc/rpc/src/starknet.rs b/crates/katana/rpc/rpc/src/starknet.rs index 4bc8e544a7..603dcff366 100644 --- a/crates/katana/rpc/rpc/src/starknet.rs +++ b/crates/katana/rpc/rpc/src/starknet.rs @@ -228,10 +228,16 @@ impl StarknetApiServer for StarknetApi { sequencer_address: block_env.sequencer_address, }; + // TODO(kariy): create a method that can perform this filtering for us instead + // of doing it manually. + + // A block should only include successful transactions, we filter out the failed + // ones (didn't pass validation stage). let transactions = executor .read() .transactions() .iter() + .filter(|(_, receipt)| receipt.is_success()) .map(|(tx, _)| tx.hash) .collect::>(); @@ -307,10 +313,16 @@ impl StarknetApiServer for StarknetApi { sequencer_address: block_env.sequencer_address, }; + // TODO(kariy): create a method that can perform this filtering for us instead + // of doing it manually. + + // A block should only include successful transactions, we filter out the failed + // ones (didn't pass validation stage). let transactions = executor .read() .transactions() .iter() + .filter(|(_, receipt)| receipt.is_success()) .map(|(tx, _)| tx.clone()) .collect::>();