Skip to content

fix(rpc)!: answer an id-less object with unstructured params - #5446

Merged
tcoratger merged 1 commit into
ethereum:masterfrom
lambdaclass:fix/rpc-notification-params
Dec 4, 2026
Merged

tcoratger merged 1 commit into
ethereum:masterfrom
lambdaclass:fix/rpc-notification-params

Conversation

@ilitteri

@ilitteri ilitteri commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

An object without an id whose params is neither an array nor an object gets the error -32600, where it got no response.

The problem

JSON-RPC 2.0 defines a notification in section 4.1 as "a Request object without an "id" member", and the server must not reply to one.
Section 4.2 says: "If present, parameters for the rpc call MUST be provided as a Structured value", that is, an array or an object.
So an object with "params": "bar" is no Request object, and no notification either.
Section 5 says that "the Server MUST reply with a Response, except for in the case of Notifications".

isNotification (Execution/Rpc/Methods.lean) read the version, the method and the missing id, but not params.
So answerJson gave no response to such an object, alone or in a batch.

The idea

A value is a notification only if it is a Request object.
So isNotification also requires that params be absent, an array or an object.
Every other object without an id goes to the reader of requests.
That reader rejects it with -32600 and the identifier null, as it already does for an object without an id whose method is no string.
answerJson_isSome_of_params (Execution/Proofs/Rpc/Methods.lean) states that such an object gets a response.

Example

{"jsonrpc":"2.0","method":"eth_chainId"}                 notification, no response
{"jsonrpc":"2.0","method":"eth_chainId","params":{}}     notification, no response
{"jsonrpc":"2.0","method":"eth_chainId","params":"bar"}  -32600, id null

Section 7 has the example "rpc call with invalid Request object": {"jsonrpc": "2.0", "method": 1, "params": "bar"} gets -32600 and the identifier null.
The last line above is that request with a string method, which only the parameters keep from being a notification.

For reviewers

  • A notification whose parameters are an object is still a notification, since section 4.2 allows parameters by name.
    The reader of requests rejects parameters by name, but a notification gets no response either way.
  • "params": null is no structured value, so such an object gets -32600.
    The reader of requests already rejects null parameters in an object with an id.
  • The message of the error is the one that the reader gives for any object without an id: request: no field id.
  • In a batch, serve answers each item with answerJson, so the batch gets the error for that item.

Checks

  • lake build --wfail (whole library, proofs and exports), after a rebase on 4309336: passed.
  • lake exe gen-bindings --check: passed.
  • lake exe check-decls: 0 findings.
    lake exe check-accessors, lake exe check-theorems and check_theorems_baseline.py --base upstream/master: passed, nothing new.
  • lake exe proof-coverage --check and lake exe rule-history --check: passed.
  • soundness_facts.py --check, check_layers.py, check_lean_layout.py --base upstream/master, check_comment_code.py, check_lean_commands.py, check_fork_cap.py and check_fixture_pins.py: passed.
  • uv run --no-sync pytest -n auto: 78094 passed, 680 skipped, 13 xfailed, before the rebase.
    After it, pytest bindings/python/tests/rpc: 915 passed.
    check_vectors.py: 2328 pinned vectors match.
  • ruff check, ruff format --check, ty check, check_raises.py, check_docstrings.py, check_python_boundary.py and check_python_comments.py --all: passed.
    codespell ran on the changed test file only.
  • Not run: ty check --python-version 3.10 of the package and the unit tests of scripts/, which this change does not touch, and the build of tests/downstream.
  • check_writing.py --base upstream/master: S1 suggestions only.

BREAKING CHANGE: execution.rpc answers an object without an id whose params is neither an array nor an object with the error -32600, where it gave no response.

JSON-RPC 2.0 defines a notification as a Request object without an id,
and section 4.2 asks that the parameters, when present, be an array or
an object. isNotification read the version, the method and the missing
id, but not the parameters. So an object such as
{"jsonrpc":"2.0","method":"eth_chainId","params":"bar"} got no
response, alone or in a batch, where section 5 asks for one.

isNotification now also requires that the parameters be absent, an
array or an object. Any other id-less object goes to the reader of
requests, which answers -32600 with the identifier null.
answerJson_isSome_of_params states that such an object gets a response.

BREAKING CHANGE: execution.rpc answers an id-less JSON-RPC object whose
params is neither an array nor an object with the error -32600, where
it gave no response.

@tcoratger tcoratger left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed with a spec, statement, architecture and docs panel. The rule matches JSON-RPC 2.0, sections 4, 4.1, 4.2 and 5: an object whose params is not structured is no Request object, so it is no notification and gets -32600. The fork does not accept maintainer pushes, so the follow-up (a theorem that states the -32600 response itself, plus doc alignment) lands in a separate PR right after this one.

@tcoratger
tcoratger merged commit 29dd50f into ethereum:master Dec 4, 2026
1 check passed
@ilitteri

ilitteri commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Reviewed with a spec, statement, architecture and docs panel. The rule matches JSON-RPC 2.0, sections 4, 4.1, 4.2 and 5: an object whose params is not structured is no Request object, so it is no notification and gets -32600. The fork does not accept maintainer pushes, so the follow-up (a theorem that states the -32600 response itself, plus doc alignment) lands in a separate PR right after this one.

I will check if I can change this rule in our fork

@ilitteri

ilitteri commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Reviewed with a spec, statement, architecture and docs panel. The rule matches JSON-RPC 2.0, sections 4, 4.1, 4.2 and 5: an object whose params is not structured is no Request object, so it is no notification and gets -32600. The fork does not accept maintainer pushes, so the follow-up (a theorem that states the -32600 response itself, plus doc alignment) lands in a separate PR right after this one.

I will check if I can change this rule in our fork

Apparently it is a GitHub limitation. "Allow edits by maintainers" isn't available in organization forks.

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.

2 participants