Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(payload) : optimize new payload job by fetching only header hash instead of block #12343

Merged
merged 3 commits into from
Nov 6, 2024

Conversation

lean-apple
Copy link
Contributor

@lean-apple lean-apple commented Nov 6, 2024

Optimization in response of this comment.

Comment on lines +147 to 159
let parent_header = if attributes.parent().is_zero() {
// Use latest header for genesis block case
self.client
.block_by_number_or_tag(BlockNumberOrTag::Latest)?
.ok_or_else(|| PayloadBuilderError::MissingParentBlock(attributes.parent()))?
.seal_slow()
.latest_header()
.map_err(PayloadBuilderError::from)?
.ok_or_else(|| PayloadBuilderError::MissingParentHeader(B256::ZERO))?
} else {
let block = self
.client
.find_block_by_hash(attributes.parent(), BlockSource::Any)?
.ok_or_else(|| PayloadBuilderError::MissingParentBlock(attributes.parent()))?;

// we already know the hash, so we can seal it
block.seal(attributes.parent())
// Fetch specific header by hash
self.client
.sealed_header_by_hash(attributes.parent())
.map_err(PayloadBuilderError::from)?
.ok_or_else(|| PayloadBuilderError::MissingParentHeader(attributes.parent()))?
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you!!

@lean-apple lean-apple marked this pull request as ready for review November 6, 2024 04:48
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

cool, this is great

@mattsse mattsse added this pull request to the merge queue Nov 6, 2024
@mattsse mattsse added C-perf A change motivated by improving speed, memory usage or disk footprint A-block-building Related to block building labels Nov 6, 2024
// Fetch specific header by hash
self.client
.sealed_header_by_hash(attributes.parent())
.map_err(PayloadBuilderError::from)?
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't seem to need these map_errs?

let config =
PayloadConfig::new(Arc::new(header), self.config.extradata.clone(), attributes);
let config = PayloadConfig::new(
Arc::new(parent_header.clone()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit but we won't need this clone if we use an intermediate hash like previously, or simply create cached_reads before config 🙏.

Merged via the queue into paradigmxyz:main with commit 0c7700f Nov 6, 2024
41 checks passed
@lean-apple lean-apple deleted the optimization-new-payload-job branch November 7, 2024 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-block-building Related to block building C-perf A change motivated by improving speed, memory usage or disk footprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants