Skip to content

Conversation

@NiravJoshi33
Copy link

Fixes Issue #242

Implements the missing mentions field filtering in the logsSubscribe/logsUnsubscribe WebSocket functionality.

  • I have implemented filter logic in notify_logs_subscribers method
  • It now supports All, AllWithVotes, and Mentions(Vec<String>) filters
  • Early continue when commitment level doesn't match

Next Steps: Tests covering different behaviors of this feature.

Feedback is very much welcomed. Happy to iterate on the approach before investing time in tests.

@NiravJoshi33
Copy link
Author

Hi,

I am excited to contribute to Surfpool. This is my first Rust PR, so I have focused on getting the core logic right before writing tests.

I'd especially appreciate feedback on:

  • My understanding of the transaction structure
  • Rust idioms and performance considerations
  • Any preferred testing patterns for WebSocket subscription features

I am ready to quickly iterate based on your feedback.

@MicaiahReid
Copy link
Member

This is awesome, @NiravJoshi33! The logic looks great, with some clean rust patterns! Well done!

I'm realizing we don't actually have tests for WS RPC methods yet. Would you want to tackle the first ones?

Our integration.rs file has examples of setting up tests and invoking regular RPC methods. At the bottom of the file I've pushed the test test_ws_scaffold, which should do the basic set up of the test for you!

@MicaiahReid
Copy link
Member

Ah, actually I couldn't push to your fork! You can enable me pushing, or this is the fn I added to the bottom of integration.rs

#[tokio::test(flavor = "multi_thread")]
async fn test_ws_scaffold() {
    use std::sync::RwLock as StdRwLock;
    let (svm_instance, _simnet_events_rx, _geyser_events_rx) = SurfnetSvm::new();

    let svm_locker = SurfnetSvmLocker::new(svm_instance);

    let runtime = tokio::runtime::Builder::new_multi_thread()
        .enable_all()
        .build()
        .expect("Failed to build Tokio runtime");

    let tokio_handle = runtime.handle();

    let uid = std::sync::atomic::AtomicUsize::new(0);
    let ws_server = crate::rpc::ws::SurfpoolWsRpc {
        uid,
        signature_subscription_map: Arc::new(StdRwLock::new(HashMap::new())),
        account_subscription_map: Arc::new(StdRwLock::new(HashMap::new())),
        slot_subscription_map: Arc::new(StdRwLock::new(HashMap::new())),
        logs_subscription_map: Arc::new(StdRwLock::new(HashMap::new())),
        tokio_handle: tokio_handle.clone(),
    };

    // subscribe to a method you want to test
    // use the svm_locker to write to the vm and/or trigger events
}

@NiravJoshi33
Copy link
Author

Thanks so much @MicaiahReid! Really appreciate the feedback and the test scaffold. 🙏

I'll check the test scaffold and study existing patterns, and start working on the tests.

Thanks for the opportunity to work on something foundational.

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