Commit 6f416e4
authored
fix: decode authorization util and prefix errors (#8656)
## Explanation
### Current
EIP-7702 production failures across mobile and extension are surfacing
as bare, unattributable strings in our error metrics — most prominently
`failed to decode param in array[0] invalid JSON input` from Sentinel
relay.
1. **Non-canonical RLP hex in authorization signatures.**
`signAuthorization` slices raw 32-byte signature halves into `r` and `s`
without canonicalizing.
2. **Bare error strings with no failure-surface attribution.** When a
7702 transaction fails, the same generic message can come from any of:
core's `eth_sendRawTransaction`, the Relay strategy's `/execute` POST,
the non-execute relay deposit path, or the Pay publish hook. Metrics
can't distinguish them, and Relay's actual server error (`{ message:
"Insufficient liquidity" }`) is discarded by `successfulFetch` in favour
of a generic URL-leaking template.
### Solution
**Canonicalize once, in core.** A new exported
`decodeAuthorizationSignature(signature)` utility in
`@metamask/transaction-controller` decodes a 65-byte EIP-7702
authorization signature into RLP-canonical `r`, `s`, and `yParity`.
`signAuthorizationList` is refactored to use it, so every signed
authorization tuple emitted by the controller is canonical out of the
box. Mobile/extension can read straight off
`txMeta.txParams.authorizationList` and submit to any backend without
their own strip helpers.
**Layered submission error prefixes.** Four prefixes, each applied at
the lowest sensible layer, that cascade up the call stack to attribute
every failure surface in metrics:
| Layer | Prefix | Wraps |
|---|---|---|
| Core RPC | `RPC submit:` | `eth_sendRawTransaction` failures |
| Relay strategy | `Relay submit:` | the entire `submitRelayQuotes` body
|
| Inner relay execute | `Relay execute:` | Relay `/execute` POST
failures (cascades inside `Relay submit:`) |
| Pay hook | `MetaMask Pay:` | the entire
`TransactionPayPublishHook.#hookWrapper` |
A private `relayFetch` helper in `relay-api.ts` replaces
`successfulFetch` for Relay endpoints. On non-OK responses it surfaces
the response body's `message` or `error` field as `<status> -
<message>`, falling back to `<status>` alone — no URL leakage, server's
actual reason preserved when present.
### Example errors as they appear in metrics
```
MetaMask Pay: Relay submit: Relay execute: 422 - Insufficient liquidity
MetaMask Pay: Relay submit: RPC submit: nonce too low
MetaMask Pay: Insufficient source token balance for relay deposit
MetaMask Pay: Relay submit: Relay execute: 500
MetaMask Pay: Relay submit: Relay execute: 400 - failed to decode param in array[0] invalid JSON input
RPC submit: replacement transaction underpriced
```
## References
- [CONF-1133](https://consensyssoftware.atlassian.net/browse/CONF-1133)
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [x] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them
[CONF-1133]:
https://consensyssoftware.atlassian.net/browse/CONF-1133?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes transaction submission error handling and EIP-7702 signature
decoding, which can affect downstream clients’ ability to submit
transactions and how failures are reported. Main risk is altered error
strings/prefixes and canonicalization behavior impacting
integrations/tests.
>
> **Overview**
> Adds a new exported `decodeAuthorizationSignature` helper for EIP-7702
that canonicalizes `r`/`s` (strips leading zeroes, uses `0x0` for zero)
and derives `yParity`, and refactors authorization signing to use it.
>
> Standardizes failure-surface attribution by wrapping submission errors
with layered prefixes: **`RPC submit:`** for `eth_sendRawTransaction`
failures (including nested `data.message`), **`Relay submit:`** for
Relay strategy execution, **`Relay execute:`** for Relay `/execute` POST
failures, and **`MetaMask Pay:`** for Pay publish hook failures.
>
> Replaces Relay’s `successfulFetch` usage with a local `relayFetch`
that preserves server-provided non-OK details (`<status> -
<message|error>` or `<status>`) without leaking request URLs, and
updates tests/changelogs accordingly.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
1eb9b8c. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent ca69efc commit 6f416e4
16 files changed
Lines changed: 524 additions & 77 deletions
File tree
- packages
- transaction-controller
- src
- utils
- transaction-pay-controller
- src
- helpers
- strategy/relay
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
10 | 15 | | |
11 | 16 | | |
12 | 17 | | |
| |||
Lines changed: 39 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3924 | 3924 | | |
3925 | 3925 | | |
3926 | 3926 | | |
3927 | | - | |
| 3927 | + | |
| 3928 | + | |
| 3929 | + | |
3928 | 3930 | | |
3929 | 3931 | | |
3930 | 3932 | | |
| |||
4276 | 4278 | | |
4277 | 4279 | | |
4278 | 4280 | | |
4279 | | - | |
| 4281 | + | |
| 4282 | + | |
| 4283 | + | |
4280 | 4284 | | |
4281 | 4285 | | |
4282 | 4286 | | |
| |||
4285 | 4289 | | |
4286 | 4290 | | |
4287 | 4291 | | |
| 4292 | + | |
| 4293 | + | |
| 4294 | + | |
| 4295 | + | |
| 4296 | + | |
| 4297 | + | |
| 4298 | + | |
| 4299 | + | |
| 4300 | + | |
| 4301 | + | |
| 4302 | + | |
| 4303 | + | |
| 4304 | + | |
| 4305 | + | |
| 4306 | + | |
| 4307 | + | |
| 4308 | + | |
| 4309 | + | |
| 4310 | + | |
| 4311 | + | |
| 4312 | + | |
| 4313 | + | |
| 4314 | + | |
| 4315 | + | |
| 4316 | + | |
| 4317 | + | |
| 4318 | + | |
| 4319 | + | |
| 4320 | + | |
| 4321 | + | |
| 4322 | + | |
| 4323 | + | |
| 4324 | + | |
4288 | 4325 | | |
4289 | 4326 | | |
4290 | 4327 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3372 | 3372 | | |
3373 | 3373 | | |
3374 | 3374 | | |
3375 | | - | |
| 3375 | + | |
3376 | 3376 | | |
3377 | 3377 | | |
3378 | 3378 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
| |||
Lines changed: 88 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
257 | 258 | | |
258 | 259 | | |
259 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
260 | 348 | | |
261 | 349 | | |
262 | 350 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
250 | 287 | | |
251 | 288 | | |
252 | 289 | | |
| |||
284 | 321 | | |
285 | 322 | | |
286 | 323 | | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
| 324 | + | |
294 | 325 | | |
295 | 326 | | |
296 | 327 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
| |||
Lines changed: 18 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
| 193 | + | |
194 | 194 | | |
195 | 195 | | |
196 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
197 | 213 | | |
198 | 214 | | |
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
111 | 145 | | |
0 commit comments