Skip to content

Commit

Permalink
build: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
suchapalaver committed Dec 11, 2024
1 parent db25d57 commit 0654887
Show file tree
Hide file tree
Showing 8 changed files with 547 additions and 429 deletions.
837 changes: 478 additions & 359 deletions Cargo.lock

Large diffs are not rendered by default.

44 changes: 21 additions & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,39 @@ members = ["crates/*"]
resolver = "2"

[workspace.dependencies]
alloy-primitives = "0.8.10"
alloy-consensus = "0.4.2"
alloy-primitives = "0.8.15"
alloy-consensus = "0.7.3"
alloy-eip2930 = "0.1.0"
alloy-rlp = "0.3.9"
base64 = "0.21.7"
alloy-rlp = "0.3.10"
alloy-trie = "0.7.6"
base64 = "0.22.1"
bincode = "1.3.3"
clap = { version = "4.4.10", features = ["derive"] }
clap = { version = "4.5.23", features = ["derive"] }
criterion = { version = "0.5.1", features = ["html_reports"] }
ethportal-api = { git = "https://github.com/ethereum/trin.git", version = "0.2.2", tag = "v0.1.0-alpha.51" }
ethportal-api = { git = "https://github.com/ethereum/trin.git", version = "0.3.0", tag = "v0.2.0-alpha.1" }
firehose-protos = { path = "crates/firehose-protos", version = "0.1.0" }
firehose-rs = { git = "https://github.com/semiotic-ai/firehose-rs.git", branch = "main" }
flat-files-decoder = { path = "crates/flat-files-decoder", version = "0.1.0" }
header-accumulator = { path = "crates/header-accumulator", version = "0.1.0" }
hex = "0.4.3"
primitive-types = "0.12.2"
prost = "0.13.1"
prost-build = "0.13.1"
prost = "0.13.4"
prost-build = "0.13.4"
prost-wkt = "0.6.0"
prost-wkt-types = "0.6.0"
rand = "0.8.5"
reth-primitives = { git = "https://github.com/paradigmxyz/reth", version = "1.1.0", tag = "v1.1.0" }
reth-trie-common = { git = "https://github.com/paradigmxyz/reth", version = "1.1.0", tag = "v1.1.0" }
rlp = "0.5.2"
serde = "1.0.208"
serde_json = "1.0.127"
tempfile = "3.0"
thiserror = "2.0.0"
tokio = "1.39.2"
tonic = "0.12.0"
tonic-build = "0.12.0"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
reth-primitives = { git = "https://github.com/paradigmxyz/reth", version = "1.1.4", tag = "v1.1.4" }
serde = "1.0.216"
serde_json = "1.0.133"
tempfile = "3.14.0"
thiserror = "2.0.6"
tokio = "1.42.0"
tonic = "0.12.3"
tonic-build = "0.12.3"
tracing = "0.1.41"
tracing-subscriber = "0.3.19"
tree_hash = "0.8.0"
trin-validation = { git = "https://github.com/ethereum/trin.git", version = "0.1.0", tag = "v0.1.0-alpha.51" }
zstd = "0.13.0"
trin-validation = { git = "https://github.com/ethereum/trin.git", version = "0.1.0", tag = "v0.2.0-alpha.1" }
zstd = "0.13.2"

[profile.dev.build-override]
opt-level = 3
Expand Down
3 changes: 1 addition & 2 deletions crates/firehose-protos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ alloy-consensus.workspace = true
alloy-eip2930.workspace = true
alloy-primitives.workspace = true
alloy-rlp.workspace = true
alloy-trie.workspace = true
ethportal-api.workspace = true
firehose-rs.workspace = true
primitive-types.workspace = true
prost.workspace = true
prost-wkt.workspace = true
prost-wkt-types.workspace = true
reth-primitives.workspace = true
reth-trie-common.workspace = true
serde.workspace = true
thiserror.workspace = true
tonic.workspace = true
Expand Down
27 changes: 13 additions & 14 deletions crates/firehose-protos/src/ethereum_v2/eth_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
// SPDX-License-Identifier: Apache-2.0

use super::{Block, BlockHeader, TransactionReceipt, TransactionTrace};
use alloy_consensus::{Receipt, ReceiptWithBloom};
use alloy_primitives::{hex, Address, Bloom, FixedBytes, Uint, B256};
use alloy_rlp::{Encodable, Header as RlpHeader};
use alloy_trie::root::ordered_trie_root_with_encoder;
use ethportal_api::types::execution::header::Header;
use firehose_rs::{FromResponse, HasNumberOrSlot, Response, SingleBlockResponse};
use prost::Message;
use prost_wkt_types::Any;
use reth_primitives::{
proofs::calculate_transaction_root, Log, Receipt, ReceiptWithBloom, TransactionSigned,
};
use reth_trie_common::root::ordered_trie_root_with_encoder;
use reth_primitives::{proofs::calculate_transaction_root, Log, TransactionSigned};
use tracing::error;

