Skip to content
Merged
22 changes: 17 additions & 5 deletions crates/l2/tee/quote-gen/Cargo.lock

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

30 changes: 0 additions & 30 deletions crates/networking/p2p/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,36 +93,6 @@ impl P2PContext {
tx_broadcaster,
})
}

#[cfg(any(test, feature = "test-utils"))]
/// Creates a dummy P2PContext for tests
/// This should only be used in tests as it won't be able to connect to the p2p network
pub async fn dummy(peer_table: PeerTable) -> P2PContext {
use ethrex_storage::EngineType;

let storage = Store::new("./temp", EngineType::InMemory).expect("Failed to create Store");
let blockchain: Arc<Blockchain> = Arc::new(Blockchain::default_with_store(storage.clone()));
let local_node = Node::from_enode_url(
"enode://d860a01f9722d78051619d1e2351aba3f43f943f6f00718d1b9baa4101932a1f5011f16bb2b1bb35db20d6fe28fa0bf09636d26a87d31de9ec6203eeedb1f666@18.138.108.67:30303",
).expect("Bad enode url");
let (channel_broadcast_send_end, _) =
tokio::sync::broadcast::channel::<(tokio::task::Id, Arc<Message>)>(100000);
P2PContext {
tracker: TaskTracker::default(),
signer: SecretKey::from_byte_array(&[0xcd; 32]).expect("32 bytes, within curve order"),
table: peer_table.clone(),
storage,
blockchain: blockchain.clone(),
broadcast: channel_broadcast_send_end,
local_node: local_node.clone(),
client_version: "".to_string(),
#[cfg(feature = "l2")]
based_context: None,
tx_broadcaster: TxBroadcaster::spawn(peer_table.clone(), blockchain, 1000)
.await
.expect("Failed to spawn tx broadcaster"),
}
}
}

#[derive(Debug, thiserror::Error)]
Expand Down
10 changes: 0 additions & 10 deletions crates/networking/p2p/peer_handler.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#[cfg(any(test, feature = "test-utils"))]
use crate::discv4::peer_table::TARGET_PEERS;
use crate::rlpx::initiator::RLPxInitiator;
use crate::{
discv4::peer_table::{PeerData, PeerTable, PeerTableError},
Expand Down Expand Up @@ -154,14 +152,6 @@ impl PeerHandler {
}
}

#[cfg(any(test, feature = "test-utils"))]
/// Creates a dummy PeerHandler for tests where interacting with peers is not needed
/// This should only be used in tests as it won't be able to interact with the node's connected peers
pub async fn dummy() -> PeerHandler {
let peer_table = PeerTable::spawn(TARGET_PEERS);
PeerHandler::new(peer_table.clone(), RLPxInitiator::dummy(peer_table).await)
}

async fn make_request(
// TODO: We should receive the PeerHandler (or self) instead, but since it is not yet spawnified it cannot be shared
// Fix this to avoid passing the PeerTable as a parameter
Expand Down
12 changes: 0 additions & 12 deletions crates/networking/p2p/rlpx/initiator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ use spawned_concurrency::{
use std::time::Duration;
use tracing::{debug, error, info};

#[cfg(any(test, feature = "test-utils"))]
use crate::discv4::peer_table::PeerTable;

#[derive(Debug, thiserror::Error)]
pub enum RLPxInitiatorError {
#[error(transparent)]
Expand Down Expand Up @@ -78,15 +75,6 @@ impl RLPxInitiator {
self.lookup_interval
}
}

#[cfg(any(test, feature = "test-utils"))]
/// Creates a dummy GenServer for tests
/// This should only be used in tests
pub async fn dummy(peer_table: PeerTable) -> GenServerHandle<RLPxInitiator> {
info!("Starting RLPx Initiator");
let state = RLPxInitiator::new(P2PContext::dummy(peer_table).await);
RLPxInitiator::start(state)
}
}

#[derive(Debug, Clone)]
Expand Down
18 changes: 0 additions & 18 deletions crates/networking/p2p/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ use ethrex_common::{
types::{AccountState, Block, BlockHash, BlockHeader},
};
use ethrex_rlp::{decode::RLPDecode, encode::RLPEncode, error::RLPDecodeError};
#[cfg(any(test, feature = "test-utils"))]
use ethrex_storage::EngineType;
use ethrex_storage::{STATE_TRIE_SEGMENTS, Store, error::StoreError};
use ethrex_trie::trie_sorted::TrieGenerationError;
use ethrex_trie::{Trie, TrieError};
Expand Down Expand Up @@ -122,22 +120,6 @@ impl Syncer {
}
}

