Skip to content

Commit

Permalink
Decode raw conditional correctly (#14397)
Browse files Browse the repository at this point in the history
Co-authored-by: VeerChaurasia <[email protected]>
Co-authored-by: Matthias Seitz <[email protected]>
  • Loading branch information
3 people authored Feb 11, 2025
1 parent c9ea423 commit 2ba54bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion crates/optimism/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ reth-optimism-chainspec.workspace = true
reth-optimism-consensus.workspace = true
reth-optimism-evm.workspace = true
reth-optimism-payload-builder.workspace = true
reth-optimism-primitives.workspace = true
# TODO remove node-builder import
reth-optimism-primitives = { workspace = true, features = ["reth-codec", "serde-bincode-compat"] }
reth-optimism-forks.workspace = true

# ethereum
Expand Down
13 changes: 7 additions & 6 deletions crates/optimism/rpc/src/eth/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ use alloy_eips::BlockNumberOrTag;
use alloy_primitives::{Bytes, B256};
use alloy_rpc_types_eth::erc4337::TransactionConditional;
use jsonrpsee_core::RpcResult;
use op_alloy_network::TransactionResponse;
use op_alloy_rpc_types::Transaction;
use reth_provider::{BlockReaderIdExt, StateProviderFactory};
use reth_rpc_eth_api::L2EthApiExtServer;
use reth_transaction_pool::{TransactionOrigin, TransactionPool};
use reth_rpc_eth_types::utils::recover_raw_transaction;
use reth_transaction_pool::{PoolTransaction, TransactionOrigin, TransactionPool};
use std::sync::Arc;

/// Maximum execution const for conditional transactions.
Expand Down Expand Up @@ -50,7 +49,7 @@ impl<N> L2EthApiExtServer for OpEthApiExt<N>
where
N: OpNodeCore + 'static,
N::Provider: BlockReaderIdExt + StateProviderFactory,
N::Pool: TransactionPool<Transaction = Transaction>,
N::Pool: TransactionPool,
{
async fn send_raw_transaction_conditional(
&self,
Expand All @@ -63,10 +62,12 @@ where
return Err(TxConditionalErr::ConditionalCostExceeded.into());
}

let tx: Transaction = serde_json::from_slice(&bytes).map_err(|_| {
let recovered_tx = recover_raw_transaction(&bytes).map_err(|_| {
OpEthApiError::Eth(reth_rpc_eth_types::EthApiError::FailedToDecodeSignedTransaction)
})?;

let tx = <N::Pool as TransactionPool>::Transaction::from_pooled(recovered_tx);

// get current header
let header_not_found = || {
OpEthApiError::Eth(reth_rpc_eth_types::EthApiError::HeaderNotFound(
Expand Down Expand Up @@ -94,7 +95,7 @@ where
.forward_raw_transaction_conditional(bytes.as_ref(), condition)
.await
.map_err(OpEthApiError::Sequencer)?;
Ok(tx.tx_hash())
Ok(*tx.hash())
} else {
// otherwise, add to pool
// TODO: include conditional
Expand Down

0 comments on commit 2ba54bf

Please sign in to comment.