Skip to content
Open
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
10 changes: 5 additions & 5 deletions Cargo.lock

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

11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -784,11 +784,12 @@ seismic-revm = { git = "https://github.com/SeismicSystems/seismic-revm.git", rev
revm-inspectors = { git = "https://github.com/SeismicSystems/seismic-revm-inspectors.git", rev = "24652f3b9ef6a8057bc46203b26d1d9857f7ae30" }

# Seismic alloy
seismic-alloy-consensus = { git = "https://github.com/SeismicSystems/seismic-alloy.git", rev = "c8fad0b93da53f2b423d2f6720abdb4a6cbb9082" }
seismic-alloy-rpc-types = { git = "https://github.com/SeismicSystems/seismic-alloy.git", rev = "c8fad0b93da53f2b423d2f6720abdb4a6cbb9082" }
seismic-alloy-network = { git = "https://github.com/SeismicSystems/seismic-alloy.git", rev = "c8fad0b93da53f2b423d2f6720abdb4a6cbb9082" }
seismic-alloy-provider = { git = "https://github.com/SeismicSystems/seismic-alloy.git", rev = "c8fad0b93da53f2b423d2f6720abdb4a6cbb9082" }
seismic-alloy-genesis = { git = "https://github.com/SeismicSystems/seismic-alloy.git", rev = "c8fad0b93da53f2b423d2f6720abdb4a6cbb9082" }
# TODO: temporarily pointing to https://github.com/SeismicSystems/seismic-alloy/pull/104. Merge that PR first.
seismic-alloy-consensus = { git = "https://github.com/SeismicSystems/seismic-alloy.git", rev = "c1ce53389ad2bf9bd04c15f4924abe77677395b6" }
seismic-alloy-rpc-types = { git = "https://github.com/SeismicSystems/seismic-alloy.git", rev = "c1ce53389ad2bf9bd04c15f4924abe77677395b6" }
seismic-alloy-network = { git = "https://github.com/SeismicSystems/seismic-alloy.git", rev = "c1ce53389ad2bf9bd04c15f4924abe77677395b6" }
seismic-alloy-provider = { git = "https://github.com/SeismicSystems/seismic-alloy.git", rev = "c1ce53389ad2bf9bd04c15f4924abe77677395b6" }
seismic-alloy-genesis = { git = "https://github.com/SeismicSystems/seismic-alloy.git", rev = "c1ce53389ad2bf9bd04c15f4924abe77677395b6" }

# evm
alloy-evm = { git = "https://github.com/SeismicSystems/seismic-evm.git", rev = "c33f3076495d153eefbde07dd81c3a575f3d19b8" }
Expand Down
11 changes: 7 additions & 4 deletions crates/seismic/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ use reth_provider::{providers::ProviderFactoryBuilder, CanonStateSubscriptions,
use reth_rpc::ValidationApi;
use reth_rpc_api::BlockSubmissionValidationApiServer;
use reth_rpc_builder::{config::RethRpcServerConfig, Identity};
use reth_rpc_eth_api::helpers::config::{EthConfigApiServer, EthConfigHandler};
use reth_rpc_eth_api::helpers::{
config::{EthConfigApiServer, EthConfigHandler},
FullEthApi,
};
use reth_rpc_eth_types::{
error::{api::FromEvmHalt, FromEvmError},
EthApiError,
Expand Down Expand Up @@ -314,7 +317,7 @@ impl<N, EthB, PVB, EB, EVB, RpcMiddleware> NodeAddOns<N>
where
N: SeismicFullNode,
EthB: EthApiBuilder<N>,
EthB::EthApi: reth_seismic_rpc::FullSeismicApi + Send + Sync + 'static,
EthB::EthApi: FullEthApi + Send + Sync + 'static,
<EthB::EthApi as reth_rpc_eth_api::EthApiTypes>::Error: Send + Sync + 'static,
jsonrpsee::types::ErrorObject<'static>:
From<<EthB::EthApi as reth_rpc_eth_api::EthApiTypes>::Error>,
Expand Down Expand Up @@ -382,7 +385,7 @@ impl<N, EthB, PVB, EB, EVB, RpcMiddleware> RethRpcAddOns<N>
where
N: SeismicFullNode,
EthB: EthApiBuilder<N>,
EthB::EthApi: reth_seismic_rpc::FullSeismicApi + Send + Sync + 'static,
EthB::EthApi: FullEthApi + Send + Sync + 'static,
<EthB::EthApi as reth_rpc_eth_api::EthApiTypes>::Error: Send + Sync + 'static,
jsonrpsee::types::ErrorObject<'static>:
From<<EthB::EthApi as reth_rpc_eth_api::EthApiTypes>::Error>,
Expand Down Expand Up @@ -412,7 +415,7 @@ impl<N, EthB, PVB, EB, EVB, RpcMiddleware> EngineValidatorAddOn<N>
where
N: SeismicFullNode<Evm: ConfigureEngineEvm<ExecutionData>>,
EthB: EthApiBuilder<N>,
EthB::EthApi: reth_seismic_rpc::FullSeismicApi + Send + Sync + 'static,
EthB::EthApi: FullEthApi + Send + Sync + 'static,
<EthB::EthApi as reth_rpc_eth_api::EthApiTypes>::Error: Send + Sync + 'static,
jsonrpsee::types::ErrorObject<'static>:
From<<EthB::EthApi as reth_rpc_eth_api::EthApiTypes>::Error>,
Expand Down
3 changes: 0 additions & 3 deletions crates/seismic/primitives/src/transaction/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ pub enum SeismicTxError {
/// The block number at which the transaction expires
expires_at_block: u64,
},
/// A write transaction (non-contract creation) cannot have `signed_read` = true
#[display("write transactions cannot have signed_read set to true")]
InvalidSignedReadForWrite,
/// Failed to decrypt calldata of seismic tx
#[display("failed to decrypt seismic transaction")]
FailedToDecrypt,
Expand Down
37 changes: 0 additions & 37 deletions crates/seismic/rpc/src/eth/api.rs

This file was deleted.

44 changes: 21 additions & 23 deletions crates/seismic/rpc/src/eth/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
//! For `eth_sendRawTransaction`, we directly call the inner eth api without decryption
//! See that function's docs for more details

use super::api::FullSeismicApi;
use crate::utils::{
convert_seismic_call_to_tx_request, parse_request_sender, signed_read_to_plaintext_tx,
};
use alloy_dyn_abi::TypedData;
use alloy_eips::eip2718::Encodable2718;
use alloy_json_rpc::RpcObject;
use alloy_primitives::{Address, Bytes, B256, U256};
use alloy_rpc_types::{
Expand All @@ -19,18 +19,19 @@ use alloy_rpc_types::{
use alloy_rpc_types_eth::simulate::{
SimBlock as EthSimBlock, SimulatePayload as EthSimulatePayload, SimulatedBlock,
};
use futures::Future;
use jsonrpsee::{
core::{async_trait, RpcResult},
proc_macros::rpc,
};
use reth_rpc_eth_api::{
helpers::{EthCall, EthTransactions},
helpers::{EthCall, EthTransactions, FullEthApi},
RpcBlock, RpcTypes,
};
use reth_rpc_eth_types::EthApiError;
use reth_tracing::tracing::*;
use seismic_alloy_consensus::{InputDecryptionElements, TxSeismicMetadata, TypedDataRequest};
use seismic_alloy_consensus::{
Decodable712, InputDecryptionElements, SeismicTxEnvelope, TxSeismicMetadata,
};
use seismic_alloy_rpc_types::{
SeismicCallRequest, SeismicRawTxRequest, SeismicTransactionRequest,
SimBlock as SeismicSimBlock, SimulatePayload as SeismicSimulatePayload,
Expand Down Expand Up @@ -75,17 +76,6 @@ pub const fn test_address() -> SocketAddr {
SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, 0))
}

/// Extension trait for `EthTransactions` to add custom transaction sending functionalities.
pub trait SeismicTransaction: EthTransactions {
/// Decodes, signs (if necessary via an internal signer or enclave),
/// and submits a typed data transaction to the pool.
/// Returns the hash of the transaction.
fn send_typed_data_transaction(
&self,
tx_request: TypedDataRequest,
) -> impl Future<Output = Result<B256, Self::Error>> + Send;
}

/// Seismic `eth_` RPC namespace overrides.
#[cfg_attr(not(feature = "client"), rpc(server, namespace = "eth"))]
#[cfg_attr(feature = "client", rpc(server, client, namespace = "eth"))]
Expand Down Expand Up @@ -161,7 +151,7 @@ impl<Eth> EthApiExt<Eth> {
#[async_trait]
impl<Eth> EthApiOverrideServer<RpcBlock<Eth::NetworkTypes>> for EthApiExt<Eth>
where
Eth: FullSeismicApi + Send + Sync + 'static,
Eth: FullEthApi + Send + Sync + 'static,
Eth::Error: Send + Sync + 'static,
jsonrpsee_types::error::ErrorObject<'static>: From<Eth::Error>,
<Eth::NetworkTypes as RpcTypes>::TransactionRequest:
Expand Down Expand Up @@ -294,15 +284,23 @@ where
/// decryption during execution is handled by the [`SeismicBlockExecutor`]
async fn send_raw_transaction(&self, tx: SeismicRawTxRequest) -> RpcResult<B256> {
debug!(target: "reth-seismic-rpc::eth", ?tx, "Serving overridden eth_sendRawTransaction extension");
match tx {
SeismicRawTxRequest::Bytes(bytes) => {
Ok(EthTransactions::send_raw_transaction(&self.eth_api, bytes).await?)
}
let bytes = match tx {
SeismicRawTxRequest::Bytes(bytes) => bytes,
SeismicRawTxRequest::TypedData(typed_data) => {
Ok(SeismicTransaction::send_typed_data_transaction(&self.eth_api, typed_data)
.await?)
// Re-encode EIP-712 typed-data submissions as RLP so they flow through
// the same `Decodable2718` pipeline as raw-bytes submissions. This keeps
// decode-time checks (e.g. signed-read rejection) uniformly enforced across all
// signed-tx ingress paths.
//
// TODO(samlaf): we should update our clients to submit EIP-712 transactions as RLP
// bytes directly rather than using the redundant `SeismicRawTxRequest::TypedData`
// wrapper, and then delete this TypedData ingress path.
let envelope = SeismicTxEnvelope::decode_712(&typed_data)
.map_err(|_| EthApiError::FailedToDecodeSignedTransaction)?;
envelope.encoded_2718().into()
}
}
};
Ok(EthTransactions::send_raw_transaction(&self.eth_api, bytes).await?)
}

async fn estimate_gas(
Expand Down
2 changes: 0 additions & 2 deletions crates/seismic/rpc/src/eth/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
//! Seismic-Reth `eth_` endpoint implementation.

pub mod api;
pub mod ext;
pub mod receipt;
pub mod transaction;
pub mod utils;

pub use api::FullSeismicApi;
pub use receipt::SeismicReceiptConverter;

mod block;
Expand Down
42 changes: 3 additions & 39 deletions crates/seismic/rpc/src/eth/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
//! Loads and formats Seismic transaction RPC response.

use super::ext::SeismicTransaction;
use crate::{
eth::{SeismicNodeCore, SignableSeismicTransactionRequest},
utils::recover_typed_data_request,
SeismicEthApi, SeismicEthApiError,
};
use crate::{eth::SignableSeismicTransactionRequest, SeismicEthApi, SeismicEthApiError};
use alloy_consensus::{transaction::Recovered, Transaction as _};
use alloy_primitives::{Address, Bytes, Signature, B256};
use alloy_rpc_types_eth::{Transaction, TransactionInfo};
Expand All @@ -21,11 +16,11 @@ use reth_rpc_layer::{
OpsWhitelistTxAuth, Whitelist, OPS_AUTH_CONTRACT, OPS_AUTH_SLOT, WHITELIST_TX_SENTINEL,
};
use reth_seismic_primitives::SeismicTransactionSigned;
use reth_storage_api::{BlockReader, BlockReaderIdExt, ProviderTx, StateProviderFactory};
use reth_storage_api::StateProviderFactory;
use reth_transaction_pool::{
AddedTransactionOutcome, PoolTransaction, TransactionOrigin, TransactionPool,
};
use seismic_alloy_consensus::{Decodable712, SeismicTxEnvelope, TypedDataRequest};
use seismic_alloy_consensus::SeismicTxEnvelope;
use seismic_alloy_rpc_types::SeismicTransactionRequest;
use std::time::{SystemTime, UNIX_EPOCH};

Expand Down Expand Up @@ -118,37 +113,6 @@ where
}
}

impl<N, Rpc> SeismicTransaction for SeismicEthApi<N, Rpc>
where
Self: LoadTransaction<Provider: BlockReaderIdExt>,
// N: RpcNodeCore,
N: SeismicNodeCore<Provider: BlockReader<Transaction = ProviderTx<Self::Provider>>>,
<<<Self as RpcNodeCore>::Pool as TransactionPool>::Transaction as PoolTransaction>::Pooled:
Decodable712,
Rpc: RpcConvert<Primitives = N::Primitives, Error = SeismicEthApiError>,
{
async fn send_typed_data_transaction(&self, tx: TypedDataRequest) -> Result<B256, Self::Error> {
let recovered = recover_typed_data_request(&tx)?;

// broadcast raw transaction to subscribers if there is any.
// TODO: maybe we need to broadcast the encoded tx instead of the recovered tx
// when other nodes receive the raw bytes the hash they recover needs to be
// type
// self.broadcast_raw_transaction(recovered.to);

let pool_transaction = <Self::Pool as TransactionPool>::Transaction::from_pooled(recovered);

// submit the transaction to the pool with a `Local` origin
let AddedTransactionOutcome { hash, .. } = self
.pool()
.add_transaction(TransactionOrigin::Local, pool_transaction)
.await
.map_err(Self::Error::from_eth_err)?;

Ok(hash)
}
}

impl<N, Rpc> LoadTransaction for SeismicEthApi<N, Rpc>
where
N: RpcNodeCore,
Expand Down
Loading
Loading