Skip to content

feat(full trace): Add full trace hook framework#103

Merged
JimmyShi22 merged 16 commits intodevfrom
jimmyshi/engine-api-middleware
Jan 21, 2026
Merged

feat(full trace): Add full trace hook framework#103
JimmyShi22 merged 16 commits intodevfrom
jimmyshi/engine-api-middleware

Conversation

@JimmyShi22
Copy link
Contributor

@JimmyShi22 JimmyShi22 commented Jan 20, 2026

This pull request introduces two new crates, xlayer-engine-api and xlayer-full-trace, to the codebase and wires them into the workspace. These crates provide a modular middleware system for the Engine API and comprehensive tracing capabilities for both Engine API and RPC transaction calls. The changes include new builder and middleware traits for the Engine API, as well as tools for tracing blockchain state changes and transaction submissions.

The most important changes are:

Engine API Middleware System:

  • Added the new crate xlayer-engine-api, which provides a builder pattern (XLayerEngineApiBuilder) and a core middleware trait (XLayerEngineApiMiddleware) for composing middleware with the Optimism Engine API. This enables extensible customization of Engine API behavior. [1] [2] [3] [4] [5]

Full Trace and Tracing Infrastructure:

  • Introduced the xlayer-full-trace crate, which supplies tracing functionality for both Engine API calls and RPC transaction submissions. This includes event hooks for tracing state changes and transaction events, as well as example usage and documentation. [1] [2] [3] [4]

Blockchain and RPC Tracing Implementations:

  • Added a blockchain tracer (blockchain_tracer.rs) that listens for canonical state changes (commits and reorgs) and triggers event handlers for block and transaction commits.
  • Implemented an RPC tracer middleware (rpc_tracer.rs) which intercepts transaction submission RPC calls (eth_sendRawTransaction, eth_sendTransaction) and invokes tracing logic before delegating to the underlying service.
  • Implemented an Engine API tracer middleware (engine_api_tracer.rs) which intercepts Engine API calls (new_payload_v2/v3/v4, fork_choice_updated_v1/v2/v3) and invokes tracing logic before delegating to the underlying OpEngineApi service.

Dependency and Workspace Updates:

  • Registered the new crates in the workspace and added their dependencies to Cargo.toml, including additional Reth and Alloy libraries to support the new functionality. [1] [2] [3]

These changes lay the groundwork for modular middleware and tracing extensibility in the XLayer node.

@JimmyShi22 JimmyShi22 marked this pull request as ready for review January 20, 2026 09:09
@JimmyShi22 JimmyShi22 changed the title feat(engine api): Add engine api hook for full trace feat(full trace): Add full trace hook framework Jan 20, 2026
let inner = self.inner.clone();
let method_owned = method.to_string();

