From 42fb75262523180582aade80eb2b5d7906f49b20 Mon Sep 17 00:00:00 2001 From: nicolas <48695862+merklefruit@users.noreply.github.com> Date: Wed, 26 Jun 2024 17:33:42 +0200 Subject: [PATCH] chore: updated dependencies (reth, alloy) + version bump --- Cargo.toml | 24 ++++++++++++------------ src/utils.rs | 33 +++++++++++++++++---------------- tests/mod.rs | 13 ++++++++++--- 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7955af1..7bb369d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,25 +1,25 @@ [package] name = "fiber" -version = "0.7.2" +version = "0.7.4" edition = "2021" license = "MIT" authors = ["Chainbound "] [dependencies] -# types & decoding -alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", features = [ - "ssz", -], rev = "7d5e42f" } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", features = [ - "ssz", -], rev = "7d5e42f" } +# alloy +alloy-rpc-types-engine = { version = "0.1.3", features = ["ssz"] } +alloy-rpc-types = { version = "0.1.3", features = ["ssz"] } alloy-rlp = "0.3" + +# reth +reth-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.0.0", default-features = false, features = ["std", "c-kzg"] } + +# ethereum ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "cf3c404" } -reth-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v0.2.0-beta.6", default-features = false, features = [ - "c-kzg", -] } -serde = { version = "1.0", features = ["derive", "rc"] } ethereum_ssz = "0.5.3" + +# serialization +serde = { version = "1.0", features = ["derive", "rc"] } base64 = "0.13.1" serde_json = "1.0" serde_repr = "0.1" diff --git a/src/utils.rs b/src/utils.rs index 4200174..352a03a 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -2,7 +2,7 @@ use alloy_rpc_types::{ AccessList, AccessListItem, Block, BlockTransactions, Header, Signature, Transaction, }; use alloy_rpc_types_engine::ExecutionPayload; -use reth_primitives::{TransactionSigned, B256, B64, U256, U64, U8}; +use reth_primitives::{TransactionSigned, B256, B64, U256}; use tonic::Request; const CLIENT_VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -46,19 +46,20 @@ pub(crate) fn parse_execution_payload_to_block(payload: ExecutionPayload) -> Blo receipts_root: v1.receipts_root, logs_bloom: v1.logs_bloom, difficulty: diff, - number: Some(U256::from(v1.block_number)), - gas_limit: U256::from(v1.gas_limit), - gas_used: U256::from(v1.gas_used), - timestamp: U256::from(v1.timestamp), + number: Some(v1.block_number), + gas_limit: v1.gas_limit as u128, + gas_used: v1.gas_used as u128, + timestamp: v1.timestamp, extra_data: v1.extra_data.clone(), mix_hash: Some(v1.prev_randao), nonce: Some(B64::ZERO), - base_fee_per_gas: Some(v1.base_fee_per_gas), - blob_gas_used: payload.as_v3().map(|v3| U64::from(v3.blob_gas_used)), - excess_blob_gas: payload.as_v3().map(|v3| U64::from(v3.excess_blob_gas)), + base_fee_per_gas: Some(v1.base_fee_per_gas.to()), + blob_gas_used: payload.as_v3().map(|v3| v3.blob_gas_used as u128), + excess_blob_gas: payload.as_v3().map(|v3| v3.excess_blob_gas as u128), transactions_root: B256::ZERO, // This field is missing in the ExecutonPayload. withdrawals_root: None, // This field is missing in the ExecutonPayload. parent_beacon_block_root: None, // This field is missing in the ExecutonPayload. + requests_root: None, // This field is missing in the ExecutonPayload. }; let mut transactions = Vec::with_capacity(v1.transactions.len()); @@ -95,22 +96,22 @@ pub(crate) fn parse_execution_payload_to_block(payload: ExecutionPayload) -> Blo hash: reth_tx.hash, nonce: reth_tx.nonce(), block_hash: Some(v1.block_hash), - block_number: Some(U256::from(v1.block_number)), - transaction_index: Some(U256::from(index)), + block_number: Some(v1.block_number), + transaction_index: Some(index as u64), from: sender, to: reth_tx.to(), value: reth_tx.value(), - gas_price: Some(U256::from(reth_tx.max_fee_per_gas())), - gas: U256::from(reth_tx.gas_limit()), - max_fee_per_gas: Some(U256::from(reth_tx.max_fee_per_gas())), - max_priority_fee_per_gas: reth_tx.max_priority_fee_per_gas().map(U256::from), - max_fee_per_blob_gas: reth_tx.max_fee_per_blob_gas().map(U256::from), + gas_price: Some(reth_tx.max_fee_per_gas()), + gas: reth_tx.gas_limit() as u128, + max_fee_per_gas: Some(reth_tx.max_fee_per_gas()), + max_priority_fee_per_gas: reth_tx.max_priority_fee_per_gas(), + max_fee_per_blob_gas: reth_tx.max_fee_per_blob_gas(), input: reth_tx.input().clone(), signature: Some(alloy_sig), chain_id: reth_tx.chain_id(), blob_versioned_hashes: reth_tx.blob_versioned_hashes(), access_list: alloy_acl, - transaction_type: Some(U8::from(u8::from(reth_tx.tx_type()))), + transaction_type: Some(u8::from(reth_tx.tx_type())), other: Default::default(), }; diff --git a/tests/mod.rs b/tests/mod.rs index 6207112..05b11fe 100644 --- a/tests/mod.rs +++ b/tests/mod.rs @@ -3,8 +3,8 @@ use std::{process::Command, str::FromStr}; use ethereum_consensus::{ssz::prelude::deserialize, types::mainnet::SignedBeaconBlock}; use fiber::Client; use reth_primitives::{ - AccessList, Address, Signature, Transaction, TransactionKind, TransactionSigned, TxEip1559, - TxHash, TxType, B256, U256, + AccessList, Address, Signature, Transaction, TransactionSigned, TxEip1559, TxHash, TxKind, + TxType, B256, U256, }; use tokio_stream::StreamExt; @@ -29,10 +29,17 @@ async fn test_new_type_3_transactions() { let mut sub = client.subscribe_new_transactions(None).await; + let mut i = 0; while let Some(tx) = sub.next().await { if tx.tx_type() == TxType::Eip4844 { println!("blob tx: {}", tx.hash()); println!("blob hashes: {:?}", tx.blob_versioned_hashes()); + + i += 1; + + if i > 3 { + break; + } } } } @@ -160,7 +167,7 @@ async fn test_send_tx() { chain_id: 1, nonce: 0x42, gas_limit: 44386, - to: TransactionKind::Call( Address::from_str("0x6069a6c32cf691f5982febae4faf8a6f3ab2f0f6").unwrap()), + to: TxKind::Call( Address::from_str("0x6069a6c32cf691f5982febae4faf8a6f3ab2f0f6").unwrap()), value: U256::from(0), input: hex::decode("a22cb4650000000000000000000000005eee75727d804a2b13038928d36f8b188945a57a0000000000000000000000000000000000000000000000000000000000000000").unwrap().into(), max_fee_per_gas: 0x4a817c800,