Solana subscriptions - #41
Merged
Merged
Conversation
nfurfaro
force-pushed
the
furnic/solana-subscriptions
branch
from
October 21, 2025 22:59
75ba248 to
4e3b871
Compare
freesig
reviewed
Oct 22, 2025
freesig
reviewed
Oct 22, 2025
freesig
left a comment
Collaborator
There was a problem hiding this comment.
Nice work there's a lot that went into this. Just a few suggestions
nfurfaro
force-pushed
the
furnic/solana-subscriptions
branch
2 times, most recently
from
October 22, 2025 16:51
6e9e647 to
ca9e424
Compare
WIP: work on getting solana logs using websockets <!-- ps-id: 2fa6abec-1050-4722-b43c-e77ce700ba16 -->
<!-- ps-id: a5ad8543-5885-4d10-a898-e7414710422f -->
<!-- ps-id: f5d4915c-e74c-477d-a6a8-ae8d768ccbbe -->
<!-- ps-id: 6cd37234-2a41-4af6-9f39-83b7b8259d82 -->
chore: put solana stuff behind feature flag refactor: use async-stream <!-- ps-id: 7398871c-c74e-4612-93d0-a66961d12b08 -->
nfurfaro
force-pushed
the
furnic/solana-subscriptions
branch
from
October 22, 2025 16:52
ca9e424 to
adb937f
Compare
freesig
approved these changes
Oct 22, 2025
freesig
left a comment
Collaborator
There was a problem hiding this comment.
Nice work. Awesome to see this land
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the ability for apps to subscribe to logs from Solana programs. Due to a limitation of the solana rpc method
logsSubscribe, only a single program may be targeted per rpc request.To work around this, weopen a single websocket per void subscription, but are then able to subscribe to multiple solana programs over the single connection.
Features enabled by this work include:
query/solana_program_logs/tests.rs).query/solana_program_logs/tests.rs).oracle/tests/query_multi_chain.rs).Notes
logsSubscribe
The Solana PubsubClient.logs_subscribe() method returns (BoxStream<'a, T>, UnsubscribeFn)
where the stream borrows from the client with lifetime 'a. This means we cannot return
the stream from an async block that owns the client, as the borrow checker prevents
returning a value that references local data.
Unlike alloy's subscribe_logs() which returns an owned subscription that can be converted
into a stream with .into_stream(), Solana's API ties the stream lifetime to the client.
To work around this, we spawn a separate task that owns both the client and the stream,
and use a tokio mpsc channel to forward events to a ReceiverStream that we can safely return.
Multiple Program Subscription Architecture
When subscribing to multiple programs, this implementation:
This approach is efficient because:
Note: The Solana RpcTransactionLogsFilter::Mentions(vec![...]) uses AND semantics
(transaction must mention ALL addresses), so we need separate subscriptions to achieve
OR semantics (transaction mentioning ANY of our programs).
closes #28
closes #29
closes #30