Skip to content

Commit

Permalink
chore: cleanup dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
Serial-ATA committed Feb 10, 2025
1 parent bc3329d commit 95a628e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 37 deletions.
2 changes: 1 addition & 1 deletion blueprints/examples/src/eigen_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub async fn constructor(
id = 0,
params(task_index, log_index, block_number),
event_listener(
listener = EvmContractEventListener<ExampleTaskManager::NewTaskCreated>,
listener = EvmContractEventListener<ExampleEigenContext, ExampleTaskManager::NewTaskCreated>,
instance = ExampleTaskManager,
abi = EXAMPLE_TASK_MANAGER_ABI_STRING,
pre_processor = handle_events,
Expand Down
1 change: 1 addition & 0 deletions crates/event-listeners/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub struct EvmContractEventListener<Ctx: Send + 'static, E: SolEvent + Send + 's
local_db: LocalDatabase<u64>,
should_cooldown: bool,
enqueued_events: VecDeque<(E, alloy_rpc_types::Log)>,
#[allow(dead_code)]
context: Ctx,
}

Expand Down
6 changes: 3 additions & 3 deletions crates/macros/blueprint-proc-macro/src/job/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ pub(crate) fn generate_event_workflow_tokenstream(
let job_processor_call_return = get_return_type_wrapper(&return_type, None);

quote! {
move |param0| async move {
move |(param0, context)| async move {
let res = #fn_name_ident (#(#ordered_inputs),*) #asyncness;
#job_processor_call_return
}
Expand Down Expand Up @@ -436,7 +436,7 @@ pub(crate) fn generate_event_workflow_tokenstream(
async fn #listener_function_name (handler: &#autogen_struct_name) -> Option<::blueprint_sdk::macros::ext::tokio::sync::oneshot::Receiver<Result<(), Box<dyn ::core::error::Error + Send>>>> {
static ONCE: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
if !ONCE.fetch_or(true, std::sync::atomic::Ordering::Relaxed) {
//::blueprint_sdk::logging::warn!("(Test mode?) Duplicated call for event listener {}", stringify!(#struct_name));
::blueprint_sdk::logging::warn!("(Test mode?) Duplicated call for event listener {}", stringify!(#struct_name));
}

let (tx, rx) = ::blueprint_sdk::macros::ext::tokio::sync::oneshot::channel();
Expand Down Expand Up @@ -778,7 +778,7 @@ pub(crate) fn generate_combined_event_listener_selector(struct_name: &Ident) ->
futures.push(listener);
}
if let Some(res) = ::blueprint_sdk::macros::ext::futures::stream::StreamExt::next(&mut futures).await {
//::blueprint_sdk::macros::ext::logging::warn!("An Event Handler for {} has stopped running", stringify!(#struct_name));
::blueprint_sdk::macros::ext::logging::warn!("An Event Handler for {} has stopped running", stringify!(#struct_name));
let res = match res {
Ok(res) => {
res
Expand Down
23 changes: 5 additions & 18 deletions crates/testing-utils/tangle/src/harness.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
use crate::multi_node::MultiNodeTestEnv;
use crate::node::transactions::{
join_operators, setup_operator_and_service, setup_operator_and_service_multiple,
};
use crate::node::transactions::
setup_operator_and_service_multiple;
use crate::Error;
use crate::{
keys::inject_tangle_key,
node::{
run,
transactions::{self, submit_and_verify_job},
transactions,
NodeConfig,
},
runner::TangleTestEnv,
InputValue, OutputValue,
};
use gadget_client_tangle::client::TangleClient;
use gadget_config::{supported_chains::SupportedChains, ContextConfig, GadgetConfiguration};
use gadget_contexts::{keystore::KeystoreContext, tangle::TangleClientContext};
use gadget_core_testing_utils::{harness::TestHarness, runner::TestEnv};
use gadget_core_testing_utils::harness::TestHarness;
use gadget_crypto_tangle_pair_signer::TanglePairSigner;
use gadget_event_listeners::core::InitializableEventHandler;
use gadget_keystore::backends::Backend;
use gadget_keystore::crypto::sp_core::{SpEcdsa, SpSr25519};
use gadget_logging::debug;
use gadget_runners::core::error::RunnerError;
use gadget_runners::tangle::tangle::{PriceTargets, TangleConfig};
use gadget_runners::tangle::tangle::PriceTargets;
use sp_core::Pair;
use std::future::Future;
use std::path::{Path, PathBuf};
use std::pin::Pin;
use tangle_subxt::tangle_testnet_runtime::api::services::events::JobCalled;
use tangle_subxt::tangle_testnet_runtime::api::services::{
calls::types::{call::Job, register::Preferences},
Expand Down Expand Up @@ -70,14 +65,6 @@ pub struct TangleTestHarness {
_node: crate::node::testnet::SubstrateNode,
}

/// A function that returns a future that returns a result containing an event handler for the job
type EventHandlerBox = Box<dyn InitializableEventHandler + Send + 'static>;
type JobResult = Result<EventHandlerBox, RunnerError>;
type JobFuture = Pin<Box<dyn Future<Output = JobResult> + Send + 'static>>;

trait JobCreator: Fn(GadgetConfiguration) -> JobFuture + Send + Sync + 'static {}
impl<T: Fn(GadgetConfiguration) -> JobFuture + Send + Sync + 'static> JobCreator for T {}

pub async fn generate_env_from_node_id(
identity: &str,
http_endpoint: Url,
Expand Down
18 changes: 4 additions & 14 deletions crates/testing-utils/tangle/src/multi_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ use gadget_keystore::backends::Backend;
use gadget_keystore::crypto::sp_core::SpSr25519;
use gadget_runners::core::error::RunnerError;
use gadget_runners::tangle::tangle::TangleConfig;
use std::fmt::{Debug, Formatter, Write};
use std::future::Future;
use std::pin::Pin;
use std::fmt::{Debug, Formatter};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use tangle_subxt::subxt::tx::Signer;
Expand All @@ -33,14 +31,6 @@ pub struct NodeHandle {
test_env: Arc<RwLock<TangleTestEnv>>,
}

/// A function that returns a future that returns a result containing an event handler for the job
type EventHandlerBox = Box<dyn InitializableEventHandler + Send + 'static>;
type JobResult = Result<EventHandlerBox, RunnerError>;
type JobFuture = Pin<Box<dyn Future<Output = JobResult> + Send + 'static>>;

trait JobCreator: Fn(GadgetConfiguration) -> JobFuture + Send + Sync + 'static {}
impl<T: Fn(GadgetConfiguration) -> JobFuture + Send + Sync + 'static> JobCreator for T {}

impl NodeHandle {
/// Adds a job to the node to be executed when the test is run.
///
Expand Down Expand Up @@ -141,7 +131,7 @@ impl MultiNodeTestEnv {

let (command_tx, command_rx) = mpsc::channel(32);
let (event_tx, _) = broadcast::channel(100);
let (initialized_tx, initialized_rx) = oneshot::channel();
let (initialized_tx, _initialized_rx) = oneshot::channel();

let env = Self {
nodes: Arc::new(RwLock::new(vec![NodeSlot::Empty; N])),
Expand Down Expand Up @@ -303,7 +293,7 @@ impl MultiNodeTestEnv {
node_id: usize,
event_tx: &broadcast::Sender<TestEvent>,
) -> Result<(), Error> {
let mut nodes = nodes.write().await;
let nodes = nodes.read().await;

let NodeSlot::Occupied(node) = nodes[node_id].clone() else {
return Err(Error::Setup(format!("Node {} not found", node_id)));
Expand Down Expand Up @@ -366,7 +356,7 @@ impl MultiNodeTestEnv {
nodes: Arc<RwLock<Vec<NodeSlot>>>,
event_tx: &broadcast::Sender<TestEvent>,
) {
let mut nodes = nodes.write().await;
let nodes = nodes.read().await;
for (node_id, node) in nodes.iter().enumerate() {
if let NodeSlot::Occupied(node) = node {
if let Err(e) = node.shutdown().await {
Expand Down
2 changes: 1 addition & 1 deletion crates/testing-utils/tangle/src/node/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ pub async fn setup_operator_and_service_multiple<T: Signer<TangleConfig>>(
sr25519_signers: &[T],
blueprint_id: u64,
preferences: Preferences,
exit_after_registration: bool,
_exit_after_registration: bool,
) -> Result<u64, TransactionError> {
let alice_client = clients
.first()
Expand Down

0 comments on commit 95a628e

Please # to comment.