fix(blockrun): remove default x402 payment cap - #684
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem / background
BlockRun x402 requests are rejected before signing whenever the upstream payment quote exceeds the hard-coded 5 USDC default cap. Request
202608110702314015628818268d9d62ioY87Dvquoted 13.8367 USDC for/v1/responses, causing the gateway to return HTTP 500 withamount 13836700 exceeds per-call cap 5000000.Evidence / root cause
SignX402Paymentand the image branch ofAdaptor.DoRequestpassedmaxAmountAtomicUSDCinto the shared payment validator.assertAmountWithinCaprejected the upstream 402 amount before creating an ERC-3009 signature, so the request failed without an on-chain charge.Scope / design
Impact and risks
This intentionally expands wallet exposure: the default BlockRun paths will sign any positive amount advertised by an otherwise valid upstream 402 response. A compromised BlockRun service or TLS boundary could request a very large payment. The network, asset, recipient-shape, time-window, and ERC-3009 nonce protections remain, but they do not bound the single-transfer amount.
The change is multi-node safe: it introduces no shared mutable or process-local coordination state. Every router instance applies the same stateless validation after deployment, and ERC-3009 nonces continue to make each authorization single-use.
Validation
go test ./relay/channel/blockrun -run "Test(ValidatePaymentOption|LooksLikeEthAddress|ExtractPaymentRequired|ParsePrivateKey|CacheRequestBody|X402)" -count=1go test ./relay/channel/blockrun -run "^$"go test ./relay/channel/task/blockrunseedance/...git diff --checkDoRequest -> SetupLogger; medium risk due relay-path behavior change.The full
go test ./relay/channel/blockrun/...suite still has existing image polling/download failures because the test environment leaves the global HTTP client uninitialized. The x402-specific tests and package compilation pass.Acceptance criteria
Production deployment recommendation
/v1model and image traffic.newapi-console,newapi-web, Terraform, and Cloudflare are not involved.