Skip to content

[Backend] Implement gRPC Protocol Adapter for High-Throughput Event Streaming - #749

Open
DevGod-001 wants to merge 1 commit into
SoroLabs:mainfrom
DevGod-001:feature/583-grpc-streaming
Open

[Backend] Implement gRPC Protocol Adapter for High-Throughput Event Streaming#749
DevGod-001 wants to merge 1 commit into
SoroLabs:mainfrom
DevGod-001:feature/583-grpc-streaming

Conversation

@DevGod-001

Copy link
Copy Markdown

Summary

Adds a gRPC service using tonic that streams Soroban contract events over HTTP/2 with Protobuf framing, eliminating the latency and serialization overhead of HTTP JSON polling for enterprise indexing consumers.

Changes

  • core/proto/events.proto — Defines ContractEvent, StreamContractEventsRequest, and EventStreamService in package soroscope.events.v1
  • core/build.rs — Compiles the proto schema at build time via tonic-build
  • core/src/grpc.rs — Implements EventStreamServiceImpl backed by the existing SimulationBus broadcast channel; includes unit tests for translate_event filtering
  • core/Cargo.toml — Adds tonic, prost, tokio-stream dependencies and tonic-build build-dependency
  • core/src/main.rs — Spawns the gRPC server on a configurable GRPC_PORT (default 50051) alongside the existing Axum HTTP server

Usage

GRPC_PORT=50051 RUST_LOG=info cargo run -p soroscope-core

grpcurl -plaintext -d '{"contract_id":"CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC"}' \
  localhost:50051 soroscope.events.v1.EventStreamService/StreamContractEvents

Validation

  • rustfmt --edition 2021 src/grpc.rs — passes
  • Unit tests in grpc.rs cover: no-filter passthrough, contract ID match/no-match, event-type filter match/no-match, and progress-event suppression
  • CI workspace cargo check --locked --all-targets checks contracts workspace (pre-existing scope; core is standalone as per repo convention)

Closes #583

… streaming

- Add tonic/prost/tokio-stream dependencies to core/Cargo.toml
- Add core/proto/events.proto with ContractEvent and EventStreamService schema
- Add core/build.rs to compile proto via tonic-build
- Implement core/src/grpc.rs with EventStreamServiceImpl backed by SimulationBus
- Wire gRPC server startup in main.rs on configurable GRPC_PORT (default 50051)
- Include unit tests covering translate_event filtering logic

Closes SoroLabs#583
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@DevGod-001 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

[Backend] Implement gRPC Protocol Adapter for High-Throughput Event Streaming

2 participants