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 block primitive traits #12450

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 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
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
73 changes: 34 additions & 39 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
30 changes: 21 additions & 9 deletions crates/optimism/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,33 @@ description = "OP primitive types"
workspace = true

[dependencies]
# reth
reth-primitives-traits.workspace = true
reth-codecs = { workspace = true, optional = true }
reth-primitives = { workspace = true, features = ["reth-codec"], optional = true }

# ethereum
alloy-primitives.workspace = true
alloy-consensus.workspace = true
op-alloy-consensus.workspace = true
alloy-eips.workspace = true
alloy-rlp.workspace = true
derive_more.workspace = true

# op
op-alloy-consensus.workspace = true

# codec
bytes.workspace = true
reth-primitives-traits.workspace = true
reth-codecs = { workspace = true, optional = true }
reth-primitives = { workspace = true, features = ["reth-codec"], optional = true }

[features]
default = ["reth-codec"]
reth-codec = ["dep:reth-codecs", "dep:reth-primitives"]
# misc
derive_more.workspace = true

[dev-dependencies]
reth-codecs = { workspace = true, features = ["test-utils"] }
rstest.workspace = true
rstest.workspace = true

[features]
default = ["reth-codec"]
reth-codec = [
"dep:reth-codecs",
"dep:reth-primitives",
]
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
19 changes: 12 additions & 7 deletions crates/primitives-traits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,28 @@ workspace = true
[dependencies]
reth-codecs.workspace = true

# ethereum
alloy-consensus = { workspace = true, features = ["serde"] }
alloy-eips.workspace = true
alloy-genesis.workspace = true
alloy-primitives.workspace = true
alloy-rlp.workspace = true

revm-primitives = { workspace = true, features = ["serde"] }

# misc
# io
rayon.workspace = true

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

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

# misc
derive_more.workspace = true
once_cell.workspace = true

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