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

rpc: add uncle_block_from_header impl and test #1554

Merged
merged 8 commits into from
Oct 24, 2024

Conversation

tcoratger
Copy link
Contributor

@tcoratger tcoratger commented Oct 23, 2024

The goal here is similar to #1532

In reth we have:

https://github.com/paradigmxyz/reth/blob/2ae93682b4978bf80bf27c777334ead30d3e04f5/crates/rpc/rpc-types-compat/src/block.rs#L178-L192

And I have found myself several times in the situation where I was forced to go through the reth-rpc-types-compat crate just for this small conversion.

Seems like more logical and smooth to have it directly in alloy since the target type is an alloy rpc type.

I did a test against reth implementation to check the results are the same

image

crates/rpc-types-eth/src/block.rs Outdated Show resolved Hide resolved
crates/rpc-types-eth/src/block.rs Outdated Show resolved Hide resolved
Comment on lines 66 to 76
size: Some(U256::from(
alloy_consensus::Block {
header,
body: alloy_consensus::BlockBody::<TxEnvelope> {
transactions: vec![],
ommers: vec![],
withdrawals: None,
},
}
.length(),
)),
Copy link
Member

Choose a reason for hiding this comment

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

the size is also based on the entire block so we need to create the block first, then get it's size

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mattsse Normally it's good. I just quickly implemented what you did in #1561 (we can merge the two one after the other it should work) so that I can use it directly here. So the logic is for this line:

  • Create a consensus primitive block
  • Calculate its length
  • Insert it here in the block size

@mattsse mattsse mentioned this pull request Oct 24, 2024
@mattsse mattsse merged commit ae1bef2 into alloy-rs:main Oct 24, 2024
26 checks passed
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