Skip to content

fix: paginated calls of thousands of charges took to long#72

Merged
sqhell merged 1 commit into
mainfrom
fix/billing-topup-api-fix
May 6, 2026
Merged

fix: paginated calls of thousands of charges took to long#72
sqhell merged 1 commit into
mainfrom
fix/billing-topup-api-fix

Conversation

@sqhell
Copy link
Copy Markdown
Contributor

@sqhell sqhell commented May 6, 2026

No description provided.

@sqhell sqhell merged commit 3e14b03 into main May 6, 2026
@sqhell sqhell deleted the fix/billing-topup-api-fix branch May 6, 2026 16:13
Copy link
Copy Markdown
Contributor

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

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 removes the get_chain_balance call from the create_billing_credit endpoint to prevent timeouts caused by inefficient history scans. While this change avoids the timeout during credit creation, feedback indicates that the underlying performance bottleneck persists in other areas, such as the balance retrieval endpoint and tool call handler. It is recommended to optimize the balance calculation logic, potentially by caching the last processed offset, to address the systemic performance issue.

I am having trouble creating individual review comments. Click here to see my feedback.

src/canton_mcp_server/server.py (1418-1422)

high

While removing the get_chain_balance call from this endpoint prevents the timeout during credit creation, the underlying performance issue remains. The get_chain_balance function (and the GET /billing/balance/{party_id} endpoint) will still encounter the same ~30s timeout because it performs a full O(N) scan of the provider's update history starting from offset 0. This means clients will still be unable to retrieve their balance. Furthermore, the same bottleneck exists in handle_tool_call_request (line 358), which will cause tool calls to timeout for busy users. A more robust fix would involve optimizing the balance calculation in canton_billing.py, for example by caching the last processed offset or using a more efficient query mechanism.

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.

1 participant