feat: register and audit agent-wallet rules on-chain#1388
Conversation
|
Warning Review limit reached
More reviews will be available in 50 minutes and 35 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR adds a complete modular-agent-address (MAA) feature, implementing cryptographic derivation precompiles, SQL persistence layer with validation, and public query API, validated by end-to-end integration tests. ChangesModular Agent Address (MAA) Feature
Sequence DiagramsequenceDiagram
participant Client
participant maa_create as maa_create Action
participant PrecompileDeriv as derive_maa_address
participant PrecompileRules as compute_rules_hash
participant maa_rules as maa_rules Table
participant maa_allowed_actions as maa_allowed_actions Table
participant maa_events as maa_events Table
Client->>maa_create: restricted (caller), unrestricted, salt, bridge, fee_mode, fee_bps, fee_flat, namespaces[], actions[], body_hashes[]
maa_create->>maa_create: validate unrestricted hex decode, fee bounds, bridge, parallel array lengths
maa_create->>PrecompileRules: fee_mode, fee_bps, fee_flat, bridge, namespaces, actions, body_hashes
PrecompileRules->>PrecompileRules: deduplicate and sort (namespace, action)
PrecompileRules->>maa_create: rules_hash (32B)
maa_create->>PrecompileDeriv: restricted, unrestricted, rules_hash, salt
PrecompileDeriv->>PrecompileDeriv: build ADDRESS_PREIMAGE, Keccak256
PrecompileDeriv->>maa_create: maa_address (20B)
maa_create->>maa_rules: INSERT rule with fee/bridge/token
maa_create->>maa_allowed_actions: BATCH INSERT allow-listed (namespace, action, body_hash)
maa_create->>maa_events: INSERT CREATE event with transaction metadata
maa_create->>Client: return maa_address
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Time Submission Status
You can submit time with the command. Example: See available commands to help comply with our Guidelines. |
|
@holdex pr submit-time 4h |
# Conflicts: # extensions/tn_utils/maa.go # extensions/tn_utils/maa_test.go
resolves: resolves: https://github.com/truflation/website/issues/4035
What
Part 2 of the Modular Agent Addresses (MAA) rule store: the node migration with the rule tables,
maa_create, and thepublic getters. Stacked on the precompiles PR — this PR's diff is the SQL plus integration tests; the precompiles it
calls live in the base branch.
Depends on (review/merge first):
Changes
048-maa.sql:maa_rules,maa_allowed_actions,maa_events(append-only audit),maa_create(therestricted/agent key signs), and 6 public getters. The rule is set once at creation and immutable — committed into
the wallet address via
rules_hash. The node computesrules_hashon-chain (never trusts a caller-supplied value), sothe address provably commits to the stored rule.
tests/streams/maa/): asserts on-chainmaa_createreproduces the golden-vector address, plusvalidation and audit behavior.
Testing
go test -tags kwiltest ./tests/streams/maa/— pass (~56s)Notes for reviewers
withdrawal/fee path are later work, not in this PR.
design: (1) whether the funding address and the wallet address are one identity (this PR makes them one); (2) whether
rules stay immutable or become editable (this PR is immutable).
Summary by CodeRabbit