Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(katana): retain transactions in pool until mined #2630

Merged
merged 5 commits into from
Nov 5, 2024

Conversation

kariy
Copy link
Member

@kariy kariy commented Nov 4, 2024

every block interval, the node would take transactions from the pool - removing it directly from the pool. this creates a small window (depending on the machine) that the transaction appears nonexistent. this is due to how the tx flows from the pool and executor. this applies for both instant and interval block production mode.

for instant mining, the window is between tx being picked up from the pool and the tx being committed to db. while for interval, tx being picked up from the pool and the tx being inserted into the pending block.

when a tx is being queried thru the rpc, the node will first check if the it exist in the db, else find in the pending block (if interval mode). this pr adds a new (last) step, which is to try finding the tx in the pool if it doesn't exist anywhere else.

Summary by CodeRabbit

  • New Features

    • Enhanced transaction management with the introduction of PendingTransactions and Subscription structures for improved handling of pending transactions.
    • Updated transaction retrieval methods in the Starknet API to utilize the transaction pool, enhancing robustness and error handling.
  • Bug Fixes

    • Improved control flow in transaction retrieval methods to provide fallback mechanisms when transactions are not found.
  • Documentation

    • Updated dependency management to include tokio for enhanced asynchronous capabilities.
  • Refactor

    • Renamed methods and updated structures for clarity and consistency in transaction handling within the pool.

@kariy kariy marked this pull request as draft November 4, 2024 21:50
coderabbitai[bot]

This comment was marked as abuse.

@kariy kariy marked this pull request as ready for review November 4, 2024 22:36
coderabbitai[bot]

This comment was marked as abuse.

@kariy kariy force-pushed the katana/retain-until-mined branch from bc83f1a to 85186b0 Compare November 5, 2024 21:11
@dojoengine dojoengine deleted a comment from coderabbitai bot Nov 5, 2024
Copy link

coderabbitai bot commented Nov 5, 2024

Walkthrough

Ohayo, sensei! This pull request introduces significant changes to the BlockProductionTask and TransactionMiner structures, incorporating generics to enhance type safety. The TransactionMiner now interacts with a new PendingTransactions type, which supports asynchronous transaction handling. Additionally, updates to the run_block_production method clarify how the miner subscribes to pending transactions. The Cargo.toml file has also been modified to refine dependency management, particularly for asynchronous programming. Overall, these changes improve transaction processing and management within the Katana framework.

Changes

File Path Change Summary
crates/katana/core/src/service/mod.rs Updated BlockProductionTask and TransactionMiner to include a new generic type O implementing PoolOrd. Modified constructors and poll methods accordingly.
crates/katana/pipeline/src/stage/sequencing.rs Altered run_block_production to instantiate TransactionMiner using self.pool.pending_transactions(). Updated BlockProductionTask instantiation.
crates/katana/pool/Cargo.toml Changed tokio dependency to include "sync" feature and added futures-util. Removed previous workspace dependency for tokio.
crates/katana/pool/src/lib.rs Added new modules pending and subscription. Updated TransactionPool methods, replacing take_transactions with pending_transactions and adding remove_transactions.
crates/katana/pool/src/ordering.rs Modified tests to use asynchronous methods for retrieving pending transactions.
crates/katana/pool/src/pending.rs Introduced PendingTransactions struct implementing Stream for yielding transactions. Added tests for transaction retrieval and stream behavior.
crates/katana/pool/src/pool.rs Added subscribers field to manage transaction notifications. Introduced notify_subscribers and notify methods. Replaced take_transactions with pending_transactions.
crates/katana/pool/src/subscription.rs Created Subscription struct implementing Stream for handling incoming transactions.
crates/katana/rpc/rpc/src/starknet/mod.rs Updated imports and modified transaction and transaction_status methods to include checks against the transaction pool for improved error handling.

Possibly related PRs

Suggested reviewers

  • steebchen: Recommended for review due to expertise in the relevant code areas.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Outside diff range and nitpick comments (11)
