Skip to content

Commit

Permalink
feat(rpc): use alloy-rpc-types for ethereum-related types (paradi…
Browse files Browse the repository at this point in the history
  • Loading branch information
Evalir authored Jan 4, 2024
1 parent e3c3ddc commit 09f04a0
Show file tree
Hide file tree
Showing 49 changed files with 91 additions and 6,813 deletions.
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

0 comments on commit 09f04a0

Please sign in to comment.