Skip to content

fix(client): split rejected RPC batches#117

Open
cesarenaldi wants to merge 1 commit into
mainfrom
fix/rpc-batch-split-retry
Open

fix(client): split rejected RPC batches#117
cesarenaldi wants to merge 1 commit into
mainfrom
fix/rpc-batch-split-retry

Conversation

@cesarenaldi

@cesarenaldi cesarenaldi commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Batch setup approval eth_call checks through the Python JSON-RPC client.
  • Retry rejected 5xx JSON-RPC batches by recursively splitting them down to single calls.
  • Preserve result ordering across split retries for approval resolution.

Fixes #116

Verification

  • uv run ruff format --check src/polymarket/_internal/eoa/rpc.py src/polymarket/_internal/actions/relayer/approvals.py tests/unit/_relayer_helpers.py tests/unit/test_eoa_rpc.py tests/unit/test_eoa_broadcast.py
  • uv run ruff check src/polymarket/_internal/eoa/rpc.py src/polymarket/_internal/actions/relayer/approvals.py tests/unit/_relayer_helpers.py tests/unit/test_eoa_rpc.py tests/unit/test_eoa_broadcast.py
  • uv run pyright src/polymarket/_internal/eoa/rpc.py src/polymarket/_internal/actions/relayer/approvals.py tests/unit/_relayer_helpers.py tests/unit/test_eoa_rpc.py tests/unit/test_eoa_broadcast.py
  • uv run pytest tests/unit

Note

Medium Risk
Changes RPC transport and approval-read paths used before submitting on-chain approvals; incorrect batch parsing or ordering could mis-detect missing approvals, though behavior is covered by new unit tests.

Overview
Adds eth_call_batch on async and sync JSON-RPC clients so multiple eth_calls go out in one HTTP JSON-RPC array, with shared parsing helpers extracted from single-call paths.

When a batch POST fails with a 5xx RequestRejectedError, the client recursively splits the batch (down to single calls) and merges results in original order; client errors below 500 are not retried via splitting.

Trading approval resolution (resolve_missing_trading_approval_calls / sync) now batches all ERC20 allowance and ERC1155 isApprovedForAll reads in one batch instead of awaiting each eth_call separately. Unit mocks and tests were updated for batch request bodies; new tests cover split-on-5xx ordering for async and sync clients.

Reviewed by Cursor Bugbot for commit 79bb0d2. Bugbot is set up for automated code reviews on this repo. Configure here.

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.

[Bug]: setup_trading_approvals() fails with RequestRejectedError (code 19, "Temporary internal error") on every attempt — deposit wallet deployment

1 participant