perf(full trace): Use on_block_build_start hook instead of on_fork_choice_updated#106
Closed
JimmyShi22 wants to merge 1 commit intodevfrom
Closed
perf(full trace): Use on_block_build_start hook instead of on_fork_choice_updated#106JimmyShi22 wants to merge 1 commit intodevfrom
JimmyShi22 wants to merge 1 commit intodevfrom
Conversation
sieniven
reviewed
Jan 22, 2026
| /// The inner OpEngineApi (set during build) | ||
| inner: Option<InnerOpEngineApi<Provider, EngineT, Pool, Validator, ChainSpec>>, | ||
| /// The provider to query block information | ||
| provider: Option<Provider>, |
Contributor
There was a problem hiding this comment.
This PR should wait for the PR #107 to be inside, and then explicitly pass the provider reference inside the engine api. We should not have the option type here, and on compile time deterministically build the engine api with the provider inside the XLayerEngineApiBuilder
sieniven
reviewed
Jan 22, 2026
| info!(target: "xlayer::engine", "XLayer Engine API initialized with tracer middleware"); | ||
|
|
||
| // Store the provider for querying block information | ||
| self.set_provider(ctx.node.provider().clone()); |
Contributor
There was a problem hiding this comment.
Already going to set the provider on start up so no need for an option
sieniven
reviewed
Jan 22, 2026
| { | ||
| /// Query the new block number for a fork choice update with payload attributes. | ||
| /// Returns None if provider is not set or if the head block cannot be found. | ||
| fn query_new_block_number(&self, head_block_hash: B256) -> Option<u64> |
Contributor
There was a problem hiding this comment.
No need to make this function fallible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors the block tracing logic in
engine_api_tracer.rsandtracer.rsto improve clarity and accuracy when tracking block build events. The main change is to trigger the tracer only when a new block is being built (i.e., when payload attributes are present), and to pass the new block number to the tracer. The tracer interface is updated to reflect this change, and supporting code is added to query the block number from the provider. Additionally, some type and field adjustments were made for better code organization.Tracing logic improvements
on_block_build_startmethod instead of the previouson_fork_choice_updatedmethod. This change is applied for fork choice updates v1, v2, and v3. [1] [2] [3] [4]query_new_block_numberto query the block number from the provider, which is used to determine the new block number for tracing.API and interface changes
Tracerstruct and its method were updated: removed the fork choice state and payload attributes arguments from the tracing method, and replaced them with the new block number.EngineApiTracerstruct now stores an optional provider for querying block information, with a setter method and updated phantom data usage. [1] [2] [3]Miscellaneous
warnto the tracing imports to log warnings when block information cannot be queried.tracer.rs.