crates/katana/pool/src/lib.rs (2)

4-4: Ohayo sensei! New modules align well with the architecture.

The addition of pending and subscription modules provides a clean separation of concerns for managing transaction visibility and state tracking.

This modular approach will make it easier to:

  • Track transaction states throughout their lifecycle
  • Maintain visibility of transactions during mining
  • Handle subscription-based notifications of state changes

Also applies to: 6-6


15-15: Ohayo! Stream-based approach improves transaction handling.

The switch from PendingTx to PendingTransactions enables better transaction state management through streaming, which is crucial for maintaining transaction visibility during the mining process.

This change aligns perfectly with the PR's objective by ensuring transactions remain accessible until they're fully mined.

crates/katana/pipeline/src/stage/sequencing.rs (2)

56-59: Ohayo sensei! The changes align well with the PR objectives.

The switch to pending_transactions() instead of add_listener() effectively addresses the transaction visibility issue during mining. This ensures transactions remain queryable until they're fully mined.

Consider adding debug-level logging when transactions transition between states (pending → mining → mined) to aid in troubleshooting potential timing issues.


Line range hint 82-91: Enhance error logging for unexpected task completion.

The error logging could be more detailed to help with debugging production issues. Consider including task-specific context in the error messages.

-                error!(target: "pipeline", reason = ?res, "Messaging task finished unexpectedly.");
+                error!(target: "pipeline", reason = ?res, task = "messaging", "Task finished unexpectedly with configuration: {:?}", self.messaging_config);
-                error!(target: "pipeline", reason = ?res, "Block production task finished unexpectedly.");
+                error!(target: "pipeline", reason = ?res, task = "block_production", "Task finished unexpectedly with miner state");
crates/katana/pool/src/ordering.rs (1)

150-154: Consider improving test readability with collect, sensei!

While the async transformation looks good, we could make the test more readable by collecting the stream into a Vec first:

