Skip to content

feat: check risk strategies - #1429

Open
Dodecahedr0x wants to merge 3 commits into
devfrom
dode/configurable-aml-checks
Open

feat: check risk strategies#1429
Dodecahedr0x wants to merge 3 commits into
devfrom
dode/configurable-aml-checks

Conversation

@Dodecahedr0x

@Dodecahedr0x Dodecahedr0x commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Introduce a configurable risk checking strategy: aggressively check all delegation actions, or only those involving programs relevant to money laundering: token programs and the magic program. Closes #1435

Breaking Changes

  • None, but a new optional config field

Summary by CodeRabbit

  • New Features

    • Added configurable AML verification strategies for all signers or only relevant program activity.
    • Risk checks now use a dedicated risk server, with relevant-program checks enabled by default.
    • Migrated task scheduling to Hydra cranks, including task creation, cancellation, funding, and faucet delegation.
    • Added configurable faucet keypair support for scheduler operations.
  • Documentation

    • Updated configuration guidance for risk-server settings, AML strategies, and scheduler faucet setup.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds configurable AML risk checking with AllSigners and RelevantPrograms. The risk client now uses a risk-server verdict. The task scheduler now creates and cancels faucet-funded Hydra cranks instead of storing tasks in SQLite. Validator startup delegates the configured faucet. Legacy crank execution support was removed.

Assessment against linked issues:

