Skip to content

feat: aleo metric provider#7469

Merged
yjamin merged 3 commits intomainfrom
yjamin/aleo-metric-provider
Dec 2, 2025
Merged

feat: aleo metric provider#7469
yjamin merged 3 commits intomainfrom
yjamin/aleo-metric-provider

Conversation

@yjamin
Copy link
Copy Markdown
Contributor

@yjamin yjamin commented Nov 26, 2025

Description

Implements aleo metrics provider

Drive-by changes

Related issues

Linear issue

Backward compatibility

Testing

Summary by CodeRabbit

  • New Features

    • Added Prometheus metrics to monitor Aleo provider performance, capturing request latency, outcomes, and provider/client lifecycle events.
    • HTTP client requests and provider instances are tracked and reported for observability.
  • Chores

    • Added a new dependency to support the metrics integration.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Nov 26, 2025

⚠️ No Changeset found

Latest commit: d1e4363

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 26, 2025

📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
Dependency & Module Setup
\rust/main/chains/hyperlane-aleo/Cargo.toml`, `rust/main/chains/hyperlane-aleo/src/provider.rs``
Added hyperlane-metric dependency and declared internal metric module
Metrics HTTP Client
\rust/main/chains/hyperlane-aleo/src/provider/metric.rs``
New MetricHttpClient wrapping RpcClient<BaseHttpClient> with Prometheus metrics; tracks provider instance lifecycle, implements Clone/Drop and HttpClient with timed request instrumentation
Aleo Provider Wiring
\rust/main/chains/hyperlane-aleo/src/provider/aleo.rs``
AleoProvider::new signature updated to accept PrometheusClientMetrics and Option<ChainInfo>; propagates metrics into FallbackHttpClient construction
Fallback Client Integration
\rust/main/chains/hyperlane-aleo/src/provider/fallback.rs``
Replaced BaseHttpClient with MetricHttpClient in fallback provider; FallbackHttpClient::new now accepts metrics and optional chain info; BlockNumberGetter made generic over HttpClient
Provider Initialization
\rust/main/hyperlane-base/src/settings/chains.rs``
build_aleo_provider signature changed to accept connection_conf/metrics/etc.; extracts middleware and client metrics and passes them into AleoProvider::new

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • New MetricHttpClient with Drop/Clone/HttpClient impls requires careful review.
  • API signature changes across provider/fallback/settings need compatibility checks.
  • Verify generic BlockNumberGetter change and metrics cloning/thread-safety.

Possibly related PRs

Suggested reviewers

  • kamiyaa
  • ameten

Poem

In the swamp of requests, a client stands tall,
Counting each ping, timing each fall.
Layers wrapped neat, with metrics in store,
Provider sings metrics, tracks every score.
A quiet little beacon, measuring all. 🧅📊

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete, missing critical details about backward compatibility, testing approach, and drive-by changes that should be documented. Fill in all template sections: specify backward compatibility implications, describe testing performed (None/Manual/Unit Tests), and clarify any drive-by changes included in this PR.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: aleo metric provider' accurately captures the main change—implementing Prometheus metrics support for the Aleo provider across multiple files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch yjamin/aleo-metric-provider

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e71d45 and d1e4363.

📒 Files selected for processing (4)
  • 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/metric.rs (1 hunks)
  • rust/main/hyperlane-base/src/settings/chains.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • rust/main/chains/hyperlane-aleo/src/provider/aleo.rs
  • rust/main/chains/hyperlane-aleo/src/provider/metric.rs
🧰 Additional context used
📓 Path-based instructions (2)
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 configurable gasPriceCapMultiplier per chain in transactionOverrides (default: 3)

Files:

  • rust/main/hyperlane-base/src/settings/chains.rs
  • rust/main/chains/hyperlane-aleo/src/provider.rs
rust/main/chains/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

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

Files:

  • rust/main/chains/hyperlane-aleo/src/provider.rs
🧠 Learnings (1)
📚 Learning: 2025-11-24T17:19:38.362Z
Learnt from: CR
Repo: hyperlane-xyz/hyperlane-monorepo PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T17:19:38.362Z
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/hyperlane-base/src/settings/chains.rs
  • rust/main/chains/hyperlane-aleo/src/provider.rs
