Skip to content

feat(ethexe/rpc): Add streaming subscription for all ethexe promises to RPC#5604

Open
vobradovich wants to merge 10 commits into
masterfrom
vo/ethexe-rpc-subscribe-promises
Open

feat(ethexe/rpc): Add streaming subscription for all ethexe promises to RPC#5604
vobradovich wants to merge 10 commits into
masterfrom
vo/ethexe-rpc-subscribe-promises

Conversation

@vobradovich

@vobradovich vobradovich commented Jun 25, 2026

Copy link
Copy Markdown
Member

Closes #5165

Summary

Adds the injected_subscribePromises / injected_unsubscribePromises JSON-RPC subscription to ethexe-rpc.

Clients receive newly computed PromiseEnvelope values containing:

  • the computed Promise
  • destination program
  • transaction sender

Subscriptions support optional server-side filtering by sender, destination, and reply code.

New API

injected_subscribePromises(
  filter?: PromiseSubscriptionFilter
) → Subscription<PromiseEnvelope>

PromiseEnvelope:

pub struct PromiseEnvelope {
    pub promise: Promise,
    pub destination: ActorId,
    pub sender: Address,
}

The filter supports:

  • sender: one address or an array of addresses
  • destination: one actor ID or an array of actor IDs
  • replyCode:
    • { "type": "success" }
    • { "type": "error" }
    • { "type": "exact", "code": "0x00010000" }

Values within one array use OR semantics. Different filter fields use AND semantics. Omitted or empty fields act as wildcards. Malformed exact reply codes are rejected during deserialization.

Architecture

  • filter.rs defines PromiseEnvelope, filter builders, serde behavior, and matching.
  • PromiseSubscriptionManager enriches each computed promise once from the stored signed transaction and broadcasts a shared Arc<PromiseEnvelope>.
  • Each subscriber applies its own filter before forwarding the envelope to its WebSocket sink.
  • The broadcast receiver is created before accepting the subscription, preventing promises from being missed during the accept round-trip.
  • Lagged subscriptions are closed because dropped promises cannot be recovered from this stream.
  • Historical promises are not replayed.

If the originating signed transaction is absent from the database, the promise remains persisted for receipt processing, but no global envelope is broadcast.

How to test

Set-Location ethexe
cargo nextest run -p ethexe-rpc --features client

Coverage includes:

  • scalar and array filter serialization
  • empty wildcard round-trips
  • sender, destination, and reply-code matching
  • exact reply-code validation
  • promise enrichment and missing-transaction behavior
  • unfiltered WebSocket delivery
  • reply-code filtering over WebSocket
  • sender and destination filtering over WebSocket

Checklist

  • PR title follows Conventional Commits
  • Single logical change
  • Tests added or updated
  • Public API and behavior documented

@vobradovich vobradovich linked an issue Jun 25, 2026 that may be closed by this pull request
@vobradovich vobradovich self-assigned this Jun 25, 2026
@vobradovich vobradovich added scope: vara.eth Vara Ethereum application layer (L2) ai-generated Created entirely by an AI agent without direct human authorship labels Jun 25, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the ethexe-rpc crate by enabling real-time streaming of computed promises. By utilizing a broadcast-based architecture, the system now supports long-lived WebSocket subscriptions, allowing clients to receive updates as they occur. The implementation includes a flexible filtering mechanism, enabling clients to selectively subscribe to specific promise outcomes, thereby optimizing bandwidth and client-side processing.

Highlights

  • New RPC Subscription: Introduced injected_subscribePromises and injected_unsubscribePromises to allow clients to stream computed promises over WebSockets.
  • Server-Side Filtering: Added a configurable PromiseSubscriptionFilter that supports filtering by reply code (Success, Error, or Exact hex match) to reduce unnecessary network traffic.
  • Broadcast Architecture: Implemented a tokio::sync::broadcast channel in PromiseSubscriptionManager to efficiently fan out promises to multiple subscribers.
  • Testing: Added comprehensive unit tests for filter logic and integration tests to verify end-to-end WebSocket promise delivery.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request implements server-side filtering for the subscribe_promises RPC subscription in ethexe, allowing clients to filter computed promises by reply code (Success, Error, or an exact hex code). It introduces the PromiseSubscriptionFilter and ReplyCodeFilter types, integrates a global broadcast channel into the PromiseSubscriptionManager, and spawns background tasks to drive subscriptions. Feedback suggests optimizing the promise broadcast by checking the receiver count before cloning the promise payload, and simplifying the hex parsing logic by validating ASCII hex digits upfront to avoid UTF-8 decoding overhead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread ethexe/rpc/src/apis/injected/promise_manager.rs Outdated
Comment thread ethexe/rpc/src/apis/injected/filter.rs Outdated
@vobradovich
vobradovich requested review from ark0f and breathx and removed request for ark0f and breathx June 25, 2026 21:24
Comment thread ethexe/rpc/src/apis/injected/filter.rs Outdated
Comment thread ethexe/rpc/src/apis/injected/filter.rs Outdated
Comment thread ethexe/rpc/common/src/filter.rs
@vobradovich

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request implements the subscribe_promises JSON-RPC subscription for the ethexe RPC layer, allowing clients to subscribe to a stream of newly computed promises. It introduces a filtering mechanism (PromiseSubscriptionFilter) to filter promises by sender, destination, and reply code, and utilizes a broadcast channel to fan out computed promises to active subscribers. Comprehensive tests are added to verify the subscription, filtering, and broadcast behavior. The reviewer suggests a minor improvement in filter.rs to use T: Deserialize<'de> instead of T: serde::de::DeserializeOwned for the FilterSet deserialization implementation to make it more idiomatic and flexible.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread ethexe/rpc/common/src/filter.rs
@vobradovich
vobradovich requested a review from ecol-master June 30, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Created entirely by an AI agent without direct human authorship scope: vara.eth Vara Ethereum application layer (L2)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add streaming subscription for all ethexe promises to RPC

3 participants