Repository navigation
feat(discovery-service): add outgoing state sync endpoint - #483
Conversation
411eaee to
b2d5c0e
Compare
ccd50ba to
b165d9e
Compare
b2d5c0e to
a7804d9
Compare
b165d9e to
2bb638c
Compare
a7804d9 to
69882e7
Compare
4fb91cb to
cdd294e
Compare
69882e7 to
705f466
Compare
cdd294e to
80a745f
Compare
705f466 to
50566ca
Compare
f451ef1 to
ee90f5d
Compare
51842a1 to
69a1b9c
Compare
4360012 to
727571e
Compare
69a1b9c to
1587335
Compare
Yoni-Starkware
left a comment
There was a problem hiding this comment.
@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
left a comment
There was a problem hiding this comment.
@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();727571e to
9234d68
Compare
1587335 to
88732ed
Compare
9234d68 to
e4ec620
Compare
m-kus
left a comment
There was a problem hiding this comment.
@m-kus resolved 3 discussions.
Reviewable status: 2 of 8 files reviewed, all discussions resolved (waiting on Yoni-Starkware).
Yoni-Starkware
left a comment
There was a problem hiding this comment.
@Yoni-Starkware reviewed 6 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on m-kus).
88732ed to
be5e372
Compare
e4ec620 to
fd64988
Compare
88732ed to
eb97939
Compare
fd64988 to
48e0e53
Compare

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?
/v1/sync/outgoing_stateendpoint implementation in the discovery service.claude/specs/discovery-service/06-api-design.mdwith detailed documentation for the endpointThis change is