Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .devcontainer/setup-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,17 @@ docker run --rm --network=host \
-url="jdbc:postgresql://127.0.0.1:${PGPORT}/${PGDATABASE}?user=${PGUSER}&password=" \
migrate

# The pool-indexer has its own database migrated from its own directory (mirrors
# the per-network prod DB), separate from the autopilot/orderbook set above.
psql -h 127.0.0.1 -U postgres -d postgres -tAc \
"SELECT 1 FROM pg_database WHERE datname='pool_indexer'" | grep -q 1 \
|| psql -h 127.0.0.1 -U postgres -d postgres -c \
"CREATE DATABASE pool_indexer OWNER \"${PGUSER}\";"
docker run --rm --network=host \
-v "$REPO_ROOT/database/sql-pool-indexer:/flyway/sql:ro" \
-v "$REPO_ROOT/database/conf:/flyway/conf:ro" \
flyway/flyway:10.7.1 \
-url="jdbc:postgresql://127.0.0.1:${PGPORT}/pool_indexer?user=${PGUSER}&password=" \
migrate

echo "==> e2e environment ready (postgres)"
1 change: 1 addition & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ jobs:
tool: nextest
- run: docker compose -f docker-compose.yaml up -d db
- run: docker compose -f docker-compose.yaml up migrations --abort-on-container-failure
- run: docker compose -f docker-compose.yaml up migrations-pool-indexer --abort-on-container-failure
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
with:
just-version: 1.39.0
Expand Down
9 changes: 2 additions & 7 deletions crates/database/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ pub const TABLES: &[&str] = &[
"last_indexed_blocks",
"onchain_order_invalidations",
"onchain_placed_orders",
"pool_indexer_checkpoints",
"presignature_events",
"proposed_jit_orders",
"quotes",
Expand All @@ -72,8 +71,6 @@ pub const TABLES: &[&str] = &[
"solver_competitions",
"surplus_capturing_jit_order_owners",
"trades",
"uniswap_v3_pool_states",
"uniswap_v3_pools",
];

/// The names of potentially big volume tables we use in the db.
Expand All @@ -88,7 +85,6 @@ pub const LARGE_TABLES: &[&str] = &[
"order_quotes",
"proposed_solutions",
"proposed_trade_executions",
"uniswap_v3_ticks",
];

pub fn all_tables() -> impl Iterator<Item = &'static str> {
Expand All @@ -98,9 +94,8 @@ pub fn all_tables() -> impl Iterator<Item = &'static str> {
/// Delete all data in the database. Only used by tests.
///
/// Truncates all tables in a single statement so Postgres accepts foreign-key
/// cycles between listed tables (e.g. `uniswap_v3_pool_states` →
/// `uniswap_v3_pools`). Individual per-table `TRUNCATE`s error out when any
/// other listed table references the one being truncated.
/// cycles between listed tables. Individual per-table `TRUNCATE`s error out
/// when any other listed table references the one being truncated.
#[expect(non_snake_case)]
pub async fn clear_DANGER_(ex: &mut PgTransaction<'_>) -> sqlx::Result<()> {
let tables = all_tables().collect::<Vec<_>>().join(", ");
Expand Down
2 changes: 1 addition & 1 deletion crates/driver/example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ max-order-age = "1m"

# [[liquidity.uniswap-v3]] # Uniswap V3 configuration (pool-indexer as data source)
# preset = "uniswap-v3"
# indexer-config = { pool-indexer = { url = "http://pool-indexer/", wait-until-timeout = "5m" } }
# indexer-config = { pool-indexer = { url = "http://pool-indexer/" } }
# max_pools_to_initialize = 100

# [[liquidity.uniswap-v3]] # Custom Uniswap V3 configuration
Expand Down
2 changes: 0 additions & 2 deletions crates/driver/src/boundary/liquidity/uniswap/v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,12 @@ async fn build_pool_data_source(
UniswapV3PoolSource::PoolIndexer(indexer) => {
tracing::info!(
url = %indexer.url,
wait_until_timeout = ?indexer.wait_until_timeout,
"uniswap v3: using pool-indexer as data source",
);
Ok(Arc::new(PoolIndexerClient::new(
indexer.url.clone(),
eth.chain(),
http,
indexer.wait_until_timeout,
)))
}
UniswapV3PoolSource::Subgraph(subgraph) => {
Expand Down
14 changes: 5 additions & 9 deletions crates/driver/src/infra/config/file/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,15 +380,11 @@ fn uniswap_v3_pool_source(
max_pools_per_tick_query,
})
}
file::IndexerConfig::PoolIndexer {
url,
wait_until_timeout,
} => liquidity::config::UniswapV3PoolSource::PoolIndexer(
liquidity::config::UniswapV3PoolIndexer {
url,
wait_until_timeout,
},
),
file::IndexerConfig::PoolIndexer { url } => {
liquidity::config::UniswapV3PoolSource::PoolIndexer(
liquidity::config::UniswapV3PoolIndexer { url },
)
}
}
}

