Feat: whale- guard implementation. - #1659
Open
YuvikaLimboo wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 Summary
This update adds a security check to the "Human-in-the-Loop" (HITL) system. It automatically flags large transactions for manual approval and adds a way to track the history of a transaction so we can verify it later.
🔗 Related Issues
Closes #1658
🧠 Context
When the system handles money or important data, we shouldn't let large amounts move without a person double-checking. This change creates a "safety trigger" for big transactions and ensures we keep a clear record (an audit trail) of who did what and when. This is standard for any professional financial or blockchain software.
🛠️ Changes
Large Transaction Check: Added a rule that stops any transaction over 100 SOL and asks for a manual review.
Better Error Messages: Added specific labels for errors, such as when a digital signature is wrong or when a record is missing important information.
Record Keeping: Added a requirement for an "audit trail" so the system knows the history of every request.
System Cleanup: Made sure these new errors talk to the main engine correctly so the whole program doesn't crash when a check fails.
🧪 How you Tested
I tested these changes using the built-in testing tools in the crates/mofa-kernel/src/hitl/policy.rs file.
Test Commands: I ran cargo test hitl::policy::policy_tests.
Big Transaction Test: I verified that a 150 SOL transaction is stopped correctly.
Missing Info Test: I verified that if the record-keeping info is missing, the system catches it and shows an error.
📸 Screenshots / Logs
Plaintext
running 2 tests
test hitl::policy::policy_tests::test_audit_validation_policy_triggers ... ok
test hitl::policy::policy_tests::test_whale_guard_triggers_on_large_amount ... ok
test result: ok. 2 passed; 0 failed; finished in 0.33s
⚠️ Breaking Changes
[x] No breaking changes (This won't break existing code).
🧹 Checklist
[x] Code is clean and follows standard Rust rules.
[x] Ran cargo fmt to fix spacing and layout.
[x] All tests passed on my computer.
[x] The commit messages explain the reasoning behind the changes.
🧩 Additional Notes for Reviewers
I have set the limit for "large transactions" to 100 SOL for now. In the future, we can make this number adjustable, but for now, it is a hard limit to keep things safe.