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

chore(sdk): improve usability BlockBody and Block traits #12450

Open
wants to merge 44 commits into
base: emhane/block-header
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c1e7aaa
Implement Transaction for SignedTransaction types
emhane Nov 10, 2024
cccd708
Improve usability transaction primitive traits
emhane Nov 10, 2024
c93bdb4
Improve usability of block primitive traits
emhane Nov 10, 2024
8e0da8f
Improve usability transaction primitive traits
emhane Nov 10, 2024
68108f8
Add blanket impl for TxType
emhane Nov 10, 2024
99c9943
Fix conflicts
emhane Nov 10, 2024
ae6d4b8
Fix arbitrary feature gate
emhane Nov 10, 2024
4590275
Merge branch 'emhane/signed-tx' into emhane/block-body
emhane Nov 11, 2024
421f5fc
Merge branch 'main' into emhane/signed-tx
emhane Nov 11, 2024
4ca8e2d
Merge branch 'emhane/signed-tx' into emhane/block-body
emhane Nov 11, 2024
270d437
Merge branch 'main' into emhane/block-body
emhane Nov 11, 2024
e77c3f1
Merge branch 'main' into emhane/signed-tx
emhane Nov 12, 2024
d0cbfc9
Add todo
emhane Nov 12, 2024
ffe638a
Fix merge conflicts
emhane Nov 12, 2024
02f1be9
Merge branch 'main' into emhane/signed-tx
emhane Nov 12, 2024
385f5d6
Fix lint
emhane Nov 12, 2024
df5bde0
Merge branch 'main' into emhane/signed-tx
emhane Nov 12, 2024
9c973ae
Fix merge conflicts
emhane Nov 12, 2024
fcda0dc
Remove redundant trait method
emhane Nov 12, 2024
a3c289d
Merge branch 'emhane/signed-tx' into emhane/block-body
emhane Nov 12, 2024
85968fb
Fix merge conflicts
emhane Nov 12, 2024
355422e
Merge branch 'main' into emhane/block-body
emhane Nov 14, 2024
5238a0c
Remove redundant trait Body
emhane Nov 14, 2024
c030e79
Add trait method SignedTransaction::recover_signers
emhane Nov 14, 2024
3fb31f1
Impl BlockBody and BlockHeader for reth_primitives::Block
emhane Nov 14, 2024
3582f28
Merge branch 'main' into emhane/block-body
emhane Nov 14, 2024
5f46bda
Improve TxType trait usability
emhane Nov 14, 2024
3b7e324
Fix merge conflicts
emhane Nov 14, 2024
543764e
Simplify use of BlockBody for all types that impl Block
emhane Nov 14, 2024
924743c
Fix lint
emhane Nov 14, 2024
133a957
Merge branch 'emhane/tx-type' into emhane/block-body
emhane Nov 14, 2024
cac0655
Inline Body impl for Block types
emhane Nov 14, 2024
ab284eb
Impl Header for all Block types
emhane Nov 14, 2024
a35ced3
Fix deps
emhane Nov 14, 2024
9fa13f9
Inline Header impl for Block types
emhane Nov 14, 2024
6924640
Merge branch 'main' into emhane/block-body
emhane Nov 15, 2024
7277ff3
Merge branch 'main' into emhane/block-body
emhane Nov 15, 2024
aae06fd
Merge branch 'main' into emhane/block-body
emhane Nov 18, 2024
85e3125
Merge branch 'main' into emhane/block-body
emhane Nov 18, 2024
d1c825d
Add module reth_primitives_traits::block_prelude
emhane Nov 18, 2024
8bf8a55
Fix lint
emhane Nov 18, 2024
fd4738d
Fix merge conflicts
emhane Nov 18, 2024
54e2921
Merge branch 'emhane/block-header' into emhane/block-body
emhane Nov 19, 2024
75d952a
Fix lint
emhane Nov 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 43 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions crates/e2e-test-utils/src/engine_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ impl<E: EngineTypes, ChainSpec: EthereumHardforks> EngineApiTestContext<E, Chain
E::ExecutionPayloadEnvelopeV3: From<E::BuiltPayload> + PayloadEnvelopeExt,
E::ExecutionPayloadEnvelopeV4: From<E::BuiltPayload> + PayloadEnvelopeExt,
{
let versioned_hashes =
payload.block().blob_versioned_hashes_iter().copied().collect::<Vec<_>>();
let versioned_hashes = payload.block().blob_versioned_hashes_copied();
// submit payload to engine api
let submission = if self
.chain_spec
Expand Down
5 changes: 3 additions & 2 deletions crates/net/eth-wire-types/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::fmt::Debug;

use alloy_rlp::{Decodable, Encodable};
use reth_primitives_traits::{Block, BlockHeader};
use reth_primitives_traits::{Block, BlockBody, BlockHeader};

/// Abstraction over primitive types which might appear in network messages. See
/// [`crate::EthMessage`] for more context.
Expand All @@ -23,7 +23,8 @@ pub trait NetworkPrimitives:
+ Eq
+ 'static;
/// The block body type.
type BlockBody: Encodable
type BlockBody: BlockBody<Header = Self::BlockHeader>
+ Encodable
+ Decodable
+ Send
+ Sync
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/payload/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use alloy_eips::{
use alloy_primitives::{keccak256, Address, Bytes, B256, B64, U256};
use alloy_rlp::Encodable;
use alloy_rpc_types_engine::{ExecutionPayloadEnvelopeV2, ExecutionPayloadV1, PayloadId};
use op_alloy_consensus::eip1559::{decode_holocene_extra_data, EIP1559ParamError};
use op_alloy_consensus::{decode_holocene_extra_data, EIP1559ParamError};
/// Re-export for use in downstream arguments.
pub use op_alloy_rpc_types_engine::OpPayloadAttributes;
use op_alloy_rpc_types_engine::{OpExecutionPayloadEnvelopeV3, OpExecutionPayloadEnvelopeV4};
Expand Down
7 changes: 4 additions & 3 deletions crates/payload/validator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ impl<ChainSpec: EthereumHardforks> ExecutionPayloadValidator<ChainSpec> {
sealed_block: &SealedBlock,
cancun_fields: &MaybeCancunPayloadFields,
) -> Result<(), PayloadError> {
let num_blob_versioned_hashes = sealed_block.blob_versioned_hashes_iter().count();
let blob_versioned_hashes = sealed_block.blob_versioned_hashes();
let num_blob_versioned_hashes = blob_versioned_hashes.len();
// Additional Cancun checks for blob transactions
if let Some(versioned_hashes) = cancun_fields.versioned_hashes() {
if num_blob_versioned_hashes != versioned_hashes.len() {
Expand All @@ -73,9 +74,9 @@ impl<ChainSpec: EthereumHardforks> ExecutionPayloadValidator<ChainSpec> {
}
// we can use `zip` safely here because we already compared their length
for (payload_versioned_hash, block_versioned_hash) in
versioned_hashes.iter().zip(sealed_block.blob_versioned_hashes_iter())
versioned_hashes.iter().zip(blob_versioned_hashes.iter())
{
if payload_versioned_hash != block_versioned_hash {
if payload_versioned_hash != *block_versioned_hash {
return Err(PayloadError::InvalidVersionedHashes)
}
}
Expand Down
25 changes: 16 additions & 9 deletions crates/primitives-traits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ homepage.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
description = "Common types in reth."
description = "Reth abstraction of EVM data primitives."

[lints]
workspace = true
Expand All @@ -23,19 +23,25 @@ alloy-primitives.workspace = true
alloy-rlp.workspace = true
revm-primitives.workspace = true

# misc
# async
once_cell.workspace = true

# io
rayon.workspace = true

# codec
byteorder = "1"
derive_more.workspace = true
roaring = "0.10.2"
serde.workspace = true
serde_with = { workspace = true, optional = true }
auto_impl.workspace = true

# required by reth-codecs
bytes.workspace = true
modular-bitfield.workspace = true
serde.workspace = true

# arbitrary utils
# misc
derive_more.workspace = true
auto_impl.workspace = true

# test-utils
arbitrary = { workspace = true, features = ["derive"], optional = true }
proptest = { workspace = true, optional = true }
proptest-arbitrary-interop = { workspace = true, optional = true }
Expand All @@ -59,7 +65,8 @@ std = [
"alloy-genesis/std",
"alloy-primitives/std",
"revm-primitives/std",
"serde/std"
"serde/std",
"once_cell/std",
]
test-utils = [
"arbitrary",
Expand Down
Loading