Objective Addressed Explanation
Add configurable risk checking to avoid checking all addresses for every action [#1435]

Assessment against linked issues: Out-of-scope changes:

Code Change Explanation
Hydra crank scheduler migration (magicblock-task-scheduler/src/service.rs:1-320, magicblock-task-scheduler/src/crank.rs:1-183) Replaces SQLite task scheduling with Hydra crank creation and cancellation. This is not part of configurable AML risk checking.
Faucet delegation and scheduler startup changes (bins/magicblock-validator/src/crank_faucet.rs:12-139, bins/magicblock-validator/src/leader.rs:176-193,539-567) Adds faucet delegation and scheduler initialization behavior unrelated to the linked AML objective.
Legacy crank execution removal (magicblock-magic-program-api/src/instruction.rs:306, programs/magicblock/src/magicblock_processor.rs:171-174) Removes the ExecuteCrank instruction and processor entrypoint. This is outside the linked risk-checking objective.

Suggested reviewers: bmuddha, gabrielepicco, thlorenz

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dode/configurable-aml-checks

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.

@Dodecahedr0x
Dodecahedr0x force-pushed the dode/configurable-aml-checks branch 2 times, most recently from 65d1e07 to 5104c59 Compare July 30, 2026 16:53
@Dodecahedr0x
Dodecahedr0x changed the base branch from master to engine-integration July 30, 2026 16:53
@bmuddha
bmuddha force-pushed the engine-integration branch 13 times, most recently from 7f9ba49 to 8a4f601 Compare August 4, 2026 14:07
@Dodecahedr0x
Dodecahedr0x force-pushed the dode/configurable-aml-checks branch from 5104c59 to b7addc0 Compare August 4, 2026 15:22

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@magicblock-chainlink/src/chainlink/fetch_cloner/mod.rs`:
- Around line 1577-1582: The signer collection in lines 1584-1602 currently
includes signers from all delegation_actions regardless of the check_strategy
result, which defeats the risk-check optimization. After the
delegation_actions_require_risk_check guard, add conditional logic based on
risk_service.check_strategy(): when the strategy indicates RelevantPrograms,
filter the actions with instruction_involves_risk_relevant_program before
collecting signers; when the strategy indicates AllSigners, preserve the current
behavior of collecting from all actions. Also add a test case that validates the
filtering behavior by including a mixed batch with both relevant and unrelated
actions to ensure only relevant signers are sent to check_addresses.
🪄 Autofix

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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 37aea70b-9b7d-4458-a5a8-acf7df61fc2d

📥 Commits

Reviewing files that changed from the base of the PR and between 65d1e07 and b7addc0.

📒 Files selected for processing (7)
  • config.example.toml
  • magicblock-aml/src/lib.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner/mod.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner/tests.rs
  • magicblock-chainlink/tests/10_aml_undelegation.rs
  • magicblock-config/src/config/chain.rs
  • magicblock-config/src/config/mod.rs

Comment thread magicblock-chainlink/src/chainlink/fetch_cloner/mod.rs Outdated
@bmuddha
bmuddha force-pushed the engine-integration branch 4 times, most recently from 39529ab to fc4f0d6 Compare August 4, 2026 20:01
@Dodecahedr0x
Dodecahedr0x force-pushed the dode/configurable-aml-checks branch from b7addc0 to 4de6e54 Compare August 4, 2026 21:53
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Dodecahedr0x commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@bmuddha
bmuddha changed the base branch from engine-integration to graphite-base/1429 August 4, 2026 23:40
@bmuddha
bmuddha force-pushed the dode/crank-refactor branch from 87d5e7c to 1e477a3 Compare August 6, 2026 17:46
@bmuddha
bmuddha force-pushed the dode/configurable-aml-checks branch from 6863017 to ea76e6a Compare August 7, 2026 18:36
@bmuddha
bmuddha force-pushed the dode/crank-refactor branch from 405bd42 to c4a54d5 Compare August 7, 2026 18:36
@Dodecahedr0x
Dodecahedr0x force-pushed the dode/configurable-aml-checks branch from ea76e6a to dee4d61 Compare August 10, 2026 09:00
@Dodecahedr0x
Dodecahedr0x changed the base branch from dode/crank-refactor to dode/external-risk-server August 10, 2026 09:01
@bmuddha
bmuddha force-pushed the dode/external-risk-server branch from c40cc22 to dd316c3 Compare August 10, 2026 14:54
@bmuddha
bmuddha force-pushed the dode/configurable-aml-checks branch from dee4d61 to 9ae900f Compare August 10, 2026 14:54
@Dodecahedr0x
Dodecahedr0x force-pushed the dode/external-risk-server branch 2 times, most recently from c40cc22 to 836e5f9 Compare August 11, 2026 07:47
@bmuddha
bmuddha force-pushed the dode/external-risk-server branch from 836e5f9 to 2e64b83 Compare August 11, 2026 13:09
@bmuddha
bmuddha force-pushed the dode/configurable-aml-checks branch from 9ae900f to 27e8c37 Compare August 11, 2026 13:09
@bmuddha
bmuddha changed the base branch from dode/external-risk-server to dode/crank-refactor August 11, 2026 13:10
@bmuddha
bmuddha force-pushed the dode/crank-refactor branch from 4761dba to dcebe2c Compare August 11, 2026 13:25
@bmuddha
bmuddha force-pushed the dode/configurable-aml-checks branch from 27e8c37 to f23a497 Compare August 11, 2026 13:25
@bmuddha
bmuddha force-pushed the dode/crank-refactor branch from dcebe2c to 7368b12 Compare August 11, 2026 14:39
@bmuddha
bmuddha force-pushed the dode/configurable-aml-checks branch from f23a497 to 845638d Compare August 11, 2026 14:39
@bmuddha
bmuddha force-pushed the dode/crank-refactor branch from 7368b12 to c0554ec Compare August 12, 2026 06:23
@bmuddha
bmuddha force-pushed the dode/configurable-aml-checks branch from 845638d to 3288f82 Compare August 12, 2026 06:23
@bmuddha
bmuddha force-pushed the dode/crank-refactor branch from c0554ec to 0b69900 Compare August 12, 2026 07:51
@bmuddha
bmuddha force-pushed the dode/configurable-aml-checks branch from 3288f82 to 25ec8f8 Compare August 12, 2026 07:51
@Dodecahedr0x
Dodecahedr0x force-pushed the dode/configurable-aml-checks branch from 25ec8f8 to 06a7780 Compare August 12, 2026 09:14
@Dodecahedr0x
Dodecahedr0x changed the base branch from dode/crank-refactor to dode/external-risk-server August 12, 2026 09:15
@bmuddha
bmuddha force-pushed the dode/external-risk-server branch from f324175 to f16f079 Compare August 12, 2026 09:23
@bmuddha
bmuddha force-pushed the dode/configurable-aml-checks branch from 06a7780 to 7177f6c Compare August 12, 2026 09:24

@GabrielePicco GabrielePicco left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@bmuddha bmuddha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

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.

feat: configurable risk check strategies

3 participants