Either::Right(Box::pin(async move {
Copy link
Contributor

Choose a reason for hiding this comment

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

Box::pin performs heap allocation per call I believe. Do we need this?

@JimmyShi22 JimmyShi22 merged commit f88111f into dev Jan 21, 2026
Args: Clone + Send + Sync + 'static,
{
/// The inner OpEngineApi (set during build)
inner: Option<InnerOpEngineApi<Provider, EngineT, Pool, Validator, ChainSpec>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

We should remove the option here to ensure that the inner engine api handler is never null.

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest we completely rename the full-trace to a generic XLayerEngineApi handler, since this infrastructure allows us to add custom logic in the future, if required

@Vui-Chee Vui-Chee deleted the jimmyshi/engine-api-middleware branch January 27, 2026 10:34
louisliu2048 pushed a commit that referenced this pull request Feb 5, 2026
* upgrade to v1.10.0 (#98)

* perf(builder): use XLayerPayloadServiceBuilder to simplify main codes (#95)

Co-authored-by: Vui-Chee <vuicheesiew@gmail.com>
Co-authored-by: Niven <sieniven@gmail.com>

* drop unused dep

* chore: better rename, fix unused variable warning (#99)

* Better refactor, fix unused var warn

* Better rename

* Remove xlayer suffix

* Align cargo chef base image with latest rust toolchain version (#100)

* Update builder version (#101)

* feat(full trace): Add full trace hook framework (#103)

* add engine api hook for full trace

* rm comment

* fix clippy

* add send tx hook

* add blockchain tracer

* cargo lock

* fix review issues

* simplify to tracer to avoid nasty type bonanza

* renamed `TracerConfig` to `Tracer`

* more renames

* EngineApiTracer derive clone over manual impl

* handle middleware overwrite problem

* reorder

* drop clone

* no box on middleware rpc tracer

* impl `EngineApiBuilder` directly to tracer

---------

Co-authored-by: Vui-Chee <vuicheesiew@gmail.com>

* fix: remove engine api, and simplify monitor logic (#107)

* remove unused reth-node-api (#108)

* fix: resolve audit issues related to flashblocks subscription (#113)

* Fix unnecessary clone

* Fix incomplete documentation of subscribe addrs filter

* Better desc

* chore(flashblocks): update builder version to v0.2.5 (#114)

* Update builder version to v0.2.5 with full link monitor updates

* Fix wspub init

* feat: Add Transaction Trace Monitoring Support (#115)

* add trace logic

* optimize

* fix ut

* fix ut

* fix

* fix

* optimize code

* optimize code

* fix

* chore: fix rust formatter (#132)

* Fix fmt

* Remove unused dep

* Fix nested if else clippy check

* Update dependencies, use reth v1.10.2 and builder v0.3.0 (#133)

* fix: upgrade reth v1.10.2 version with bug fixes (#134)

* Fix revm dep

* Update reth version, use merge fixes version

* Add audit report (#135)

* add audit report

* add audit report

---------

Co-authored-by: chunsheng.wang <chunsheng.wang@okg.com>

* feat: add flashblocks enabled RPC method (#136)

* feat: add flashblocks enabled RPC method

* chore: clippy

* chore: add unit tests

* chore: reword documentation

* remove min gas rpc (#138)

---------

Co-authored-by: jimmyshi <417711026@qq.com>
Co-authored-by: Niven <sieniven@gmail.com>
Co-authored-by: Leo <335209779@qq.com>
Co-authored-by: wangchunsheng-ops <13614269216@163.com>
Co-authored-by: chunsheng.wang <chunsheng.wang@okg.com>
Co-authored-by: lucas <66681646+limyeechern@users.noreply.github.com>
louisliu2048 pushed a commit that referenced this pull request Feb 5, 2026
* upgrade to v1.10.0 (#98)

* perf(builder): use XLayerPayloadServiceBuilder to simplify main codes (#95)

Co-authored-by: Vui-Chee <vuicheesiew@gmail.com>
Co-authored-by: Niven <sieniven@gmail.com>

* drop unused dep

* chore: better rename, fix unused variable warning (#99)

* Better refactor, fix unused var warn

* Better rename

* Remove xlayer suffix

* Align cargo chef base image with latest rust toolchain version (#100)

* Update builder version (#101)

* feat(full trace): Add full trace hook framework (#103)

* add engine api hook for full trace

* rm comment

* fix clippy

* add send tx hook

* add blockchain tracer

* cargo lock

* fix review issues

* simplify to tracer to avoid nasty type bonanza

* renamed `TracerConfig` to `Tracer`

* more renames

* EngineApiTracer derive clone over manual impl

* handle middleware overwrite problem

* reorder

* drop clone

* no box on middleware rpc tracer

* impl `EngineApiBuilder` directly to tracer

---------

Co-authored-by: Vui-Chee <vuicheesiew@gmail.com>

* fix: remove engine api, and simplify monitor logic (#107)

* remove unused reth-node-api (#108)

* fix: resolve audit issues related to flashblocks subscription (#113)

* Fix unnecessary clone

* Fix incomplete documentation of subscribe addrs filter

* Better desc

* chore(flashblocks): update builder version to v0.2.5 (#114)

* Update builder version to v0.2.5 with full link monitor updates

* Fix wspub init

* feat: Add Transaction Trace Monitoring Support (#115)

* add trace logic

* optimize

* fix ut

* fix ut

* fix

* fix

* optimize code

* optimize code

* fix

* chore: fix rust formatter (#132)

* Fix fmt

* Remove unused dep

* Fix nested if else clippy check

* Update dependencies, use reth v1.10.2 and builder v0.3.0 (#133)

* fix: upgrade reth v1.10.2 version with bug fixes (#134)

* Fix revm dep

* Update reth version, use merge fixes version

* Add audit report (#135)

* add audit report

* add audit report

---------

Co-authored-by: chunsheng.wang <chunsheng.wang@okg.com>

* feat: add flashblocks enabled RPC method (#136)

* feat: add flashblocks enabled RPC method

* chore: clippy

* chore: add unit tests

* chore: reword documentation

* remove min gas rpc (#138)

---------

Co-authored-by: jimmyshi <417711026@qq.com>
Co-authored-by: Niven <sieniven@gmail.com>
Co-authored-by: Leo <335209779@qq.com>
Co-authored-by: wangchunsheng-ops <13614269216@163.com>
Co-authored-by: chunsheng.wang <chunsheng.wang@okg.com>
Co-authored-by: lucas <66681646+limyeechern@users.noreply.github.com>
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.

3 participants