Expand Down
35 changes: 19 additions & 16 deletions crates/driver/src/infra/config/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,16 +637,7 @@ enum IndexerConfig {
max_pools_per_tick_query: usize,
},
#[serde(rename_all = "kebab-case")]
PoolIndexer {
url: Url,
/// Upper bound on a single `wait_until` call. Size per-network to
/// comfortably exceed the worst-case first-deploy seed time.
#[serde(
with = "humantime_serde",
default = "uniswap_v3::default_pool_indexer_wait_until_timeout"
)]
wait_until_timeout: Duration,
},
PoolIndexer { url: Url },
}

#[derive(Clone, Debug, Deserialize)]
Expand All @@ -656,19 +647,13 @@ enum UniswapV3Preset {
}

mod uniswap_v3 {
use std::time::Duration;

pub fn default_max_pools_to_initialize() -> usize {
100
}

pub fn default_max_pools_per_tick_query() -> usize {
usize::MAX
}

pub fn default_pool_indexer_wait_until_timeout() -> Duration {
Duration::from_secs(300)
}
}

#[derive(Clone, Debug, Deserialize)]
Expand Down Expand Up @@ -1205,6 +1190,24 @@ mod tests {
assert!(err.to_string().contains("must be signers"));
}

#[test]
fn pool_indexer_config_needs_only_a_url() {
let config: IndexerConfig =
toml::from_str(r#"pool-indexer = { url = "http://pool-indexer/" }"#).unwrap();
assert!(matches!(config, IndexerConfig::PoolIndexer { .. }));
}

#[test]
fn pool_indexer_config_rejects_wait_until_timeout() {
// The field was dropped (bootstrap is its own initContainer now); a
// stale config still carrying it should fail loudly, not be ignored.
let err = toml::from_str::<IndexerConfig>(
r#"pool-indexer = { url = "http://pool-indexer/", wait-until-timeout = "5m" }"#,
)
.unwrap_err();
assert!(err.to_string().contains("wait-until-timeout"));
}

#[test]
fn submission_accounts_new_accepts_signers() {
let signer = Account::PrivateKey(
Expand Down
5 changes: 0 additions & 5 deletions crates/driver/src/infra/liquidity/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,6 @@ pub struct UniswapV3PoolIndexer {
/// Service root, e.g. `http://pool-indexer/` exposing
/// `/api/v1/{network}/uniswap/v3/`.
pub url: Url,

/// Upper bound on a single `wait_until` call. Size per-network to
/// comfortably exceed the worst-case first-deploy seed time (~13 min
/// for mainnet's ~60k pools; tens of seconds for smaller chains).
pub wait_until_timeout: Duration,
}

/// Where Uniswap V3 pool definitions and tick data are fetched from. Exactly
Expand Down
Loading
Loading