Skip to content

feat(discovery-service): add outgoing state sync endpoint - #483

Merged
m-kus merged 1 commit into
mainfrom
pr-split/15b-outgoing-endpoint
Feb 23, 2026
Merged

m-kus merged 1 commit into
mainfrom
pr-split/15b-outgoing-endpoint

Conversation

@m-kus

@m-kus m-kus commented Feb 13, 2026 •

Copy link
Copy Markdown

Add outgoing channel sync endpoint to discovery service

TL;DR

Implements the outgoing channel sync endpoint for the discovery service, allowing clients to discover all outgoing channels and subchannels for a sender.

What changed?

  • Added the /v1/sync/outgoing_state endpoint implementation in the discovery service
  • Updated the API specification in .claude/specs/discovery-service/06-api-design.md with detailed documentation for the endpoint
  • Added request/response types and validation logic for the new endpoint
  • Implemented integration tests for the outgoing sync endpoint

This change is Reviewable

@m-kus
m-kus force-pushed the pr-split/15a-incoming-endpoint branch from 411eaee to b2d5c0e Compare February 13, 2026 13:55
@m-kus
m-kus force-pushed the pr-split/15b-outgoing-endpoint branch from ccd50ba to b165d9e Compare February 13, 2026 13:55
@m-kus
m-kus force-pushed the pr-split/15a-incoming-endpoint branch from b2d5c0e to a7804d9 Compare February 16, 2026 15:15
@m-kus
m-kus force-pushed the pr-split/15b-outgoing-endpoint branch from b165d9e to 2bb638c Compare February 16, 2026 15:15
@m-kus
m-kus force-pushed the pr-split/15a-incoming-endpoint branch from a7804d9 to 69882e7 Compare February 16, 2026 16:21
@m-kus
m-kus force-pushed the pr-split/15b-outgoing-endpoint branch 2 times, most recently from 4fb91cb to cdd294e Compare February 16, 2026 16:42
@m-kus
m-kus force-pushed the pr-split/15a-incoming-endpoint branch from 69882e7 to 705f466 Compare February 16, 2026 16:42
@m-kus
m-kus force-pushed the pr-split/15b-outgoing-endpoint branch from cdd294e to 80a745f Compare February 16, 2026 17:08
@m-kus
m-kus force-pushed the pr-split/15a-incoming-endpoint branch from 705f466 to 50566ca Compare February 16, 2026 17:08

@Yoni-Starkware Yoni-Starkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Yoni-Starkware reviewed 2 files and all commit messages, and made 2 comments.
Reviewable status: 2 of 8 files reviewed, 2 unresolved discussions (waiting on m-kus).


crates/discovery-service/src/api/handlers.rs line 200 at r2 (raw file):

        block = %block_ref,
        "outgoing_sync request"
    );

Please share with the incoming_sync code

Code quote:

    validate_cursor(&request.cursor, &state.validation_limits)?;
    if let Some(ref recipients) = request.recipients {
        validate_recipients(recipients, &state.validation_limits)?;
    }
    let block_ref =
        validate_block_ref(request.last_known_block, request.block_ref, &state.backend).await?;
    let viewing_key = SecretFelt::new(request.viewing_key);

    let snapshot = state
        .backend
        .snapshot(request.contract_address, Some(BlockId::Hash(block_ref)))
        .await
        .map_err(|e| {
            warn!("Failed to create snapshot: {}", e);
            (
                StatusCode::INTERNAL_SERVER_ERROR,
                ApiErrorResponse::new(
                    error_codes::INTERNAL_ERROR,
                    format!("Failed to create snapshot: {}", e),
                ),
            )
        })?;

    let budget = IoBudget::new(state.validation_limits.server_budget);
    let cursor_limits = CursorLimits {
        max_channels: state.validation_limits.max_cursor_channels,
        max_subchannels: state.validation_limits.max_cursor_subchannels_per_channel,
    };

    debug!(
        sender = felt_hex(&request.sender_address),
        recipients = ?request.recipients.as_ref().map(|r| r.len()),
        block = %block_ref,
        "outgoing_sync request"
    );

crates/discovery-service/src/api/types.rs line 212 at r2 (raw file):

    /// response to continue discovery.
    #[serde(default)]
    pub cursor: DiscoveryCursor,

Please share with the incoming struct

Code quote:

pub struct OutgoingSyncRequest {
    /// The privacy pool contract address.
    pub contract_address: Felt,
    /// The sender's address.
    pub sender_address: Felt,
    /// The sender's private viewing key.
    pub viewing_key: Felt,
    /// Block hash for reorg detection. Set on first request of a new sync
    /// session to the `block_hash` from your last completed sync.
    /// Server returns 409 if this block was reorged out.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub last_known_block: Option<Felt>,
    /// Block hash to query state at. Ensures consistent reads across
    /// paginated requests. Leave empty on first request (server uses
    /// current head). On pagination, use the value from previous response.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub block_ref: Option<Felt>,
    /// Discovery cursor for pagination. Use the cursor from previous
    /// response to continue discovery.
    #[serde(default)]
    pub cursor: DiscoveryCursor,

@Yoni-Starkware Yoni-Starkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Yoni-Starkware made 1 comment.
Reviewable status: 2 of 8 files reviewed, 3 unresolved discussions (waiting on m-kus).


crates/discovery-service/tests/common/indexer.rs line 185 at r2 (raw file):

        let resp = reqwest::Client::new().post(&url).json(req).send().await?;

        let status = resp.status();

Please share

Code quote:

        let url = format!("http://{}/v1/sync/outgoing_state", self.api_host);
        let resp = reqwest::Client::new().post(&url).json(req).send().await?;

        let status = resp.status();

@m-kus
m-kus force-pushed the pr-split/15b-outgoing-endpoint branch from 727571e to 9234d68 Compare February 22, 2026 17:26
@m-kus
m-kus force-pushed the pr-split/15a-incoming-endpoint branch from 1587335 to 88732ed Compare February 22, 2026 17:26
@m-kus
m-kus force-pushed the pr-split/15b-outgoing-endpoint branch from 9234d68 to e4ec620 Compare February 22, 2026 18:19

@m-kus m-kus left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@m-kus resolved 3 discussions.
Reviewable status: 2 of 8 files reviewed, all discussions resolved (waiting on Yoni-Starkware).

@m-kus
m-kus requested a review from Yoni-Starkware February 22, 2026 18:20

@Yoni-Starkware Yoni-Starkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

:lgtm:

@Yoni-Starkware reviewed 6 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on m-kus).

@m-kus
m-kus force-pushed the pr-split/15a-incoming-endpoint branch from 88732ed to be5e372 Compare February 23, 2026 11:25
@m-kus
m-kus changed the base branch from pr-split/15a-incoming-endpoint to graphite-base/483 February 23, 2026 11:26
@m-kus
m-kus force-pushed the pr-split/15b-outgoing-endpoint branch from e4ec620 to fd64988 Compare February 23, 2026 11:31
@m-kus
m-kus force-pushed the graphite-base/483 branch from 88732ed to eb97939 Compare February 23, 2026 11:31
@m-kus
m-kus changed the base branch from graphite-base/483 to main February 23, 2026 11:31
@m-kus
m-kus enabled auto-merge (squash) February 23, 2026 11:34
@m-kus
m-kus force-pushed the pr-split/15b-outgoing-endpoint branch from fd64988 to 48e0e53 Compare February 23, 2026 11:34
@m-kus
m-kus merged commit c1bf8e3 into main Feb 23, 2026
6 checks passed
@m-kus
m-kus deleted the pr-split/15b-outgoing-endpoint branch February 23, 2026 11:36
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