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(rpc): use alloy-rpc-types for ethereum-related types #5947

Merged
merged 4 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ alloy-primitives = "0.5"
alloy-dyn-abi = "0.5"
alloy-sol-types = "0.5"
alloy-rlp = "0.3"
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", features = ["jsonrpsee-types"] }
ethers-core = { version = "2.0", default-features = false }
ethers-providers = { version = "2.0", default-features = false }
ethers-signers = { version = "2.0", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/transaction/sidecar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ const _: [(); std::mem::size_of::<BlobTransactionSidecar>()] =
[(); std::mem::size_of::<BlobTransactionSidecarRlp>()];

const _: [(); std::mem::size_of::<BlobTransactionSidecar>()] =
[(); std::mem::size_of::<reth_rpc_types::BlobTransactionSidecar>()];
[(); std::mem::size_of::<reth_rpc_types::transaction::BlobTransactionSidecar>()];

impl BlobTransactionSidecarRlp {
fn wrap_ref(other: &BlobTransactionSidecar) -> &Self {
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc-testing-util/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ where
BlockId::Number(tag) => self.block_by_number(tag, false).await,
}?
.ok_or_else(|| RpcError::Custom("block not found".to_string()))?;
let hashes = block.transactions.iter().map(|tx| (tx, opts.clone())).collect::<Vec<_>>();
let hashes = block.transactions.hashes().map(|tx| (*tx, opts.clone())).collect::<Vec<_>>();
let stream = futures::stream::iter(hashes.into_iter().map(move |(tx, opts)| async move {
match self.debug_trace_transaction_json(tx, opts).await {
Ok(result) => Ok((result, tx)),
Expand Down
2 changes: 2 additions & 0 deletions crates/rpc/rpc-types-compat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ workspace = true
reth-primitives.workspace = true
reth-rpc-types.workspace = true
alloy-rlp.workspace = true
alloy-rpc-types.workspace = true
serde_json.workspace = true

[features]
optimism = ["reth-primitives/optimism", "reth-rpc-types/optimism"]
2 changes: 2 additions & 0 deletions crates/rpc/rpc-types-compat/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ fn from_block_with_transactions(
total_difficulty: Some(total_difficulty),
size: Some(U256::from(block_length)),
withdrawals,
other: Default::default(),
}
}

Expand All @@ -196,5 +197,6 @@ pub fn uncle_block_from_header(header: PrimitiveHeader) -> Block {
withdrawals: Some(vec![]),
size,
total_difficulty: None,
other: Default::default(),
}
}
7 changes: 2 additions & 5 deletions crates/rpc/rpc-types-compat/src/engine/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,8 @@ pub fn try_payload_v2_to_block(payload: ExecutionPayloadV2) -> Result<Block, Pay
// this performs the same conversion as the underlying V1 payload, but calculates the
// withdrawals root and adds withdrawals
let mut base_sealed_block = try_payload_v1_to_block(payload.payload_inner)?;
let withdrawals: Vec<_> = payload
.withdrawals
.iter()
.map(|w| convert_standalone_withdraw_to_withdrawal(w.clone()))
.collect();
let withdrawals: Vec<_> =
payload.withdrawals.iter().map(|w| convert_standalone_withdraw_to_withdrawal(*w)).collect();
let withdrawals_root = proofs::calculate_withdrawals_root(&withdrawals);
base_sealed_block.withdrawals = Some(withdrawals);
base_sealed_block.header.withdrawals_root = Some(withdrawals_root);
Expand Down
7 changes: 5 additions & 2 deletions crates/rpc/rpc-types-compat/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,14 @@ fn fill(
blob_versioned_hashes,
// Optimism fields
#[cfg(feature = "optimism")]
optimism: reth_rpc_types::OptimismTransactionFields {
other: reth_rpc_types::OptimismTransactionFields {
source_hash: signed_tx.source_hash(),
mint: signed_tx.mint().map(U128::from),
is_system_tx: signed_tx.is_deposit().then_some(signed_tx.is_system_transaction()),
},
}
.into(),
#[cfg(not(feature = "optimism"))]
other: Default::default(),
}
}

Expand Down
5 changes: 3 additions & 2 deletions crates/rpc/rpc-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ workspace = true
# ethereum
alloy-rlp = { workspace = true, features = ["arrayvec", "derive"] }
alloy-primitives = { workspace = true, features = ["rand", "rlp", "serde"] }
alloy-rpc-types.workspace = true
ethereum_ssz_derive = { version = "0.5", optional = true }
ethereum_ssz = { version = "0.5", optional = true }

Expand All @@ -38,8 +39,8 @@ proptest-derive = { workspace = true, optional = true }

[features]
default = ["jsonrpsee-types"]
arbitrary = ["dep:arbitrary", "dep:proptest-derive", "dep:proptest", "alloy-primitives/arbitrary"]
ssz = ["dep:ethereum_ssz" ,"dep:ethereum_ssz_derive", "alloy-primitives/ssz"]
arbitrary = ["dep:arbitrary", "dep:proptest-derive", "dep:proptest", "alloy-primitives/arbitrary", "alloy-rpc-types/arbitrary"]
ssz = ["dep:ethereum_ssz" ,"dep:ethereum_ssz_derive", "alloy-primitives/ssz", "alloy-rpc-types/ssz"]
optimism = []


Expand Down
4 changes: 2 additions & 2 deletions crates/rpc/rpc-types/src/beacon/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

use crate::{
beacon::{withdrawals::BeaconWithdrawal, BlsPublicKey},
engine::ExecutionPayloadV3,
ExecutionPayload, ExecutionPayloadV1, ExecutionPayloadV2, Withdrawal,
engine::{ExecutionPayload, ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3},
Withdrawal,
};
use alloy_primitives::{Address, Bloom, Bytes, B256, U256};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
Expand Down
88 changes: 0 additions & 88 deletions crates/rpc/rpc-types/src/eth/account.rs

This file was deleted.

Loading
Loading