diff --git a/Cargo.lock b/Cargo.lock index fdac17694..5d14adc41 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3964,7 +3964,6 @@ dependencies = [ "indexer-receipt", "insta", "itertools 0.14.0", - "lazy_static", "pin-project 1.1.9", "prometheus", "prost", @@ -4021,7 +4020,6 @@ dependencies = [ "insta", "itertools 0.14.0", "jsonrpsee", - "lazy_static", "prometheus", "ractor", "rand 0.8.5", @@ -7521,7 +7519,6 @@ dependencies = [ "bip39", "bon 3.3.2", "indexer-allocation", - "lazy_static", "rstest 0.24.0", "sqlx", "stdext", diff --git a/Cargo.toml b/Cargo.toml index f6e2676a8..118e6c707 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,6 @@ opt-level = 3 [workspace.dependencies] clap = "4.4.3" -lazy_static = "1.4.0" axum = { version = "0.7.9", default-features = false, features = [ "tokio", "http1", diff --git a/crates/service/Cargo.toml b/crates/service/Cargo.toml index abf56ba22..b27829255 100644 --- a/crates/service/Cargo.toml +++ b/crates/service/Cargo.toml @@ -31,7 +31,6 @@ graphql_client.workspace = true tracing-subscriber = { workspace = true, features = ["fmt"] } clap = { workspace = true, features = ["derive"] } build-info.workspace = true -lazy_static.workspace = true prost.workspace = true async-trait.workspace = true async-graphql = { version = "7.0.11", default-features = false } diff --git a/crates/service/src/metrics.rs b/crates/service/src/metrics.rs index 994bd988f..aac494e3b 100644 --- a/crates/service/src/metrics.rs +++ b/crates/service/src/metrics.rs @@ -1,39 +1,40 @@ // Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs. // SPDX-License-Identifier: Apache-2.0 -use std::net::SocketAddr; +use std::{net::SocketAddr, sync::LazyLock}; use axum::{routing::get, serve, Router}; -use lazy_static::lazy_static; use prometheus::{ register_counter_vec, register_histogram_vec, CounterVec, HistogramVec, TextEncoder, }; use reqwest::StatusCode; use tokio::net::TcpListener; -lazy_static! { - /// Metric registered in global registry for - /// indexer query handler - /// - /// Labels: "deployment", "allocation", "sender" - pub static ref HANDLER_HISTOGRAM: HistogramVec = register_histogram_vec!( +/// Metric registered in global registry for +/// indexer query handler +/// +/// Labels: "deployment", "allocation", "sender" +pub static HANDLER_HISTOGRAM: LazyLock = LazyLock::new(|| { + register_histogram_vec!( "indexer_query_handler_seconds", "Histogram for default indexer query handler", &["deployment", "allocation", "sender", "status_code"] - ).unwrap(); + ) + .unwrap() +}); - /// Metric registered in global registry for - /// Failed receipt checks - /// - /// Labels: "deployment", "allocation", "sender" - pub static ref FAILED_RECEIPT: CounterVec = register_counter_vec!( +/// Metric registered in global registry for +/// Failed receipt checks +/// +/// Labels: "deployment", "allocation", "sender" +pub static FAILED_RECEIPT: LazyLock = LazyLock::new(|| { + register_counter_vec!( "indexer_receipt_failed_total", "Failed receipt checks", &["deployment", "allocation", "sender"] ) - .unwrap(); - -} + .unwrap() +}); pub fn serve_metrics(host_and_port: SocketAddr) { tracing::info!(address = %host_and_port, "Serving prometheus metrics"); diff --git a/crates/service/src/routes/cost.rs b/crates/service/src/routes/cost.rs index bafb73831..afbd8b541 100644 --- a/crates/service/src/routes/cost.rs +++ b/crates/service/src/routes/cost.rs @@ -1,10 +1,9 @@ // Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs. // SPDX-License-Identifier: Apache-2.0 -use std::str::FromStr; +use std::{str::FromStr, sync::LazyLock}; use async_graphql::{Context, EmptyMutation, EmptySubscription, Object, Schema, SimpleObject}; -use lazy_static::lazy_static; use prometheus::{ register_counter, register_counter_vec, register_histogram, register_histogram_vec, Counter, CounterVec, Histogram, HistogramVec, @@ -16,45 +15,57 @@ use thegraph_core::DeploymentId; use crate::database::cost_model::{self, CostModel}; -lazy_static! { - pub static ref COST_MODEL_METRIC: HistogramVec = register_histogram_vec!( +pub static COST_MODEL_METRIC: LazyLock = LazyLock::new(|| { + register_histogram_vec!( "indexer_cost_model_seconds", "Histogram metric for single cost model query", &["deployment"] ) - .unwrap(); - pub static ref COST_MODEL_FAILED: CounterVec = register_counter_vec!( + .unwrap() +}); +pub static COST_MODEL_FAILED: LazyLock = LazyLock::new(|| { + register_counter_vec!( "indexer_cost_model_failed_total", "Total failed Cost Model query", &["deployment"] ) - .unwrap(); - pub static ref COST_MODEL_INVALID: Counter = register_counter!( + .unwrap() +}); +pub static COST_MODEL_INVALID: LazyLock = LazyLock::new(|| { + register_counter!( "indexer_cost_model_invalid_total", "Cost model queries with invalid deployment id", ) - .unwrap(); - pub static ref COST_MODEL_BATCH_METRIC: Histogram = register_histogram!( + .unwrap() +}); +pub static COST_MODEL_BATCH_METRIC: LazyLock = LazyLock::new(|| { + register_histogram!( "indexer_cost_model_batch_seconds", "Histogram metric for batch cost model query", ) - .unwrap(); - pub static ref COST_MODEL_BATCH_SIZE: Histogram = register_histogram!( + .unwrap() +}); +pub static COST_MODEL_BATCH_SIZE: LazyLock = LazyLock::new(|| { + register_histogram!( "indexer_cost_model_batch_size", "This shows the size of deployment ids cost model batch queries got", ) - .unwrap(); - pub static ref COST_MODEL_BATCH_FAILED: Counter = register_counter!( + .unwrap() +}); +pub static COST_MODEL_BATCH_FAILED: LazyLock = LazyLock::new(|| { + register_counter!( "indexer_cost_model_batch_failed_total", "Total failed batch cost model queries", ) - .unwrap(); - pub static ref COST_MODEL_BATCH_INVALID: Counter = register_counter!( + .unwrap() +}); +pub static COST_MODEL_BATCH_INVALID: LazyLock = LazyLock::new(|| { + register_counter!( "indexer_cost_model_batch_invalid_total", "Batch cost model queries with invalid deployment ids", ) - .unwrap(); -} + .unwrap() +}); #[derive(Clone, Debug, Serialize, Deserialize, SimpleObject)] pub struct GraphQlCostModel { diff --git a/crates/service/src/routes/status.rs b/crates/service/src/routes/status.rs index 7c26cb748..c036426a6 100644 --- a/crates/service/src/routes/status.rs +++ b/crates/service/src/routes/status.rs @@ -1,7 +1,7 @@ // Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs. // SPDX-License-Identifier: Apache-2.0 -use std::collections::HashSet; +use std::{collections::HashSet, sync::LazyLock}; use async_graphql_axum::GraphQLRequest; use axum::{extract::State, response::IntoResponse, Json}; @@ -14,23 +14,24 @@ use thegraph_graphql_http::{ use crate::{error::SubgraphServiceError, service::GraphNodeState}; -lazy_static::lazy_static! { - static ref SUPPORTED_ROOT_FIELDS: HashSet<&'static str> = - vec![ - "indexingStatuses", - "chains", - "latestBlock", - "earliestBlock", - "publicProofsOfIndexing", - "entityChangesInBlock", - "blockData", - "blockHashFromNumber", - "cachedEthereumCalls", - "subgraphFeatures", - "apiVersions", - "version" - ].into_iter().collect(); -} +static SUPPORTED_ROOT_FIELDS: LazyLock> = LazyLock::new(|| { + [ + "indexingStatuses", + "chains", + "latestBlock", + "earliestBlock", + "publicProofsOfIndexing", + "entityChangesInBlock", + "blockData", + "blockHashFromNumber", + "cachedEthereumCalls", + "subgraphFeatures", + "apiVersions", + "version", + ] + .into_iter() + .collect() +}); struct WrappedGraphQLRequest(async_graphql::Request); diff --git a/crates/service/src/service/tap_receipt_header.rs b/crates/service/src/service/tap_receipt_header.rs index 2bb38c78f..a5be7c9dd 100644 --- a/crates/service/src/service/tap_receipt_header.rs +++ b/crates/service/src/service/tap_receipt_header.rs @@ -1,9 +1,10 @@ // Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs. // SPDX-License-Identifier: Apache-2.0 +use std::sync::LazyLock; + use axum_extra::headers::{self, Header, HeaderName, HeaderValue}; use base64::prelude::*; -use lazy_static::lazy_static; use prometheus::{register_counter, Counter}; use prost::Message; use tap_aggregator::grpc; @@ -14,11 +15,10 @@ use crate::tap::TapReceipt; #[derive(Debug, PartialEq)] pub struct TapHeader(pub TapReceipt); -lazy_static! { - static ref TAP_RECEIPT: HeaderName = HeaderName::from_static("tap-receipt"); - pub static ref TAP_RECEIPT_INVALID: Counter = - register_counter!("indexer_tap_invalid_total", "Invalid tap receipt decode",).unwrap(); -} +static TAP_RECEIPT: LazyLock = LazyLock::new(|| HeaderName::from_static("tap-receipt")); +pub static TAP_RECEIPT_INVALID: LazyLock = LazyLock::new(|| { + register_counter!("indexer_tap_invalid_total", "Invalid tap receipt decode",).unwrap() +}); impl Header for TapHeader { fn name() -> &'static HeaderName { diff --git a/crates/tap-agent/Cargo.toml b/crates/tap-agent/Cargo.toml index 4a339cbdd..8fd0bd725 100644 --- a/crates/tap-agent/Cargo.toml +++ b/crates/tap-agent/Cargo.toml @@ -32,7 +32,6 @@ axum.workspace = true tap_core.workspace = true tap_graph.workspace = true tokio = { workspace = true, features = ["rt-multi-thread"] } -lazy_static.workspace = true thegraph-core.workspace = true clap.workspace = true tracing-subscriber.workspace = true diff --git a/crates/tap-agent/src/agent/sender_account.rs b/crates/tap-agent/src/agent/sender_account.rs index a4305ed8b..4945738bd 100644 --- a/crates/tap-agent/src/agent/sender_account.rs +++ b/crates/tap-agent/src/agent/sender_account.rs @@ -4,6 +4,7 @@ use std::{ collections::{HashMap, HashSet}, str::FromStr, + sync::LazyLock, time::Duration, }; @@ -16,7 +17,6 @@ use indexer_query::{ unfinalized_transactions, UnfinalizedTransactions, }; use indexer_watcher::watch_pipe; -use lazy_static::lazy_static; use prometheus::{register_gauge_vec, register_int_gauge_vec, GaugeVec, IntGaugeVec}; use ractor::{Actor, ActorProcessingErr, ActorRef, MessagingErr, SupervisionEvent}; use reqwest::Url; @@ -48,52 +48,65 @@ use crate::{ tracker::{SenderFeeTracker, SimpleFeeTracker}, }; -lazy_static! { - static ref SENDER_DENIED: IntGaugeVec = - register_int_gauge_vec!("tap_sender_denied", "Sender is denied", &["sender"]).unwrap(); - static ref ESCROW_BALANCE: GaugeVec = register_gauge_vec!( +static SENDER_DENIED: LazyLock = LazyLock::new(|| { + register_int_gauge_vec!("tap_sender_denied", "Sender is denied", &["sender"]).unwrap() +}); +static ESCROW_BALANCE: LazyLock = LazyLock::new(|| { + register_gauge_vec!( "tap_sender_escrow_balance_grt_total", "Sender escrow balance", &["sender"] ) - .unwrap(); - static ref UNAGGREGATED_FEES: GaugeVec = register_gauge_vec!( + .unwrap() +}); +static UNAGGREGATED_FEES: LazyLock = LazyLock::new(|| { + register_gauge_vec!( "tap_unaggregated_fees_grt_total", "Unggregated Fees value", &["sender", "allocation"] ) - .unwrap(); - static ref SENDER_FEE_TRACKER: GaugeVec = register_gauge_vec!( + .unwrap() +}); +static SENDER_FEE_TRACKER: LazyLock = LazyLock::new(|| { + register_gauge_vec!( "tap_sender_fee_tracker_grt_total", "Sender fee tracker metric", &["sender"] ) - .unwrap(); - static ref INVALID_RECEIPT_FEES: GaugeVec = register_gauge_vec!( + .unwrap() +}); +static INVALID_RECEIPT_FEES: LazyLock = LazyLock::new(|| { + register_gauge_vec!( "tap_invalid_receipt_fees_grt_total", "Failed receipt fees", &["sender", "allocation"] ) - .unwrap(); - static ref PENDING_RAV: GaugeVec = register_gauge_vec!( + .unwrap() +}); +static PENDING_RAV: LazyLock = LazyLock::new(|| { + register_gauge_vec!( "tap_pending_rav_grt_total", "Pending ravs values", &["sender", "allocation"] ) - .unwrap(); - static ref MAX_FEE_PER_SENDER: GaugeVec = register_gauge_vec!( + .unwrap() +}); +static MAX_FEE_PER_SENDER: LazyLock = LazyLock::new(|| { + register_gauge_vec!( "tap_max_fee_per_sender_grt_total", "Max fee per sender in the config", &["sender"] ) - .unwrap(); - static ref RAV_REQUEST_TRIGGER_VALUE: GaugeVec = register_gauge_vec!( + .unwrap() +}); +static RAV_REQUEST_TRIGGER_VALUE: LazyLock = LazyLock::new(|| { + register_gauge_vec!( "tap_rav_request_trigger_value", "RAV request trigger value divisor", &["sender"] ) - .unwrap(); -} + .unwrap() +}); const INITIAL_RAV_REQUEST_CONCURRENT: usize = 1; diff --git a/crates/tap-agent/src/agent/sender_accounts_manager.rs b/crates/tap-agent/src/agent/sender_accounts_manager.rs index f31ea95bf..894ae9f5d 100644 --- a/crates/tap-agent/src/agent/sender_accounts_manager.rs +++ b/crates/tap-agent/src/agent/sender_accounts_manager.rs @@ -5,6 +5,7 @@ use std::{ collections::{HashMap, HashSet}, fmt::Display, str::FromStr, + sync::LazyLock, time::Duration, }; @@ -24,16 +25,16 @@ use tokio::{select, sync::watch::Receiver}; use super::sender_account::{ SenderAccount, SenderAccountArgs, SenderAccountConfig, SenderAccountMessage, }; -use crate::{agent::sender_allocation::SenderAllocationMessage, lazy_static}; +use crate::agent::sender_allocation::SenderAllocationMessage; -lazy_static! { - static ref RECEIPTS_CREATED: CounterVec = register_counter_vec!( +static RECEIPTS_CREATED: LazyLock = LazyLock::new(|| { + register_counter_vec!( "tap_receipts_received_total", "Receipts received since start of the program.", &["sender", "allocation"] ) - .unwrap(); -} + .unwrap() +}); /// Notification received by pgnotify /// diff --git a/crates/tap-agent/src/agent/sender_allocation.rs b/crates/tap-agent/src/agent/sender_allocation.rs index fef46487f..960dbfc3c 100644 --- a/crates/tap-agent/src/agent/sender_allocation.rs +++ b/crates/tap-agent/src/agent/sender_allocation.rs @@ -4,7 +4,7 @@ use std::{ future::Future, marker::PhantomData, - sync::Arc, + sync::{Arc, LazyLock}, time::{Duration, Instant}, }; @@ -37,7 +37,6 @@ use crate::{ sender_accounts_manager::NewReceiptNotification, unaggregated_receipts::UnaggregatedReceipts, }, - lazy_static, tap::{ context::{ checks::{AllocationId, Signature}, @@ -47,32 +46,38 @@ use crate::{ }, }; -lazy_static! { - static ref CLOSED_SENDER_ALLOCATIONS: CounterVec = register_counter_vec!( +static CLOSED_SENDER_ALLOCATIONS: LazyLock = LazyLock::new(|| { + register_counter_vec!( "tap_closed_sender_allocation_total", "Count of sender-allocation managers closed since the start of the program", &["sender"] ) - .unwrap(); - static ref RAVS_CREATED: CounterVec = register_counter_vec!( + .unwrap() +}); +static RAVS_CREATED: LazyLock = LazyLock::new(|| { + register_counter_vec!( "tap_ravs_created_total", "RAVs updated or created per sender allocation since the start of the program", &["sender", "allocation"] ) - .unwrap(); - static ref RAVS_FAILED: CounterVec = register_counter_vec!( + .unwrap() +}); +static RAVS_FAILED: LazyLock = LazyLock::new(|| { + register_counter_vec!( "tap_ravs_failed_total", "RAV requests failed since the start of the program", &["sender", "allocation"] ) - .unwrap(); - static ref RAV_RESPONSE_TIME: HistogramVec = register_histogram_vec!( + .unwrap() +}); +static RAV_RESPONSE_TIME: LazyLock = LazyLock::new(|| { + register_histogram_vec!( "tap_rav_response_time_seconds", "RAV response time per sender", &["sender"] ) - .unwrap(); -} + .unwrap() +}); /// Possible Rav Errors returned in case of a failure in Rav Request /// diff --git a/crates/tap-agent/src/lib.rs b/crates/tap-agent/src/lib.rs index a0ce61549..86501e82d 100644 --- a/crates/tap-agent/src/lib.rs +++ b/crates/tap-agent/src/lib.rs @@ -11,20 +11,22 @@ //! Its main goal is that the value never goes below the balance available //! in the escrow account for a given sender. +use std::sync::LazyLock; + use indexer_config::Config; -use lazy_static::lazy_static; use tap_core::tap_eip712_domain; use thegraph_core::alloy::sol_types::Eip712Domain; -lazy_static! { - /// Static configuration - pub static ref CONFIG: Config = cli::get_config().expect("Failed to load configuration"); - /// Static EIP_712_DOMAIN used with config values - pub static ref EIP_712_DOMAIN: Eip712Domain = tap_eip712_domain( +/// Static configuration +pub static CONFIG: LazyLock = + LazyLock::new(|| cli::get_config().expect("Failed to load configuration")); +/// Static EIP_712_DOMAIN used with config values +pub static EIP_712_DOMAIN: LazyLock = LazyLock::new(|| { + tap_eip712_domain( CONFIG.blockchain.chain_id as u64, CONFIG.blockchain.receipts_verifier_address, - ); -} + ) +}); pub mod adaptative_concurrency; pub mod agent; diff --git a/crates/tap-agent/src/main.rs b/crates/tap-agent/src/main.rs index 3627af8ad..21a91eb6a 100644 --- a/crates/tap-agent/src/main.rs +++ b/crates/tap-agent/src/main.rs @@ -8,7 +8,9 @@ use tokio::signal::unix::{signal, SignalKind}; #[tokio::main] async fn main() -> anyhow::Result<()> { // Parse basic configurations, also initializes logging. - lazy_static::initialize(&CONFIG); + + // initialize LazyLock'd config + _ = &*CONFIG; let (manager, handler) = agent::start_agent().await; tracing::info!("TAP Agent started."); diff --git a/crates/tap-agent/src/tap/context/receipt.rs b/crates/tap-agent/src/tap/context/receipt.rs index 99e4eef15..56ea90808 100644 --- a/crates/tap-agent/src/tap/context/receipt.rs +++ b/crates/tap-agent/src/tap/context/receipt.rs @@ -385,11 +385,11 @@ mod test { collections::{Bound, HashMap}, ops::RangeBounds, str::FromStr, + sync::LazyLock, }; use bigdecimal::{num_bigint::ToBigInt, ToPrimitive}; use indexer_monitor::EscrowAccounts; - use lazy_static::lazy_static; use rstest::{fixture, rstest}; use sqlx::PgPool; use tap_core::{ @@ -411,9 +411,8 @@ mod test { const ALLOCATION_ID_IRRELEVANT: Address = ALLOCATION_ID_1; - lazy_static! { - static ref SENDER_IRRELEVANT: (PrivateKeySigner, Address) = SENDER_2.clone(); - } + static SENDER_IRRELEVANT: LazyLock<(PrivateKeySigner, Address)> = + LazyLock::new(|| SENDER_2.clone()); #[fixture] fn escrow_accounts() -> Receiver { diff --git a/crates/tap-agent/src/test.rs b/crates/tap-agent/src/test.rs index 372576f72..e313f0990 100644 --- a/crates/tap-agent/src/test.rs +++ b/crates/tap-agent/src/test.rs @@ -5,6 +5,7 @@ use std::{ collections::{HashMap, HashSet}, net::SocketAddr, + sync::LazyLock, time::Duration, }; @@ -13,7 +14,6 @@ use anyhow::anyhow; use bigdecimal::num_bigint::BigInt; use indexer_monitor::{DeploymentDetails, EscrowAccounts, SubgraphClient}; use indexer_receipt::TapReceipt; -use lazy_static::lazy_static; use ractor::{concurrency::JoinHandle, Actor, ActorRef}; use rand::{distributions::Alphanumeric, thread_rng, Rng}; use reqwest::Url; @@ -52,13 +52,11 @@ use crate::{ }, }; -lazy_static! { - // pub static ref SENDER: (PrivateKeySigner, Address) = wallet(0); - pub static ref SENDER_2: (PrivateKeySigner, Address) = wallet(1); - pub static ref INDEXER: (PrivateKeySigner, Address) = wallet(3); - pub static ref TAP_EIP712_DOMAIN_SEPARATOR: Eip712Domain = - tap_eip712_domain(1, Address::from([0x11u8; 20]),); -} +// pub static ref SENDER: (PrivateKeySigner, Address) = wallet(0); +pub static SENDER_2: LazyLock<(PrivateKeySigner, Address)> = LazyLock::new(|| wallet(1)); +pub static INDEXER: LazyLock<(PrivateKeySigner, Address)> = LazyLock::new(|| wallet(3)); +pub static TAP_EIP712_DOMAIN_SEPARATOR: LazyLock = + LazyLock::new(|| tap_eip712_domain(1, Address::from([0x11u8; 20]))); pub const TRIGGER_VALUE: u128 = 500; pub const RECEIPT_LIMIT: u64 = 10000; diff --git a/crates/test-assets/Cargo.toml b/crates/test-assets/Cargo.toml index 5951bfee3..c2e89f698 100644 --- a/crates/test-assets/Cargo.toml +++ b/crates/test-assets/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [dependencies] indexer-allocation = { path = "../allocation" } bip39 = "2.0.0" -lazy_static.workspace = true tap_core.workspace = true tap_graph.workspace = true thegraph-core.workspace = true @@ -14,4 +13,4 @@ bon.workspace = true sqlx.workspace = true tokio.workspace = true rstest = "0.24.0" -stdext = "0.3.3" \ No newline at end of file +stdext = "0.3.3" diff --git a/crates/test-assets/src/lib.rs b/crates/test-assets/src/lib.rs index b3037f202..729569170 100644 --- a/crates/test-assets/src/lib.rs +++ b/crates/test-assets/src/lib.rs @@ -6,12 +6,12 @@ use std::{ future::Future, pin::Pin, str::FromStr, + sync::LazyLock, time::{Duration, SystemTime, UNIX_EPOCH}, }; use bip39::Mnemonic; use indexer_allocation::{Allocation, AllocationStatus, SubgraphDeployment}; -use lazy_static::lazy_static; use sqlx::{migrate, PgPool, Postgres}; use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain}; use tap_graph::{Receipt, SignedReceipt}; @@ -133,14 +133,16 @@ pub const ALLOCATION_ID_3: Address = address!("69f961358846fdb64b04e1fd7b2701237 pub const VERIFIER_ADDRESS: Address = address!("1111111111111111111111111111111111111111"); -lazy_static! { - pub static ref INDEXER_MNEMONIC: Mnemonic = Mnemonic::from_str( - "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", - ).unwrap(); +pub static INDEXER_MNEMONIC: LazyLock = LazyLock::new(|| { + Mnemonic::from_str( + "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", +).unwrap() +}); - /// These are the expected json-serialized contents of the value returned by - /// AllocationMonitor::current_eligible_allocations with the values above at epoch threshold 940. - pub static ref INDEXER_ALLOCATIONS: HashMap = HashMap::from([ +/// These are the expected json-serialized contents of the value returned by +/// AllocationMonitor::current_eligible_allocations with the values above at epoch threshold 940. +pub static INDEXER_ALLOCATIONS: LazyLock> = LazyLock::new(|| { + HashMap::from([ ( ALLOCATION_ID_0, Allocation { @@ -153,8 +155,9 @@ lazy_static! { closed_at_epoch: None, subgraph_deployment: SubgraphDeployment { id: DeploymentId::from_str( - "0xbbde25a2c85f55b53b7698b9476610c3d1202d88870e66502ab0076b7218f98a" - ).unwrap(), + "0xbbde25a2c85f55b53b7698b9476610c3d1202d88870e66502ab0076b7218f98a", + ) + .unwrap(), denied_at: Some(0), }, status: AllocationStatus::Null, @@ -177,8 +180,9 @@ lazy_static! { closed_at_epoch: None, subgraph_deployment: SubgraphDeployment { id: DeploymentId::from_str( - "0xcda7fa0405d6fd10721ed13d18823d24b535060d8ff661f862b26c23334f13bf" - ).unwrap(), + "0xcda7fa0405d6fd10721ed13d18823d24b535060d8ff661f862b26c23334f13bf", + ) + .unwrap(), denied_at: Some(0), }, status: AllocationStatus::Null, @@ -201,8 +205,9 @@ lazy_static! { closed_at_epoch: Some(953), subgraph_deployment: SubgraphDeployment { id: DeploymentId::from_str( - "0xbbde25a2c85f55b53b7698b9476610c3d1202d88870e66502ab0076b7218f98a" - ).unwrap(), + "0xbbde25a2c85f55b53b7698b9476610c3d1202d88870e66502ab0076b7218f98a", + ) + .unwrap(), denied_at: Some(0), }, status: AllocationStatus::Null, @@ -225,8 +230,9 @@ lazy_static! { closed_at_epoch: Some(953), subgraph_deployment: SubgraphDeployment { id: DeploymentId::from_str( - "0xc064c354bc21dd958b1d41b67b8ef161b75d2246b425f68ed4c74964ae705cbd" - ).unwrap(), + "0xc064c354bc21dd958b1d41b67b8ef161b75d2246b425f68ed4c74964ae705cbd", + ) + .unwrap(), denied_at: Some(0), }, status: AllocationStatus::Null, @@ -237,80 +243,89 @@ lazy_static! { query_fees_collected: None, }, ), - ]); + ]) +}); - pub static ref ESCROW_ACCOUNTS_BALANCES: HashMap = HashMap::from([ - (address!("9858EfFD232B4033E47d90003D41EC34EcaEda94"), U256::from(24)), // TAP_SENDER - (address!("22d491bde2303f2f43325b2108d26f1eaba1e32b"), U256::from(42)), - (address!("192c3B6e0184Fa0Cc5B9D2bDDEb6B79Fb216a002"), U256::from(2975)), - ]); - - - /// Maps signers back to their senders - pub static ref ESCROW_ACCOUNTS_SIGNERS_TO_SENDERS: HashMap = HashMap::from([ +pub static ESCROW_ACCOUNTS_BALANCES: LazyLock> = LazyLock::new(|| { + HashMap::from([ ( - address!("533661F0fb14d2E8B26223C86a610Dd7D2260892"), // TAP_SIGNER - address!("9858EfFD232B4033E47d90003D41EC34EcaEda94"), // TAP_SENDER - ), + address!("9858EfFD232B4033E47d90003D41EC34EcaEda94"), + U256::from(24), + ), // TAP_SENDER ( - address!("2740f6fA9188cF53ffB6729DDD21575721dE92ce"), - address!("9858EfFD232B4033E47d90003D41EC34EcaEda94"), // TAP_SENDER - ), - ( - address!("245059163ff6ee14279aa7b35ea8f0fdb967df6e"), address!("22d491bde2303f2f43325b2108d26f1eaba1e32b"), - ), - ]); - - - pub static ref ESCROW_ACCOUNTS_SENDERS_TO_SIGNERS: HashMap> = HashMap::from([ - ( - address!("9858EfFD232B4033E47d90003D41EC34EcaEda94"), // TAP_SENDER - vec![ - address!("533661F0fb14d2E8B26223C86a610Dd7D2260892"), // TAP_SIGNER - address!("2740f6fA9188cF53ffB6729DDD21575721dE92ce"), - ], - ), - ( - address!("22d491bde2303f2f43325b2108d26f1eaba1e32b"), - vec![address!("245059163ff6ee14279aa7b35ea8f0fdb967df6e")], + U256::from(42), ), ( address!("192c3B6e0184Fa0Cc5B9D2bDDEb6B79Fb216a002"), - vec![], + U256::from(2975), ), - ]); - - - /// 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, - VERIFIER_ADDRESS - ); -} + ]) +}); + +/// Maps signers back to their senders +pub static ESCROW_ACCOUNTS_SIGNERS_TO_SENDERS: LazyLock> = + LazyLock::new(|| { + HashMap::from([ + ( + address!("533661F0fb14d2E8B26223C86a610Dd7D2260892"), // TAP_SIGNER + address!("9858EfFD232B4033E47d90003D41EC34EcaEda94"), // TAP_SENDER + ), + ( + address!("2740f6fA9188cF53ffB6729DDD21575721dE92ce"), + address!("9858EfFD232B4033E47d90003D41EC34EcaEda94"), // TAP_SENDER + ), + ( + address!("245059163ff6ee14279aa7b35ea8f0fdb967df6e"), + address!("22d491bde2303f2f43325b2108d26f1eaba1e32b"), + ), + ]) + }); + +pub static ESCROW_ACCOUNTS_SENDERS_TO_SIGNERS: LazyLock>> = + LazyLock::new(|| { + HashMap::from([ + ( + address!("9858EfFD232B4033E47d90003D41EC34EcaEda94"), // TAP_SENDER + vec![ + address!("533661F0fb14d2E8B26223C86a610Dd7D2260892"), // TAP_SIGNER + address!("2740f6fA9188cF53ffB6729DDD21575721dE92ce"), + ], + ), + ( + address!("22d491bde2303f2f43325b2108d26f1eaba1e32b"), + vec![address!("245059163ff6ee14279aa7b35ea8f0fdb967df6e")], + ), + (address!("192c3B6e0184Fa0Cc5B9D2bDDEb6B79Fb216a002"), vec![]), + ]) + }); + +/// Fixture to generate a wallet and address. +/// Address: 0x9858EfFD232B4033E47d90003D41EC34EcaEda94 +pub static TAP_SENDER: LazyLock<(PrivateKeySigner, Address)> = LazyLock::new(|| { + 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 TAP_SIGNER: LazyLock<(PrivateKeySigner, Address)> = LazyLock::new(|| { + 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 TAP_EIP712_DOMAIN: LazyLock = + LazyLock::new(|| tap_eip712_domain(1, VERIFIER_ADDRESS)); #[derive(bon::Builder)] pub struct SignedReceiptRequest {