#[cfg(any(test, feature = "test-utils"))]
/// Creates a dummy Syncer for tests where syncing is not needed
/// This should only be used in tests as it won't be able to connect to the p2p network
pub async fn dummy() -> Self {
Self {
snap_enabled: Arc::new(AtomicBool::new(false)),
peers: PeerHandler::dummy().await,
// This won't be used
cancel_token: CancellationToken::new(),
blockchain: Arc::new(Blockchain::default_with_store(
Store::new("", EngineType::InMemory).expect("Failed to start Store Engine"),
)),
datadir: ".".into(),
}
}

/// Starts a sync cycle, updating the state with all blocks between the current head and the sync head
/// Will perform either full or snap sync depending on the manager's `snap_mode`
/// In full mode, all blocks will be fetched via p2p eth requests and executed to rebuild the state
Expand Down
13 changes: 0 additions & 13 deletions crates/networking/p2p/sync_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,6 @@ impl SyncManager {
sync_manager
}

#[cfg(any(test, feature = "test-utils"))]
/// Creates a dummy SyncManager for tests where syncing is not needed
/// This should only be used in tests as it won't be able to connect to the p2p network
pub async fn dummy() -> Self {
Self {
snap_enabled: Arc::new(AtomicBool::new(false)),
syncer: Arc::new(Mutex::new(Syncer::dummy().await)),
last_fcu_head: Arc::new(Mutex::new(H256::zero())),
store: Store::new("temp.db", ethrex_storage::EngineType::InMemory)
.expect("Failed to start Storage Engine"),
}
}

/// Sets the latest fcu head and starts the next sync cycle if the syncer is currently inactive
pub fn sync_to_head(&self, fcu_head: H256) {
self.set_head(fcu_head);
Expand Down
1 change: 1 addition & 0 deletions crates/networking/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ envy = "0.4.2"
thiserror.workspace = true
secp256k1.workspace = true
uuid.workspace = true
hex-literal = "0.4.1"

[dev-dependencies]
hex-literal = "0.4.1"
Expand Down
3 changes: 1 addition & 2 deletions crates/networking/rpc/eth/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,13 @@ mod tests {
logs::{AddressFilter, LogsFilter, TopicFilter},
},
rpc::{FILTER_DURATION, map_http_requests},
utils::test_utils::{self, default_context_with_storage, start_test_api},
test_utils::{TEST_GENESIS, default_context_with_storage, start_test_api},
};
use crate::{types::block_identifier::BlockIdentifier, utils::RpcRequest};
use ethrex_common::types::Genesis;
use ethrex_storage::{EngineType, Store};

use serde_json::{Value, json};
use test_utils::TEST_GENESIS;

#[tokio::test]
async fn filter_request_smoke_test_valid_params() {
Expand Down
4 changes: 2 additions & 2 deletions crates/networking/rpc/eth/gas_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ impl RpcHandler for GasPrice {
#[cfg(test)]
mod tests {
use super::GasPrice;
use crate::eth::test_utils::{
use crate::test_utils::{
BASE_PRICE_IN_WEI, add_eip1559_tx_blocks, add_legacy_tx_blocks, add_mixed_tx_blocks,
setup_store,
};

use crate::utils::test_utils::default_context_with_storage;
use crate::test_utils::default_context_with_storage;
use crate::{
rpc::{RpcHandler, map_http_requests},
utils::{RpcRequest, parse_json_hex},
Expand Down
2 changes: 1 addition & 1 deletion crates/networking/rpc/eth/gas_tip_estimator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl Default for GasTipEstimator {
#[cfg(test)]
mod tests {
use super::*;
use crate::eth::test_utils::{
use crate::test_utils::{
BASE_PRICE_IN_WEI, add_eip1559_tx_blocks, add_empty_blocks, add_legacy_tx_blocks,
add_mixed_tx_blocks, setup_store,
};
Expand Down
8 changes: 3 additions & 5 deletions crates/networking/rpc/eth/max_priority_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ impl RpcHandler for MaxPriorityFee {
#[cfg(test)]
mod tests {
use super::*;
use crate::eth::test_utils::{
use crate::test_utils::{
BASE_PRICE_IN_WEI, add_eip1559_tx_blocks, add_legacy_tx_blocks, add_mixed_tx_blocks,
setup_store,
default_context_with_storage, example_p2p_node, setup_store,
};

use crate::utils::test_utils::default_context_with_storage;
use crate::{
rpc::{RpcApiContext, RpcHandler, map_http_requests},
utils::{RpcRequest, parse_json_hex, test_utils::example_p2p_node},
utils::{RpcRequest, parse_json_hex},
};
use ethrex_common::types::MIN_GAS_TIP;
use serde_json::json;
Expand Down
Loading