perf: reduce auth header allocations and validate before async#316
Open
KENILSHAHH wants to merge 4 commits intoPolymarket:mainfrom
Open
perf: reduce auth header allocations and validate before async#316KENILSHAHH wants to merge 4 commits intoPolymarket:mainfrom
KENILSHAHH wants to merge 4 commits intoPolymarket:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #316 +/- ##
==========================================
+ Coverage 85.54% 85.56% +0.02%
==========================================
Files 32 32
Lines 5167 5175 +8
==========================================
+ Hits 4420 4428 +8
Misses 747 747
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
Would love the feedback here @chaz-polymarket |
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.
Summary
to_string().parse()withHeaderValue::from()for integer header values (timestamps, nonces), eliminating throwaway heap allocations on every authenticatedrequest
[u8; 36]buffers instead of heap-allocating viato_string()fee_rate_bps()andtick_size()async calls in the limit order builder so invalid orders fail immediatelywithout network round-trips
Test plan
--all-featuresNote
Medium Risk
Touches request authentication header construction and limit-order validation ordering; while behavior should be equivalent, mistakes could break authenticated calls or change validation timing in a trading-critical path.
Overview
Reduces per-request allocations in auth header generation by constructing numeric headers via
HeaderValue::from(...)and formatting UUID API keys into a stack buffer (instead ofto_string().parse()) across L1/L2 and Builder local auth flows.Reorders limit order validation in
OrderBuilder<Limit>::buildsosizechecks (missing/scale/non-positive) happen before asyncfee_rate_bps/tick_sizecalls, causing invalid orders to fail immediately without network round-trips.Written by Cursor Bugbot for commit 868c3a8. This will update automatically on new commits. Configure here.