Skip to content

Commit

Permalink
Merge branch 'master' into feature/integration-tests-forkless-upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
xgreenx authored May 29, 2024
2 parents d6f4275 + 70dcde6 commit 0dc95cf
Show file tree
Hide file tree
Showing 18 changed files with 33 additions and 180 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Removed
- [#1913](https://github.com/FuelLabs/fuel-core/pull/1913): Removed dead code from the project.

## [Version 0.27.0]

### Added
Expand Down
23 changes: 0 additions & 23 deletions crates/chain-config/src/config/state/parquet/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ use parquet::{
data_type::ByteArrayType,
schema::types::Type,
};
use postcard::ser_flavors::{
AllocVec,
Flavor,
};

pub struct Encoder<W>
where
Expand Down Expand Up @@ -88,22 +84,3 @@ where
Ok(())
}
}

pub trait Encode<T> {
fn encode(data: &T) -> anyhow::Result<Vec<u8>>;
}

pub struct PostcardEncode;

impl<T> Encode<T> for PostcardEncode
where
T: serde::Serialize,
{
fn encode(data: &T) -> anyhow::Result<Vec<u8>> {
let mut serializer = postcard::Serializer {
output: AllocVec::new(),
};
data.serialize(&mut serializer)?;
Ok(serializer.output.finalize()?)
}
}
28 changes: 24 additions & 4 deletions crates/fuel-core/src/p2p_test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,20 @@ pub async fn make_nodes(
{
match bootstrap_type {
BootstrapType::BootstrapNodes => {
node_config.p2p.as_mut().unwrap().bootstrap_nodes = boots.clone();
node_config
.p2p
.as_mut()
.unwrap()
.bootstrap_nodes
.clone_from(&boots);
}
BootstrapType::ReservedNodes => {
node_config.p2p.as_mut().unwrap().reserved_nodes = boots.clone();
node_config
.p2p
.as_mut()
.unwrap()
.reserved_nodes
.clone_from(&boots);
}
}

Expand Down Expand Up @@ -341,10 +351,20 @@ pub async fn make_nodes(

match bootstrap_type {
BootstrapType::BootstrapNodes => {
node_config.p2p.as_mut().unwrap().bootstrap_nodes = boots.clone();
node_config
.p2p
.as_mut()
.unwrap()
.bootstrap_nodes
.clone_from(&boots);
}
BootstrapType::ReservedNodes => {
node_config.p2p.as_mut().unwrap().reserved_nodes = boots.clone();
node_config
.p2p
.as_mut()
.unwrap()
.reserved_nodes
.clone_from(&boots);
}
}
update_signing_key(&mut node_config, pub_key);
Expand Down
14 changes: 0 additions & 14 deletions crates/services/importer/src/importer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,20 +487,6 @@ where
}
}

trait ShouldBeUnique {
fn should_be_unique(&self, height: &BlockHeight) -> Result<(), Error>;
}

impl<T> ShouldBeUnique for Option<T> {
fn should_be_unique(&self, height: &BlockHeight) -> Result<(), Error> {
if self.is_some() {
Err(Error::NotUnique(*height))
} else {
Ok(())
}
}
}

/// The wrapper around `ImportResult` to notify about the end of the processing of a new block.
struct Awaiter {
result: ImportResult,
Expand Down
4 changes: 2 additions & 2 deletions crates/services/p2p/src/p2p_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ mod tests {
let mut p2p_config = p2p_config.clone();
p2p_config.max_peers_connected = node_a_max_peers_allowed as u32;
// it still tries to dial all nodes!
p2p_config.bootstrap_nodes = nodes_multiaddrs.clone();
p2p_config.bootstrap_nodes.clone_from(&nodes_multiaddrs);

build_service_from_config(p2p_config).await
};
Expand All @@ -933,7 +933,7 @@ mod tests {
let mut p2p_config = p2p_config.clone();
p2p_config.max_peers_connected = node_b_max_peers_allowed as u32;
// it still tries to dial all nodes!
p2p_config.bootstrap_nodes = nodes_multiaddrs.clone();
p2p_config.bootstrap_nodes.clone_from(&nodes_multiaddrs);

build_service_from_config(p2p_config).await
};
Expand Down
2 changes: 1 addition & 1 deletion crates/services/p2p/src/peer_manager/heartbeat_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ impl HeartbeatData {
}

#[allow(clippy::cast_possible_truncation)]
#[allow(non_snake_case)]
#[cfg(test)]
mod tests {
#![allow(non_snake_case)]
use super::*;

#[tokio::test(start_paused = true)]
Expand Down
43 changes: 0 additions & 43 deletions crates/services/p2p/src/peer_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::config::Config;
use libp2p::{
self,
core::Endpoint,
identify,
swarm::{
derive_prelude::{
ConnectionClosed,
Expand Down Expand Up @@ -159,45 +158,3 @@ impl NetworkBehaviour for Behaviour {
Poll::Pending
}
}

trait FromAction<T: NetworkBehaviour>: NetworkBehaviour {
fn convert_action(
&mut self,
action: ToSwarm<T::ToSwarm, THandlerInEvent<T>>,
) -> Option<ToSwarm<Self::ToSwarm, THandlerInEvent<Self>>>;
}

impl FromSwarmEvent for Behaviour {}
impl FromSwarmEvent for identify::Behaviour {}

trait FromSwarmEvent: NetworkBehaviour {
fn handle_swarm_event(&mut self, event: &FromSwarm) {
match event {
FromSwarm::NewListener(e) => {
self.on_swarm_event(FromSwarm::NewListener(*e));
}
FromSwarm::ExpiredListenAddr(e) => {
self.on_swarm_event(FromSwarm::ExpiredListenAddr(*e));
}
FromSwarm::ListenerError(e) => {
self.on_swarm_event(FromSwarm::ListenerError(*e));
}
FromSwarm::ListenerClosed(e) => {
self.on_swarm_event(FromSwarm::ListenerClosed(*e));
}
FromSwarm::NewExternalAddrCandidate(e) => {
self.on_swarm_event(FromSwarm::NewExternalAddrCandidate(*e));
}
FromSwarm::ExternalAddrExpired(e) => {
self.on_swarm_event(FromSwarm::ExternalAddrExpired(*e));
}
FromSwarm::NewListenAddr(e) => {
self.on_swarm_event(FromSwarm::NewListenAddr(*e));
}
FromSwarm::AddressChange(e) => {
self.on_swarm_event(FromSwarm::AddressChange(*e));
}
_ => {}
}
}
}
17 changes: 0 additions & 17 deletions crates/services/producer/src/mocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,6 @@ impl TxPool for MockTxPool {
#[derive(Default)]
pub struct MockExecutor(pub MockDb);

#[derive(Debug)]
struct DatabaseTransaction {
database: MockDb,
}

impl AsMut<MockDb> for DatabaseTransaction {
fn as_mut(&mut self) -> &mut MockDb {
&mut self.database
}
}

impl AsRef<MockDb> for DatabaseTransaction {
fn as_ref(&self) -> &MockDb {
&self.database
}
}

impl AsMut<MockDb> for MockDb {
fn as_mut(&mut self) -> &mut MockDb {
self
Expand Down
4 changes: 0 additions & 4 deletions crates/services/relayer/src/service/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ pub struct EthState {

type EthHeight = u64;

#[derive(Clone, Debug)]
/// Type for tracking block height ranges.
struct Heights<T>(RangeInclusive<T>);

#[derive(Clone, Debug)]
/// The gap between the eth block height on
/// the relayer and the Ethereum node.
Expand Down
33 changes: 0 additions & 33 deletions crates/services/sync/src/tracing_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,6 @@ pub trait TraceErr {
fn trace_err(self, msg: &str) -> Self;
}

pub trait TraceNone: Sized {
fn trace_none<F>(self, f: F) -> Self
where
F: FnOnce();
fn trace_none_error(self, msg: &str) -> Self {
self.trace_none(|| tracing::error!("{}", msg))
}
fn trace_none_warn(self, msg: &str) -> Self {
self.trace_none(|| tracing::warn!("{}", msg))
}
fn trace_none_info(self, msg: &str) -> Self {
self.trace_none(|| tracing::info!("{}", msg))
}
fn trace_none_debug(self, msg: &str) -> Self {
self.trace_none(|| tracing::debug!("{}", msg))
}
fn trace_none_trace(self, msg: &str) -> Self {
self.trace_none(|| tracing::trace!("{}", msg))
}
}

impl<T, E> TraceErr for Result<T, E>
where
E: Display,
Expand All @@ -36,15 +15,3 @@ where
self
}
}

impl<T> TraceNone for Option<T> {
fn trace_none<F>(self, f: F) -> Self
where
F: FnOnce(),
{
if self.is_none() {
f();
}
self
}
}
4 changes: 0 additions & 4 deletions crates/services/txpool/src/containers/price_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ impl SortableKey for TipSortKey {
fn value(&self) -> &Self::Value {
&self.tip
}

fn tx_id(&self) -> &TxId {
&self.tx_id
}
}

impl PartialEq for TipSortKey {
Expand Down
7 changes: 1 addition & 6 deletions crates/services/txpool/src/containers/sort.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use crate::{
types::*,
TxInfo,
};
use crate::TxInfo;
use fuel_core_types::services::txpool::ArcPoolTx;
use std::collections::BTreeMap;

Expand Down Expand Up @@ -51,6 +48,4 @@ pub trait SortableKey: Ord {
fn new(info: &TxInfo) -> Self;

fn value(&self) -> &Self::Value;

fn tx_id(&self) -> &TxId;
}
4 changes: 0 additions & 4 deletions crates/services/txpool/src/containers/time_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ impl SortableKey for TimeSortKey {
fn value(&self) -> &Self::Value {
&self.time
}

fn tx_id(&self) -> &TxId {
&self.tx_id
}
}

impl PartialEq for TimeSortKey {
Expand Down
14 changes: 0 additions & 14 deletions crates/services/txpool/src/service/update_sender.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{
collections::HashMap,
future::Future,
pin::Pin,
time::Duration,
};
Expand Down Expand Up @@ -114,9 +113,6 @@ pub trait CreateChannel {
trait Permits {
/// Try to acquire a permit.
fn try_acquire(self: Arc<Self>) -> Option<Permit>;

/// Wait for a permit to be available.
fn acquire(self: Arc<Self>) -> Pin<Box<dyn Future<Output = Permit> + Send + Sync>>;
}

/// Combines `Permits` and `std::fmt::Debug`.
Expand All @@ -142,16 +138,6 @@ impl Permits for Semaphore {
b
})
}

fn acquire(self: Arc<Self>) -> Pin<Box<dyn Future<Output = Permit> + Send + Sync>> {
Box::pin(async move {
let p = Semaphore::acquire_owned(self)
.await
.expect("Semaphore is not ever closed");
let b: Permit = Box::new(p);
b
})
}
}

impl PermitTrait for OwnedSemaphorePermit {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ impl Permits for Arc<usize> {
p
})
}
fn acquire(self: Arc<Self>) -> Pin<Box<dyn Future<Output = Permit> + Send + Sync>> {
unimplemented!()
}
}

#[proptest]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,6 @@ impl Permits for () {
fn try_acquire(self: Arc<Self>) -> Option<Permit> {
Some(Permit::from(Box::new(())))
}

fn acquire(self: Arc<Self>) -> Pin<Box<dyn Future<Output = Permit> + Send + Sync>> {
Box::pin(async move { Permit::from(Box::new(())) })
}
}

pub(super) struct MockCreateChannel;
Expand Down
4 changes: 1 addition & 3 deletions crates/services/upgradable-executor/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,7 @@ mod test {
})
.collect::<BTreeMap<_, _>>();

if let Some(expected_version) =
seen_crate_versions.get(&crate_version.to_string())
{
if let Some(expected_version) = seen_crate_versions.get(crate_version) {
assert_eq!(
*expected_version,
Executor::<Storage, DisabledRelayer>::VERSION,
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/src/structured_storage/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ mod test {
crate::basic_storage_tests!(
ContractsState,
<ContractsState as Mappable>::Key::default(),
vec![0u8; 32],
[0u8; 32],
vec![0u8; 32].into(),
generate_key_for_same_contract
);
Expand Down

0 comments on commit 0dc95cf

Please sign in to comment.