Skip to content

ci: add hotpath profiling && comment ci#867

Merged
mojoX911 merged 1 commit into
citadel-tech:masterfrom
0xEgao:ci-hotpath
May 13, 2026
Merged

ci: add hotpath profiling && comment ci#867
mojoX911 merged 1 commit into
citadel-tech:masterfrom
0xEgao:ci-hotpath

Conversation

@0xEgao
Copy link
Copy Markdown
Collaborator

@0xEgao 0xEgao commented May 12, 2026

Pull Request

Description

Adds hotpath to ci for profiling, by introducing a hotpath-profile workflow that runs a single integration test hotpath_profile on both PR head and base commits, generates maker and taker JSON metrics, and uploads them as a profile-metrics artifact, plus a hotpath-comment workflow that triggers on the profile workflow completion, downloads that artifact, and posts maker/taker base-vs-head comparison comments to the PR.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code refactor / performance improvement
  • Documentation update only
  • CI / Docker / Build changes
  • Other (please describe):

Protocol Version(s) Affected

  • Legacy (ECDSA — messages.rs, contract.rs, handlers.rs)
  • Taproot-Musig2 (messages2.rs, contract2.rs, handlers2.rs)
  • Both
  • Neither (infrastructure / tooling only)

Note: When modifying protocol logic, changes must be made to both versions unless the
scope is explicitly version-specific.

Affected Component(s)

  • makerd (background daemon)
  • taker (CLI client)
  • maker-cli (command-line tool)
  • Core protocol / cryptography / library
  • watch_tower (contract monitoring & recovery)
  • Docker / deployment scripts
  • Tests / test framework
  • Documentation (docs/)
  • Other (please specify):

Checklist

Code Quality

  • I ran cargo +nightly fmt --all and committed the result
  • I ran cargo +stable clippy --all-features --lib --bins --tests -- -D warnings with zero warnings
  • I ran cargo +stable clippy --examples -- -D warnings with zero warnings
  • I ran RUSTDOCFLAGS="-D warnings" cargo +nightly doc --all-features --document-private-items --no-deps with zero warnings
  • Pre-commit git hook passes (ln -s ../../git_hooks/pre-commit .git/hooks/pre-commit if not already set)

Testing

  • All unit tests pass (cargo test)
  • Integration tests pass (cargo test --features integration-test)
  • Changes were manually tested on regtest
  • End-to-end maker ↔ taker swap tested (where applicable)
  • Test-only code is gated behind #[cfg(feature = "integration-test")]

Documentation

  • Relevant files in the docs/ folder were updated
  • Complex logic is commented

Security & Privacy (Critical)

  • This change preserves trustlessness and atomic swap guarantees
  • No regression in sybil resistance or fidelity bond logic
  • Tor anonymity and P2P message flow were reviewed
  • No new attack vectors or trust assumptions introduced
  • Edge cases and error handling considered
  • ZMQ subscription integrity (raw tx/block feed) is unaffected
  • integration-test feature flag is not reachable in production code paths

Summary by CodeRabbit

  • New Features

    • Automated hotpath performance profiling: scheduled benchmarks collect metrics and post summarized results as PR comments.
  • Tests

    • Added an integration test that runs hotpath benchmarks and produces separate maker/taker profiling reports.
    • Test harness now conditionally enables the hotpath profiling test when the feature is active.

Review Change Stack

Copilot AI review requested due to automatic review settings May 12, 2026 08:45
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

📝 Walkthrough

Walkthrough

Adds a feature-gated integration test that profiles a full coinswap run and emits full + maker/taker filtered JSON reports. Adds two GitHub Actions: hotpath-profile (runs head/base benchmarks, uploads profile-metrics) and hotpath-comment (downloads metrics and posts maker/taker comparison comments to the PR).

Changes

Hotpath profiling benchmark infrastructure

Layer / File(s) Summary
Hotpath profiling integration test
src/hotpath_local.rs, tests/integration/hotpath_profile.rs, tests/integration/main.rs
Integration test (hotpath_profile_swap) profiles a full coinswap scenario with maker/taker peers, funds accounts, executes swap, finalizes profiling output, and writes filtered metrics for coinswap::maker and coinswap::taker. Adds write_filtered_report_by_prefixes and a feature-gated read_json_report_with_retries. Test module is compiled only with the hotpath feature.
CI benchmark orchestration and result posting
.github/workflows/hotpath-profile.yml, .github/workflows/hotpath-comment.yml
hotpath-profile runs the profiling test for PR head and base, captures JSON outputs and PR metadata into /tmp/metrics/, and uploads them as profile-metrics artifact. hotpath-comment triggers on successful hotpath-profile runs, downloads the artifact, installs hotpath-utils, and posts maker and taker benchmark comparison comments using the workflow token and PR number.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A hop and a skip, profiling flows free,
Metrics dance through the coinswap spree,
Makers and takers, benchmarks align,
Comments bloom where the numbers shine! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main changes: adding hotpath profiling to CI with comment functionality. It is concise and directly relates to the primary objectives.
Description check ✅ Passed The PR description covers all required sections: it clearly explains what was added (two workflows for hotpath profiling and commenting), marks the appropriate change type (CI/Docker/Build), protocol version (Neither), and affected component (Tests/test framework). Most checklist items are properly marked as completed. The description aligns well with the changes made.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds CI automation to run Hotpath profiling on a representative integration-test swap and post base-vs-head performance comparisons back to the pull request.

