Skip to content

docs: describe the on-device prepare-and-sign flow#358

Merged
eldenpark merged 2 commits into
elden/redesign-transfer-2from
elden/redesign-transfer-2-1
May 27, 2026
Merged

docs: describe the on-device prepare-and-sign flow#358
eldenpark merged 2 commits into
elden/redesign-transfer-2from
elden/redesign-transfer-2-1

Conversation

@eldenpark
Copy link
Copy Markdown
Contributor

Add docs/architecture/transactions/prepare_sign_tx.md — a public-facing
description of how Bedrock turns a user intent into a signed ERC-4337
UserOperation, intended for external auditors of the wallet's
self-custody guarantees.

Sections:

  • Trust model: calldata is constructed locally; the user signs only
    payloads the device can independently verify.
  • What this design replaces: a sequenceDiagram of the legacy
    prepare/send flow where the server encoded calldata and the device
    signed an opaque hash — the two trust gaps that motivated the
    redesign.
  • High-level flow: build callData → wrap in Safe execTransaction →
    compute userOpHash → sponsor → sign → submit → poll.
  • Sponsored path and decline → self-sponsored retry, each with a
    sequenceDiagram and the JSON-RPC wire shapes.
  • Sponsorship decline payload contract: required token /
    paymasterAddress fields, optional advisory cost fields the wallet
    tolerates as absent.
  • Per-step details and observable error categories.
  • Versioning and compatibility: path-versioned endpoint, the
    non-breaking / breaking change distinction, and how Bedrock's FFI
    versioning decouples consumers from server version changes.

The file is intended to be kept up to date as the on-device flow
evolves; it documents the wire contract, not internal infrastructure.

@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 27, 2026

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@eldenpark eldenpark force-pushed the elden/redesign-transfer-2 branch from 9e64d91 to 34de181 Compare May 27, 2026 00:23
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2ffda58cb6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +164 to +167
The five gas fields are zeroed and the paymaster fields (`paymaster`,
`paymasterData`, `paymasterVerificationGasLimit`, `paymasterPostOpGasLimit`)
are **absent** from the response, not present-with-zero values. Bedrock
detects absent fields via `Option<…>` in Rust and skips
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Align no-paymaster response schema with V2 parser

This states that bundler-sponsored responses have zeroed gas and absent paymaster fields, but the SDK’s V2 parser (PmSponsorUserOperationResponse) currently requires paymasterVerificationGasLimit and paymasterPostOpGasLimit and tests expect them present (often as 0x0). If an endpoint is implemented from this doc, Bedrock will fail to deserialize the sponsorship response and transaction execution will stop with a JSON/RPC error.

Useful? React with 👍 / 👎.

Comment on lines +270 to +274
- returns `-32602 "sponsorship declined"` with the structured payload above.

Bedrock never retries on transport errors or `-32603` (internal server
error) — those surface as errors to the user. The decline payload is the
only branch that triggers the self-sponsored retry.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove unsupported automatic decline-retry claim

The document says -32602 decline payloads trigger a self-sponsored retry, but current V2 execution does not implement that branch: RPC errors are surfaced as RpcResponseError and sign_and_execute_v2 returns immediately on pm_sponsorUserOperation failure. As written, this promises behavior Bedrock does not perform and can mislead integrators and auditors about failure handling.

Useful? React with 👍 / 👎.

Add docs/architecture/transactions/prepare_sign_tx.md — a public-facing
description of how Bedrock turns a user intent into a signed ERC-4337
UserOperation, intended for external auditors of the wallet's
self-custody guarantees.

Sections:

- Trust model: calldata is constructed locally; the user signs only
  payloads the device can independently verify.
- What this design replaces: a sequenceDiagram of the legacy
  prepare/send flow where the server encoded calldata and the device
  signed an opaque hash — the two trust gaps that motivated the
  redesign.
- High-level flow: build callData → wrap in Safe execTransaction →
  compute userOpHash → sponsor → sign → submit → poll.
- Sponsored path and decline → self-sponsored retry, each with a
  sequenceDiagram and the JSON-RPC wire shapes.
- Sponsorship decline payload contract: required token /
  paymasterAddress fields, optional advisory cost fields the wallet
  tolerates as absent.
- Per-step details and observable error categories.
- Versioning and compatibility: path-versioned endpoint, the
  non-breaking / breaking change distinction, and how Bedrock's FFI
  versioning decouples consumers from server version changes.

The file is intended to be kept up to date as the on-device flow
evolves; it documents the wire contract, not internal infrastructure.
@eldenpark eldenpark force-pushed the elden/redesign-transfer-2-1 branch from 2ffda58 to dcde82e Compare May 27, 2026 00:25
@eldenpark eldenpark merged commit 9d93d4e into elden/redesign-transfer-2 May 27, 2026
10 checks passed
@eldenpark eldenpark deleted the elden/redesign-transfer-2-1 branch May 27, 2026 21:22
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.

1 participant