Skip to content

fix(python): return the Beacon API event data as JSON text - #2515

Merged
tcoratger merged 1 commit into
ethereum:masterfrom
tcoratger:fix-boundary-events
Nov 14, 2026
Merged

tcoratger merged 1 commit into
ethereum:masterfrom
tcoratger:fix-boundary-events

Conversation

@tcoratger

Copy link
Copy Markdown
Collaborator

The Beacon API pool and publish endpoints, and the gossip event export, now return the data of each event as its JSON text instead of a parsed value.
This makes the soundness CI job pass again, since the consensus package module no longer imports json.

The problem

The Python boundary check, scripts/check_python_boundary.py, forbids json in a package module: a wrapper passes typed values to the native call and back.
api_post and api_gossip_event parsed the event data with json.loads, so the check failed on master.

The idea

The native calls already return each event as a pair (topic name, JSON data text).
That text is the data field of the Beacon API event stream, and the fork choice event exports api_chain_events and api_fast_confirmation_event return the same pair.
So the two wrappers now return the native pair unchanged, and the tests parse the text themselves.

Example

A valid capella block published to blocks gives the events ("block_gossip", '{"slot":"…","block":"0x…"}') and ("block", '{…,"execution_optimistic":false}').
Before, the second element was a dict; now it is that text, and json.loads gives the same dict as before.

For reviewers

  • This breaks Python callers of the two functions; CHANGELOG.md records it under 0.4.0.
  • The tests gain two helpers in test_beacon_api_events.py: parsed parses the events of each answer, and gossip_event parses the event of one object.
    The pool and publish tests import parsed; tests that compare only topics are unchanged.
  • No allowlist entry is added.

Checks

  • scripts/check_python_boundary.py: passes.
  • python -m unittest scripts/test_check_python_boundary.py: OK.
  • ruff check --no-fix, ruff format --check, ty check: pass.
  • scripts/check_python_comments.py --all, scripts/check_docstrings.py: pass.
  • pytest on test_beacon_api_publish.py, test_beacon_api_events.py and test_beacon_api_pool.py, with the extension built by uv sync: 490 passed.

🤖 Generated with Claude Code

The pool and publish endpoints and the gossip event export return the
data of each event as the JSON text that the native call gives, as the
fork choice event exports already do. The consensus package module no
longer imports json, so the Python boundary check passes again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tcoratger
tcoratger merged commit 4884a11 into ethereum:master Nov 14, 2026
2 checks passed
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