perf: prewarm order metadata and reuse order hash - #114
Open
casterkay wants to merge 2 commits into
Open
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.
Summary
warm_up_order_metadataAPI so callers can populate order-construction metadata before latency-sensitive order creationSignedOrderV1andSignedOrderV2order_hashout of submitted JSONWhy
Order creation may otherwise perform tick-size, negative-risk, fee, version, and builder-fee REST lookups on first use. Consumers that need the venue order ID also currently rebuild and hash the same typed data after signing. This gives callers public, dependency-owned APIs for both optimizations without copying private internals.
Tests
python -m pytest -q— 232 passed, 15 subtests passedorder_hashis excluded from the order wire payloadNote
Low Risk
Performance and API surface additions on order construction; signing semantics and wire payloads are preserved with regression tests.
Overview
Adds
warm_up_order_metadata(condition_id, builder_code?)so callers can prefetch CLOB market info (tick size, neg risk, fee metadata), V1 per-token fee caps, and optional builder fee rates before latency-sensitivecreate_order/create_market_ordercalls. Builder fee loading is centralized in__load_builder_fee_rate, reused by warmup and the existing lazy cache path.Signed orders now carry an
order_hashfield onSignedOrderV1andSignedOrderV2, populated from the same EIP-712 encode/sign step via_build_order_signature_and_hash(oneencode_typed_dataper build for EOA-style paths; POLY_1271 still hashes once for the hash).order_to_json_v1/order_to_json_v2do not sendorder_hashon the wire.Tests cover warmup avoiding metadata GETs on first orders, stable signature/hash values, single-encode behavior, and JSON exclusion of
order_hash.Reviewed by Cursor Bugbot for commit 905aae8. Bugbot is set up for automated code reviews on this repo. Configure here.