Conversation
WalkthroughThis change removes the fingerprinting mechanism that previously enforced uniqueness constraints on context rules in the SmartAccount module. The fingerprint-based duplicate detection, storage infrastructure, and associated tests are entirely eliminated. The behavior now allows redundant rules, delegating responsibility to callers to avoid redundancy. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #663 +/- ##
==========================================
- Coverage 96.16% 96.14% -0.03%
==========================================
Files 59 59
Lines 6134 6090 -44
==========================================
- Hits 5899 5855 -44
Misses 235 235 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/accounts/src/smart_account/test/signers_and_policies.rs (1)
258-299: Add a regression for exact duplicate rules.This still uses two different
CallContracttargets, so it only proves refcounting across distinct rules. The behavior this PR changes is that two identical rules can now coexist; please add a companion test that creates the sameContextRuleTypeand signer set twice, then removes one and asserts the shared signer entry is only decremented, not deregistered.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/accounts/src/smart_account/test/signers_and_policies.rs` around lines 258 - 299, Add a new test that covers the regression where two identical rules (same ContextRuleType and identical signer set) coexist: create a Signer::Delegated instance and call add_context_rule twice with the same ContextRuleType::CallContract (same target) and the same Vec of signers (cloning the same signer), then remove the signer from only the first rule using get_signer_id and remove_signer and assert via SmartAccountStorageKey::SignerData that the SignerEntry.count is decremented (== 1) rather than the signer being deregistered; mirror the existing remove_signer_shared_across_rules_decrements_count pattern (use Env::default(), Address::generate, add_context_rule, get_signer_id, remove_signer) but name the test e.g. remove_signer_exact_duplicate_rules_decrements_count.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/accounts/src/smart_account/mod.rs`:
- Around line 200-204: The current API (get_context_rules_count,
get_context_rule) leaves callers unable to enumerate live rules because rule IDs
are monotonic while Count decrements on deletion; update the contract to either
enforce on-chain uniqueness or add an enumerable/view API so callers can
reconstruct the live set—specifically add a function like get_context_rule_ids
or next_rule_id (or both) and/or a live iterator over rule IDs, update relevant
logic in the smart_account module where rules are created/removed (referencing
Count, get_context_rules_count, get_context_rule, and the rule creation/removal
functions) so deletions maintain an index or expose the next_id/IDs view to
callers.
---
Nitpick comments:
In `@packages/accounts/src/smart_account/test/signers_and_policies.rs`:
- Around line 258-299: Add a new test that covers the regression where two
identical rules (same ContextRuleType and identical signer set) coexist: create
a Signer::Delegated instance and call add_context_rule twice with the same
ContextRuleType::CallContract (same target) and the same Vec of signers (cloning
the same signer), then remove the signer from only the first rule using
get_signer_id and remove_signer and assert via
SmartAccountStorageKey::SignerData that the SignerEntry.count is decremented (==
1) rather than the signer being deregistered; mirror the existing
remove_signer_shared_across_rules_decrements_count pattern (use Env::default(),
Address::generate, add_context_rule, get_signer_id, remove_signer) but name the
test e.g. remove_signer_exact_duplicate_rules_decrements_count.
🪄 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: CHILL
Plan: Pro
Run ID: dfa53ed8-872b-4e0a-98fe-ba0b7cd15eb4
📒 Files selected for processing (5)
packages/accounts/src/smart_account/mod.rspackages/accounts/src/smart_account/storage.rspackages/accounts/src/smart_account/test/fingerprints.rspackages/accounts/src/smart_account/test/mod.rspackages/accounts/src/smart_account/test/signers_and_policies.rs
💤 Files with no reviewable changes (2)
- packages/accounts/src/smart_account/test/mod.rs
- packages/accounts/src/smart_account/test/fingerprints.rs
PR Checklist
Summary by CodeRabbit