use crate::error::ProtosError;
Expand Down Expand Up @@ -280,23 +279,23 @@ impl TryFrom<&TransactionTrace> for FullReceipt {
type Error = ProtosError;

fn try_from(trace: &TransactionTrace) -> Result<Self, Self::Error> {
let tx_type = trace.try_into()?;

let trace_receipt = trace.receipt()?;

let logs = trace_receipt.logs()?;

let receipt = Receipt {
success: trace.is_success(),
tx_type,
status: trace.is_success().into(),
logs,
cumulative_gas_used: trace_receipt.cumulative_gas_used,
cumulative_gas_used: trace_receipt.cumulative_gas_used as u128,
};

let bloom = Bloom::try_from(trace_receipt)?;
let logs_bloom = Bloom::try_from(trace_receipt)?;

Ok(Self {
receipt: ReceiptWithBloom { receipt, bloom },
receipt: ReceiptWithBloom {
receipt,
logs_bloom,
},
state_root: trace_receipt.state_root.to_vec(),
})
}
Expand Down Expand Up @@ -332,14 +331,14 @@ impl FullReceipt {
self.rlp_header().encode(encoded);
self.state_root.as_slice().encode(encoded);
Encodable::encode(&self.receipt.receipt.cumulative_gas_used, encoded);
self.receipt.bloom.encode(encoded);
self.receipt.logs_bloom.encode(encoded);
self.receipt.receipt.logs.encode(encoded);
}

/// For Byzantium and later: only encode the inner receipt contents using the `reth_primitives`
/// [`ReceiptWithBloom`] `encode_inner` method.
fn encode_byzantium_and_later_receipt(&self, encoded: &mut Vec<u8>) {
self.receipt.encode_inner(encoded, false);
self.receipt.encode(encoded);
}

/// Returns a reference to the [`ReceiptWithBloom`] for this [`FullReceipt`]
Expand All @@ -351,7 +350,7 @@ impl FullReceipt {
fn rlp_header(&self) -> RlpHeader {
let payload_length = self.state_root.as_slice().length()
+ self.receipt.receipt.cumulative_gas_used.length()
+ self.receipt.bloom.length()
+ self.receipt.logs_bloom.length()
+ self.receipt.receipt.logs.length();

RlpHeader {
Expand Down
3 changes: 1 addition & 2 deletions crates/firehose-protos/src/ethereum_v2/log.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2024-, Semiotic AI, Inc.
// SPDX-License-Identifier: Apache-2.0

use alloy_primitives::{hex, Address, Bytes, B256};
use reth_primitives::LogData;
use alloy_primitives::{hex, Address, Bytes, LogData, B256};

use crate::error::ProtosError;

Expand Down
59 changes: 33 additions & 26 deletions crates/firehose-protos/src/ethereum_v2/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

use std::fmt::Display;

use alloy_consensus::{TxEip1559, TxEip2930, TxLegacy};
use alloy_consensus::{TxEip1559, TxEip2930, TxLegacy, TxType, TypedTransaction};
use alloy_eip2930::{AccessList, AccessListItem};
use alloy_primitives::{
hex, Address, Bytes, ChainId, FixedBytes, Parity, TxKind, Uint, U128, U256,
hex, Address, Bytes, ChainId, FixedBytes, PrimitiveSignature, TxKind, Uint, U128, U256,
};
use reth_primitives::{Signature, Transaction, TransactionSigned, TxType};
use reth_primitives::{Transaction, TransactionSigned};
use tracing::debug;

use crate::error::ProtosError;
Expand Down Expand Up @@ -62,7 +62,7 @@ impl TransactionTrace {
self.status == 1
}

fn parity(&self) -> Result<Parity, ProtosError> {
fn parity(&self) -> Result<bool, ProtosError> {
// Extract the first byte of the V value (Ethereum's V value).
let v = self.v();

Expand All @@ -85,7 +85,7 @@ impl TransactionTrace {
}
};

Ok(parity.into())
Ok(parity)
}

pub(crate) fn receipt(&self) -> Result<&TransactionReceipt, ProtosError> {
Expand Down Expand Up @@ -144,7 +144,7 @@ impl TryFrom<&TransactionTrace> for TxKind {
}
}

impl TryFrom<&TransactionTrace> for Signature {
impl TryFrom<&TransactionTrace> for PrimitiveSignature {
type Error = ProtosError;

fn try_from(trace: &TransactionTrace) -> Result<Self, Self::Error> {
Expand All @@ -165,11 +165,11 @@ impl TryFrom<&TransactionTrace> for Signature {
// Extract the Y parity from the V value.
let odd_y_parity = trace.parity()?;

Ok(Signature::new(r, s, odd_y_parity))
Ok(Self::new(r, s, odd_y_parity))
}
}

impl TryFrom<&TransactionTrace> for reth_primitives::TxType {
impl TryFrom<&TransactionTrace> for TxType {
type Error = ProtosError;

fn try_from(trace: &TransactionTrace) -> Result<Self, Self::Error> {
Expand All @@ -180,20 +180,20 @@ impl TryFrom<&TransactionTrace> for reth_primitives::TxType {
}
}

impl TryFrom<&TransactionTrace> for Transaction {
impl TryFrom<&TransactionTrace> for TypedTransaction {
type Error = ProtosError;

fn try_from(trace: &TransactionTrace) -> Result<Self, Self::Error> {
let tx_type = reth_primitives::TxType::try_from(trace)?;
let tx_type = TxType::try_from(trace)?;
let nonce = trace.nonce;
let gas_price = get_u128_or_default(&trace.gas_price)?;
let gas_limit = trace.gas_limit;
let to = TxKind::try_from(trace)?;
let value = Uint::from(get_u128_or_default(&trace.value)?);
let input = Bytes::copy_from_slice(trace.input.as_slice());

let transaction: Transaction = match tx_type {
TxType::Legacy => Transaction::Legacy(TxLegacy {
let transaction: TypedTransaction = match tx_type {
TxType::Legacy => Self::Legacy(TxLegacy {
chain_id: get_legacy_chain_id(trace),
nonce,
gas_price,
Expand All @@ -202,7 +202,7 @@ impl TryFrom<&TransactionTrace> for Transaction {
value,
input,
}),
TxType::Eip2930 => Transaction::Eip2930(TxEip2930 {
TxType::Eip2930 => Self::Eip2930(TxEip2930 {
chain_id: CHAIN_ID,
nonce,
gas_price,
Expand All @@ -212,7 +212,7 @@ impl TryFrom<&TransactionTrace> for Transaction {
access_list: AccessList::try_from(trace)?,
input,
}),
TxType::Eip1559 => Transaction::Eip1559(TxEip1559 {
TxType::Eip1559 => Self::Eip1559(TxEip1559 {
chain_id: CHAIN_ID,
nonce,
gas_limit,
Expand Down Expand Up @@ -243,14 +243,21 @@ impl TryFrom<&TransactionTrace> for TransactionSigned {
type Error = ProtosError;

fn try_from(trace: &TransactionTrace) -> Result<Self, Self::Error> {
let transaction = Transaction::try_from(trace)?;
let signature = Signature::try_from(trace)?;
let typed_tx = TypedTransaction::try_from(trace)?;
let transaction = match typed_tx {
TypedTransaction::Legacy(tx) => Transaction::Legacy(tx),
TypedTransaction::Eip2930(tx) => Transaction::Eip2930(tx),
TypedTransaction::Eip1559(tx) => Transaction::Eip1559(tx),
TypedTransaction::Eip4844(tx) => Transaction::Eip4844(tx.into()),
TypedTransaction::Eip7702(tx) => Transaction::Eip7702(tx),
};
let signature = PrimitiveSignature::try_from(trace)?;
let hash = FixedBytes::from_slice(trace.hash.as_slice());

Ok(TransactionSigned {
transaction,
signature,
hash,
hash: hash.into(),
})
}
}
Expand Down Expand Up @@ -341,13 +348,13 @@ mod tests {
..Default::default()
};

let signature = Signature::try_from(&trace).unwrap();
let signature = PrimitiveSignature::try_from(&trace).unwrap();
assert_eq!(signature.r(), U256::from(1));
assert_eq!(signature.s(), U256::from(1));
assert!(!trace.parity().unwrap().y_parity());
assert!(!trace.parity().unwrap());

trace.v = vec![28];
assert!(trace.parity().unwrap().y_parity());
assert!(trace.parity().unwrap());
}

#[test]
Expand All @@ -371,9 +378,9 @@ mod tests {
..Default::default()
};

let tx = Transaction::try_from(&trace).unwrap();
let tx = TypedTransaction::try_from(&trace).unwrap();
match tx {
Transaction::Legacy(tx) => {
TypedTransaction::Legacy(tx) => {
assert_eq!(tx.nonce, 1);
assert_eq!(tx.gas_price, 1);
assert_eq!(tx.gas_limit, 21000);
Expand All @@ -384,13 +391,13 @@ mod tests {

// EIP-2930 transaction
trace.r#type = Type::TrxTypeAccessList as i32;
let tx = Transaction::try_from(&trace).unwrap();
assert!(matches!(tx, Transaction::Eip2930(_)));
let tx = TypedTransaction::try_from(&trace).unwrap();
assert!(matches!(tx, TypedTransaction::Eip2930(_)));

// EIP-1559 transaction
trace.r#type = Type::TrxTypeDynamicFee as i32;
let tx = Transaction::try_from(&trace).unwrap();
assert!(matches!(tx, Transaction::Eip1559(_)));
let tx = TypedTransaction::try_from(&trace).unwrap();
assert!(matches!(tx, TypedTransaction::Eip1559(_)));
}

#[test]
Expand Down
1 change: 0 additions & 1 deletion crates/flat-files-decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ alloy-eip2930.workspace = true
bincode.workspace = true
firehose-protos.workspace = true
prost.workspace = true
reth-primitives.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
thiserror.workspace = true
Expand Down
2 changes: 0 additions & 2 deletions crates/header-accumulator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ base64.workspace = true
clap.workspace = true
ethportal-api.workspace = true
firehose-protos.workspace = true
primitive-types.workspace = true
rlp.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
tracing.workspace = true
Expand Down

0 comments on commit 0654887

Please sign in to comment.