Skip to content

Refactor ExecutionEventRecorder into reusable pieces#2093

Open
kjcamann wants to merge 2 commits intomainfrom
ken/new-cxx-recorder
Open

Refactor ExecutionEventRecorder into reusable pieces#2093
kjcamann wants to merge 2 commits intomainfrom
ken/new-cxx-recorder

Conversation

@kjcamann
Copy link
Contributor

@kjcamann kjcamann commented Feb 23, 2026

This refactoring is present in other branches that use event rings for other tasks, e.g., the real-time EVM opcode tracer branch uses a new of event ring content type MONAD_EVENT_CONTENT_TYPE_EVMT, and reuses most of the existing code through this refactoring.

This PR is made up of two commits: the first adds new the new infrastructure and the second refactors the existing ExecutionEventRecorder to use that new infrastructure. The two commit messages describe each change in detail.

Copilot AI review requested due to automatic review settings February 23, 2026 00:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the ExecutionEventRecorder into reusable components, enabling the event ring infrastructure to be used for different types of events beyond execution events. The refactoring extracts common event ring ownership and recording logic into new generic classes.

Changes:

  • Introduced OwnedEventRing class to manage event ring lifecycle (file descriptor, memory mapping, filesystem cleanup)
  • Introduced EventRecorder base class providing a generic C++ interface for event recording with template-based type safety
  • Refactored ExecutionEventRecorder to extend EventRecorder and focus on execution-specific flow tracking (block/transaction IDs)
  • Renamed ReservedExecEvent<T> to ReservedEvent<T> to reflect the generic nature of the infrastructure
  • Moved tests from execution-specific location to core library tests, adding comprehensive coverage for the new generic interfaces
  • Added new test event type MONAD_TEST_EVENT_VLT for testing variable-length trailing data handling

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
category/core/event/owned_event_ring.hpp New RAII class for managing event ring ownership and lifecycle
category/core/event/owned_event_ring.cpp Implementation of OwnedEventRing destructor handling cleanup
category/core/event/event_recorder.hpp New generic C++ interface for type-safe event recording with error handling
category/core/event/event_recorder.cpp Implementation of setup_record_error_event for overflow handling
category/execution/ethereum/event/exec_event_recorder.hpp Refactored to extend EventRecorder, focusing on execution-specific extensions
category/execution/ethereum/event/exec_event_recorder.cpp Simplified to just define global instances, logic moved to base classes
cmd/monad/event.cpp Refactored initialization to use new infrastructure, added init_owned_event_ring helper
test/ethereum_test/src/event.cpp Updated to use OwnedEventRing and new ExecutionEventRecorder constructor
test/ethereum_test/src/blockchain_test.cpp Changed to access event ring through g_exec_event_ring instead of recorder
category/execution/ethereum/event/record_block_events.cpp Updated type from ReservedExecEvent to ReservedEvent
category/execution/ethereum/event/record_txn_events.cpp Updated type from ReservedExecEvent to ReservedEvent
category/execution/monad/event/record_consensus_events.cpp Updated type from ReservedExecEvent to ReservedEvent
category/execution/ethereum/event/test/test_exec_event_recorder.cpp Deleted - tests moved to core library
category/core/test/event_recorder.cpp Added comprehensive tests for new EventRecorder C++ interface
category/core/event/test_event_ctypes.h Added MONAD_TEST_EVENT_VLT for testing
category/core/event/test_event_ctypes_metadata.c Added metadata for new test event type
category/core/CMakeLists.txt Added new source files to build

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kjcamann kjcamann force-pushed the ken/new-cxx-recorder branch from 4e87d88 to 799a306 Compare February 23, 2026 06:28
@kjcamann kjcamann force-pushed the ken/new-cxx-recorder branch from 799a306 to 14a66eb Compare March 6, 2026 17:41
This factors out the C++ event recording infrastructure (that is part
of exec_event_recorder.{hpp,cpp}) into a "generic" event recorder
class with C++ features. In a subsequent commit, the current execution
event recorder will be changed to use this generic utility class.

The reason for doing this is that currently, there is only a single
recorder (the execution event ring). In other branches, other recorders
exist (e.g., the EVM opcode tracer) which have their own C++ helper
objects. This moves the common functionality to a shared class.

Another thing that happens in this refactoring is that event ring
ownership is made a separate concept from the event ring recorder, and
is managed by the RAII helper "OwnedEventRing." Previously, the
exclusive recorder was also responsible for owning the event ring file.
Separating the two concepts simplifies the initialization code when
there are multiple rings.
This also removes the execution event recorder's unit test test, since
the non-trivial functionality lives in the "common" core test now.
@kjcamann kjcamann force-pushed the ken/new-cxx-recorder branch from 14a66eb to 6566b00 Compare March 13, 2026 16:09
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