From 5e8071ed955aef38cb9f04457fd704e3e4b8a252 Mon Sep 17 00:00:00 2001 From: Gustavo Inacio Date: Tue, 19 Nov 2024 18:10:10 -0600 Subject: [PATCH 01/11] refactor: rename types to allocation crate Signed-off-by: Gustavo Inacio --- Cargo.lock | 28 ++++++++++--------- Cargo.toml | 2 +- crates/{types => allocation}/Cargo.toml | 2 +- crates/{types => allocation}/src/lib.rs | 0 crates/common/Cargo.toml | 2 +- crates/common/src/allocations.rs | 2 +- crates/common/src/attestation/monitor.rs | 2 +- crates/common/src/attestation/signer.rs | 4 +-- crates/common/src/lib.rs | 1 - crates/common/src/test_vectors.rs | 2 +- crates/service/Cargo.toml | 1 + crates/service/src/tap.rs | 3 +- .../src/tap/checks/allocation_eligible.rs | 2 +- crates/tap-agent/Cargo.toml | 1 + .../src/agent/sender_accounts_manager.rs | 4 +-- crates/tests/tap-utils/Cargo.toml | 2 +- 16 files changed, 31 insertions(+), 27 deletions(-) rename crates/{types => allocation}/Cargo.toml (89%) rename crates/{types => allocation}/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index e3342ff2b..6b907d14f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3472,6 +3472,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "indexer-allocation" +version = "0.1.0" +dependencies = [ + "alloy", + "anyhow", + "indexer-query", + "serde", + "thegraph-core", +] + [[package]] name = "indexer-common" version = "1.4.0" @@ -3486,9 +3497,9 @@ dependencies = [ "env_logger", "eventuals", "graphql_client", + "indexer-allocation", "indexer-config", "indexer-query", - "indexer-types", "lazy_static", "prometheus", "reqwest 0.12.9", @@ -3572,6 +3583,7 @@ dependencies = [ "graphql 0.3.0", "graphql_client", "hex-literal", + "indexer-allocation", "indexer-common", "indexer-config", "indexer-dips", @@ -3610,6 +3622,7 @@ dependencies = [ "futures", "futures-util", "graphql_client", + "indexer-allocation", "indexer-common", "indexer-config", "indexer-query", @@ -3633,17 +3646,6 @@ dependencies = [ "wiremock 0.6.2", ] -[[package]] -name = "indexer-types" -version = "0.1.0" -dependencies = [ - "alloy", - "anyhow", - "indexer-query", - "serde", - "thegraph-core", -] - [[package]] name = "indexmap" version = "1.9.3" @@ -6716,7 +6718,7 @@ version = "0.1.0" dependencies = [ "alloy", "bip39", - "indexer-types", + "indexer-allocation", "lazy_static", "tap_core", "thegraph-core", diff --git a/Cargo.toml b/Cargo.toml index d7ad713d8..3b5775c22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = [ "crates/query", "crates/service", "crates/tap-agent", - "crates/types", + "crates/allocation", "crates/tests/tap-utils", ] resolver = "2" diff --git a/crates/types/Cargo.toml b/crates/allocation/Cargo.toml similarity index 89% rename from crates/types/Cargo.toml rename to crates/allocation/Cargo.toml index d38be691b..99453d253 100644 --- a/crates/types/Cargo.toml +++ b/crates/allocation/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "indexer-types" +name = "indexer-allocation" version = "0.1.0" edition = "2021" diff --git a/crates/types/src/lib.rs b/crates/allocation/src/lib.rs similarity index 100% rename from crates/types/src/lib.rs rename to crates/allocation/src/lib.rs diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index cb1a1be0e..8362ddb9c 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] indexer-config = { path = "../config" } indexer-query = { path = "../query" } -indexer-types = { path = "../types" } +indexer-allocation = { path = "../allocation" } thiserror.workspace = true async-trait.workspace = true alloy.workspace = true diff --git a/crates/common/src/allocations.rs b/crates/common/src/allocations.rs index a8618d8ad..6eb80cfe1 100644 --- a/crates/common/src/allocations.rs +++ b/crates/common/src/allocations.rs @@ -3,8 +3,8 @@ use crate::{client::SubgraphClient, watcher::new_watcher}; use alloy::{primitives::Address, primitives::TxHash}; +use indexer_allocation::Allocation; use indexer_query::allocations_query::{self, AllocationsQuery}; -use indexer_types::Allocation; use std::{ collections::HashMap, time::{Duration, SystemTime, UNIX_EPOCH}, diff --git a/crates/common/src/attestation/monitor.rs b/crates/common/src/attestation/monitor.rs index 90146bdb7..3da691403 100644 --- a/crates/common/src/attestation/monitor.rs +++ b/crates/common/src/attestation/monitor.rs @@ -9,7 +9,7 @@ use tokio::sync::watch::Receiver; use tracing::warn; use crate::{attestation::signer::AttestationSigner, watcher::join_and_map_watcher}; -use indexer_types::Allocation; +use indexer_allocation::Allocation; /// An always up-to-date list of attestation signers, one for each of the indexer's allocations. pub fn attestation_signers( diff --git a/crates/common/src/attestation/signer.rs b/crates/common/src/attestation/signer.rs index 2c5879517..99a261546 100644 --- a/crates/common/src/attestation/signer.rs +++ b/crates/common/src/attestation/signer.rs @@ -10,7 +10,7 @@ use alloy::{ }; use thegraph_core::{attestation, Address, Attestation, ChainId, DeploymentId}; -use indexer_types::Allocation; +use indexer_allocation::Allocation; pub fn derive_key_pair( indexer_mnemonic: &str, @@ -122,7 +122,7 @@ mod tests { use test_log::test; use crate::test_vectors::DISPUTE_MANAGER_ADDRESS; - use indexer_types::{Allocation, AllocationStatus, SubgraphDeployment}; + use indexer_allocation::{Allocation, AllocationStatus, SubgraphDeployment}; use super::*; diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 855b52094..1e755f0a1 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -21,4 +21,3 @@ pub mod monitors { pub use crate::client::{DeploymentDetails, SubgraphClient}; pub use escrow_accounts::{EscrowAccounts, EscrowAccountsError}; -pub use indexer_types::{Allocation, AllocationStatus, SubgraphDeployment}; diff --git a/crates/common/src/test_vectors.rs b/crates/common/src/test_vectors.rs index 5f24f1f95..ef322ba9e 100644 --- a/crates/common/src/test_vectors.rs +++ b/crates/common/src/test_vectors.rs @@ -8,7 +8,7 @@ use bip39::Mnemonic; use lazy_static::lazy_static; use thegraph_core::{Address, DeploymentId}; -use indexer_types::{Allocation, AllocationStatus, SubgraphDeployment}; +use indexer_allocation::{Allocation, AllocationStatus, SubgraphDeployment}; /// The allocation IDs below are generated using the mnemonic /// "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" diff --git a/crates/service/Cargo.toml b/crates/service/Cargo.toml index 65a1c0a57..9872ed932 100644 --- a/crates/service/Cargo.toml +++ b/crates/service/Cargo.toml @@ -8,6 +8,7 @@ license = "Apache-2.0" [dependencies] indexer-common = { path = "../common" } +indexer-allocation = { path = "../allocation" } indexer-config = { path = "../config" } indexer-dips = { path = "../dips" } indexer-query = { path = "../query" } diff --git a/crates/service/src/tap.rs b/crates/service/src/tap.rs index b4b80c55f..0961ad680 100644 --- a/crates/service/src/tap.rs +++ b/crates/service/src/tap.rs @@ -9,7 +9,8 @@ use crate::tap::checks::timestamp_check::TimestampCheck; use crate::tap::checks::value_check::MinimumValue; use alloy::dyn_abi::Eip712Domain; use alloy::primitives::Address; -use indexer_common::{Allocation, EscrowAccounts}; +use indexer_allocation::Allocation; +use indexer_common::EscrowAccounts; use receipt_store::{DatabaseReceipt, InnerContext}; use sqlx::PgPool; use std::fmt::Debug; diff --git a/crates/service/src/tap/checks/allocation_eligible.rs b/crates/service/src/tap/checks/allocation_eligible.rs index 199890645..965a7b135 100644 --- a/crates/service/src/tap/checks/allocation_eligible.rs +++ b/crates/service/src/tap/checks/allocation_eligible.rs @@ -6,7 +6,7 @@ use std::collections::HashMap; use alloy::primitives::Address; use anyhow::anyhow; -use indexer_common::Allocation; +use indexer_allocation::Allocation; use tap_core::receipt::{ checks::{Check, CheckError, CheckResult}, state::Checking, diff --git a/crates/tap-agent/Cargo.toml b/crates/tap-agent/Cargo.toml index c4c28d447..caf573804 100644 --- a/crates/tap-agent/Cargo.toml +++ b/crates/tap-agent/Cargo.toml @@ -10,6 +10,7 @@ path = "src/main.rs" [dependencies] indexer-common = { path = "../common" } +indexer-allocation = { path = "../allocation" } indexer-config = { path = "../config" } indexer-query = { path = "../query" } alloy.workspace = true diff --git a/crates/tap-agent/src/agent/sender_accounts_manager.rs b/crates/tap-agent/src/agent/sender_accounts_manager.rs index aa10e1a41..afbf3164e 100644 --- a/crates/tap-agent/src/agent/sender_accounts_manager.rs +++ b/crates/tap-agent/src/agent/sender_accounts_manager.rs @@ -15,9 +15,9 @@ use alloy::primitives::Address; use anyhow::Result; use anyhow::{anyhow, bail}; use futures::{stream, StreamExt}; -use indexer_common::escrow_accounts::EscrowAccounts; use indexer_common::watcher::watch_pipe; -use indexer_common::{Allocation, SubgraphClient}; +use indexer_allocation::Allocation; +use indexer_common::{escrow_accounts::EscrowAccounts, SubgraphClient}; use prometheus::{register_counter_vec, CounterVec}; use ractor::concurrency::JoinHandle; use ractor::{Actor, ActorCell, ActorProcessingErr, ActorRef, SupervisionEvent}; diff --git a/crates/tests/tap-utils/Cargo.toml b/crates/tests/tap-utils/Cargo.toml index 440596d2c..b0b1303f7 100644 --- a/crates/tests/tap-utils/Cargo.toml +++ b/crates/tests/tap-utils/Cargo.toml @@ -9,4 +9,4 @@ bip39 = "2.0.0" lazy_static.workspace = true tap_core.workspace = true thegraph-core.workspace = true -indexer-types = { path = "../../types" } +indexer-allocation = { path = "../../allocation" } From 3b22bb94d3d2b8447c2b37e63866e95c91001650 Mon Sep 17 00:00:00 2001 From: Gustavo Inacio Date: Tue, 19 Nov 2024 17:59:18 -0600 Subject: [PATCH 02/11] refactor: rename test utils Signed-off-by: Gustavo Inacio --- Cargo.lock | 28 ++--- Cargo.toml | 2 +- crates/common/Cargo.toml | 2 +- crates/common/src/attestation/monitor.rs | 2 +- crates/common/src/attestation/signer.rs | 2 +- crates/common/src/client/subgraph_client.rs | 4 +- crates/common/src/dispute_manager.rs | 11 +- crates/common/src/escrow_accounts.rs | 11 +- crates/common/src/lib.rs | 3 - crates/service/Cargo.toml | 2 +- .../service/src/service/tap_receipt_header.rs | 2 +- .../service/src/tap/checks/deny_list_check.rs | 2 +- crates/service/src/tap/checks/value_check.rs | 2 +- .../tap-utils => test-assets}/Cargo.toml | 4 +- .../src/lib.rs} | 105 +++++++++++++++- crates/tests/tap-utils/src/lib.rs | 114 ------------------ 16 files changed, 138 insertions(+), 158 deletions(-) rename crates/{tests/tap-utils => test-assets}/Cargo.toml (71%) rename crates/{common/src/test_vectors.rs => test-assets/src/lib.rs} (68%) delete mode 100644 crates/tests/tap-utils/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 6b907d14f..55402a487 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3507,8 +3507,8 @@ dependencies = [ "serde_json", "sqlx", "tap_core", + "test-assets", "test-log", - "test-tap-utils", "thegraph-core", "thiserror", "tokio", @@ -3595,7 +3595,7 @@ dependencies = [ "serde_json", "sqlx", "tap_core", - "test-tap-utils", + "test-assets", "thegraph-core", "thegraph-graphql-http", "thiserror", @@ -6692,6 +6692,18 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "test-assets" +version = "0.1.0" +dependencies = [ + "alloy", + "bip39", + "indexer-allocation", + "lazy_static", + "tap_core", + "thegraph-core", +] + [[package]] name = "test-log" version = "0.2.16" @@ -6712,18 +6724,6 @@ dependencies = [ "syn 2.0.79", ] -[[package]] -name = "test-tap-utils" -version = "0.1.0" -dependencies = [ - "alloy", - "bip39", - "indexer-allocation", - "lazy_static", - "tap_core", - "thegraph-core", -] - [[package]] name = "thegraph-core" version = "0.7.0" diff --git a/Cargo.toml b/Cargo.toml index 3b5775c22..4494b2151 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ members = [ "crates/service", "crates/tap-agent", "crates/allocation", - "crates/tests/tap-utils", + "crates/test-assets", ] resolver = "2" diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 8362ddb9c..3f8ab7185 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -33,4 +33,4 @@ bip39 = "2.0.0" env_logger = { version = "0.11.0", default-features = false } test-log = { version = "0.2.12", default-features = false } wiremock = "0.5.19" -test-tap-utils = { path = "../tests/tap-utils" } +test-assets = { path = "../test-assets" } diff --git a/crates/common/src/attestation/monitor.rs b/crates/common/src/attestation/monitor.rs index 3da691403..7bb422001 100644 --- a/crates/common/src/attestation/monitor.rs +++ b/crates/common/src/attestation/monitor.rs @@ -75,7 +75,7 @@ fn modify_sigers( mod tests { use tokio::sync::watch; - use crate::test_vectors::{DISPUTE_MANAGER_ADDRESS, INDEXER_ALLOCATIONS, INDEXER_MNEMONIC}; + use test_assets::{DISPUTE_MANAGER_ADDRESS, INDEXER_ALLOCATIONS, INDEXER_MNEMONIC}; use super::*; diff --git a/crates/common/src/attestation/signer.rs b/crates/common/src/attestation/signer.rs index 99a261546..9adad16f5 100644 --- a/crates/common/src/attestation/signer.rs +++ b/crates/common/src/attestation/signer.rs @@ -121,8 +121,8 @@ mod tests { use std::str::FromStr; use test_log::test; - use crate::test_vectors::DISPUTE_MANAGER_ADDRESS; use indexer_allocation::{Allocation, AllocationStatus, SubgraphDeployment}; + use test_assets::DISPUTE_MANAGER_ADDRESS; use super::*; diff --git a/crates/common/src/client/subgraph_client.rs b/crates/common/src/client/subgraph_client.rs index 6a6e88163..aa68c6a63 100644 --- a/crates/common/src/client/subgraph_client.rs +++ b/crates/common/src/client/subgraph_client.rs @@ -254,8 +254,6 @@ mod test { use wiremock::matchers::{method, path}; use wiremock::{Mock, MockServer, ResponseTemplate}; - use crate::test_vectors::{self}; - use super::*; const NETWORK_SUBGRAPH_URL: &str = @@ -266,7 +264,7 @@ mod test { let mock = Mock::given(method("POST")) .and(path(format!( "/subgraphs/id/{}", - *test_vectors::NETWORK_SUBGRAPH_DEPLOYMENT + *test_assets::NETWORK_SUBGRAPH_DEPLOYMENT ))) .respond_with(ResponseTemplate::new(200).set_body_raw( r#" diff --git a/crates/common/src/dispute_manager.rs b/crates/common/src/dispute_manager.rs index ea671bc97..6327b1ca3 100644 --- a/crates/common/src/dispute_manager.rs +++ b/crates/common/src/dispute_manager.rs @@ -27,17 +27,14 @@ pub async fn dispute_manager( #[cfg(test)] mod test { use serde_json::json; + use test_assets::DISPUTE_MANAGER_ADDRESS; use tokio::time::sleep; use wiremock::{ matchers::{method, path}, Mock, MockServer, ResponseTemplate, }; - use crate::{ - client::DeploymentDetails, - client::SubgraphClient, - test_vectors::{self, DISPUTE_MANAGER_ADDRESS}, - }; + use crate::{client::DeploymentDetails, client::SubgraphClient}; use super::*; @@ -50,7 +47,7 @@ mod test { DeploymentDetails::for_query_url(&format!( "{}/subgraphs/id/{}", &mock_server.uri(), - *test_vectors::NETWORK_SUBGRAPH_DEPLOYMENT + *test_assets::NETWORK_SUBGRAPH_DEPLOYMENT )) .unwrap(), ) @@ -62,7 +59,7 @@ mod test { Mock::given(method("POST")) .and(path(format!( "/subgraphs/id/{}", - *test_vectors::NETWORK_SUBGRAPH_DEPLOYMENT + *test_assets::NETWORK_SUBGRAPH_DEPLOYMENT ))) .respond_with(ResponseTemplate::new(200).set_body_json( json!({ "data": { "graphNetwork": { "disputeManager": *DISPUTE_MANAGER_ADDRESS }}}), diff --git a/crates/common/src/escrow_accounts.rs b/crates/common/src/escrow_accounts.rs index f8d7a8c5e..85fc93d6c 100644 --- a/crates/common/src/escrow_accounts.rs +++ b/crates/common/src/escrow_accounts.rs @@ -165,7 +165,7 @@ async fn get_escrow_accounts( #[cfg(test)] mod tests { use test_log::test; - use test_tap_utils::{ + use test_assets::{ ESCROW_ACCOUNTS_BALANCES, ESCROW_ACCOUNTS_SENDERS_TO_SIGNERS, ESCROW_ACCOUNTS_SIGNERS_TO_SENDERS, }; @@ -173,7 +173,6 @@ mod tests { use wiremock::{Mock, MockServer, ResponseTemplate}; use crate::client::DeploymentDetails; - use crate::test_vectors; use super::*; @@ -201,7 +200,7 @@ mod tests { DeploymentDetails::for_query_url(&format!( "{}/subgraphs/id/{}", &mock_server.uri(), - *test_vectors::ESCROW_SUBGRAPH_DEPLOYMENT + *test_assets::ESCROW_SUBGRAPH_DEPLOYMENT )) .unwrap(), ) @@ -211,17 +210,17 @@ mod tests { let mock = Mock::given(method("POST")) .and(path(format!( "/subgraphs/id/{}", - *test_vectors::ESCROW_SUBGRAPH_DEPLOYMENT + *test_assets::ESCROW_SUBGRAPH_DEPLOYMENT ))) .respond_with( ResponseTemplate::new(200) - .set_body_raw(test_vectors::ESCROW_QUERY_RESPONSE, "application/json"), + .set_body_raw(test_assets::ESCROW_QUERY_RESPONSE, "application/json"), ); mock_server.register(mock).await; let mut accounts = escrow_accounts( escrow_subgraph, - *test_vectors::INDEXER_ADDRESS, + *test_assets::INDEXER_ADDRESS, Duration::from_secs(60), true, ) diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 1e755f0a1..8baea520e 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -9,9 +9,6 @@ pub mod escrow_accounts; pub mod wallet; pub mod watcher; -#[cfg(test)] -mod test_vectors; - pub mod monitors { pub use super::allocations::indexer_allocations; pub use super::attestation::attestation_signers; diff --git a/crates/service/Cargo.toml b/crates/service/Cargo.toml index 9872ed932..6a9189065 100644 --- a/crates/service/Cargo.toml +++ b/crates/service/Cargo.toml @@ -54,7 +54,7 @@ cost-model = { git = "https://github.com/graphprotocol/agora", rev = "3ed34ca" } [dev-dependencies] hex-literal = "0.4.1" -test-tap-utils = { path = "../tests/tap-utils" } +test-assets = { path = "../test-assets" } [build-dependencies] build-info-build = { version = "0.0.39", default-features = false } diff --git a/crates/service/src/service/tap_receipt_header.rs b/crates/service/src/service/tap_receipt_header.rs index 0f373e5ce..d5937cb45 100644 --- a/crates/service/src/service/tap_receipt_header.rs +++ b/crates/service/src/service/tap_receipt_header.rs @@ -71,7 +71,7 @@ mod test { use axum::http::HeaderValue; use axum_extra::headers::Header; - use test_tap_utils::create_signed_receipt; + use test_assets::create_signed_receipt; use super::TapReceipt; diff --git a/crates/service/src/tap/checks/deny_list_check.rs b/crates/service/src/tap/checks/deny_list_check.rs index 32745d3d6..43e7a658f 100644 --- a/crates/service/src/tap/checks/deny_list_check.rs +++ b/crates/service/src/tap/checks/deny_list_check.rs @@ -202,7 +202,7 @@ mod tests { use tap_core::receipt::{Context, ReceiptWithState}; use tokio::sync::watch; - use test_tap_utils::{ + use test_assets::{ self, create_signed_receipt, ESCROW_ACCOUNTS_BALANCES, ESCROW_ACCOUNTS_SENDERS_TO_SIGNERS, TAP_EIP712_DOMAIN, TAP_SENDER, }; diff --git a/crates/service/src/tap/checks/value_check.rs b/crates/service/src/tap/checks/value_check.rs index 0591b1f20..01acc1d5d 100644 --- a/crates/service/src/tap/checks/value_check.rs +++ b/crates/service/src/tap/checks/value_check.rs @@ -348,7 +348,7 @@ enum CostModelNotification { mod tests { use alloy::primitives::{address, Address}; use std::time::Duration; - use test_tap_utils::create_signed_receipt; + use test_assets::create_signed_receipt; use sqlx::PgPool; use tap_core::receipt::{checks::Check, Context, ReceiptWithState}; diff --git a/crates/tests/tap-utils/Cargo.toml b/crates/test-assets/Cargo.toml similarity index 71% rename from crates/tests/tap-utils/Cargo.toml rename to crates/test-assets/Cargo.toml index b0b1303f7..20f242472 100644 --- a/crates/tests/tap-utils/Cargo.toml +++ b/crates/test-assets/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "test-tap-utils" +name = "test-assets" version = "0.1.0" edition = "2021" [dependencies] +indexer-allocation = { path = "../allocation" } alloy.workspace = true bip39 = "2.0.0" lazy_static.workspace = true tap_core.workspace = true thegraph-core.workspace = true -indexer-allocation = { path = "../../allocation" } diff --git a/crates/common/src/test_vectors.rs b/crates/test-assets/src/lib.rs similarity index 68% rename from crates/common/src/test_vectors.rs rename to crates/test-assets/src/lib.rs index ef322ba9e..67d3f9e2e 100644 --- a/crates/common/src/test_vectors.rs +++ b/crates/test-assets/src/lib.rs @@ -3,9 +3,18 @@ use std::{collections::HashMap, str::FromStr}; -use alloy::primitives::U256; +use alloy::{ + dyn_abi::Eip712Domain, + primitives::U256, + signers::local::{coins_bip39::English, MnemonicBuilder, PrivateKeySigner}, +}; use bip39::Mnemonic; use lazy_static::lazy_static; +use tap_core::{ + receipt::{Receipt, SignedReceipt}, + signed_message::EIP712SignedMessage, + tap_eip712_domain, +}; use thegraph_core::{Address, DeploymentId}; use indexer_allocation::{Allocation, AllocationStatus, SubgraphDeployment}; @@ -179,4 +188,98 @@ lazy_static! { }, ), ]); + + pub static ref ESCROW_ACCOUNTS_BALANCES: HashMap = HashMap::from([ + (Address::from_str("0x9858EfFD232B4033E47d90003D41EC34EcaEda94").unwrap(), U256::from(24)), // TAP_SENDER + (Address::from_str("0x22d491bde2303f2f43325b2108d26f1eaba1e32b").unwrap(), U256::from(42)), + (Address::from_str("0x192c3B6e0184Fa0Cc5B9D2bDDEb6B79Fb216a002").unwrap(), U256::from(2975)), + ]); + + + /// Maps signers back to their senders + pub static ref ESCROW_ACCOUNTS_SIGNERS_TO_SENDERS: HashMap = HashMap::from([ + ( + Address::from_str("0x533661F0fb14d2E8B26223C86a610Dd7D2260892").unwrap(), // TAP_SIGNER + Address::from_str("0x9858EfFD232B4033E47d90003D41EC34EcaEda94").unwrap(), // TAP_SENDER + ), + ( + Address::from_str("0x2740f6fA9188cF53ffB6729DDD21575721dE92ce").unwrap(), + Address::from_str("0x9858EfFD232B4033E47d90003D41EC34EcaEda94").unwrap(), // TAP_SENDER + ), + ( + Address::from_str("0x245059163ff6ee14279aa7b35ea8f0fdb967df6e").unwrap(), + Address::from_str("0x22d491bde2303f2f43325b2108d26f1eaba1e32b").unwrap(), + ), + ]); + + + pub static ref ESCROW_ACCOUNTS_SENDERS_TO_SIGNERS: HashMap> = HashMap::from([ + ( + Address::from_str("0x9858EfFD232B4033E47d90003D41EC34EcaEda94").unwrap(), // TAP_SENDER + vec![ + Address::from_str("0x533661F0fb14d2E8B26223C86a610Dd7D2260892").unwrap(), // TAP_SIGNER + Address::from_str("0x2740f6fA9188cF53ffB6729DDD21575721dE92ce").unwrap(), + ], + ), + ( + Address::from_str("0x22d491bde2303f2f43325b2108d26f1eaba1e32b").unwrap(), + vec![Address::from_str("0x245059163ff6ee14279aa7b35ea8f0fdb967df6e").unwrap()], + ), + ( + Address::from_str("0x192c3B6e0184Fa0Cc5B9D2bDDEb6B79Fb216a002").unwrap(), + vec![], + ), + ]); + + + /// Fixture to generate a wallet and address. + /// Address: 0x9858EfFD232B4033E47d90003D41EC34EcaEda94 + pub static ref TAP_SENDER: (PrivateKeySigner, Address) = { + let wallet: PrivateKeySigner = MnemonicBuilder::::default() + .phrase("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about") + .build() + .unwrap(); + let address = wallet.address(); + + (wallet, address) + }; + + /// Fixture to generate a wallet and address. + /// Address: 0x533661F0fb14d2E8B26223C86a610Dd7D2260892 + pub static ref TAP_SIGNER: (PrivateKeySigner, Address) = { + let wallet: PrivateKeySigner = MnemonicBuilder::::default() + .phrase("rude pipe parade travel organ vendor card festival magnet novel forget refuse keep draft tool") + .build() + .unwrap(); + let address = wallet.address(); + + (wallet, address) + }; + + pub static ref TAP_EIP712_DOMAIN: Eip712Domain = tap_eip712_domain( + 1, + Address::from([0x11u8; 20]) + ); +} + +/// Function to generate a signed receipt using the TAP_SIGNER wallet. +pub async fn create_signed_receipt( + allocation_id: Address, + nonce: u64, + timestamp_ns: u64, + value: u128, +) -> SignedReceipt { + let (wallet, _) = &*self::TAP_SIGNER; + + EIP712SignedMessage::new( + &self::TAP_EIP712_DOMAIN, + Receipt { + allocation_id, + nonce, + timestamp_ns, + value, + }, + wallet, + ) + .unwrap() } diff --git a/crates/tests/tap-utils/src/lib.rs b/crates/tests/tap-utils/src/lib.rs deleted file mode 100644 index 3169f6b24..000000000 --- a/crates/tests/tap-utils/src/lib.rs +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs. -// SPDX-License-Identifier: Apache-2.0 - -use std::{collections::HashMap, str::FromStr}; - -use alloy::{ - dyn_abi::Eip712Domain, - primitives::U256, - signers::local::{coins_bip39::English, MnemonicBuilder, PrivateKeySigner}, -}; -use lazy_static::lazy_static; -use tap_core::{ - receipt::{Receipt, SignedReceipt}, - signed_message::EIP712SignedMessage, - tap_eip712_domain, -}; -use thegraph_core::Address; - -lazy_static! { - - pub static ref ESCROW_ACCOUNTS_BALANCES: HashMap = HashMap::from([ - (Address::from_str("0x9858EfFD232B4033E47d90003D41EC34EcaEda94").unwrap(), U256::from(24)), // TAP_SENDER - (Address::from_str("0x22d491bde2303f2f43325b2108d26f1eaba1e32b").unwrap(), U256::from(42)), - (Address::from_str("0x192c3B6e0184Fa0Cc5B9D2bDDEb6B79Fb216a002").unwrap(), U256::from(2975)), - ]); - - - /// Maps signers back to their senders - pub static ref ESCROW_ACCOUNTS_SIGNERS_TO_SENDERS: HashMap = HashMap::from([ - ( - Address::from_str("0x533661F0fb14d2E8B26223C86a610Dd7D2260892").unwrap(), // TAP_SIGNER - Address::from_str("0x9858EfFD232B4033E47d90003D41EC34EcaEda94").unwrap(), // TAP_SENDER - ), - ( - Address::from_str("0x2740f6fA9188cF53ffB6729DDD21575721dE92ce").unwrap(), - Address::from_str("0x9858EfFD232B4033E47d90003D41EC34EcaEda94").unwrap(), // TAP_SENDER - ), - ( - Address::from_str("0x245059163ff6ee14279aa7b35ea8f0fdb967df6e").unwrap(), - Address::from_str("0x22d491bde2303f2f43325b2108d26f1eaba1e32b").unwrap(), - ), - ]); - - - pub static ref ESCROW_ACCOUNTS_SENDERS_TO_SIGNERS: HashMap> = HashMap::from([ - ( - Address::from_str("0x9858EfFD232B4033E47d90003D41EC34EcaEda94").unwrap(), // TAP_SENDER - vec![ - Address::from_str("0x533661F0fb14d2E8B26223C86a610Dd7D2260892").unwrap(), // TAP_SIGNER - Address::from_str("0x2740f6fA9188cF53ffB6729DDD21575721dE92ce").unwrap(), - ], - ), - ( - Address::from_str("0x22d491bde2303f2f43325b2108d26f1eaba1e32b").unwrap(), - vec![Address::from_str("0x245059163ff6ee14279aa7b35ea8f0fdb967df6e").unwrap()], - ), - ( - Address::from_str("0x192c3B6e0184Fa0Cc5B9D2bDDEb6B79Fb216a002").unwrap(), - vec![], - ), - ]); - - - /// Fixture to generate a wallet and address. - /// Address: 0x9858EfFD232B4033E47d90003D41EC34EcaEda94 - pub static ref TAP_SENDER: (PrivateKeySigner, Address) = { - let wallet: PrivateKeySigner = MnemonicBuilder::::default() - .phrase("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about") - .build() - .unwrap(); - let address = wallet.address(); - - (wallet, address) - }; - - /// Fixture to generate a wallet and address. - /// Address: 0x533661F0fb14d2E8B26223C86a610Dd7D2260892 - pub static ref TAP_SIGNER: (PrivateKeySigner, Address) = { - let wallet: PrivateKeySigner = MnemonicBuilder::::default() - .phrase("rude pipe parade travel organ vendor card festival magnet novel forget refuse keep draft tool") - .build() - .unwrap(); - let address = wallet.address(); - - (wallet, address) - }; - - pub static ref TAP_EIP712_DOMAIN: Eip712Domain = tap_eip712_domain( - 1, - Address::from([0x11u8; 20]) - ); -} - -/// Function to generate a signed receipt using the TAP_SIGNER wallet. -pub async fn create_signed_receipt( - allocation_id: Address, - nonce: u64, - timestamp_ns: u64, - value: u128, -) -> SignedReceipt { - let (wallet, _) = &*self::TAP_SIGNER; - - EIP712SignedMessage::new( - &self::TAP_EIP712_DOMAIN, - Receipt { - allocation_id, - nonce, - timestamp_ns, - value, - }, - wallet, - ) - .unwrap() -} From 1a46e53fb7b0c27b6a4b99a89472baed436718c1 Mon Sep 17 00:00:00 2001 From: Gustavo Inacio Date: Tue, 19 Nov 2024 18:00:26 -0600 Subject: [PATCH 03/11] refactor: create attestation crate Signed-off-by: Gustavo Inacio --- Cargo.lock | 14 ++++++++++++++ Cargo.toml | 1 + crates/attestation/Cargo.toml | 15 +++++++++++++++ .../signer.rs => attestation/src/lib.rs} | 0 crates/common/Cargo.toml | 1 + .../{attestation/monitor.rs => attestation.rs} | 5 +++-- crates/common/src/attestation/mod.rs | 8 -------- crates/service/Cargo.toml | 1 + crates/service/src/service/indexer_service.rs | 2 +- 9 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 crates/attestation/Cargo.toml rename crates/{common/src/attestation/signer.rs => attestation/src/lib.rs} (100%) rename crates/common/src/{attestation/monitor.rs => attestation.rs} (97%) delete mode 100644 crates/common/src/attestation/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 55402a487..3148f2c11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3483,6 +3483,18 @@ dependencies = [ "thegraph-core", ] +[[package]] +name = "indexer-attestation" +version = "0.1.0" +dependencies = [ + "alloy", + "anyhow", + "indexer-allocation", + "test-assets", + "test-log", + "thegraph-core", +] + [[package]] name = "indexer-common" version = "1.4.0" @@ -3498,6 +3510,7 @@ dependencies = [ "eventuals", "graphql_client", "indexer-allocation", + "indexer-attestation", "indexer-config", "indexer-query", "lazy_static", @@ -3584,6 +3597,7 @@ dependencies = [ "graphql_client", "hex-literal", "indexer-allocation", + "indexer-attestation", "indexer-common", "indexer-config", "indexer-dips", diff --git a/Cargo.toml b/Cargo.toml index 4494b2151..b0f9b0494 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ members = [ "crates/tap-agent", "crates/allocation", "crates/test-assets", + "crates/attestation", ] resolver = "2" diff --git a/crates/attestation/Cargo.toml b/crates/attestation/Cargo.toml new file mode 100644 index 000000000..621651c54 --- /dev/null +++ b/crates/attestation/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "indexer-attestation" +version = "0.1.0" +edition = "2021" + +[dependencies] +indexer-allocation = { path = "../allocation" } +alloy.workspace = true +thegraph-core.workspace = true +anyhow.workspace = true + + +[dev-dependencies] +test-log = { version = "0.2.12", default-features = false } +test-assets = { path = "../test-assets" } diff --git a/crates/common/src/attestation/signer.rs b/crates/attestation/src/lib.rs similarity index 100% rename from crates/common/src/attestation/signer.rs rename to crates/attestation/src/lib.rs diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 3f8ab7185..35172f2ca 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" indexer-config = { path = "../config" } indexer-query = { path = "../query" } indexer-allocation = { path = "../allocation" } +indexer-attestation = { path = "../attestation" } thiserror.workspace = true async-trait.workspace = true alloy.workspace = true diff --git a/crates/common/src/attestation/monitor.rs b/crates/common/src/attestation.rs similarity index 97% rename from crates/common/src/attestation/monitor.rs rename to crates/common/src/attestation.rs index 7bb422001..07d54b486 100644 --- a/crates/common/src/attestation/monitor.rs +++ b/crates/common/src/attestation.rs @@ -2,14 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 use bip39::Mnemonic; +use indexer_allocation::Allocation; +use indexer_attestation::AttestationSigner; +use crate::watcher::join_and_map_watcher; use std::sync::Arc; use std::{collections::HashMap, sync::Mutex}; use thegraph_core::{Address, ChainId}; use tokio::sync::watch::Receiver; use tracing::warn; -use crate::{attestation::signer::AttestationSigner, watcher::join_and_map_watcher}; -use indexer_allocation::Allocation; /// An always up-to-date list of attestation signers, one for each of the indexer's allocations. pub fn attestation_signers( diff --git a/crates/common/src/attestation/mod.rs b/crates/common/src/attestation/mod.rs deleted file mode 100644 index 45065d0db..000000000 --- a/crates/common/src/attestation/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs. -// SPDX-License-Identifier: Apache-2.0 - -mod monitor; -pub mod signer; - -pub use monitor::attestation_signers; -pub use signer::{derive_key_pair, AttestationSigner}; diff --git a/crates/service/Cargo.toml b/crates/service/Cargo.toml index 6a9189065..6e59f8504 100644 --- a/crates/service/Cargo.toml +++ b/crates/service/Cargo.toml @@ -8,6 +8,7 @@ license = "Apache-2.0" [dependencies] indexer-common = { path = "../common" } +indexer-attestation = { path = "../attestation" } indexer-allocation = { path = "../allocation" } indexer-config = { path = "../config" } indexer-dips = { path = "../dips" } diff --git a/crates/service/src/service/indexer_service.rs b/crates/service/src/service/indexer_service.rs index 3325402e6..9f42e587f 100644 --- a/crates/service/src/service/indexer_service.rs +++ b/crates/service/src/service/indexer_service.rs @@ -13,8 +13,8 @@ use axum::{ }; use axum::{serve, ServiceExt}; use build_info::BuildInfo; +use indexer_attestation::AttestationSigner; use indexer_common::{ - attestation::AttestationSigner, client::{DeploymentDetails, SubgraphClient}, escrow_accounts::{EscrowAccounts, EscrowAccountsError}, monitors::{attestation_signers, dispute_manager, escrow_accounts, indexer_allocations}, From 7df697cf6877c0aa5e98dcfc0039368d62b51d66 Mon Sep 17 00:00:00 2001 From: Gustavo Inacio Date: Tue, 19 Nov 2024 18:01:14 -0600 Subject: [PATCH 04/11] refactor: create watcher crate Signed-off-by: Gustavo Inacio --- Cargo.lock | 11 +++++++++++ Cargo.toml | 1 + crates/common/Cargo.toml | 1 + crates/common/src/allocations.rs | 3 ++- crates/common/src/attestation.rs | 2 +- crates/common/src/client/monitor.rs | 2 +- crates/common/src/dispute_manager.rs | 3 ++- crates/common/src/escrow_accounts.rs | 4 ++-- crates/common/src/lib.rs | 1 - crates/tap-agent/Cargo.toml | 1 + crates/tap-agent/src/agent/sender_account.rs | 2 +- crates/tap-agent/src/agent/sender_accounts_manager.rs | 2 +- .../tap-agent/src/tap/context/checks/allocation_id.rs | 3 ++- crates/watcher/Cargo.toml | 9 +++++++++ crates/{common/src/watcher.rs => watcher/src/lib.rs} | 0 15 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 crates/watcher/Cargo.toml rename crates/{common/src/watcher.rs => watcher/src/lib.rs} (100%) diff --git a/Cargo.lock b/Cargo.lock index 3148f2c11..e4098ce32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3513,6 +3513,7 @@ dependencies = [ "indexer-attestation", "indexer-config", "indexer-query", + "indexer-watcher", "lazy_static", "prometheus", "reqwest 0.12.9", @@ -3640,6 +3641,7 @@ dependencies = [ "indexer-common", "indexer-config", "indexer-query", + "indexer-watcher", "jsonrpsee", "lazy_static", "prometheus", @@ -3660,6 +3662,15 @@ dependencies = [ "wiremock 0.6.2", ] +[[package]] +name = "indexer-watcher" +version = "0.1.0" +dependencies = [ + "anyhow", + "tokio", + "tracing", +] + [[package]] name = "indexmap" version = "1.9.3" diff --git a/Cargo.toml b/Cargo.toml index b0f9b0494..5d182f8bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ members = [ "crates/allocation", "crates/test-assets", "crates/attestation", + "crates/watcher", ] resolver = "2" diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 35172f2ca..5effd74d3 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -8,6 +8,7 @@ indexer-config = { path = "../config" } indexer-query = { path = "../query" } indexer-allocation = { path = "../allocation" } indexer-attestation = { path = "../attestation" } +indexer-watcher = { path = "../watcher" } thiserror.workspace = true async-trait.workspace = true alloy.workspace = true diff --git a/crates/common/src/allocations.rs b/crates/common/src/allocations.rs index 6eb80cfe1..d4f88666e 100644 --- a/crates/common/src/allocations.rs +++ b/crates/common/src/allocations.rs @@ -1,10 +1,11 @@ // Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs. // SPDX-License-Identifier: Apache-2.0 -use crate::{client::SubgraphClient, watcher::new_watcher}; +use crate::client::SubgraphClient; use alloy::{primitives::Address, primitives::TxHash}; use indexer_allocation::Allocation; use indexer_query::allocations_query::{self, AllocationsQuery}; +use indexer_watcher::new_watcher; use std::{ collections::HashMap, time::{Duration, SystemTime, UNIX_EPOCH}, diff --git a/crates/common/src/attestation.rs b/crates/common/src/attestation.rs index 07d54b486..6b50e429e 100644 --- a/crates/common/src/attestation.rs +++ b/crates/common/src/attestation.rs @@ -4,7 +4,7 @@ use bip39::Mnemonic; use indexer_allocation::Allocation; use indexer_attestation::AttestationSigner; -use crate::watcher::join_and_map_watcher; +use indexer_watcher::join_and_map_watcher; use std::sync::Arc; use std::{collections::HashMap, sync::Mutex}; use thegraph_core::{Address, ChainId}; diff --git a/crates/common/src/client/monitor.rs b/crates/common/src/client/monitor.rs index f2aed7765..53ba9de16 100644 --- a/crates/common/src/client/monitor.rs +++ b/crates/common/src/client/monitor.rs @@ -13,7 +13,7 @@ use serde::Deserialize; use thegraph_core::DeploymentId; use tokio::sync::watch::Receiver; -use crate::watcher::new_watcher; +use indexer_watcher::new_watcher; #[derive(Clone, Debug, Deserialize, Eq, PartialEq)] pub struct DeploymentStatus { diff --git a/crates/common/src/dispute_manager.rs b/crates/common/src/dispute_manager.rs index 6327b1ca3..481232f58 100644 --- a/crates/common/src/dispute_manager.rs +++ b/crates/common/src/dispute_manager.rs @@ -1,10 +1,11 @@ // Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs. // SPDX-License-Identifier: Apache-2.0 -use crate::{client::SubgraphClient, watcher::new_watcher}; +use crate::client::SubgraphClient; use alloy::primitives::Address; use anyhow::Error; use indexer_query::dispute_manager::{self, DisputeManager}; +use indexer_watcher::new_watcher; use std::time::Duration; use tokio::sync::watch::Receiver; diff --git a/crates/common/src/escrow_accounts.rs b/crates/common/src/escrow_accounts.rs index 85fc93d6c..445a95d2c 100644 --- a/crates/common/src/escrow_accounts.rs +++ b/crates/common/src/escrow_accounts.rs @@ -14,7 +14,7 @@ use thiserror::Error; use tokio::sync::watch::Receiver; use tracing::{error, warn}; -use crate::{client::SubgraphClient, watcher}; +use crate::client::SubgraphClient; #[derive(Error, Debug)] pub enum EscrowAccountsError { @@ -93,7 +93,7 @@ pub async fn escrow_accounts( interval: Duration, reject_thawing_signers: bool, ) -> Result, anyhow::Error> { - watcher::new_watcher(interval, move || { + indexer_watcher::new_watcher(interval, move || { get_escrow_accounts(escrow_subgraph, indexer_address, reject_thawing_signers) }) .await diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 8baea520e..fac2ecd6e 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -7,7 +7,6 @@ pub mod client; mod dispute_manager; pub mod escrow_accounts; pub mod wallet; -pub mod watcher; pub mod monitors { pub use super::allocations::indexer_allocations; diff --git a/crates/tap-agent/Cargo.toml b/crates/tap-agent/Cargo.toml index caf573804..2db5783c5 100644 --- a/crates/tap-agent/Cargo.toml +++ b/crates/tap-agent/Cargo.toml @@ -10,6 +10,7 @@ path = "src/main.rs" [dependencies] indexer-common = { path = "../common" } +indexer-watcher = { path = "../watcher" } indexer-allocation = { path = "../allocation" } indexer-config = { path = "../config" } indexer-query = { path = "../query" } diff --git a/crates/tap-agent/src/agent/sender_account.rs b/crates/tap-agent/src/agent/sender_account.rs index 5cd9061c7..b74c22a71 100644 --- a/crates/tap-agent/src/agent/sender_account.rs +++ b/crates/tap-agent/src/agent/sender_account.rs @@ -8,7 +8,7 @@ use bigdecimal::num_bigint::ToBigInt; use bigdecimal::ToPrimitive; use futures::{stream, StreamExt}; -use indexer_common::watcher::watch_pipe; +use indexer_watcher::watch_pipe; use indexer_query::unfinalized_transactions; use indexer_query::{ closed_allocations::{self, ClosedAllocations}, diff --git a/crates/tap-agent/src/agent/sender_accounts_manager.rs b/crates/tap-agent/src/agent/sender_accounts_manager.rs index afbf3164e..cb5e59d62 100644 --- a/crates/tap-agent/src/agent/sender_accounts_manager.rs +++ b/crates/tap-agent/src/agent/sender_accounts_manager.rs @@ -15,9 +15,9 @@ use alloy::primitives::Address; use anyhow::Result; use anyhow::{anyhow, bail}; use futures::{stream, StreamExt}; -use indexer_common::watcher::watch_pipe; use indexer_allocation::Allocation; use indexer_common::{escrow_accounts::EscrowAccounts, SubgraphClient}; +use indexer_watcher::watch_pipe; use prometheus::{register_counter_vec, CounterVec}; use ractor::concurrency::JoinHandle; use ractor::{Actor, ActorCell, ActorProcessingErr, ActorRef, SupervisionEvent}; diff --git a/crates/tap-agent/src/tap/context/checks/allocation_id.rs b/crates/tap-agent/src/tap/context/checks/allocation_id.rs index 8ae1be645..99029ad4a 100644 --- a/crates/tap-agent/src/tap/context/checks/allocation_id.rs +++ b/crates/tap-agent/src/tap/context/checks/allocation_id.rs @@ -5,8 +5,9 @@ use std::time::Duration; use alloy::primitives::Address; use anyhow::anyhow; -use indexer_common::{watcher::new_watcher, SubgraphClient}; +use indexer_common::SubgraphClient; use indexer_query::{tap_transactions, TapTransactions}; +use indexer_watcher::new_watcher; use tap_core::receipt::{ checks::{Check, CheckError, CheckResult}, state::Checking, diff --git a/crates/watcher/Cargo.toml b/crates/watcher/Cargo.toml new file mode 100644 index 000000000..0a5daed61 --- /dev/null +++ b/crates/watcher/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "indexer-watcher" +version = "0.1.0" +edition = "2021" + +[dependencies] +tokio = { workspace = true, features = ["macros", "rt", "time", "sync"] } +tracing.workspace = true +anyhow.workspace = true diff --git a/crates/common/src/watcher.rs b/crates/watcher/src/lib.rs similarity index 100% rename from crates/common/src/watcher.rs rename to crates/watcher/src/lib.rs From 3e7796f8d432654085e82c297a789853c4a7d9ad Mon Sep 17 00:00:00 2001 From: Gustavo Inacio Date: Tue, 19 Nov 2024 18:24:59 -0600 Subject: [PATCH 05/11] refactor: move wallet to service Signed-off-by: Gustavo Inacio --- Cargo.lock | 1 + Cargo.toml | 1 + crates/common/Cargo.toml | 3 +-- crates/common/src/lib.rs | 1 - crates/service/Cargo.toml | 1 + crates/service/src/lib.rs | 1 + crates/service/src/service/indexer_service.rs | 2 +- crates/{common => service}/src/wallet.rs | 0 8 files changed, 6 insertions(+), 4 deletions(-) rename crates/{common => service}/src/wallet.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index e4098ce32..07d2aefa3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3590,6 +3590,7 @@ dependencies = [ "axum-extra", "base64 0.22.1", "bigdecimal", + "bip39", "build-info", "build-info-build", "clap", diff --git a/Cargo.toml b/Cargo.toml index 5d182f8bc..69893578e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,3 +70,4 @@ thegraph-core = { git = "https://github.com/edgeandnode/toolshed", rev = "166353 ] } thegraph-graphql-http = "0.2.0" graphql_client = { version = "0.14.0", features = ["reqwest-rustls"] } +bip39 = "2.0.0" diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 5effd74d3..91165817e 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -25,11 +25,10 @@ axum.workspace = true lazy_static.workspace = true build-info.workspace = true graphql_client.workspace = true - serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } tokio = { workspace = true, features = ["fs", "tokio-macros"] } -bip39 = "2.0.0" +bip39.workspace = true [dev-dependencies] env_logger = { version = "0.11.0", default-features = false } diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index fac2ecd6e..69c8dbda1 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -6,7 +6,6 @@ pub mod attestation; pub mod client; mod dispute_manager; pub mod escrow_accounts; -pub mod wallet; pub mod monitors { pub use super::allocations::indexer_allocations; diff --git a/crates/service/Cargo.toml b/crates/service/Cargo.toml index 6e59f8504..3c3f94da9 100644 --- a/crates/service/Cargo.toml +++ b/crates/service/Cargo.toml @@ -52,6 +52,7 @@ axum-extra = { version = "0.9.3", features = [ ], default-features = false } tokio-util = "0.7.10" cost-model = { git = "https://github.com/graphprotocol/agora", rev = "3ed34ca" } +bip39.workspace = true [dev-dependencies] hex-literal = "0.4.1" diff --git a/crates/service/src/lib.rs b/crates/service/src/lib.rs index 551e170aa..ac967df4e 100644 --- a/crates/service/src/lib.rs +++ b/crates/service/src/lib.rs @@ -7,3 +7,4 @@ mod error; mod routes; pub mod service; mod tap; +mod wallet; diff --git a/crates/service/src/service/indexer_service.rs b/crates/service/src/service/indexer_service.rs index 9f42e587f..b0b312ac7 100644 --- a/crates/service/src/service/indexer_service.rs +++ b/crates/service/src/service/indexer_service.rs @@ -18,7 +18,6 @@ use indexer_common::{ client::{DeploymentDetails, SubgraphClient}, escrow_accounts::{EscrowAccounts, EscrowAccountsError}, monitors::{attestation_signers, dispute_manager, escrow_accounts, indexer_allocations}, - wallet::public_key, }; use prometheus::TextEncoder; use reqwest::StatusCode; @@ -45,6 +44,7 @@ use crate::routes::health; use crate::routes::request_handler; use crate::routes::static_subgraph_request_handler; use crate::tap::IndexerTapContext; +use crate::wallet::public_key; use indexer_config::Config; use super::SubgraphService; diff --git a/crates/common/src/wallet.rs b/crates/service/src/wallet.rs similarity index 100% rename from crates/common/src/wallet.rs rename to crates/service/src/wallet.rs From 79241e0b79d749fbd64502b172575ec6e03370cb Mon Sep 17 00:00:00 2001 From: Gustavo Inacio Date: Tue, 19 Nov 2024 18:29:36 -0600 Subject: [PATCH 06/11] refactor: make attestation and client mod private Signed-off-by: Gustavo Inacio --- crates/common/src/lib.rs | 6 +++--- crates/service/src/service/indexer_service.rs | 3 +-- crates/service/src/tap/checks/deny_list_check.rs | 2 +- crates/service/src/tap/checks/sender_balance_check.rs | 2 +- crates/tap-agent/src/agent/sender_account.rs | 5 ++--- crates/tap-agent/src/agent/sender_accounts_manager.rs | 5 ++--- crates/tap-agent/src/agent/sender_allocation.rs | 4 ++-- crates/tap-agent/src/tap/context.rs | 2 +- crates/tap-agent/src/tap/context/checks/signature.rs | 2 +- crates/tap-agent/src/tap/context/error.rs | 2 +- crates/tap-agent/src/tap/context/rav.rs | 2 +- crates/tap-agent/src/tap/context/receipt.rs | 2 +- crates/tap-agent/src/tap/mod.rs | 2 +- 13 files changed, 18 insertions(+), 21 deletions(-) diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 69c8dbda1..d075ebe0c 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 mod allocations; -pub mod attestation; -pub mod client; +mod attestation; +mod client; mod dispute_manager; -pub mod escrow_accounts; +mod escrow_accounts; pub mod monitors { pub use super::allocations::indexer_allocations; diff --git a/crates/service/src/service/indexer_service.rs b/crates/service/src/service/indexer_service.rs index b0b312ac7..a2efa7340 100644 --- a/crates/service/src/service/indexer_service.rs +++ b/crates/service/src/service/indexer_service.rs @@ -15,9 +15,8 @@ use axum::{serve, ServiceExt}; use build_info::BuildInfo; use indexer_attestation::AttestationSigner; use indexer_common::{ - client::{DeploymentDetails, SubgraphClient}, - escrow_accounts::{EscrowAccounts, EscrowAccountsError}, monitors::{attestation_signers, dispute_manager, escrow_accounts, indexer_allocations}, + DeploymentDetails, EscrowAccounts, EscrowAccountsError, SubgraphClient, }; use prometheus::TextEncoder; use reqwest::StatusCode; diff --git a/crates/service/src/tap/checks/deny_list_check.rs b/crates/service/src/tap/checks/deny_list_check.rs index 43e7a658f..586e84cd6 100644 --- a/crates/service/src/tap/checks/deny_list_check.rs +++ b/crates/service/src/tap/checks/deny_list_check.rs @@ -3,7 +3,7 @@ use alloy::dyn_abi::Eip712Domain; use alloy::primitives::Address; -use indexer_common::escrow_accounts::EscrowAccounts; +use indexer_common::EscrowAccounts; use sqlx::postgres::PgListener; use sqlx::PgPool; use std::collections::HashSet; diff --git a/crates/service/src/tap/checks/sender_balance_check.rs b/crates/service/src/tap/checks/sender_balance_check.rs index 5e5bbc912..a99d5dd76 100644 --- a/crates/service/src/tap/checks/sender_balance_check.rs +++ b/crates/service/src/tap/checks/sender_balance_check.rs @@ -4,7 +4,7 @@ use alloy::dyn_abi::Eip712Domain; use alloy::primitives::U256; use anyhow::anyhow; -use indexer_common::escrow_accounts::EscrowAccounts; +use indexer_common::EscrowAccounts; use tap_core::receipt::{ checks::{Check, CheckError, CheckResult}, state::Checking, diff --git a/crates/tap-agent/src/agent/sender_account.rs b/crates/tap-agent/src/agent/sender_account.rs index b74c22a71..5bcfb88e1 100644 --- a/crates/tap-agent/src/agent/sender_account.rs +++ b/crates/tap-agent/src/agent/sender_account.rs @@ -26,7 +26,7 @@ use tokio::task::JoinHandle; use alloy::dyn_abi::Eip712Domain; use alloy::primitives::Address; use anyhow::Result; -use indexer_common::{escrow_accounts::EscrowAccounts, SubgraphClient}; +use indexer_common::{EscrowAccounts, SubgraphClient}; use ractor::{Actor, ActorProcessingErr, ActorRef, MessagingErr, SupervisionEvent}; use sqlx::PgPool; use tap_core::rav::SignedRAV; @@ -1039,8 +1039,7 @@ pub mod tests { }; use alloy::hex::ToHexExt; use alloy::primitives::{Address, U256}; - use indexer_common::escrow_accounts::EscrowAccounts; - use indexer_common::{DeploymentDetails, SubgraphClient}; + use indexer_common::{DeploymentDetails, EscrowAccounts, SubgraphClient}; use ractor::concurrency::JoinHandle; use ractor::{call, Actor, ActorProcessingErr, ActorRef, ActorStatus}; use reqwest::Url; diff --git a/crates/tap-agent/src/agent/sender_accounts_manager.rs b/crates/tap-agent/src/agent/sender_accounts_manager.rs index cb5e59d62..f3f5ba1b0 100644 --- a/crates/tap-agent/src/agent/sender_accounts_manager.rs +++ b/crates/tap-agent/src/agent/sender_accounts_manager.rs @@ -16,7 +16,7 @@ use anyhow::Result; use anyhow::{anyhow, bail}; use futures::{stream, StreamExt}; use indexer_allocation::Allocation; -use indexer_common::{escrow_accounts::EscrowAccounts, SubgraphClient}; +use indexer_common::{EscrowAccounts, SubgraphClient}; use indexer_watcher::watch_pipe; use prometheus::{register_counter_vec, CounterVec}; use ractor::concurrency::JoinHandle; @@ -593,8 +593,7 @@ mod tests { ALLOCATION_ID_1, INDEXER, SENDER, SENDER_2, SENDER_3, SIGNER, TAP_EIP712_DOMAIN_SEPARATOR, }; use alloy::hex::ToHexExt; - use indexer_common::client::{DeploymentDetails, SubgraphClient}; - use indexer_common::escrow_accounts::EscrowAccounts; + use indexer_common::{DeploymentDetails, EscrowAccounts, SubgraphClient}; use ractor::concurrency::JoinHandle; use ractor::{Actor, ActorProcessingErr, ActorRef}; use reqwest::Url; diff --git a/crates/tap-agent/src/agent/sender_allocation.rs b/crates/tap-agent/src/agent/sender_allocation.rs index 5d7f64ef8..1401b5aa1 100644 --- a/crates/tap-agent/src/agent/sender_allocation.rs +++ b/crates/tap-agent/src/agent/sender_allocation.rs @@ -10,7 +10,7 @@ use alloy::primitives::Address; use alloy::{dyn_abi::Eip712Domain, hex::ToHexExt}; use anyhow::{anyhow, ensure, Result}; use bigdecimal::{num_bigint::BigInt, ToPrimitive}; -use indexer_common::{escrow_accounts::EscrowAccounts, SubgraphClient}; +use indexer_common::{EscrowAccounts, SubgraphClient}; use jsonrpsee::{core::client::ClientT, rpc_params}; use prometheus::{register_counter_vec, register_histogram_vec, CounterVec, HistogramVec}; use ractor::{Actor, ActorProcessingErr, ActorRef}; @@ -872,7 +872,7 @@ pub mod tests { }, }; use futures::future::join_all; - use indexer_common::{escrow_accounts::EscrowAccounts, DeploymentDetails, SubgraphClient}; + use indexer_common::{EscrowAccounts, DeploymentDetails, SubgraphClient}; use jsonrpsee::http_client::HttpClientBuilder; use ractor::{ call, cast, concurrency::JoinHandle, Actor, ActorProcessingErr, ActorRef, ActorStatus, diff --git a/crates/tap-agent/src/tap/context.rs b/crates/tap-agent/src/tap/context.rs index b49a34d88..6ae2c4473 100644 --- a/crates/tap-agent/src/tap/context.rs +++ b/crates/tap-agent/src/tap/context.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use alloy::primitives::Address; -use indexer_common::escrow_accounts::EscrowAccounts; +use indexer_common::EscrowAccounts; use sqlx::PgPool; use tokio::sync::watch::Receiver; diff --git a/crates/tap-agent/src/tap/context/checks/signature.rs b/crates/tap-agent/src/tap/context/checks/signature.rs index afec26ea0..8590913d2 100644 --- a/crates/tap-agent/src/tap/context/checks/signature.rs +++ b/crates/tap-agent/src/tap/context/checks/signature.rs @@ -3,7 +3,7 @@ use alloy::{dyn_abi::Eip712Domain, primitives::U256}; use anyhow::anyhow; -use indexer_common::escrow_accounts::EscrowAccounts; +use indexer_common::EscrowAccounts; use tap_core::receipt::{ checks::{Check, CheckError, CheckResult}, state::Checking, diff --git a/crates/tap-agent/src/tap/context/error.rs b/crates/tap-agent/src/tap/context/error.rs index 91e43a991..ee72bcc35 100644 --- a/crates/tap-agent/src/tap/context/error.rs +++ b/crates/tap-agent/src/tap/context/error.rs @@ -9,7 +9,7 @@ pub enum AdapterError { EscrowEventualError { error: String }, #[error("Could not get available escrow for sender")] - AvailableEscrowError(#[from] indexer_common::escrow_accounts::EscrowAccountsError), + AvailableEscrowError(#[from] indexer_common::EscrowAccountsError), #[error("Sender {sender} escrow balance is too large to fit in u128, could not get available escrow.")] BalanceTooLarge { sender: Address }, diff --git a/crates/tap-agent/src/tap/context/rav.rs b/crates/tap-agent/src/tap/context/rav.rs index 5ec237ccc..29b24e9af 100644 --- a/crates/tap-agent/src/tap/context/rav.rs +++ b/crates/tap-agent/src/tap/context/rav.rs @@ -128,7 +128,7 @@ impl RAVStore for TapAgentContext { #[cfg(test)] mod test { - use indexer_common::escrow_accounts::EscrowAccounts; + use indexer_common::EscrowAccounts; use sqlx::PgPool; use tokio::sync::watch; diff --git a/crates/tap-agent/src/tap/context/receipt.rs b/crates/tap-agent/src/tap/context/receipt.rs index 5cbc3402b..d73f963e4 100644 --- a/crates/tap-agent/src/tap/context/receipt.rs +++ b/crates/tap-agent/src/tap/context/receipt.rs @@ -199,7 +199,7 @@ mod test { }; use alloy::{primitives::U256, signers::local::PrivateKeySigner}; use anyhow::Result; - use indexer_common::escrow_accounts::EscrowAccounts; + use indexer_common::EscrowAccounts; use lazy_static::lazy_static; use sqlx::PgPool; use std::collections::HashMap; diff --git a/crates/tap-agent/src/tap/mod.rs b/crates/tap-agent/src/tap/mod.rs index 535538ca6..1dbf740d2 100644 --- a/crates/tap-agent/src/tap/mod.rs +++ b/crates/tap-agent/src/tap/mod.rs @@ -3,7 +3,7 @@ use alloy::hex::ToHexExt; use alloy::primitives::Address; -use indexer_common::escrow_accounts::EscrowAccounts; +use indexer_common::EscrowAccounts; use tokio::sync::watch::Receiver; pub mod context; From eb0b622d8f2042652acff63fd9ed95868dc3bd4a Mon Sep 17 00:00:00 2001 From: Gustavo Inacio Date: Tue, 19 Nov 2024 18:41:59 -0600 Subject: [PATCH 07/11] refactor: update common imports Signed-off-by: Gustavo Inacio --- Cargo.lock | 9 --------- crates/common/Cargo.toml | 15 +++------------ 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 07d2aefa3..adeedad3f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3501,26 +3501,17 @@ version = "1.4.0" dependencies = [ "alloy", "anyhow", - "async-trait", "axum", - "bigdecimal", "bip39", - "build-info", "env_logger", - "eventuals", "graphql_client", "indexer-allocation", "indexer-attestation", - "indexer-config", "indexer-query", "indexer-watcher", - "lazy_static", - "prometheus", "reqwest 0.12.9", "serde", "serde_json", - "sqlx", - "tap_core", "test-assets", "test-log", "thegraph-core", diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 91165817e..7d5435731 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -4,30 +4,21 @@ version = "1.4.0" edition = "2021" [dependencies] -indexer-config = { path = "../config" } indexer-query = { path = "../query" } indexer-allocation = { path = "../allocation" } indexer-attestation = { path = "../attestation" } indexer-watcher = { path = "../watcher" } thiserror.workspace = true -async-trait.workspace = true alloy.workspace = true anyhow.workspace = true -eventuals.workspace = true -reqwest.workspace = true -sqlx.workspace = true -tap_core.workspace = true +reqwest = { workspace = true, features = ["json"] } tracing.workspace = true -bigdecimal.workspace = true -prometheus.workspace = true thegraph-core.workspace = true axum.workspace = true -lazy_static.workspace = true -build-info.workspace = true graphql_client.workspace = true serde = { workspace = true, features = ["derive"] } -serde_json = { workspace = true } -tokio = { workspace = true, features = ["fs", "tokio-macros"] } +serde_json.workspace = true +tokio.workspace = true bip39.workspace = true [dev-dependencies] From dde1e48bfc0d22f7cc83c2ce5621047e5ee3e6ce Mon Sep 17 00:00:00 2001 From: Gustavo Inacio Date: Tue, 19 Nov 2024 18:51:48 -0600 Subject: [PATCH 08/11] refactor: rename common to monitor Signed-off-by: Gustavo Inacio --- Cargo.lock | 56 +++++++++---------- Cargo.toml | 6 +- crates/{common => monitor}/CHANGELOG.md | 0 crates/{common => monitor}/Cargo.toml | 2 +- crates/{common => monitor}/src/allocations.rs | 0 crates/{common => monitor}/src/attestation.rs | 0 crates/{common => monitor}/src/client/mod.rs | 0 .../{common => monitor}/src/client/monitor.rs | 0 .../src/client/subgraph_client.rs | 0 .../src/dispute_manager.rs | 0 .../src/escrow_accounts.rs | 0 crates/{common => monitor}/src/lib.rs | 0 crates/service/Cargo.toml | 2 +- crates/service/src/routes/static_subgraph.rs | 2 +- crates/service/src/service/indexer_service.rs | 2 +- crates/service/src/tap.rs | 2 +- .../service/src/tap/checks/deny_list_check.rs | 2 +- .../src/tap/checks/sender_balance_check.rs | 2 +- crates/tap-agent/Cargo.toml | 2 +- crates/tap-agent/src/agent.rs | 2 +- crates/tap-agent/src/agent/sender_account.rs | 4 +- .../src/agent/sender_accounts_manager.rs | 4 +- .../tap-agent/src/agent/sender_allocation.rs | 4 +- crates/tap-agent/src/tap/context.rs | 2 +- .../src/tap/context/checks/allocation_id.rs | 4 +- .../src/tap/context/checks/signature.rs | 2 +- crates/tap-agent/src/tap/context/error.rs | 2 +- crates/tap-agent/src/tap/context/rav.rs | 2 +- crates/tap-agent/src/tap/context/receipt.rs | 2 +- crates/tap-agent/src/tap/mod.rs | 2 +- 30 files changed, 54 insertions(+), 54 deletions(-) rename crates/{common => monitor}/CHANGELOG.md (100%) rename crates/{common => monitor}/Cargo.toml (96%) rename crates/{common => monitor}/src/allocations.rs (100%) rename crates/{common => monitor}/src/attestation.rs (100%) rename crates/{common => monitor}/src/client/mod.rs (100%) rename crates/{common => monitor}/src/client/monitor.rs (100%) rename crates/{common => monitor}/src/client/subgraph_client.rs (100%) rename crates/{common => monitor}/src/dispute_manager.rs (100%) rename crates/{common => monitor}/src/escrow_accounts.rs (100%) rename crates/{common => monitor}/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index adeedad3f..63a473e12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3495,32 +3495,6 @@ dependencies = [ "thegraph-core", ] -[[package]] -name = "indexer-common" -version = "1.4.0" -dependencies = [ - "alloy", - "anyhow", - "axum", - "bip39", - "env_logger", - "graphql_client", - "indexer-allocation", - "indexer-attestation", - "indexer-query", - "indexer-watcher", - "reqwest 0.12.9", - "serde", - "serde_json", - "test-assets", - "test-log", - "thegraph-core", - "thiserror", - "tokio", - "tracing", - "wiremock 0.5.22", -] - [[package]] name = "indexer-config" version = "1.2.1" @@ -3556,6 +3530,32 @@ dependencies = [ "thiserror", ] +[[package]] +name = "indexer-monitor" +version = "1.4.0" +dependencies = [ + "alloy", + "anyhow", + "axum", + "bip39", + "env_logger", + "graphql_client", + "indexer-allocation", + "indexer-attestation", + "indexer-query", + "indexer-watcher", + "reqwest 0.12.9", + "serde", + "serde_json", + "test-assets", + "test-log", + "thegraph-core", + "thiserror", + "tokio", + "tracing", + "wiremock 0.5.22", +] + [[package]] name = "indexer-query" version = "0.1.0" @@ -3591,9 +3591,9 @@ dependencies = [ "hex-literal", "indexer-allocation", "indexer-attestation", - "indexer-common", "indexer-config", "indexer-dips", + "indexer-monitor", "indexer-query", "lazy_static", "prometheus", @@ -3630,8 +3630,8 @@ dependencies = [ "futures-util", "graphql_client", "indexer-allocation", - "indexer-common", "indexer-config", + "indexer-monitor", "indexer-query", "indexer-watcher", "jsonrpsee", diff --git a/Cargo.toml b/Cargo.toml index 69893578e..8eba38279 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,14 +1,14 @@ [workspace] members = [ - "crates/common", + "crates/allocation", + "crates/attestation", "crates/config", "crates/dips", + "crates/monitor", "crates/query", "crates/service", "crates/tap-agent", - "crates/allocation", "crates/test-assets", - "crates/attestation", "crates/watcher", ] resolver = "2" diff --git a/crates/common/CHANGELOG.md b/crates/monitor/CHANGELOG.md similarity index 100% rename from crates/common/CHANGELOG.md rename to crates/monitor/CHANGELOG.md diff --git a/crates/common/Cargo.toml b/crates/monitor/Cargo.toml similarity index 96% rename from crates/common/Cargo.toml rename to crates/monitor/Cargo.toml index 7d5435731..845d23971 100644 --- a/crates/common/Cargo.toml +++ b/crates/monitor/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "indexer-common" +name = "indexer-monitor" version = "1.4.0" edition = "2021" diff --git a/crates/common/src/allocations.rs b/crates/monitor/src/allocations.rs similarity index 100% rename from crates/common/src/allocations.rs rename to crates/monitor/src/allocations.rs diff --git a/crates/common/src/attestation.rs b/crates/monitor/src/attestation.rs similarity index 100% rename from crates/common/src/attestation.rs rename to crates/monitor/src/attestation.rs diff --git a/crates/common/src/client/mod.rs b/crates/monitor/src/client/mod.rs similarity index 100% rename from crates/common/src/client/mod.rs rename to crates/monitor/src/client/mod.rs diff --git a/crates/common/src/client/monitor.rs b/crates/monitor/src/client/monitor.rs similarity index 100% rename from crates/common/src/client/monitor.rs rename to crates/monitor/src/client/monitor.rs diff --git a/crates/common/src/client/subgraph_client.rs b/crates/monitor/src/client/subgraph_client.rs similarity index 100% rename from crates/common/src/client/subgraph_client.rs rename to crates/monitor/src/client/subgraph_client.rs diff --git a/crates/common/src/dispute_manager.rs b/crates/monitor/src/dispute_manager.rs similarity index 100% rename from crates/common/src/dispute_manager.rs rename to crates/monitor/src/dispute_manager.rs diff --git a/crates/common/src/escrow_accounts.rs b/crates/monitor/src/escrow_accounts.rs similarity index 100% rename from crates/common/src/escrow_accounts.rs rename to crates/monitor/src/escrow_accounts.rs diff --git a/crates/common/src/lib.rs b/crates/monitor/src/lib.rs similarity index 100% rename from crates/common/src/lib.rs rename to crates/monitor/src/lib.rs diff --git a/crates/service/Cargo.toml b/crates/service/Cargo.toml index 3c3f94da9..4a9c6f2f3 100644 --- a/crates/service/Cargo.toml +++ b/crates/service/Cargo.toml @@ -7,7 +7,7 @@ license = "Apache-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -indexer-common = { path = "../common" } +indexer-monitor = { path = "../monitor" } indexer-attestation = { path = "../attestation" } indexer-allocation = { path = "../allocation" } indexer-config = { path = "../config" } diff --git a/crates/service/src/routes/static_subgraph.rs b/crates/service/src/routes/static_subgraph.rs index b2447b0ac..eab55c996 100644 --- a/crates/service/src/routes/static_subgraph.rs +++ b/crates/service/src/routes/static_subgraph.rs @@ -6,7 +6,7 @@ use reqwest::StatusCode; use serde_json::json; use tracing::warn; -use indexer_common::SubgraphClient; +use indexer_monitor::SubgraphClient; #[autometrics::autometrics] pub async fn static_subgraph_request_handler( diff --git a/crates/service/src/service/indexer_service.rs b/crates/service/src/service/indexer_service.rs index a2efa7340..405984391 100644 --- a/crates/service/src/service/indexer_service.rs +++ b/crates/service/src/service/indexer_service.rs @@ -14,7 +14,7 @@ use axum::{ use axum::{serve, ServiceExt}; use build_info::BuildInfo; use indexer_attestation::AttestationSigner; -use indexer_common::{ +use indexer_monitor::{ monitors::{attestation_signers, dispute_manager, escrow_accounts, indexer_allocations}, DeploymentDetails, EscrowAccounts, EscrowAccountsError, SubgraphClient, }; diff --git a/crates/service/src/tap.rs b/crates/service/src/tap.rs index 0961ad680..ad5f1135f 100644 --- a/crates/service/src/tap.rs +++ b/crates/service/src/tap.rs @@ -10,7 +10,7 @@ use crate::tap::checks::value_check::MinimumValue; use alloy::dyn_abi::Eip712Domain; use alloy::primitives::Address; use indexer_allocation::Allocation; -use indexer_common::EscrowAccounts; +use indexer_monitor::EscrowAccounts; use receipt_store::{DatabaseReceipt, InnerContext}; use sqlx::PgPool; use std::fmt::Debug; diff --git a/crates/service/src/tap/checks/deny_list_check.rs b/crates/service/src/tap/checks/deny_list_check.rs index 586e84cd6..44ca5af5e 100644 --- a/crates/service/src/tap/checks/deny_list_check.rs +++ b/crates/service/src/tap/checks/deny_list_check.rs @@ -3,7 +3,7 @@ use alloy::dyn_abi::Eip712Domain; use alloy::primitives::Address; -use indexer_common::EscrowAccounts; +use indexer_monitor::EscrowAccounts; use sqlx::postgres::PgListener; use sqlx::PgPool; use std::collections::HashSet; diff --git a/crates/service/src/tap/checks/sender_balance_check.rs b/crates/service/src/tap/checks/sender_balance_check.rs index a99d5dd76..cc31c7425 100644 --- a/crates/service/src/tap/checks/sender_balance_check.rs +++ b/crates/service/src/tap/checks/sender_balance_check.rs @@ -4,7 +4,7 @@ use alloy::dyn_abi::Eip712Domain; use alloy::primitives::U256; use anyhow::anyhow; -use indexer_common::EscrowAccounts; +use indexer_monitor::EscrowAccounts; use tap_core::receipt::{ checks::{Check, CheckError, CheckResult}, state::Checking, diff --git a/crates/tap-agent/Cargo.toml b/crates/tap-agent/Cargo.toml index 2db5783c5..2bc04f2e3 100644 --- a/crates/tap-agent/Cargo.toml +++ b/crates/tap-agent/Cargo.toml @@ -9,7 +9,7 @@ name = "indexer-tap-agent" path = "src/main.rs" [dependencies] -indexer-common = { path = "../common" } +indexer-monitor = { path = "../monitor" } indexer-watcher = { path = "../watcher" } indexer-allocation = { path = "../allocation" } indexer-config = { path = "../config" } diff --git a/crates/tap-agent/src/agent.rs b/crates/tap-agent/src/agent.rs index 7d84b186f..42f72f31f 100644 --- a/crates/tap-agent/src/agent.rs +++ b/crates/tap-agent/src/agent.rs @@ -1,7 +1,7 @@ // Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs. // SPDX-License-Identifier: Apache-2.0 -use indexer_common::{ +use indexer_monitor::{ monitors::{escrow_accounts, indexer_allocations}, DeploymentDetails, SubgraphClient, }; diff --git a/crates/tap-agent/src/agent/sender_account.rs b/crates/tap-agent/src/agent/sender_account.rs index 5bcfb88e1..465596f4a 100644 --- a/crates/tap-agent/src/agent/sender_account.rs +++ b/crates/tap-agent/src/agent/sender_account.rs @@ -26,7 +26,7 @@ use tokio::task::JoinHandle; use alloy::dyn_abi::Eip712Domain; use alloy::primitives::Address; use anyhow::Result; -use indexer_common::{EscrowAccounts, SubgraphClient}; +use indexer_monitor::{EscrowAccounts, SubgraphClient}; use ractor::{Actor, ActorProcessingErr, ActorRef, MessagingErr, SupervisionEvent}; use sqlx::PgPool; use tap_core::rav::SignedRAV; @@ -1039,7 +1039,7 @@ pub mod tests { }; use alloy::hex::ToHexExt; use alloy::primitives::{Address, U256}; - use indexer_common::{DeploymentDetails, EscrowAccounts, SubgraphClient}; + use indexer_monitor::{DeploymentDetails, EscrowAccounts, SubgraphClient}; use ractor::concurrency::JoinHandle; use ractor::{call, Actor, ActorProcessingErr, ActorRef, ActorStatus}; use reqwest::Url; diff --git a/crates/tap-agent/src/agent/sender_accounts_manager.rs b/crates/tap-agent/src/agent/sender_accounts_manager.rs index f3f5ba1b0..283c65c08 100644 --- a/crates/tap-agent/src/agent/sender_accounts_manager.rs +++ b/crates/tap-agent/src/agent/sender_accounts_manager.rs @@ -16,7 +16,7 @@ use anyhow::Result; use anyhow::{anyhow, bail}; use futures::{stream, StreamExt}; use indexer_allocation::Allocation; -use indexer_common::{EscrowAccounts, SubgraphClient}; +use indexer_monitor::{EscrowAccounts, SubgraphClient}; use indexer_watcher::watch_pipe; use prometheus::{register_counter_vec, CounterVec}; use ractor::concurrency::JoinHandle; @@ -593,7 +593,7 @@ mod tests { ALLOCATION_ID_1, INDEXER, SENDER, SENDER_2, SENDER_3, SIGNER, TAP_EIP712_DOMAIN_SEPARATOR, }; use alloy::hex::ToHexExt; - use indexer_common::{DeploymentDetails, EscrowAccounts, SubgraphClient}; + use indexer_monitor::{DeploymentDetails, EscrowAccounts, SubgraphClient}; use ractor::concurrency::JoinHandle; use ractor::{Actor, ActorProcessingErr, ActorRef}; use reqwest::Url; diff --git a/crates/tap-agent/src/agent/sender_allocation.rs b/crates/tap-agent/src/agent/sender_allocation.rs index 1401b5aa1..f859b861a 100644 --- a/crates/tap-agent/src/agent/sender_allocation.rs +++ b/crates/tap-agent/src/agent/sender_allocation.rs @@ -10,7 +10,7 @@ use alloy::primitives::Address; use alloy::{dyn_abi::Eip712Domain, hex::ToHexExt}; use anyhow::{anyhow, ensure, Result}; use bigdecimal::{num_bigint::BigInt, ToPrimitive}; -use indexer_common::{EscrowAccounts, SubgraphClient}; +use indexer_monitor::{EscrowAccounts, SubgraphClient}; use jsonrpsee::{core::client::ClientT, rpc_params}; use prometheus::{register_counter_vec, register_histogram_vec, CounterVec, HistogramVec}; use ractor::{Actor, ActorProcessingErr, ActorRef}; @@ -872,7 +872,7 @@ pub mod tests { }, }; use futures::future::join_all; - use indexer_common::{EscrowAccounts, DeploymentDetails, SubgraphClient}; + use indexer_monitor::{EscrowAccounts, DeploymentDetails, SubgraphClient}; use jsonrpsee::http_client::HttpClientBuilder; use ractor::{ call, cast, concurrency::JoinHandle, Actor, ActorProcessingErr, ActorRef, ActorStatus, diff --git a/crates/tap-agent/src/tap/context.rs b/crates/tap-agent/src/tap/context.rs index 6ae2c4473..b543bb21f 100644 --- a/crates/tap-agent/src/tap/context.rs +++ b/crates/tap-agent/src/tap/context.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use alloy::primitives::Address; -use indexer_common::EscrowAccounts; +use indexer_monitor::EscrowAccounts; use sqlx::PgPool; use tokio::sync::watch::Receiver; diff --git a/crates/tap-agent/src/tap/context/checks/allocation_id.rs b/crates/tap-agent/src/tap/context/checks/allocation_id.rs index 99029ad4a..46990da91 100644 --- a/crates/tap-agent/src/tap/context/checks/allocation_id.rs +++ b/crates/tap-agent/src/tap/context/checks/allocation_id.rs @@ -5,7 +5,7 @@ use std::time::Duration; use alloy::primitives::Address; use anyhow::anyhow; -use indexer_common::SubgraphClient; +use indexer_monitor::SubgraphClient; use indexer_query::{tap_transactions, TapTransactions}; use indexer_watcher::new_watcher; use tap_core::receipt::{ @@ -111,7 +111,7 @@ async fn query_escrow_check_transactions( #[cfg(test)] mod tests { - use indexer_common::{DeploymentDetails, SubgraphClient}; + use indexer_monitor::{DeploymentDetails, SubgraphClient}; #[tokio::test] async fn test_transaction_exists() { diff --git a/crates/tap-agent/src/tap/context/checks/signature.rs b/crates/tap-agent/src/tap/context/checks/signature.rs index 8590913d2..8010062fd 100644 --- a/crates/tap-agent/src/tap/context/checks/signature.rs +++ b/crates/tap-agent/src/tap/context/checks/signature.rs @@ -3,7 +3,7 @@ use alloy::{dyn_abi::Eip712Domain, primitives::U256}; use anyhow::anyhow; -use indexer_common::EscrowAccounts; +use indexer_monitor::EscrowAccounts; use tap_core::receipt::{ checks::{Check, CheckError, CheckResult}, state::Checking, diff --git a/crates/tap-agent/src/tap/context/error.rs b/crates/tap-agent/src/tap/context/error.rs index ee72bcc35..aa5d443f7 100644 --- a/crates/tap-agent/src/tap/context/error.rs +++ b/crates/tap-agent/src/tap/context/error.rs @@ -9,7 +9,7 @@ pub enum AdapterError { EscrowEventualError { error: String }, #[error("Could not get available escrow for sender")] - AvailableEscrowError(#[from] indexer_common::EscrowAccountsError), + AvailableEscrowError(#[from] indexer_monitor::EscrowAccountsError), #[error("Sender {sender} escrow balance is too large to fit in u128, could not get available escrow.")] BalanceTooLarge { sender: Address }, diff --git a/crates/tap-agent/src/tap/context/rav.rs b/crates/tap-agent/src/tap/context/rav.rs index 29b24e9af..c644bca4a 100644 --- a/crates/tap-agent/src/tap/context/rav.rs +++ b/crates/tap-agent/src/tap/context/rav.rs @@ -128,7 +128,7 @@ impl RAVStore for TapAgentContext { #[cfg(test)] mod test { - use indexer_common::EscrowAccounts; + use indexer_monitor::EscrowAccounts; use sqlx::PgPool; use tokio::sync::watch; diff --git a/crates/tap-agent/src/tap/context/receipt.rs b/crates/tap-agent/src/tap/context/receipt.rs index d73f963e4..83120e657 100644 --- a/crates/tap-agent/src/tap/context/receipt.rs +++ b/crates/tap-agent/src/tap/context/receipt.rs @@ -199,7 +199,7 @@ mod test { }; use alloy::{primitives::U256, signers::local::PrivateKeySigner}; use anyhow::Result; - use indexer_common::EscrowAccounts; + use indexer_monitor::EscrowAccounts; use lazy_static::lazy_static; use sqlx::PgPool; use std::collections::HashMap; diff --git a/crates/tap-agent/src/tap/mod.rs b/crates/tap-agent/src/tap/mod.rs index 1dbf740d2..839ee6036 100644 --- a/crates/tap-agent/src/tap/mod.rs +++ b/crates/tap-agent/src/tap/mod.rs @@ -3,7 +3,7 @@ use alloy::hex::ToHexExt; use alloy::primitives::Address; -use indexer_common::EscrowAccounts; +use indexer_monitor::EscrowAccounts; use tokio::sync::watch::Receiver; pub mod context; From 84772542e2ee1f4602d23c30e25eab81e357adfa Mon Sep 17 00:00:00 2001 From: Gustavo Inacio Date: Tue, 19 Nov 2024 18:53:33 -0600 Subject: [PATCH 09/11] refactor: update monitor imports Signed-off-by: Gustavo Inacio --- crates/monitor/src/lib.rs | 16 +++++++--------- crates/service/src/service/indexer_service.rs | 4 ++-- crates/tap-agent/src/agent.rs | 5 +---- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/crates/monitor/src/lib.rs b/crates/monitor/src/lib.rs index d075ebe0c..765ee6299 100644 --- a/crates/monitor/src/lib.rs +++ b/crates/monitor/src/lib.rs @@ -7,12 +7,10 @@ mod client; mod dispute_manager; mod escrow_accounts; -pub mod monitors { - pub use super::allocations::indexer_allocations; - pub use super::attestation::attestation_signers; - pub use super::dispute_manager::dispute_manager; - pub use super::escrow_accounts::escrow_accounts; -} - -pub use crate::client::{DeploymentDetails, SubgraphClient}; -pub use escrow_accounts::{EscrowAccounts, EscrowAccountsError}; +pub use crate::{ + allocations::indexer_allocations, + attestation::attestation_signers, + client::{DeploymentDetails, SubgraphClient}, + dispute_manager::dispute_manager, + escrow_accounts::{escrow_accounts, EscrowAccounts, EscrowAccountsError}, +}; diff --git a/crates/service/src/service/indexer_service.rs b/crates/service/src/service/indexer_service.rs index 405984391..ec05ebeb7 100644 --- a/crates/service/src/service/indexer_service.rs +++ b/crates/service/src/service/indexer_service.rs @@ -15,8 +15,8 @@ use axum::{serve, ServiceExt}; use build_info::BuildInfo; use indexer_attestation::AttestationSigner; use indexer_monitor::{ - monitors::{attestation_signers, dispute_manager, escrow_accounts, indexer_allocations}, - DeploymentDetails, EscrowAccounts, EscrowAccountsError, SubgraphClient, + attestation_signers, dispute_manager, escrow_accounts, indexer_allocations, DeploymentDetails, + EscrowAccounts, EscrowAccountsError, SubgraphClient, }; use prometheus::TextEncoder; use reqwest::StatusCode; diff --git a/crates/tap-agent/src/agent.rs b/crates/tap-agent/src/agent.rs index 42f72f31f..cd069ab3d 100644 --- a/crates/tap-agent/src/agent.rs +++ b/crates/tap-agent/src/agent.rs @@ -1,14 +1,11 @@ // Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs. // SPDX-License-Identifier: Apache-2.0 -use indexer_monitor::{ - monitors::{escrow_accounts, indexer_allocations}, - DeploymentDetails, SubgraphClient, -}; use indexer_config::{ Config, EscrowSubgraphConfig, GraphNodeConfig, IndexerConfig, NetworkSubgraphConfig, SubgraphConfig, SubgraphsConfig, TapConfig, }; +use indexer_monitor::{escrow_accounts, indexer_allocations, DeploymentDetails, SubgraphClient}; use ractor::concurrency::JoinHandle; use ractor::{Actor, ActorRef}; use sender_account::SenderAccountConfig; From 56dfb74a2b21d242c429eccd4fe1355955a0c92d Mon Sep 17 00:00:00 2001 From: Gustavo Inacio Date: Tue, 19 Nov 2024 18:58:31 -0600 Subject: [PATCH 10/11] chore: update release please Signed-off-by: Gustavo Inacio --- .release-please-manifest.json | 1 - crates/monitor/CHANGELOG.md | 51 ----------------------------------- crates/monitor/Cargo.toml | 2 +- release-please-config.json | 1 - 4 files changed, 1 insertion(+), 54 deletions(-) delete mode 100644 crates/monitor/CHANGELOG.md diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 926caecea..957ed080c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,6 +1,5 @@ { "crates/tap-agent": "1.7.3", - "crates/common": "1.4.0", "crates/config": "1.2.1", "crates/service": "1.3.2" } diff --git a/crates/monitor/CHANGELOG.md b/crates/monitor/CHANGELOG.md deleted file mode 100644 index 2f778649a..000000000 --- a/crates/monitor/CHANGELOG.md +++ /dev/null @@ -1,51 +0,0 @@ -# Changelog - -## [1.4.0](https://github.com/graphprotocol/indexer-rs/compare/indexer-common-v1.3.1...indexer-common-v1.4.0) (2024-11-08) - - -### Features - -* Add grace period ([#467](https://github.com/graphprotocol/indexer-rs/issues/467)) ([775f2f6](https://github.com/graphprotocol/indexer-rs/commit/775f2f62e6c7aad0489beef03a9346a943d7b406)) -* add subgraph health endpoint ([#449](https://github.com/graphprotocol/indexer-rs/issues/449)) ([bab22af](https://github.com/graphprotocol/indexer-rs/commit/bab22afabb10c58138f5d72f366cf3bf015b8251)) - -## [1.3.1](https://github.com/graphprotocol/indexer-rs/compare/indexer-common-v1.3.0...indexer-common-v1.3.1) (2024-11-06) - - -### Bug Fixes - -* use request from gateway instead of serde req ([#464](https://github.com/graphprotocol/indexer-rs/issues/464)) ([fdeda9f](https://github.com/graphprotocol/indexer-rs/commit/fdeda9fea996f96e1c0a7bef291a551f426f5591)) - -## [1.3.0](https://github.com/graphprotocol/indexer-rs/compare/indexer-common-v1.2.1...indexer-common-v1.3.0) (2024-11-01) - - -### Features - -* enable value check ([#430](https://github.com/graphprotocol/indexer-rs/issues/430)) ([466a5a9](https://github.com/graphprotocol/indexer-rs/commit/466a5a92c66f5cd31f5aa9c20fb51cd0df391d6c)) - -## [1.2.1](https://github.com/graphprotocol/indexer-rs/compare/indexer-common-v1.2.0...indexer-common-v1.2.1) (2024-10-30) - - -### Bug Fixes - -* add more information about failing subgraph query ([#436](https://github.com/graphprotocol/indexer-rs/issues/436)) ([1e52f82](https://github.com/graphprotocol/indexer-rs/commit/1e52f82ec240c63c940bcc3b20e58750c31b4d66)) -* proper build graph-node query url ([#438](https://github.com/graphprotocol/indexer-rs/issues/438)) ([df94692](https://github.com/graphprotocol/indexer-rs/commit/df94692e66f48a186deeac99bda8e0fcfddb2e52)) - -## [1.2.0](https://github.com/graphprotocol/indexer-rs/compare/indexer-common-v1.1.0...indexer-common-v1.2.0) (2024-10-30) - - -### Features - -* add value check ([#153](https://github.com/graphprotocol/indexer-rs/issues/153)) ([1e4a3cd](https://github.com/graphprotocol/indexer-rs/commit/1e4a3cdd8c18b5356e64285b8082d8abde20d6de)) - - -### Bug Fixes - -* disable value check ([#429](https://github.com/graphprotocol/indexer-rs/issues/429)) ([eb31981](https://github.com/graphprotocol/indexer-rs/commit/eb3198174dab1b08f365c5ac4e47da62c88b6fb4)) -* initialize allocations monitor ([#428](https://github.com/graphprotocol/indexer-rs/issues/428)) ([f0c7d03](https://github.com/graphprotocol/indexer-rs/commit/f0c7d0367abf8a833f1824264780df50ad6a3c52)) - -## [1.1.0](https://github.com/graphprotocol/indexer-rs/compare/indexer-common-v1.0.0...indexer-common-v1.1.0) (2024-10-09) - - -### Features - -* add metrics to service ([#319](https://github.com/graphprotocol/indexer-rs/issues/319)) ([57c89e2](https://github.com/graphprotocol/indexer-rs/commit/57c89e237a57b49214eaf902303e3d89c9d82396)) diff --git a/crates/monitor/Cargo.toml b/crates/monitor/Cargo.toml index 845d23971..c29d15425 100644 --- a/crates/monitor/Cargo.toml +++ b/crates/monitor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "indexer-monitor" -version = "1.4.0" +version = "0.1.0" edition = "2021" [dependencies] diff --git a/release-please-config.json b/release-please-config.json index 684352a64..b430b0c17 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -4,7 +4,6 @@ "release-type": "rust", "plugins": ["cargo-workspace"], "packages": { - "crates/common": {}, "crates/config": {}, "crates/service": {}, "crates/tap-agent": {} From 48959af0728e15d6e1b223769b7135d0af63bb1b Mon Sep 17 00:00:00 2001 From: Gustavo Inacio Date: Tue, 19 Nov 2024 19:03:26 -0600 Subject: [PATCH 11/11] refactor: cargo fmt Signed-off-by: Gustavo Inacio --- crates/monitor/src/attestation.rs | 1 - crates/monitor/src/escrow_accounts.rs | 2 +- crates/tap-agent/src/agent/sender_account.rs | 2 +- crates/tap-agent/src/agent/sender_allocation.rs | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/monitor/src/attestation.rs b/crates/monitor/src/attestation.rs index 6b50e429e..b81c568fd 100644 --- a/crates/monitor/src/attestation.rs +++ b/crates/monitor/src/attestation.rs @@ -11,7 +11,6 @@ use thegraph_core::{Address, ChainId}; use tokio::sync::watch::Receiver; use tracing::warn; - /// An always up-to-date list of attestation signers, one for each of the indexer's allocations. pub fn attestation_signers( indexer_allocations_rx: Receiver>, diff --git a/crates/monitor/src/escrow_accounts.rs b/crates/monitor/src/escrow_accounts.rs index 445a95d2c..95c0a82a8 100644 --- a/crates/monitor/src/escrow_accounts.rs +++ b/crates/monitor/src/escrow_accounts.rs @@ -164,11 +164,11 @@ async fn get_escrow_accounts( #[cfg(test)] mod tests { - use test_log::test; use test_assets::{ ESCROW_ACCOUNTS_BALANCES, ESCROW_ACCOUNTS_SENDERS_TO_SIGNERS, ESCROW_ACCOUNTS_SIGNERS_TO_SENDERS, }; + use test_log::test; use wiremock::matchers::{method, path}; use wiremock::{Mock, MockServer, ResponseTemplate}; diff --git a/crates/tap-agent/src/agent/sender_account.rs b/crates/tap-agent/src/agent/sender_account.rs index 465596f4a..bc61d9be3 100644 --- a/crates/tap-agent/src/agent/sender_account.rs +++ b/crates/tap-agent/src/agent/sender_account.rs @@ -8,12 +8,12 @@ use bigdecimal::num_bigint::ToBigInt; use bigdecimal::ToPrimitive; use futures::{stream, StreamExt}; -use indexer_watcher::watch_pipe; use indexer_query::unfinalized_transactions; use indexer_query::{ closed_allocations::{self, ClosedAllocations}, UnfinalizedTransactions, }; +use indexer_watcher::watch_pipe; use jsonrpsee::http_client::HttpClientBuilder; use prometheus::{register_gauge_vec, register_int_gauge_vec, GaugeVec, IntGaugeVec}; use reqwest::Url; diff --git a/crates/tap-agent/src/agent/sender_allocation.rs b/crates/tap-agent/src/agent/sender_allocation.rs index f859b861a..98ae0910b 100644 --- a/crates/tap-agent/src/agent/sender_allocation.rs +++ b/crates/tap-agent/src/agent/sender_allocation.rs @@ -872,7 +872,7 @@ pub mod tests { }, }; use futures::future::join_all; - use indexer_monitor::{EscrowAccounts, DeploymentDetails, SubgraphClient}; + use indexer_monitor::{DeploymentDetails, EscrowAccounts, SubgraphClient}; use jsonrpsee::http_client::HttpClientBuilder; use ractor::{ call, cast, concurrency::JoinHandle, Actor, ActorProcessingErr, ActorRef, ActorStatus,