From fbecf74610b7b9b0443a1c50ba319b5bb59b8947 Mon Sep 17 00:00:00 2001 From: Gustavo Inacio Date: Thu, 1 Aug 2024 17:44:24 -0300 Subject: [PATCH] refactor(all): bump tap-core to 1.0.0 Signed-off-by: Gustavo Inacio --- Cargo.lock | 31 ++----------------- common/Cargo.toml | 8 +++-- .../indexer_service/http/indexer_service.rs | 4 +-- common/src/tap/checks/allocation_eligible.rs | 3 +- common/src/tap/checks/deny_list_check.rs | 3 +- .../src/tap/checks/receipt_max_val_check.rs | 5 +-- common/src/tap/checks/sender_balance_check.rs | 3 +- common/src/tap/checks/timestamp_check.rs | 5 +-- common/src/tap/receipt_store.rs | 2 +- tap-agent/Cargo.toml | 4 +-- tap-agent/src/agent/sender_allocation.rs | 20 +++++++----- .../src/tap/context/checks/allocation_id.rs | 3 +- tap-agent/src/tap/context/checks/signature.rs | 3 +- tap-agent/src/tap/context/checks/value.rs | 3 +- tap-agent/src/tap/context/receipt.rs | 2 +- tap-agent/src/tap/test_utils.rs | 2 +- 16 files changed, 47 insertions(+), 54 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 677538d0..e531e0ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3149,7 +3149,7 @@ dependencies = [ "serde", "serde_json", "sqlx", - "tap_core 0.8.0", + "tap_core", "test-log", "thegraph", "thegraph-core", @@ -3213,7 +3213,7 @@ dependencies = [ "serde_yaml", "sqlx", "tap_aggregator", - "tap_core 0.8.0", + "tap_core", "tempfile", "thegraph", "thiserror", @@ -6436,36 +6436,11 @@ dependencies = [ "serde", "serde_json", "strum 0.24.1", - "tap_core 1.0.0", + "tap_core", "tokio", "tracing-subscriber", ] -[[package]] -name = "tap_core" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad526409d342a57c965a18f6a9138f999b12ca5d0529c198f8ae4a2395b0561" -dependencies = [ - "alloy-primitives 0.6.4", - "alloy-sol-types 0.6.4", - "anyhow", - "async-trait", - "ethereum-types", - "ethers", - "ethers-contract", - "ethers-contract-derive", - "ethers-core", - "rand 0.8.5", - "rand_core 0.6.4", - "rstest", - "serde", - "strum 0.24.1", - "strum_macros 0.24.3", - "thiserror", - "tokio", -] - [[package]] name = "tap_core" version = "1.0.0" diff --git a/common/Cargo.toml b/common/Cargo.toml index eaabc49a..2c708772 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -31,7 +31,7 @@ thegraph = { git = "https://github.com/edgeandnode/toolshed", tag = "thegraph-v0 thegraph-graphql-http = { version = "0.2.1", features = [ "http-client-reqwest", ] } -tap_core = "0.8.0" +tap_core = "1.0.0" axum = { version = "0.7.5", default_features = true } axum-extra = { version = "0.9.3", features = ["typed-header"] } thiserror = "1.0.49" @@ -40,7 +40,11 @@ build-info = "0.0.34" autometrics = { version = "1.0.1", features = ["prometheus-exporter"] } tracing = "0.1.40" tower_governor = "0.3.2" -tower-http = { version = "0.5.2", features = ["trace", "cors", "normalize-path"] } +tower-http = { version = "0.5.2", features = [ + "trace", + "cors", + "normalize-path", +] } tokio-util = "0.7.10" bigdecimal = "0.4.2" thegraph-core = { version = "0.5.2", features = ["subgraph-client"] } diff --git a/common/src/indexer_service/http/indexer_service.rs b/common/src/indexer_service/http/indexer_service.rs index 8ab7941a..0e203ed0 100644 --- a/common/src/indexer_service/http/indexer_service.rs +++ b/common/src/indexer_service/http/indexer_service.rs @@ -24,7 +24,7 @@ use eventuals::Eventual; use reqwest::StatusCode; use serde::{de::DeserializeOwned, Serialize}; use sqlx::postgres::PgPoolOptions; -use tap_core::{manager::Manager, receipt::checks::Checks}; +use tap_core::{manager::Manager, receipt::checks::CheckList}; use thegraph::types::Address; use thegraph::types::{Attestation, DeploymentId}; use thiserror::Error; @@ -306,7 +306,7 @@ impl IndexerService { ) .await; - let tap_manager = Manager::new(domain_separator, indexer_context, Checks::new(checks)); + let tap_manager = Manager::new(domain_separator, indexer_context, CheckList::new(checks)); let state = Arc::new(IndexerServiceState { config: options.config.clone(), diff --git a/common/src/tap/checks/allocation_eligible.rs b/common/src/tap/checks/allocation_eligible.rs index f6980b26..07f7606b 100644 --- a/common/src/tap/checks/allocation_eligible.rs +++ b/common/src/tap/checks/allocation_eligible.rs @@ -9,7 +9,8 @@ use eventuals::Eventual; use tap_core::receipt::{ checks::{Check, CheckResult}, - Checking, ReceiptWithState, + state::Checking, + ReceiptWithState, }; use crate::prelude::Allocation; diff --git a/common/src/tap/checks/deny_list_check.rs b/common/src/tap/checks/deny_list_check.rs index 0fe21cca..6aae7bcd 100644 --- a/common/src/tap/checks/deny_list_check.rs +++ b/common/src/tap/checks/deny_list_check.rs @@ -11,7 +11,8 @@ use std::sync::RwLock; use std::{str::FromStr, sync::Arc}; use tap_core::receipt::{ checks::{Check, CheckResult}, - Checking, ReceiptWithState, + state::Checking, + ReceiptWithState, }; use thegraph::types::Address; use tracing::error; diff --git a/common/src/tap/checks/receipt_max_val_check.rs b/common/src/tap/checks/receipt_max_val_check.rs index 1baf1d37..63a446b8 100644 --- a/common/src/tap/checks/receipt_max_val_check.rs +++ b/common/src/tap/checks/receipt_max_val_check.rs @@ -8,7 +8,8 @@ pub struct ReceiptMaxValueCheck { use tap_core::receipt::{ checks::{Check, CheckResult}, - Checking, ReceiptWithState, + state::Checking, + ReceiptWithState, }; impl ReceiptMaxValueCheck { @@ -47,7 +48,7 @@ mod tests { use super::*; use tap_core::{ - receipt::{checks::Check, Checking, Receipt, ReceiptWithState}, + receipt::{checks::Check, state::Checking, Receipt, ReceiptWithState}, signed_message::EIP712SignedMessage, }; diff --git a/common/src/tap/checks/sender_balance_check.rs b/common/src/tap/checks/sender_balance_check.rs index 22903bdb..d00e2796 100644 --- a/common/src/tap/checks/sender_balance_check.rs +++ b/common/src/tap/checks/sender_balance_check.rs @@ -8,7 +8,8 @@ use ethers_core::types::U256; use eventuals::Eventual; use tap_core::receipt::{ checks::{Check, CheckResult}, - Checking, ReceiptWithState, + state::Checking, + ReceiptWithState, }; use tracing::error; diff --git a/common/src/tap/checks/timestamp_check.rs b/common/src/tap/checks/timestamp_check.rs index 76fd5026..1580415a 100644 --- a/common/src/tap/checks/timestamp_check.rs +++ b/common/src/tap/checks/timestamp_check.rs @@ -9,7 +9,8 @@ pub struct TimestampCheck { use tap_core::receipt::{ checks::{Check, CheckResult}, - Checking, ReceiptWithState, + state::Checking, + ReceiptWithState, }; impl TimestampCheck { @@ -52,7 +53,7 @@ mod tests { use super::*; use tap_core::{ - receipt::{checks::Check, Checking, Receipt, ReceiptWithState}, + receipt::{checks::Check, state::Checking, Receipt, ReceiptWithState}, signed_message::EIP712SignedMessage, }; diff --git a/common/src/tap/receipt_store.rs b/common/src/tap/receipt_store.rs index 742b2f7c..200f2999 100644 --- a/common/src/tap/receipt_store.rs +++ b/common/src/tap/receipt_store.rs @@ -7,7 +7,7 @@ use bigdecimal::num_bigint::BigInt; use sqlx::types::BigDecimal; use tap_core::{ manager::adapters::ReceiptStore, - receipt::{Checking, ReceiptWithState}, + receipt::{state::Checking, ReceiptWithState}, }; use tracing::error; diff --git a/tap-agent/Cargo.toml b/tap-agent/Cargo.toml index b668c534..36b4f132 100644 --- a/tap-agent/Cargo.toml +++ b/tap-agent/Cargo.toml @@ -36,8 +36,8 @@ sqlx = { version = "0.7.2", features = [ "rust_decimal", "chrono", ] } -tap_aggregator = "0.3.0" -tap_core = "0.8.0" +tap_aggregator = "0.3.1" +tap_core = "1.0.0" thiserror = "1.0.44" tokio = { version = "1.33.0" } thegraph = { git = "https://github.com/edgeandnode/toolshed", tag = "thegraph-v0.5.0" } diff --git a/tap-agent/src/agent/sender_allocation.rs b/tap-agent/src/agent/sender_allocation.rs index 77a593c4..ec79c264 100644 --- a/tap-agent/src/agent/sender_allocation.rs +++ b/tap-agent/src/agent/sender_allocation.rs @@ -24,8 +24,9 @@ use tap_core::{ manager::adapters::RAVRead, rav::{RAVRequest, ReceiptAggregateVoucher, SignedRAV}, receipt::{ - checks::{Check, Checks}, - Failed, ReceiptWithState, + checks::{Check, CheckList}, + state::Failed, + ReceiptWithState, }, signed_message::EIP712SignedMessage, }; @@ -331,7 +332,7 @@ impl SenderAllocationState { let tap_manager = TapManager::new( domain_separator.clone(), context, - Checks::new(required_checks), + CheckList::new(required_checks), ); let http_client = HttpClientBuilder::default() @@ -508,6 +509,10 @@ impl SenderAllocationState { ), _ => e.into(), })?; + let valid_receipts: Vec<_> = valid_receipts + .into_iter() + .map(|r| r.signed_receipt().clone()) + .collect(); let rav_response_time_start = Instant::now(); let response: JsonRpcResponse> = self .http_client @@ -763,8 +768,9 @@ pub mod tests { }; use tap_aggregator::{jsonrpsee_helpers::JsonRpcResponse, server::run_server}; use tap_core::receipt::{ - checks::{Check, Checks}, - Checking, ReceiptWithState, + checks::{Check, CheckList}, + state::Checking, + ReceiptWithState, }; use wiremock::{ matchers::{body_string_contains, method}, @@ -1348,7 +1354,7 @@ pub mod tests { .await; let mut state = SenderAllocationState::new(args).await.unwrap(); - let checks = Checks::new(vec![Arc::new(FailingCheck)]); + let checks = CheckList::new(vec![Arc::new(FailingCheck)]); // create some checks let checking_receipts = vec![ @@ -1360,7 +1366,7 @@ pub mod tests { .into_iter() .map(|receipt| async { receipt.finalize_receipt_checks(&checks).await.unwrap_err() }) .collect::>(); - let failing_receipts = join_all(failing_receipts).await; + let failing_receipts: Vec<_> = join_all(failing_receipts).await; // store the failing receipts let result = state.store_invalid_receipts(&failing_receipts).await; diff --git a/tap-agent/src/tap/context/checks/allocation_id.rs b/tap-agent/src/tap/context/checks/allocation_id.rs index f364a868..273d5456 100644 --- a/tap-agent/src/tap/context/checks/allocation_id.rs +++ b/tap-agent/src/tap/context/checks/allocation_id.rs @@ -9,7 +9,8 @@ use eventuals::{Eventual, EventualExt}; use indexer_common::subgraph_client::{Query, SubgraphClient}; use tap_core::receipt::{ checks::{Check, CheckResult}, - Checking, ReceiptWithState, + state::Checking, + ReceiptWithState, }; use tokio::time::sleep; use tracing::error; diff --git a/tap-agent/src/tap/context/checks/signature.rs b/tap-agent/src/tap/context/checks/signature.rs index 1ebbaf5b..0641b679 100644 --- a/tap-agent/src/tap/context/checks/signature.rs +++ b/tap-agent/src/tap/context/checks/signature.rs @@ -8,7 +8,8 @@ use eventuals::Eventual; use indexer_common::escrow_accounts::EscrowAccounts; use tap_core::receipt::{ checks::{Check, CheckResult}, - Checking, ReceiptWithState, + state::Checking, + ReceiptWithState, }; use crate::tap::context::error::AdapterError; diff --git a/tap-agent/src/tap/context/checks/value.rs b/tap-agent/src/tap/context/checks/value.rs index f4d928cd..01dad389 100644 --- a/tap-agent/src/tap/context/checks/value.rs +++ b/tap-agent/src/tap/context/checks/value.rs @@ -10,7 +10,8 @@ use anyhow::anyhow; use tap_core::{ receipt::{ checks::{Check, CheckResult}, - Checking, ReceiptWithState, + state::Checking, + ReceiptWithState, }, signed_message::MessageId, }; diff --git a/tap-agent/src/tap/context/receipt.rs b/tap-agent/src/tap/context/receipt.rs index c6f87844..88cf5ead 100644 --- a/tap-agent/src/tap/context/receipt.rs +++ b/tap-agent/src/tap/context/receipt.rs @@ -12,7 +12,7 @@ use bigdecimal::{num_bigint::ToBigInt, ToPrimitive}; use sqlx::{postgres::types::PgRange, types::BigDecimal}; use tap_core::{ manager::adapters::{safe_truncate_receipts, ReceiptDelete, ReceiptRead}, - receipt::{Checking, Receipt, ReceiptWithState, SignedReceipt}, + receipt::{state::Checking, Receipt, ReceiptWithState, SignedReceipt}, }; use thegraph::types::Address; diff --git a/tap-agent/src/tap/test_utils.rs b/tap-agent/src/tap/test_utils.rs index ecb7966d..47bc6e4e 100644 --- a/tap-agent/src/tap/test_utils.rs +++ b/tap-agent/src/tap/test_utils.rs @@ -14,7 +14,7 @@ use lazy_static::lazy_static; use sqlx::PgPool; use tap_core::{ rav::{ReceiptAggregateVoucher, SignedRAV}, - receipt::{Checking, Receipt, ReceiptWithState, SignedReceipt}, + receipt::{state::Checking, Receipt, ReceiptWithState, SignedReceipt}, signed_message::EIP712SignedMessage, }; use thegraph::types::Address;