-
Notifications
You must be signed in to change notification settings - Fork 152
Autopilot Native Price API #3988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
f37f048 to
4699fb5
Compare
31968f3 to
5db5fc0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a native price API in the autopilot service and configures the orderbook to forward native price requests to it, addressing inconsistencies caused by separate caches in different processes. The implementation includes a fallback mechanism to the legacy price estimators if the autopilot is unavailable.
Key Changes:
- Added an HTTP API server to autopilot exposing a
/native_price/:tokenendpoint - Implemented a forwarding native price estimator in the orderbook that delegates to the autopilot API with fallback support
- Updated e2e test infrastructure with a reverse proxy to support the dual-autopilot test scenario
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
crates/autopilot/src/infra/api.rs |
New HTTP API server for serving native price requests with error mapping |
crates/autopilot/src/infra/mod.rs |
Module declaration for the new API module |
crates/autopilot/src/run.rs |
Integration of the API server with graceful shutdown handling |
crates/autopilot/src/arguments.rs |
Added CLI argument for configuring the native price API bind address |
crates/autopilot/Cargo.toml |
Added axum, tower, and tower-http dependencies with tracing support |
crates/orderbook/src/native_price_forwarder.rs |
New forwarding estimator that proxies requests to autopilot with fallback logic |
crates/orderbook/src/lib.rs |
Module declaration for the native price forwarder |
crates/orderbook/src/run.rs |
Wraps the native price estimator with the forwarder when autopilot URL is configured |
crates/orderbook/src/arguments.rs |
Added CLI argument for the autopilot native price API URL |
crates/e2e/src/setup/proxy.rs |
New reverse proxy implementation for load balancing between two autopilot instances in tests |
crates/e2e/src/setup/mod.rs |
Module declaration for the proxy |
crates/e2e/src/setup/services.rs |
Updated default test configuration to use autopilot for native prices |
crates/e2e/tests/e2e/autopilot_leader.rs |
Updated dual-autopilot test to use the proxy for native price API failover |
Cargo.lock |
Dependency updates reflecting new autopilot dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Reminder: Please consider backward compatibility when modifying the API specification.
Caused by: |
# Conflicts: # crates/e2e/tests/e2e/autopilot_leader.rs
| estimator: Arc<dyn NativePriceEstimating>, | ||
| timeout: Duration, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having everything together in one file is okay for now but when we introduce more endpoints (e.g. for debugging stuff or so) we should have a better code structure.
Description
From the original issue #3831:
Changes
axumserver toautopilotto handle/native_pricerequestsDriverprefix to distinguish between legacy and new approachForwarderprefix is added to use the Forwarder native price estimator.dual_autopilot_only_leader_produces_auctionsrequires running 2 autopilots at the same time for some period of time. Since it doesn't make much sense to specify more than 2 autopilot URLs in the orderbook config, a reverse proxy is introduced to make this test pass. This proxy simulates k8s behavior: when 2 instances of the same service are running, requests are automatically routed between them. An alternative approach is to run 2 autopilot APIs on different ports and specify them in the orderbook config, but the reverse proxy simulates the production behavior.openapi.ymlfile with the hope that this component will be decentralized in the future.How to test
Updated e2e tests. This also requires running tests on staging manually.
Related Issues
Partially fixes #3831
Further implementation
Once we are confident the new approach works well, the old config with native price estimators can be dropped from the orderbook crate.