-let pendings = executor::block_on_stream(pool.pending_transactions());
-pendings.into_iter().zip(txs).for_each(|(pending, tx)| {
+let pendings = executor::block_on_stream(pool.pending_transactions()).collect::<Vec<_>>();
+pendings.into_iter().zip(txs).for_each(|(pending, tx)| {
    assert_eq!(pending.tx.as_ref(), &tx);
});
crates/katana/pool/src/subscription.rs (1)

13-16: Ohayo, sensei! Consider using an async mutex for txs.

Since the Subscription struct operates within asynchronous contexts, using a synchronous mutex (parking_lot::Mutex) may lead to blocking the thread. An asynchronous mutex like tokio::sync::Mutex is more suitable for this scenario.

Suggestion:

Update the mutex to tokio::sync::Mutex:

- use parking_lot::Mutex;
+ use tokio::sync::Mutex;

13  pub struct Subscription<T, O: PoolOrd> {
14      txs: Mutex<BTreeSet<PendingTx<T, O>>>,
15      receiver: mpsc::UnboundedReceiver<PendingTx<T, O>>,
16  }

Remember to adjust the locking calls accordingly:

- let mut txs = this.txs.lock();
+ let mut txs = this.txs.lock().await;

Note that since poll_next cannot be an async function (due to the Stream trait requirements), you may need to use tokio::sync::Mutex::blocking_lock() if necessary.

crates/katana/pool/src/pending.rs (3)

11-12: Fix duplicated word in documentation comment.

Ohayo, sensei! There's a minor typo in the documentation comment: the word "by" is duplicated in "sorted by by its priority."


91-91: Update comment to reference the correct batch.

Ohayo, sensei! The comment should refer to the "second batch" of transactions instead of the "first batch."


97-98: Correct grammar in comment.

Ohayo, sensei! The comment should say "transactions" instead of "transaction" to reflect the plural.

crates/katana/pool/src/pool.rs (2)

157-158: Address TODO: Implement Cache for Rejected Transactions

Ohayo, sensei! The TODO comment indicates the need to create a cache for rejected transactions to comply with the RPC spec for getTransactionStatus. Implementing this will allow clients to retrieve the status of rejected transactions as per the specification.

Would you like assistance in implementing the cache for rejected transactions, or should we open a new GitHub issue to track this task?


Line range hint 387-393: Update Test to Reflect Non-Destructive pending_transactions

Ohayo, sensei! The test pool_operations assumes that calling pending_transactions removes transactions from the pool. With the new implementation, transactions are not removed when retrieved. The assertions checking for an empty pool will fail. Please update the test to reflect the current behavior.

Here's the suggested change:

     // take all transactions
     let _ = pool.pending_transactions();

-    // all txs should've been removed
-    assert!(pool.size() == 0);
-    assert!(pool.inner.transactions.read().is_empty());
-    assert!(txs.iter().all(|tx| pool.get(tx.hash()).is_none()));
+    // transactions should still be in the pool
+    assert_eq!(pool.size(), txs.len());
+    assert!(!pool.inner.transactions.read().is_empty());
+    assert!(txs.iter().all(|tx| pool.get(tx.hash()).is_some()));
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8b2d976 and 85186b0.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • crates/katana/core/src/service/mod.rs (5 hunks)
  • crates/katana/pipeline/src/stage/sequencing.rs (1 hunks)
  • crates/katana/pool/Cargo.toml (1 hunks)
  • crates/katana/pool/src/lib.rs (4 hunks)
  • crates/katana/pool/src/ordering.rs (3 hunks)
  • crates/katana/pool/src/pending.rs (1 hunks)
  • crates/katana/pool/src/pool.rs (12 hunks)
  • crates/katana/pool/src/subscription.rs (1 hunks)
  • crates/katana/rpc/rpc/src/starknet/mod.rs (4 hunks)
🔇 Additional comments (19)
crates/katana/pool/Cargo.toml (2)

16-16: Ohayo! The tokio sync feature addition looks good, sensei!

The explicit inclusion of the "sync" feature is essential for the transaction pool management improvements, particularly for coordinating transaction visibility during mining.


20-20: The futures-util addition is well-placed, sensei!

Adding futures-util as a dev dependency is appropriate for testing the async transaction handling. Let's verify its usage:

✅ Verification successful

Ohayo! The futures-util dependency is perfectly placed and used correctly, sensei!

The verification confirms that:

  • futures-util is correctly added as a dev-dependency in Cargo.toml
  • It's being used in testing code within pending.rs for poll assertions
  • The dependency placement aligns with its test-focused usage
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of futures-util in tests
# Expected: Find test files using futures-util utilities

rg -t rust "use futures_util" crates/katana/pool/src

Length of output: 54


Script:

#!/bin/bash
# Let's check for any futures-util usage patterns more broadly
rg -t rust "futures_util::" crates/katana/pool/src

# Also check if it's used in tests directory specifically
rg -t rust "futures_util" crates/katana/pool/src/tests

# Let's see what test files exist to understand the structure
fd . crates/katana/pool/src/tests

# Check the Cargo.toml to see if it's actually a dev-dependency
cat crates/katana/pool/Cargo.toml

Length of output: 1019

crates/katana/pool/src/lib.rs (2)

50-52: Ohayo! Well-documented streaming interface.

The new pending_transactions method with its clear documentation explains the streaming behavior, which is essential for maintaining transaction visibility during mining.


62-64: Documentation and error handling still needed.

The previous review comment about adding documentation and error handling for remove_transactions is still applicable.

crates/katana/pipeline/src/stage/sequencing.rs (1)

56-59: Verify error handling for pending transactions stream.

The pending transactions stream should be resilient to temporary disruptions.

Let's check how errors are handled in the pending transactions implementation:

✅ Verification successful

Let me search for more specific error handling implementation in the pending transactions stream.


Let me check one more aspect of the implementation to see how the subscription part works when the iterator is exhausted.


Let me check one final aspect - the error handling in the transaction pool implementation.


Let me check one final aspect of the implementation - specifically the poll_next method.


Ohayo sensei! After analyzing the pending transactions implementation, I can now provide a conclusive response.

The pending transactions stream implementation is properly resilient to disruptions.

The implementation shows a robust two-phase approach:

  • First phase uses an iterator over existing transactions (this.all.next())
  • If exhausted, it falls back to subscription-based polling (this.subscription.poll_next_unpin(cx))

The error handling is comprehensive:

  • Pool-level errors are properly categorized and handled via PoolError enum
  • Transaction validation errors are propagated through PoolResult
  • Stream implementation gracefully handles transitions between phases
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for error handling in pending transactions implementation
rg -A 5 "pending_transactions|PendingTransactions" 

Length of output: 16113


Script:

#!/bin/bash
# Search for error handling in the pending transactions stream implementation
ast-grep --pattern 'impl$$$Stream for PendingTransactions$$$'

# Also check the implementation details
rg -A 10 "impl.*Stream.*PendingTransactions"

Length of output: 835


Script:

#!/bin/bash
# Search for the full implementation of poll_next and subscription handling
rg -A 20 "fn poll_next.*PendingTransactions"

# Also check the Subscription implementation
rg -A 10 "impl.*Subscription"

Length of output: 1442


Script:

#!/bin/bash
# Search for error handling in the pool implementation
rg -A 10 "PoolError|PoolResult"

# Also check the full implementation of poll_next for PendingTransactions
ast-grep --pattern 'fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'\''_'\'\'>) -> Poll<Option<Self::Item>> {
  $$$
}'

Length of output: 7986


Script:

#!/bin/bash
# Search for the poll_next implementation in pending.rs
rg -A 15 "fn poll_next.*self: Pin<&mut Self>, cx: &mut Context" crates/katana/pool/src/pending.rs

Length of output: 491

crates/katana/pool/src/ordering.rs (3)

128-129: Ohayo sensei! The futures executor import looks good!

The addition of futures::executor is necessary for the new async transaction handling approach, aligning well with the PR's objective of improving transaction visibility during mining.


182-182: Excellent implementation of async transaction collection, sensei!

The use of block_on_stream with immediate collection to Vec is clean and maintains the thorough verification of tip-based ordering. The implementation aligns perfectly with the PR's goal of improving transaction handling.


Line range hint 128-182: Verify consistent usage of async transaction handling across tests

Let's ensure all test files have been updated to use the new async pattern consistently.

✅ Verification successful

The previous results show the migration to async, but we need to verify the actual implementations and test patterns to ensure consistency. This will help us confirm if all test files are properly using the async pattern.


Async transaction handling is consistently implemented across the codebase

The verification shows that:

  • All transaction handling uses the new async pattern via pending_transactions()
  • No instances of old synchronous take_transactions() were found
  • The async implementation is consistently used across:
    • Pool implementation (pool.rs)
    • Transaction ordering (ordering.rs)
    • Pipeline sequencing (sequencing.rs)
    • RPC interfaces (dev.rs, torii.rs)
    • Test files properly use block_on_stream for async handling
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent usage of async transaction handling in tests
# Look for any remaining synchronous transaction collection patterns that might have been missed

# Search for old synchronous patterns
echo "Checking for potential remaining synchronous transaction collection patterns..."
rg -l 'take_transactions\(\)' 'crates/katana'

# Search for new async patterns to verify consistent implementation
echo "Verifying consistent async implementation..."
rg -l 'pending_transactions\(\)' 'crates/katana'

Length of output: 542


Script:

#!/bin/bash
# Let's examine the implementation of pending_transactions() to verify consistency
echo "Checking pending_transactions implementations..."
rg -A 5 'pending_transactions' crates/katana

# Let's also check for any test files to ensure they're using the async pattern
echo -e "\nChecking test files for transaction handling patterns..."
fd -e rs test crates/katana -x rg -l 'transactions|pending' {}

Length of output: 10558

crates/katana/core/src/service/mod.rs (2)

30-34: Generics Enhance Flexibility of BlockProductionTask

Ohayo, sensei! The introduction of generics EF and O in the BlockProductionTask struct, with constraints EF: ExecutorFactory and O: PoolOrd<Transaction = ExecutableTxWithHash>, improves the flexibility and type safety of the code by allowing different executor factories and transaction ordering strategies.


83-83: Verify Correct Timing of Transaction Removal

Ohayo, sensei! At line 83, the code removes mined transactions from the pool using this.pool.remove_transactions(&outcome.txs);. Given the PR's goal to reduce visibility gaps by retaining transactions until they are fully mined, please verify that this removal doesn't reintroduce the issue by ensuring transactions are only removed after they are fully committed.

crates/katana/pool/src/pending.rs (3)

14-20: PendingTransactions struct is well-defined.

Ohayo, sensei! The struct definition is clear and encapsulates the necessary fields with proper visibility.


22-37: Implementation of Stream trait is correct.

Ohayo, sensei! The poll_next method correctly implements the Stream trait, efficiently handling pending transactions and new subscriptions.


105-138: subscription_stream_wakeup test is effective and well-structured.

Ohayo, sensei! The test accurately verifies that the stream wakes up when new transactions are added, ensuring correct asynchronous behavior.

crates/katana/pool/src/pool.rs (2)

185-189: Potential Performance Issue in pending_transactions Method

Ohayo, sensei! Cloning all transactions in pending_transactions with self.inner.transactions.read().clone() could be inefficient for large pools. This may lead to high memory usage and slow performance. As previously noted, consider iterating over references or using a more efficient data structure to avoid cloning the entire set.


428-462: Tests for remove_transactions Method Look Good

Ohayo, sensei! The added tests for the remove_transactions method are comprehensive and effectively verify that transactions are correctly removed from the pool.

crates/katana/rpc/rpc/src/starknet/mod.rs (4)

15-15: Ohayo sensei! Importing TransactionPool Correctly

The addition of TransactionPool to the import statement is appropriate and necessary for the updated transaction handling logic.


26-26: Ohayo sensei! Including TxWithHash for Enhanced Transaction Information

The inclusion of TxWithHash in the imports supports improved transaction handling by providing more detailed transaction information.


568-569: Ohayo sensei! Consistent Transaction Status Retrieval from Pool

The code appropriately checks the transaction pool when a transaction hash is not found elsewhere and returns TransactionStatus::Received if it exists in the pool.


434-436: Ohayo sensei! Ensure Correct Conversion of Transactions from Pool

The code correctly retrieves the transaction from the pool when it's not found elsewhere and converts it using TxWithHash::from(tx.as_ref()). To ensure type correctness and prevent potential issues with references, please verify that the usage of as_ref() is necessary.

Run the following script to inspect the types and confirm that tx.as_ref() aligns with the expected input for TxWithHash::from:

✅ Verification successful

Ohayo sensei! Usage of as_ref() is Correct and Necessary

The as_ref() usage is correct because:

  • The pool returns Option<Arc<ExecutableTxWithHash>>
  • TxWithHash::from is implemented for both owned and referenced ExecutableTxWithHash
  • The ExecutableTxWithHash struct has #[derive(AsRef)], making as_ref() a valid operation
  • Using as_ref() avoids unnecessary cloning of the Arc-wrapped transaction
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the types involved in transaction retrieval and conversion.

# Expected: `tx` is of a type that, after applying `as_ref()`, matches the expected input for `TxWithHash::from`.

# Check the return type of `self.inner.pool.get(hash)`
rg -A 2 'fn get\(&self, hash: TxHash\) -> Option\<(?P<type>.+)\>' crates/katana/pool/src/lib.rs

# Check the implementation of `From` trait for `TxWithHash`
rg -A 2 'impl From<&(?P<source_type>.+)> for TxWithHash' crates/katana_primitives/transaction.rs

Length of output: 437


Script:

#!/bin/bash
# Let's fix the regex and search for the correct files

# Check the return type of pool.get()
rg -A 2 'fn get.*TxHash.*Option' crates/katana/pool/src/

# Check From implementation for TxWithHash
fd -e rs transaction.rs
rg -A 2 'impl From.*for TxWithHash' 

Length of output: 1647


Script:

#!/bin/bash
# Let's check the actual type definitions and implementations

# Check the Transaction type in pool
rg -B 2 'type Transaction' crates/katana/pool/src/lib.rs

# Check ExecutableTxWithHash definition
rg -A 5 'struct ExecutableTxWithHash' crates/katana/primitives/src/transaction.rs

# Check if there are any other From implementations for TxWithHash
rg 'impl.*From.*TxWithHash' crates/katana/primitives/src/transaction.rs

Length of output: 568


Script:

#!/bin/bash
# Let's check the pool's transaction type and its implementation

# Check the actual transaction type returned by the pool
rg -A 5 'pub struct Pool' crates/katana/pool/src/pool.rs

# Check the implementation of PoolTransaction trait
rg -A 5 'impl PoolTransaction' crates/katana/pool/src/

# Check the full ExecutableTxWithHash struct and its traits
rg -B 5 -A 10 'struct ExecutableTxWithHash' crates/katana/primitives/src/transaction.rs

Length of output: 1439

crates/katana/pool/src/subscription.rs Show resolved Hide resolved
crates/katana/core/src/service/mod.rs Show resolved Hide resolved
crates/katana/pool/src/pool.rs Show resolved Hide resolved
crates/katana/pool/src/pool.rs Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
crates/katana/pool/src/pool.rs (2)

157-158: Implement rejected transactions cache for RPC spec compliance.

Ohayo, sensei! The TODO comment indicates a need for a rejected transactions cache to comply with the RPC spec's getTransactionStatus requirements. I can help implement this feature.

Would you like me to help implement the rejected transactions cache? I can:

  1. Design a time-based LRU cache for rejected transactions
  2. Integrate it with the getTransactionStatus RPC endpoint
  3. Add appropriate tests

430-462: Enhance test coverage with edge cases.

Ohayo, sensei! While the current tests are good, consider adding these edge cases:

  1. Removing non-existent transactions
  2. Removing an empty list of transactions
  3. Removing transactions while subscribers are active
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 85186b0 and 7fb575f.

📒 Files selected for processing (2)
  • crates/katana/pool/src/ordering.rs (3 hunks)
  • crates/katana/pool/src/pool.rs (12 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/katana/pool/src/ordering.rs
🔇 Additional comments (3)
crates/katana/pool/src/pool.rs (3)

8-8: LGTM! Well-structured subscriber management implementation.

The addition of async channels and subscription types provides a solid foundation for transaction retention.

Also applies to: 12-13, 37-39, 60-60


93-116: Previous review comment about cloning optimization is still valid.


214-218: Previous review comment about HashSet optimization is still valid.

crates/katana/pool/src/pool.rs Show resolved Hide resolved
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 93.87755% with 15 lines in your changes missing coverage. Please review.

Project coverage is 57.09%. Comparing base (8b2d976) to head (7fb575f).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
crates/katana/pool/src/pool.rs 88.60% 9 Missing ⚠️
crates/katana/rpc/rpc/src/starknet/mod.rs 0.00% 5 Missing ⚠️
crates/katana/pool/src/subscription.rs 95.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2630      +/-   ##
==========================================
+ Coverage   56.90%   57.09%   +0.18%     
==========================================
  Files         397      399       +2     
  Lines       49461    49661     +200     
==========================================
+ Hits        28148    28355     +207     
+ Misses      21313    21306       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants