Skip to content

add grpc backed EventSubscriber and example #165

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

Merged
merged 5 commits into from
May 23, 2025
Merged

Conversation

wphan
Copy link
Member

@wphan wphan commented May 9, 2025

  • adds EventSubscriber::subscribe_grpc to start an EventSubscriber backed by yellowstone grpc
  • starts a new connection to the grpc server
  • hard coded to confirmed commitment, may want to bubble this up to the user

closes #154


let raw_event_tx_clone = raw_event_tx.clone();
grpc.on_transaction(Box::new(move |tx_update: TransactionUpdate| {
raw_event_tx_clone.try_send(tx_update).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it possible to handle the update inline here? maybe then can pass TransactionUpdate by ref

Suggested change
raw_event_tx_clone.try_send(tx_update).unwrap();
let start = std::time::Instant::now();
let slot = event.slot;
self.process_log(event).await;
let elapsed = start.elapsed();
debug!(target: "grpc", "transaction slot: {}, len: {} callbacks took {:?}", slot, raw_event_rx.len(), elapsed);

Copy link
Member Author

Choose a reason for hiding this comment

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

couldn't get this to work since process_log is async. Maybe i should change grpc.on_transaction to take async callbacks?

Comment on lines +409 to +429
let tx = match tx_update.transaction {
Some(ref tx) => tx,
None => {
warn!(target: "grpc", "empty transaction update: {tx_update:?}");
continue;
}
};
let transaction = match tx.transaction {
Some(ref tx) => tx,
None => {
warn!(target: "grpc", "empty transaction update: {tx_update:?}");
continue;
}
};
let meta = match tx.meta {
Some(ref meta) => meta,
None => {
warn!(target: "grpc", "empty transaction meta: {tx_update:?}");
continue;
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

wondering what happens if valid tx but has no meta? not sure if that'll happen in practice

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah i dont think it'll happen in practice, but i feel it's safer to check. I saw a surprising number of tx logs without signatures (11111...) from websocket, but none were like that from grpc

Copy link
Collaborator

@jordy25519 jordy25519 left a comment

Choose a reason for hiding this comment

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

lgtm, we can always optimize the little things if we need to later

@wphan wphan merged commit 892d571 into main May 23, 2025
1 check failed
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.

gRPC support tx events
2 participants