Skip to content

feat(rpc): add machine-readable UserOp safety warnings - #879

Open
realmehmetali wants to merge 1 commit into
worldcoin:mainfrom
realmehmetali:codex/agent-safety-warnings
Open

feat(rpc): add machine-readable UserOp safety warnings#879
realmehmetali wants to merge 1 commit into
worldcoin:mainfrom
realmehmetali:codex/agent-safety-warnings

Conversation

@realmehmetali

@realmehmetali realmehmetali commented Jul 18, 2026

Copy link
Copy Markdown

Summary

  • Populate the existing warnings response field with typed, deterministic safety signals.
  • Warn on unlimited ERC-20 approvals, active operator approvals, and smart-account authority changes affecting the simulated sender.
  • Evaluate the final approval state so a permission revoked or reduced later in the same operation does not leave a stale warning.
  • Return no warnings for reverted simulations and deterministically deduplicate warning codes.

Why

Autonomous agents and smart-account wallets need machine-readable safety inputs before they sign. The simulator already extracts objective approval and account-management effects; exposing those facts as stable warning codes lets clients enforce local policy without trusting an external reputation service.

These warnings describe state changes, not intent. They do not label a destination, asset, or operation as malicious.

Safety and scope

  • Read-only RPC response change; no consensus, execution, state, or gas behavior changes.
  • No external calls, allowlists, reputation feeds, credentials, or new dependencies.
  • Only effects on the simulated sender can produce warnings.
  • Existing response shape is preserved: the previously reserved warnings array is now populated with typed entries.

Validation

  • cargo fmt --all -- --check
  • cargo test -p world-chain-rpc --lib (16 passed)
  • cargo test -p world-chain-rpc --test fork_simulate --no-run
  • cargo clippy -p world-chain-rpc --lib --tests -- -D warnings

New tests cover final approval ordering, grant-then-revoke behavior, account-authority changes, reverted simulations, unrelated accounts, deterministic deduplication, and stable JSON serialization.


Note

Low Risk
Read-only RPC response enrichment with no execution or state changes; only affects clients consuming the previously empty warnings array.

Overview
The simulate_unsignedUserOp response fills the reserved warnings field with typed SimulationWarning entries instead of always returning an empty array. Warnings describe objective effects on the simulated sender only—unlimited ERC-20 approvals, active ApprovalForAll-style operator grants, and smart-account authority changes (ownership, modules, proxy upgrade, self-destruct, authorization)—not malicious intent.

generate_simulation_warnings derives warnings from existing exposure_changes and contract_management output. Approval signals use the final state per (asset, counterparty, approval kind) so a later reduce/revoke in the same UserOp does not leave a stale warning. Reverted simulations return no warnings; results are deduplicated and ordered via BTreeSet.

New unit tests cover approval ordering, grant/revoke, account-management mapping, unrelated accounts, reverts, and stable JSON serialization for warning types.

Reviewed by Cursor Bugbot for commit ee6bb2a. Bugbot is set up for automated code reviews on this repo. Configure here.

Populate the existing warnings field from simulation effects. Evaluate final approval state to avoid warnings for permissions revoked later in the same operation.
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