feat: external risk service - #1407
Conversation
|
Important Review skippedToo many files! This PR contains 395 files, which is 295 over the limit of 100. To get a review, narrow the scope: Upgrade to a paid plan to raise the limit. Usage-priced reviews support at most 300 files. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (6)
📒 Files selected for processing (643)
You can disable this status message by setting the 📝 WalkthroughWalkthroughThis PR replaces the Range API AML client with a thin HTTP client querying Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 `@config.example.toml`:
- Around line 272-287: The full-coverage example config test is missing
assertions for the new Chainlink risk settings. Update
test_example_config_full_coverage in tests.rs to also verify
config.chainlink.risk.risk_server_url and config.chainlink.risk.request_timeout
alongside config.chainlink.risk.enabled, so the example file’s new values are
covered and any drift is caught. Use the existing
test_example_config_full_coverage and config.chainlink.risk fields to locate the
check.
In `@magicblock-aml/src/lib.rs`:
- Around line 43-57: `Risk::try_from_config` currently stores
`config.risk_server_url` without validation, so invalid or empty URLs only fail
later during requests. Add a parse/validation step in `try_from_config` before
constructing `Self`, and map failures to an appropriate `RiskError` so startup
fails fast. Keep the existing `Client::builder` setup and `base_url` assignment,
but ensure `RiskConfig::risk_server_url` is validated before trimming and
storing it.
In `@magicblock-chainlink/src/chainlink/errors.rs`:
- Around line 73-74: Rename the RangeRisk error variant to RiskCheckFailed in
the errors enum so it matches the new risk server naming. Update the enum
definition in the Errors/RiskError area and keep the existing #[error(...)]
message and #[from] conversion aligned with the new variant name, then fix any
references that still use RangeRisk across the Chainlink error handling code.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 1ead3eac-31fd-40bc-b762-990a70bf8305
⛔ Files ignored due to path filters (2)
Cargo.lockis excluded by!**/*.locktest-integration/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (11)
config.example.tomlmagicblock-aml/Cargo.tomlmagicblock-aml/src/lib.rsmagicblock-api/src/magic_validator.rsmagicblock-chainlink/src/chainlink/errors.rsmagicblock-chainlink/src/chainlink/mod.rsmagicblock-config/src/config/chain.rsmagicblock-config/src/consts.rsmagicblock-config/src/tests.rstest-integration/test-aml/src/lib.rstest-integration/test-chainlink/tests/ix_aml_undelegation.rs
💤 Files with no reviewable changes (2)
- magicblock-aml/Cargo.toml
- magicblock-api/src/magic_validator.rs
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
config.example.toml (1)
273-277: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winUpdate stale documentation to match the new risk server architecture.
These comments still reference the deprecated "Range Risk API" and "Range API", which might cause confusion since the client and configuration have been updated to use a generic risk server.
📝 Proposed fix
-# Optional: Range Risk API validation for post-delegation actions signers +# Optional: Risk server validation for post-delegation actions signers # ------------------------------------------------------------------------------ # When enabled, all signers referenced by post-delegation actions are checked -# against Range API before actions are allowed to execute. +# against the risk server before actions are allowed to execute. [chainlink.risk]🤖 Prompt for 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. In `@config.example.toml` around lines 273 - 277, Update the comments above the [chainlink.risk] configuration section to replace the deprecated “Range Risk API” and “Range API” terminology with the current generic risk server terminology, while preserving the documented validation behavior.
🤖 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.
Outside diff comments:
In `@config.example.toml`:
- Around line 273-277: Update the comments above the [chainlink.risk]
configuration section to replace the deprecated “Range Risk API” and “Range API”
terminology with the current generic risk server terminology, while preserving
the documented validation behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 2110284f-dc0f-4102-8e7e-ffd82ab37cb6
⛔ Files ignored due to path filters (2)
Cargo.lockis excluded by!**/*.locktest-integration/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (8)
config.example.tomlmagicblock-aml/src/lib.rsmagicblock-api/src/magic_validator.rsmagicblock-chainlink/src/chainlink/errors.rsmagicblock-chainlink/src/chainlink/mod.rsmagicblock-config/src/config/chain.rsmagicblock-config/src/consts.rsmagicblock-config/src/tests.rs
d84816f to
9e0810e
Compare
Summary
Relies on the query filtering service to get risk results, sharing the same cache to reduce API calls. Closes #1433
Breaking Changes
Summary by CodeRabbit
pubkey-based queries.risk-server-urlandrequest-timeout.GET /risk?pubkey=response format.