This repository is a Rust workspace for the mempool/MEV system.
crates/commonshared domain types and utility primitivescrates/event-logcanonical append-only event contractscrates/ingesttransaction decode + RPC/devp2p ingestion pipelinescrates/feature-engineMEV-oriented feature derivationcrates/storagestorage adapters and persistence servicescrates/viz-apiAPI for observability/replay visualization clientscrates/replaydeterministic replay and lifecycle/reorg-aware statecrates/benchlatency benchmark harness and profiling helpersapps/web-uiMagic UI-style 2D frontend for replay/analysis
Current metrics and alert-threshold primitives are defined in crates/common:
- peer/session churn
- ingest lag
- decode failure rate
- coverage collapse
- storage write latency
- clock skew
The p2p ingest pipeline exposes queue/backpressure telemetry:
queue_depth_currentqueue_depth_peakqueue_dropped_totalduplicates_dropped_total
Run the full acceptance verification command:
./scripts/verify_phase_checks.shThis command runs:
cargo test --workspacecargo build -p replay --bin replay-clicargo build -p viz-api --bin viz-api
The demo-focused V2 plan and KPI contract are documented at:
docs/plans/2026-02-21-mev-infra-v2-implementation.mddocs/plans/v2_scope_kpi.mddocs/perf/v2_baseline.md
The legacy implementation plan now lives at:
docs/mempool_mev_implementation.md
viz-api can ingest real pending transactions from Ethereum-compatible RPC providers.
Chain workers are loaded from configs/chain_config.json by default. Override file path with:
VIZ_API_CHAIN_CONFIG_PATH(optional): custom chain config JSON path
Legacy env-based overrides are still supported:
VIZ_API_CHAINS(optional): JSON chain list override (takes priority over file)VIZ_API_ETH_WS_URL(optional): single-chain WebSocket override for the primary chainVIZ_API_ETH_HTTP_URL(optional): single-chain HTTP override for the primary chainVIZ_API_SOURCE_ID(optional): single-chain source label override for the primary chainVIZ_API_MAX_SEEN_HASHES(optional): dedup cache size for live feed (default:10000)VIZ_API_RPC_BATCH_SIZE(optional): hashes pereth_getTransactionByHashbatch request (default:32)VIZ_API_RPC_MAX_IN_FLIGHT(optional): per-chain in-flight RPC batch cap (default:4)VIZ_API_RPC_RETRY_ATTEMPTS(optional): retry count after initial batch request failure (default:2)VIZ_API_RPC_RETRY_BACKOFF_MS(optional): base retry backoff in milliseconds (default:100)VIZ_API_RPC_BATCH_FLUSH_MS(optional): max wait before flushing queued hashes into batch fetch (default:40)VIZ_API_SILENT_CHAIN_TIMEOUT_SECS(optional): rotate to the next endpoint when a chain receives no pending notifications for this many seconds (default:20)
File-based multi-chain example (configs/chain_config.json):
{
"chains": [
{
"chain_key": "eth-mainnet",
"chain_id": 1,
"source_id": "rpc-eth-mainnet",
"endpoints": [
{
"ws_url": "wss://YOUR_ETH_WS_URL",
"http_url": "https://YOUR_ETH_HTTP_URL"
}
]
},
{
"chain_key": "base-mainnet",
"chain_id": 8453,
"source_id": "rpc-base-mainnet",
"endpoints": [
{
"ws_url": "wss://YOUR_BASE_WS_URL",
"http_url": "https://YOUR_BASE_HTTP_URL"
}
]
}
]
}Start:
cargo run -p viz-api --bin viz-apiThe following endpoints accept an optional chain_id query parameter:
/dashboard/snapshot/transactions/transactions/all/features/recent/opps/recent
/dashboard/snapshot also returns chain_ingest_status, a per-chain worker status list (state, endpoint index/url, silent duration, and rotation count).
Examples:
curl "http://127.0.0.1:3000/transactions?chain_id=1&limit=50"
curl "http://127.0.0.1:3000/dashboard/snapshot?chain_id=8453&tx_limit=100"Run the pipeline latency budget check and generate baseline artifacts:
bash scripts/profile_pipeline.sh --check-budgetArtifacts are written to:
target/perf/pipeline_latency_summary.jsontarget/perf/runtime_allocator_matrix.tsvtarget/perf/pipeline_latency_snapshot.logdocs/perf/v2_baseline.md
Run the deterministic transaction ingest/read-path baseline harness:
bash scripts/perf_tx_pipeline_baseline.shOptional environment variables:
VIZ_API_TX_PERF_TX_COUNTto override seeded transaction volume (default:2000)VIZ_API_TX_PERF_ARTIFACTto write to a specific artifact pathTX_PIPELINE_PERF_ARTIFACT_DIRto override artifact directory (default:artifacts/perf)
Artifacts are written to:
artifacts/perf/tx_pipeline_perf_baseline_<timestamp>.jsonartifacts/perf/tx_pipeline_perf_baseline_latest.json
Verification:
bash scripts/demo_v2.sh --verifyRun API + UI together:
bash scripts/demo_v2.sh --runReference docs:
docs/demo/v2_demo.mddocs/demo/sample_output.md