feat(profile-metrics-controller): add batched proof-of-ownership signing - #10142
Draft
hmalik88 wants to merge 4 commits into
Draft
feat(profile-metrics-controller): add batched proof-of-ownership signing#10142hmalik88 wants to merge 4 commits into
hmalik88 wants to merge 4 commits into
Conversation
Contributor
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
hmalik88
marked this pull request as draft
September 8, 2026 13:11
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.
Explanation
This PR adds batched proof-of-ownership signing to
@metamask/profile-metrics-controller. Previously,ProfileMetricsControllerrequested one proof signature per queued account by callingProofOfOwnershipService:signfor each account. For snap-backed non-EVM accounts, that meant oneSnapController:handleRequestcall per account, causing large proof-signing fan-out during profile metrics sync.This PR adds
ProofOfOwnershipService:signBatchand updatesProfileMetricsControllerto call it once per entropy-source batch. The service keeps EVM behavior unchanged by signing each EVM account throughKeyringController:signPersonalMessage, but groups snap-backed non-EVM accounts bysnapIdand sends onesignProofOfOwnershipBatchrequest per snap.Batch responses preserve input order. Per-item snap errors are handled per account, so successful proofs in the same batch are still submitted. Whole snap batch failures or malformed responses are allowed to throw, so the sync queue is not cleared on a broken batch integration.
References
Requires wallet snaps to support
signProofOfOwnershipBatch:Breaking Change
ProfileMetricsControllernow callsProofOfOwnershipService:signBatchwhen attaching ownership proofs during profile metrics sync.Consumers must update their controller messenger wiring to delegate
ProofOfOwnershipService:signBatchtoProfileMetricsController. Clients must also ensure the involved wallet snaps support thesignProofOfOwnershipBatchJSON-RPC method before adopting this core version, because this change does not fall back to singletonsignProofOfOwnershipcalls.Checklist
Note
High Risk
Breaking messenger and snap contract changes affect profile metrics proof signing; miswired clients or snaps without batch support can block sync or fail polls until fixed.
Overview
Profile metrics sync now attaches ownership proofs via a single batch signing call per entropy-source batch instead of one
ProofOfOwnershipService:signper account.ProofOfOwnershipService exposes
signBatch: EVM accounts still sign through the keyring individually; snap-backed accounts are grouped by snap ID and sent onesignProofOfOwnershipBatchJSON-RPC call per snap. Responses stay in input order, with per-item{ proof }or{ error }for partial failures.ProfileMetricsController
#attachProofsbuilds all account/nonce pairs, callsProofOfOwnershipService:signBatchonce, and maps results back onto queued accounts. Whole-batch failures (rejection, wrong result count) throw and leave the sync queue intact; individual signing errors still allow submit without proof for those accounts.This is a breaking change: consumers must wire
ProofOfOwnershipService:signBatchon the controller messenger, and wallet snaps must implementsignProofOfOwnershipBatch(no fallback to single-account snap signing).Reviewed by Cursor Bugbot for commit cb8f743. Bugbot is set up for automated code reviews on this repo. Configure here.