Skip to content

Feat: whale- guard implementation. - #1659

Open
YuvikaLimboo wants to merge 3 commits into
mofa-org:mainfrom
YuvikaLimboo:feat/whale-guard-implementation
Open

Feat: whale- guard implementation.#1659
YuvikaLimboo wants to merge 3 commits into
mofa-org:mainfrom
YuvikaLimboo:feat/whale-guard-implementation

Conversation

@YuvikaLimboo

Copy link
Copy Markdown

📋 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.

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.

Add transaction safety limits and history tracking.

1 participant