Skip to content
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ This changelog covers Firehose-specific changes only. For upstream reth changes,

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## op-reth-v2.8.1-fh3.1-1

### Fixed

- Optimism post-exec transactions (type `0x7d`, activated by the OP Stack Lagoon upgrade) are
traced as `TRX_TYPE_OPTIMISM_POST_EXEC` instead of stopping the node. `firehose-tracer` moves
to 5.5.1.

## op-reth-v2.8.1-fh3.1

### Changed
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ vergen-git2 = "10.0.1"
ipnet = "2.11"

## Firehose Additions
firehose-tracer = "5.5.0"
firehose-tracer = "5.5.1"
reth-firehose = { path = "crates/firehose" }
reth-firehose-tests = { path = "crates/firehose-tests" }

Expand Down
115 changes: 111 additions & 4 deletions crates/firehose/src/mapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,20 @@ pub fn signed_tx_to_tx_event<Tx>(
where
Tx: alloy_consensus::Transaction + TxHashRef,
{
// A transaction the block model cannot represent must stop the node: dropping it would emit
// a block that differs from the chain, and failing block execution would make the node
// reject a valid block.
let tx_type = tx.ty().try_into().unwrap_or_else(|_| {
panic!(
"Firehose cannot trace transaction {} of type {:#x}: the block model has no such \
transaction type, so this node cannot emit this block",
tx.tx_hash(),
tx.ty()
)
});

TxEvent {
// FIXME: That is not true, what about Optimism specialized transaction types? We might
// to have a special mapper that knows the chain and as such is aware of some types
// that could not exists anywhere else. We will need to deal with this.
tx_type: tx.ty().try_into().expect("All transaction types handled for now"),
tx_type,
hash: *tx.tx_hash(),
from: signer,
to: tx.to(),
Expand Down Expand Up @@ -374,3 +383,101 @@ fn map_signed_authorization(
s: B256::new(auth.s().to_be_bytes::<32>()),
}
}

#[cfg(test)]
mod tests {
use super::*;
use alloy_consensus::{transaction::TxHashRef, Transaction, Typed2718};
use alloy_eips::{eip2930::AccessList, eip7702::SignedAuthorization};
use alloy_primitives::{ChainId, TxKind};
use firehose_tracer::types::TxType;

/// An unsigned transaction with the OP Stack post-exec type byte (0x7d), shaped like
/// `op_alloy_consensus::TxPostExec`: no gas, no value, the payload as input.
#[derive(Debug)]
struct PostExecTx {
hash: B256,
input: Bytes,
}

impl Typed2718 for PostExecTx {
fn ty(&self) -> u8 {
0x7d
}
}

impl TxHashRef for PostExecTx {
fn tx_hash(&self) -> &B256 {
&self.hash
}
}

impl Transaction for PostExecTx {
fn chain_id(&self) -> Option<ChainId> {
None
}
fn nonce(&self) -> u64 {
0
}
fn gas_limit(&self) -> u64 {
0
}
fn gas_price(&self) -> Option<u128> {
None
}
fn max_fee_per_gas(&self) -> u128 {
0
}
fn max_priority_fee_per_gas(&self) -> Option<u128> {
None
}
fn max_fee_per_blob_gas(&self) -> Option<u128> {
None
}
fn priority_fee_or_price(&self) -> u128 {
0
}
fn effective_gas_price(&self, _: Option<u64>) -> u128 {
0
}
fn is_dynamic_fee(&self) -> bool {
false
}
fn kind(&self) -> TxKind {
TxKind::Call(Address::ZERO)
}
fn is_create(&self) -> bool {
false
}
fn value(&self) -> U256 {
U256::ZERO
}
fn input(&self) -> &Bytes {
&self.input
}
fn access_list(&self) -> Option<&AccessList> {
None
}
fn blob_versioned_hashes(&self) -> Option<&[B256]> {
None
}
fn authorization_list(&self) -> Option<&[SignedAuthorization]> {
None
}
}

#[test]
fn maps_optimism_post_exec_transaction() {
let tx = PostExecTx { hash: B256::repeat_byte(0x7d), input: Bytes::from_static(&[0xc0]) };

let event =
signed_tx_to_tx_event(&tx, Address::ZERO, 3, B256::ZERO, B256::ZERO, Bytes::new());

assert_eq!(event.tx_type, TxType::OptimismPostExec);
assert_eq!(event.hash, tx.hash);
assert_eq!(event.from, Address::ZERO);
assert_eq!(event.input, tx.input);
assert_eq!(event.gas, 0);
assert_eq!(event.index, 3);
}
}
Loading