⏰ 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)
  • GitHub Check: build-and-push-to-gcr
  • GitHub Check: e2e-matrix (radix)
  • GitHub Check: e2e-matrix (cosmosnative)
  • GitHub Check: e2e-matrix (cosmwasm)
  • GitHub Check: e2e-matrix (sealevel)
  • GitHub Check: e2e-matrix (starknet)
  • GitHub Check: e2e-matrix (evm)
  • GitHub Check: yarn-install
  • GitHub Check: test-rs
  • GitHub Check: lander-coverage
  • GitHub Check: lint-rs
🔇 Additional comments (2)
rust/main/chains/hyperlane-aleo/src/provider.rs (1)

9-9: Clean addition of the metrics module.

This internal module declaration properly wires in the new metrics-enabled HTTP client. Keeps things tidy by not exposing it publicly from this file.

rust/main/hyperlane-base/src/settings/chains.rs (1)

1468-1484: Metrics integration follows the established pattern nicely.

The function signature and implementation match the approach used by other chain providers (Radix, Starknet, Cosmos). Metrics extraction is consistent, and all eleven call sites throughout the file have been updated properly.

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.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 instrumentation
rust/main/chains/hyperlane-aleo/src/provider/fallback.rs (2)

10-10: Consider importing Itertools directly from the itertools crate.

Now, I'm not one to tell folks how to run their swamp, but importing Itertools from snarkvm_console_account is 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 with collect_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::new wrapping into the same iteration, avoiding the intermediate collection.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c4f3d33 and 6e71d45.

⛔ Files ignored due to path filters (1)
  • rust/main/Cargo.lock is 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-ethereum for EVM, hyperlane-cosmos for Cosmos ecosystem, hyperlane-sealevel for Solana/SVM, and hyperlane-fuel for Fuel VM

Files:

  • rust/main/chains/hyperlane-aleo/src/provider/aleo.rs
  • rust/main/chains/hyperlane-aleo/src/provider/metric.rs
  • rust/main/chains/hyperlane-aleo/src/provider.rs
  • rust/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 configurable gasPriceCapMultiplier per chain in transactionOverrides (default: 3)

Files:

  • rust/main/chains/hyperlane-aleo/src/provider/aleo.rs
  • rust/main/chains/hyperlane-aleo/src/provider/metric.rs
  • rust/main/chains/hyperlane-aleo/src/provider.rs
  • rust/main/hyperlane-base/src/settings/chains.rs
  • rust/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.toml
  • rust/main/chains/hyperlane-aleo/src/provider/aleo.rs
  • rust/main/chains/hyperlane-aleo/src/provider.rs
  • rust/main/hyperlane-base/src/settings/chains.rs
  • rust/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 MetricHttpClient is 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 Clone and Drop implementations 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 path as 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::new expects:

  • metrics: PrometheusClientMetrics ✓ (provided via metrics.client_metrics())
  • chain: Option<hyperlane_metric::prometheus_metric::ChainInfo> ✓ (provided via middleware_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 MetricHttpClient threads metrics through the fallback provider chain exactly as intended.


44-50: Good generalization of BlockNumberGetter.

Nice work making this generic over any HttpClient implementation. 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.

Comment thread rust/main/chains/hyperlane-aleo/src/provider/metric.rs
Comment thread rust/main/chains/hyperlane-aleo/src/provider/aleo.rs
Comment thread rust/main/chains/hyperlane-aleo/src/provider/aleo.rs
@yjamin yjamin added this pull request to the merge queue Dec 2, 2025
Merged via the queue into main with commit d42116d Dec 2, 2025
42 checks passed
@yjamin yjamin deleted the yjamin/aleo-metric-provider branch December 2, 2025 09:05
@github-project-automation github-project-automation Bot moved this from In Review to Done in Hyperlane Tasks Dec 2, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (f756046) to head (d1e4363).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #7469   +/-   ##
============================
============================
Components Coverage Δ
core ∅ <ø> (∅)
hooks ∅ <ø> (∅)
isms ∅ <ø> (∅)
token ∅ <ø> (∅)
middlewares ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants