Conversation
|
📝 WalkthroughWalkthroughAdds Prometheus metrics to the Aleo provider: introduces a MetricHttpClient, updates fallback and provider wiring to accept and propagate metrics, and threads metrics from settings into provider construction. Changes
Sequence DiagramsequenceDiagram
participant Settings as build_aleo_provider
participant Aleo as AleoProvider::new
participant Fallback as FallbackHttpClient::new
participant Metric as MetricHttpClient
participant Prom as PrometheusMetrics
Settings->>Aleo: new(conf, domain, signer, metrics, chain_info)
Aleo->>Fallback: new(urls, metrics, chain_info)
loop for each URL
Fallback->>Metric: new(url, metrics, metrics_config)
Metric->>Prom: increment provider_instance
end
Note over Metric: On request -> record start_time -> delegate to inner RpcClient -> update metrics (path, success/time)
Metric->>Fallback: ready client
Fallback->>Aleo: fallback provider constructed
Aleo->>Settings: provider instance returned
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used📓 Path-based instructions (2)rust/main/**/*.rs📄 CodeRabbit inference engine (CLAUDE.md)
Files:
rust/main/chains/**/*.rs📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (1)📚 Learning: 2025-11-24T17:19:38.362ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
🔇 Additional comments (2)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
rust/main/chains/hyperlane-aleo/src/provider/metric.rs (2)
12-18: Doc comment doesn't match the struct.The comment says "Fallback Http Client" but this is
MetricHttpClient. Looks like a copy-paste leftover from somewhere else. Not a big deal, but might confuse future travelers through this swamp.-/// Fallback Http Client that tries multiple RpcClients in order +/// Metrics-enabled Http Client that wraps an RpcClient with Prometheus instrumentation #[derive(Debug)] pub struct MetricHttpClient {
43-43: Another stray doc comment.Same issue as before — mentions "FallbackHttpClient" when this is
MetricHttpClient::new.- /// Creates a new FallbackHttpClient from a list of base urls + /// Creates a new MetricHttpClient wrapping the given URL with metrics instrumentationrust/main/chains/hyperlane-aleo/src/provider/fallback.rs (2)
10-10: Consider importingItertoolsdirectly from theitertoolscrate.Now, I'm not one to tell folks how to run their swamp, but importing
Itertoolsfromsnarkvm_console_accountis a bit like getting onions from the donkey's saddlebag when you've got a perfectly good garden. It's a re-export, and while it works, it hides the actual dependency and could confuse future maintainers.-use snarkvm_console_account::{DeserializeOwned, Itertools}; +use itertools::Itertools; +use snarkvm_console_account::DeserializeOwned;
28-41: Simplify the iterator chain to avoid redundant collection.There's layers here like an onion, but some of 'em we don't need. You're collecting into a
Vec, converting back to an iterator, then collecting again withcollect_vec(). We can streamline this whole thing into a single pass.let clients = urls .into_iter() .map(|url| { let metrics_config = PrometheusConfig::from_url(&url, ClientConnectionType::Rpc, chain.clone()); MetricHttpClient::new(url, metrics.clone(), metrics_config) }) - .collect::<ChainResult<Vec<_>>>()? - .into_iter() - .map(RpcClient::new) - .collect_vec(); + .map(|client| client.map(RpcClient::new)) + .collect::<ChainResult<Vec<_>>>()?; let fallback = FallbackProvider::new(clients); Ok(Self { fallback })This folds the
RpcClient::newwrapping into the same iteration, avoiding the intermediate collection.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
rust/main/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (6)
rust/main/chains/hyperlane-aleo/Cargo.toml(1 hunks)rust/main/chains/hyperlane-aleo/src/provider.rs(1 hunks)rust/main/chains/hyperlane-aleo/src/provider/aleo.rs(2 hunks)rust/main/chains/hyperlane-aleo/src/provider/fallback.rs(1 hunks)rust/main/chains/hyperlane-aleo/src/provider/metric.rs(1 hunks)rust/main/hyperlane-base/src/settings/chains.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
rust/main/chains/**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
Rust chain implementations must support
hyperlane-ethereumfor EVM,hyperlane-cosmosfor Cosmos ecosystem,hyperlane-sealevelfor Solana/SVM, andhyperlane-fuelfor Fuel VM
Files:
rust/main/chains/hyperlane-aleo/src/provider/aleo.rsrust/main/chains/hyperlane-aleo/src/provider/metric.rsrust/main/chains/hyperlane-aleo/src/provider.rsrust/main/chains/hyperlane-aleo/src/provider/fallback.rs
rust/main/**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
Gas price escalation in transaction management must follow the formula:
Max(Min(Max(Escalate(oldGasPrice), newEstimatedGasPrice), gasPriceCapMultiplier × newEstimatedGasPrice), oldGasPrice)to prevent indefinite escalation while maintaining competitiveness and RBF compatibility, with configurablegasPriceCapMultiplierper chain in transactionOverrides (default: 3)
Files:
rust/main/chains/hyperlane-aleo/src/provider/aleo.rsrust/main/chains/hyperlane-aleo/src/provider/metric.rsrust/main/chains/hyperlane-aleo/src/provider.rsrust/main/hyperlane-base/src/settings/chains.rsrust/main/chains/hyperlane-aleo/src/provider/fallback.rs
🧠 Learnings (5)
📚 Learning: 2025-11-24T17:19:38.332Z
Learnt from: CR
Repo: hyperlane-xyz/hyperlane-monorepo PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T17:19:38.332Z
Learning: Applies to rust/main/chains/**/*.rs : Rust chain implementations must support `hyperlane-ethereum` for EVM, `hyperlane-cosmos` for Cosmos ecosystem, `hyperlane-sealevel` for Solana/SVM, and `hyperlane-fuel` for Fuel VM
Applied to files:
rust/main/chains/hyperlane-aleo/Cargo.tomlrust/main/chains/hyperlane-aleo/src/provider/aleo.rsrust/main/chains/hyperlane-aleo/src/provider.rsrust/main/hyperlane-base/src/settings/chains.rsrust/main/chains/hyperlane-aleo/src/provider/fallback.rs
📚 Learning: 2025-08-26T13:46:37.695Z
Learnt from: paulbalaji
Repo: hyperlane-xyz/hyperlane-monorepo PR: 6943
File: rust/main/config/mainnet_config.json:965-965
Timestamp: 2025-08-26T13:46:37.695Z
Learning: In the repository hyperlane-xyz/hyperlane-monorepo, skip reviewing the file rust/main/config/mainnet_config.json in future code reviews as requested by paulbalaji.
Applied to files:
rust/main/chains/hyperlane-aleo/Cargo.toml
📚 Learning: 2025-08-26T13:46:37.695Z
Learnt from: paulbalaji
Repo: hyperlane-xyz/hyperlane-monorepo PR: 6943
File: rust/main/config/mainnet_config.json:965-965
Timestamp: 2025-08-26T13:46:37.695Z
Learning: In the repository hyperlane-xyz/hyperlane-monorepo, skip reviewing the file rust/main/config/testnet_config.json in future code reviews as requested by paulbalaji.
Applied to files:
rust/main/chains/hyperlane-aleo/Cargo.toml
📚 Learning: 2025-11-20T12:17:33.363Z
Learnt from: yjamin
Repo: hyperlane-xyz/hyperlane-monorepo PR: 7414
File: rust/main/chains/hyperlane-aleo/src/provider/aleo.rs:161-210
Timestamp: 2025-11-20T12:17:33.363Z
Learning: In Aleo's ConsensusStore (rust/main/chains/hyperlane-aleo/src/provider/aleo.rs), StorageMode::Production should always be used when opening the store. This mode refers to persisting the ZK proof trusted setup to the filesystem, not the network environment (production vs test). The trusted setup should always be saved to disk.
Applied to files:
rust/main/chains/hyperlane-aleo/src/provider/aleo.rs
📚 Learning: 2025-11-20T12:20:42.691Z
Learnt from: yjamin
Repo: hyperlane-xyz/hyperlane-monorepo PR: 7414
File: rust/main/chains/hyperlane-aleo/src/provider/traits.rs:252-0
Timestamp: 2025-11-20T12:20:42.691Z
Learning: In rust/main/chains/hyperlane-aleo/src/provider/traits.rs, the `get_state_paths_for_commitments` and `get_state_paths_for_commitments_async` methods intentionally use `.unwrap_or_default()` to return an empty Vec on any error. This behavior matches SnarkVM's internal QueryTrait implementation and should not be changed to propagate errors.
Applied to files:
rust/main/chains/hyperlane-aleo/src/provider/aleo.rs
🧬 Code graph analysis (4)
rust/main/chains/hyperlane-aleo/src/provider/aleo.rs (2)
rust/main/chains/hyperlane-aleo/src/provider/fallback.rs (1)
new(23-41)rust/main/chains/hyperlane-aleo/src/provider/metric.rs (1)
new(44-59)
rust/main/chains/hyperlane-aleo/src/provider/metric.rs (1)
rust/main/chains/hyperlane-aleo/src/provider/fallback.rs (3)
new(23-41)request(55-69)request_post(72-85)
rust/main/hyperlane-base/src/settings/chains.rs (1)
rust/main/hyperlane-base/src/settings/base.rs (1)
metrics(96-102)
rust/main/chains/hyperlane-aleo/src/provider/fallback.rs (2)
rust/main/chains/hyperlane-aleo/src/provider/metric.rs (1)
new(44-59)rust/main/chains/hyperlane-aleo/src/provider/base.rs (1)
new(25-38)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: build-and-push-to-gcr
- GitHub Check: e2e-matrix (radix)
- GitHub Check: e2e-matrix (starknet)
- GitHub Check: e2e-matrix (sealevel)
- GitHub Check: e2e-matrix (evm)
- GitHub Check: e2e-matrix (cosmosnative)
- GitHub Check: e2e-matrix (cosmwasm)
- GitHub Check: lander-coverage
- GitHub Check: lint-rs
- GitHub Check: test-rs
🔇 Additional comments (9)
rust/main/chains/hyperlane-aleo/src/provider.rs (1)
8-8: LGTM!Module declaration fits right in with the rest of the swamp— I mean, the module structure. Private visibility is appropriate since
MetricHttpClientis used internally by the provider layer.rust/main/chains/hyperlane-aleo/Cargo.toml (1)
14-14: LGTM!This dependency is needed for the metrics types, and the path follows the same pattern as the other hyperlane crates in this swamp. All good here.
rust/main/chains/hyperlane-aleo/src/provider/aleo.rs (2)
10-10: LGTM!Import looks proper. Nothing to worry about here, just business as usual.
53-79: Metrics wiring looks solid.The constructor properly threads metrics through to both the proving service and the main RPC client. Using
.clone()for the first client and moving for the second is efficient. This follows the same pattern used by other providers like Cosmos, Radix, and Starknet in the codebase. Nice work getting this onion layered properly.rust/main/chains/hyperlane-aleo/src/provider/metric.rs (2)
20-40: Good work on the metric lifecycle management.Manual
CloneandDropimplementations ensure the provider instance count stays accurate. Every clone bumps the count, every drop decreases it. This pattern keeps the metrics honest about how many clients are actually alive out there in the swamp.
62-89: HttpClient implementation looks proper.The timing capture and metric updates are correctly placed around the actual request. Using
pathas a label should be fine for Aleo's REST API since paths are typically static endpoints rather than dynamic URLs with IDs.One thing to keep in mind for the future: if paths ever include dynamic segments (like transaction IDs), the cardinality could balloon. But for now, this looks good.
rust/main/hyperlane-base/src/settings/chains.rs (1)
1458-1473: Perfect! I now have all the information needed to verify the review comment.Type compatibility verified — no issues found.
The implementation is correct.
AleoProvider::newexpects:
metrics: PrometheusClientMetrics✓ (provided viametrics.client_metrics())chain: Option<hyperlane_metric::prometheus_metric::ChainInfo>✓ (provided viamiddleware_metrics.chain.clone())Both types match exactly. The metrics wiring pattern is sound and follows the established conventions used by other providers.
rust/main/chains/hyperlane-aleo/src/provider/fallback.rs (2)
16-19: Struct type update looks proper.The swamp's been renovated nicely - switching to
MetricHttpClientthreads metrics through the fallback provider chain exactly as intended.
44-50: Good generalization of BlockNumberGetter.Nice work making this generic over any
HttpClientimplementation. Now any client that does its job properly can get the block number, whether it's metric-wrapped or not. That's the kind of flexibility that makes things work together nicely.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7469 +/- ##
============================
============================
🚀 New features to boost your workflow:
|
Description
Implements aleo metrics provider
Drive-by changes
Related issues
Linear issue
Backward compatibility
Testing
Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.