Changes:

  • Adds a hotpath_profile_swap integration test that runs a swap under Hotpath and writes filtered maker/taker JSON reports.
  • Exposes a test-only JSON report reader in hotpath_local to support the integration benchmark harness.
  • Introduces two GitHub Actions workflows: one to generate/upload metrics, and one to download metrics and comment on the PR.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/integration/main.rs Registers the hotpath profiling test module behind the hotpath feature.
tests/integration/hotpath_profile.rs New integration benchmark that runs a swap under Hotpath and emits filtered maker/taker metrics JSON.
src/hotpath_local.rs Adds a test-only public wrapper to read Hotpath JSON reports with retries.
.github/workflows/hotpath-profile.yml New workflow to run the benchmark on head and base and upload metrics artifact.
.github/workflows/hotpath-comment.yml New workflow_run job that downloads metrics and posts comparison comments to the PR.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/hotpath-profile.yml
Comment thread .github/workflows/hotpath-comment.yml
Comment thread .github/workflows/hotpath-comment.yml
Comment thread .github/workflows/hotpath-comment.yml Outdated
Copy link
Copy Markdown

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/hotpath-profile.yml:
- Around line 3-5: The workflow currently triggers on the broad "on:
pull_request" event; narrow it to avoid running on every commit by replacing or
augmenting that trigger with specific "types" (e.g., types: [opened, reopened,
synchronize]) and/or add "paths" or "paths-ignore" filters so the job only runs
for relevant files (e.g., profiling config or benchmarks); update the "on:
pull_request" block to include the chosen types and/or paths filters to limit
executions.
- Around line 43-59: The base benchmark run ("Base benchmark" step that runs the
cargo test --release --test integration hotpath_profile_swap ...) can reuse
incremental build artifacts from the head run; add cache invalidation by either
running cargo clean right before the Base benchmark step or change the
rust-cache usage to use a distinct shared-key for the base run so it restores an
independent target directory; update the workflow to insert the clean or unique
shared-key in the "Base benchmark" step immediately before executing the cargo
test command.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 438f61ac-18fb-4beb-a33f-c308f7d2abed

📥 Commits

Reviewing files that changed from the base of the PR and between 0d5d362 and b734443.

📒 Files selected for processing (5)
  • .github/workflows/hotpath-comment.yml
  • .github/workflows/hotpath-profile.yml
  • src/hotpath_local.rs
  • tests/integration/hotpath_profile.rs
  • tests/integration/main.rs

Comment thread .github/workflows/hotpath-profile.yml
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.59%. Comparing base (776b75d) to head (d7be1e1).
⚠️ Report is 163 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #867      +/-   ##
==========================================
+ Coverage   68.87%   78.59%   +9.71%     
==========================================
  Files          35       57      +22     
  Lines        4932    15762   +10830     
==========================================
+ Hits         3397    12388    +8991     
- Misses       1535     3374    +1839     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/hotpath-profile.yml:
- Around line 44-63: The Base benchmark step currently assumes the test target
hotpath_profile_swap exists after checking out the base commit; add a pre-check
that verifies the test exists in the base commit and skip the benchmark if it
does not. Concretely, before the "Base benchmark" run block (after the "Checkout
base" step) run a lightweight command to list test targets and confirm
hotpath_profile_swap is present (or check for the integration test name in cargo
test --list for the integration test suite), and only execute the cargo test
--release --test integration hotpath_profile_swap ... when that check succeeds;
otherwise emit a clear log message and mark the benchmark as skipped so the
workflow does not fail. Ensure the workflow step names ("Checkout base", "Base
benchmark") and the test target name (hotpath_profile_swap) are used so the
change is easy to locate and validate.

In `@tests/integration/hotpath_profile.rs`:
- Around line 117-131: The test currently starts the coinswap
(taker.start_coinswap) and immediately signals makers to shutdown and joins
maker_threads without verifying swap completion; add a verification step that
waits for the swap referenced by summary.swap_id to reach a completed state (or
fail/timeout) before shutting down makers. Implement this by calling an existing
wait/status helper (e.g., taker.wait_for_swap_completion(&summary.swap_id) or
polling taker.get_swap_status()/is_swap_complete(&summary.swap_id) with a
reasonable timeout and assert the swap completed successfully), and only after
that set maker.shutdown.store(true, Relaxed) and join maker_threads; if no
helper exists, add a small polling loop in the test to check the swap state and
fail the test on timeout.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: bd891a49-6798-4e11-908e-2c81260832c8

📥 Commits

Reviewing files that changed from the base of the PR and between b734443 and d7be1e1.

📒 Files selected for processing (5)
  • .github/workflows/hotpath-comment.yml
  • .github/workflows/hotpath-profile.yml
  • src/hotpath_local.rs
  • tests/integration/hotpath_profile.rs
  • tests/integration/main.rs

Comment thread .github/workflows/hotpath-profile.yml
Comment thread tests/integration/hotpath_profile.rs
Copy link
Copy Markdown

@mojoX911 mojoX911 left a comment

Choose a reason for hiding this comment

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

Ack

@mojoX911 mojoX911 merged commit 12eaf19 into citadel-tech:master May 13, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants