mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: append tx conditional to pooled tx (#14403)
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -8635,6 +8635,7 @@ dependencies = [
|
|||||||
"reth-optimism-forks",
|
"reth-optimism-forks",
|
||||||
"reth-optimism-payload-builder",
|
"reth-optimism-payload-builder",
|
||||||
"reth-optimism-primitives",
|
"reth-optimism-primitives",
|
||||||
|
"reth-optimism-txpool",
|
||||||
"reth-primitives",
|
"reth-primitives",
|
||||||
"reth-primitives-traits",
|
"reth-primitives-traits",
|
||||||
"reth-provider",
|
"reth-provider",
|
||||||
|
|||||||
@ -35,6 +35,7 @@ reth-optimism-chainspec.workspace = true
|
|||||||
reth-optimism-consensus.workspace = true
|
reth-optimism-consensus.workspace = true
|
||||||
reth-optimism-evm.workspace = true
|
reth-optimism-evm.workspace = true
|
||||||
reth-optimism-payload-builder.workspace = true
|
reth-optimism-payload-builder.workspace = true
|
||||||
|
reth-optimism-txpool.workspace = true
|
||||||
# TODO remove node-builder import
|
# TODO remove node-builder import
|
||||||
reth-optimism-primitives = { workspace = true, features = ["reth-codec", "serde-bincode-compat"] }
|
reth-optimism-primitives = { workspace = true, features = ["reth-codec", "serde-bincode-compat"] }
|
||||||
reth-optimism-forks.workspace = true
|
reth-optimism-forks.workspace = true
|
||||||
@ -79,6 +80,7 @@ optimism = [
|
|||||||
"reth-optimism-consensus/optimism",
|
"reth-optimism-consensus/optimism",
|
||||||
"reth-optimism-payload-builder/optimism",
|
"reth-optimism-payload-builder/optimism",
|
||||||
"reth-optimism-primitives/optimism",
|
"reth-optimism-primitives/optimism",
|
||||||
|
"reth-optimism-txpool/optimism",
|
||||||
]
|
]
|
||||||
client = [
|
client = [
|
||||||
"jsonrpsee/client",
|
"jsonrpsee/client",
|
||||||
|
|||||||
@ -5,6 +5,7 @@ use alloy_eips::BlockNumberOrTag;
|
|||||||
use alloy_primitives::{Bytes, B256};
|
use alloy_primitives::{Bytes, B256};
|
||||||
use alloy_rpc_types_eth::erc4337::TransactionConditional;
|
use alloy_rpc_types_eth::erc4337::TransactionConditional;
|
||||||
use jsonrpsee_core::RpcResult;
|
use jsonrpsee_core::RpcResult;
|
||||||
|
use reth_optimism_txpool::conditional::MaybeConditionalTransaction;
|
||||||
use reth_provider::{BlockReaderIdExt, StateProviderFactory};
|
use reth_provider::{BlockReaderIdExt, StateProviderFactory};
|
||||||
use reth_rpc_eth_api::L2EthApiExtServer;
|
use reth_rpc_eth_api::L2EthApiExtServer;
|
||||||
use reth_rpc_eth_types::utils::recover_raw_transaction;
|
use reth_rpc_eth_types::utils::recover_raw_transaction;
|
||||||
@ -49,7 +50,7 @@ impl<N> L2EthApiExtServer for OpEthApiExt<N>
|
|||||||
where
|
where
|
||||||
N: OpNodeCore + 'static,
|
N: OpNodeCore + 'static,
|
||||||
N::Provider: BlockReaderIdExt + StateProviderFactory,
|
N::Provider: BlockReaderIdExt + StateProviderFactory,
|
||||||
N::Pool: TransactionPool,
|
N::Pool: TransactionPool<Transaction: MaybeConditionalTransaction>,
|
||||||
{
|
{
|
||||||
async fn send_raw_transaction_conditional(
|
async fn send_raw_transaction_conditional(
|
||||||
&self,
|
&self,
|
||||||
@ -66,7 +67,7 @@ where
|
|||||||
OpEthApiError::Eth(reth_rpc_eth_types::EthApiError::FailedToDecodeSignedTransaction)
|
OpEthApiError::Eth(reth_rpc_eth_types::EthApiError::FailedToDecodeSignedTransaction)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let tx = <N::Pool as TransactionPool>::Transaction::from_pooled(recovered_tx);
|
let mut tx = <N::Pool as TransactionPool>::Transaction::from_pooled(recovered_tx);
|
||||||
|
|
||||||
// get current header
|
// get current header
|
||||||
let header_not_found = || {
|
let header_not_found = || {
|
||||||
@ -97,8 +98,8 @@ where
|
|||||||
.map_err(OpEthApiError::Sequencer)?;
|
.map_err(OpEthApiError::Sequencer)?;
|
||||||
Ok(*tx.hash())
|
Ok(*tx.hash())
|
||||||
} else {
|
} else {
|
||||||
// otherwise, add to pool
|
// otherwise, add to pool with the appended conditional
|
||||||
// TODO: include conditional
|
tx.set_conditional(condition);
|
||||||
let hash = self.pool().add_transaction(TransactionOrigin::External, tx).await.map_err(
|
let hash = self.pool().add_transaction(TransactionOrigin::External, tx).await.map_err(
|
||||||
|e| OpEthApiError::Eth(reth_rpc_eth_types::EthApiError::PoolError(e.into())),
|
|e| OpEthApiError::Eth(reth_rpc_eth_types::EthApiError::PoolError(e.into())),
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user