-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat(payload) : optimize new payload job by fetching only header hash instead of block #12343
Conversation
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()))? | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!!
There was a problem hiding this 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
// Fetch specific header by hash | ||
self.client | ||
.sealed_header_by_hash(attributes.parent()) | ||
.map_err(PayloadBuilderError::from)? |
There was a problem hiding this comment.
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_err
s?
let config = | ||
PayloadConfig::new(Arc::new(header), self.config.extradata.clone(), attributes); | ||
let config = PayloadConfig::new( | ||
Arc::new(parent_header.clone()), |
There was a problem hiding this comment.
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
🙏.
Optimization in response of this comment.