Skip to content

Commit 236fefe

Browse files
authored
chore: bump tap_core to v3 (#592)
* chore: bump tap_core to v3 Signed-off-by: Gustavo Inacio <[email protected]> * refactor: rename TriggerRAVRequest to TriggerRavRequest Signed-off-by: Gustavo Inacio <[email protected]> --------- Signed-off-by: Gustavo Inacio <[email protected]>
1 parent 0e34f19 commit 236fefe

32 files changed

+352
-388
lines changed

Cargo.lock

Lines changed: 158 additions & 110 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,23 @@ uuid = { version = "1.11.0", features = ["v7"] }
5252
tracing = { version = "0.1.40", default-features = false }
5353
bigdecimal = "0.4.3"
5454
build-info = "0.0.39"
55-
tap_core = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", rev = "6af1add", default-features = false }
56-
tap_aggregator = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", rev = "6af1add", default-features = false }
55+
tap_core = { version = "3.0.0", default-features = false }
56+
tap_aggregator = { version = "0.4.0", default-features = false }
57+
tap_graph = { version = "0.1.0", default-features = false }
5758
tracing-subscriber = { version = "0.3", features = [
5859
"json",
5960
"env-filter",
6061
"ansi",
6162
], default-features = false }
62-
thegraph-core = { version = "0.10.0", features = [
63+
thegraph-core = { version = "0.11.0", features = [
6364
"attestation",
6465
"alloy-eip712",
6566
"alloy-sol-types",
6667
"alloy-rlp",
6768
"alloy-signers",
6869
"alloy-signer-local",
6970
"alloy-signer-mnemonic",
70-
"serde"
71+
"serde",
7172
] }
7273
thegraph-graphql-http = { version = "0.3.2", features = ["reqwest"] }
7374
graphql_client = { version = "0.14.0", features = ["reqwest-rustls"] }

crates/service/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ async-graphql-axum = "7.0.11"
3737
base64.workspace = true
3838
graphql = { git = "https://github.com/edgeandnode/toolshed", tag = "graphql-v0.3.0" }
3939
tap_core.workspace = true
40+
tap_graph.workspace = true
4041
uuid.workspace = true
4142
typed-builder.workspace = true
4243
tower_governor = { version = "0.5.0", features = ["axum"] }

crates/service/src/error.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ pub enum IndexerServiceError {
2929

3030
#[error("Issues with provided receipt: {0}")]
3131
TapCoreError(#[from] tap_core::Error),
32+
33+
#[error("Issues with provided receipt: {0}")]
34+
Eip712Error(#[from] tap_core::signed_message::Eip712Error),
35+
3236
#[error("There was an error while accessing escrow account: {0}")]
3337
EscrowAccount(#[from] EscrowAccountsError),
3438
}
@@ -38,13 +42,13 @@ impl StatusCodeExt for IndexerServiceError {
3842
use IndexerServiceError as E;
3943
match &self {
4044
E::TapCoreError(ref error) => match error {
41-
TapError::SignatureError(_)
42-
| TapError::ReceiptError(ReceiptError::CheckFailure(_)) => StatusCode::BAD_REQUEST,
45+
TapError::ReceiptError(ReceiptError::CheckFailure(_)) => StatusCode::BAD_REQUEST,
4346
_ => StatusCode::INTERNAL_SERVER_ERROR,
4447
},
4548
E::EscrowAccount(_) | E::ReceiptNotFound => StatusCode::PAYMENT_REQUIRED,
4649
E::DeploymentIdNotFound => StatusCode::INTERNAL_SERVER_ERROR,
4750
E::AxumError(_) | E::SerializationError(_) => StatusCode::BAD_GATEWAY,
51+
E::Eip712Error(_) => StatusCode::BAD_REQUEST,
4852
}
4953
}
5054
}

crates/service/src/middleware/allocation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use axum::{
88
middleware::Next,
99
response::Response,
1010
};
11-
use tap_core::receipt::SignedReceipt;
11+
use tap_graph::SignedReceipt;
1212
use thegraph_core::{alloy::primitives::Address, DeploymentId};
1313
use tokio::sync::watch;
1414

crates/service/src/middleware/auth/tap.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ use axum::{
1818
};
1919
use tap_core::{
2020
manager::{adapters::ReceiptStore, Manager},
21-
receipt::{Context, SignedReceipt},
21+
receipt::Context,
2222
};
23+
use tap_graph::{ReceiptAggregateVoucher, SignedReceipt};
2324
use tower_http::auth::AsyncAuthorizeRequest;
2425

2526
use crate::{error::IndexerServiceError, middleware::prometheus_metrics::MetricLabels};
@@ -30,7 +31,7 @@ use crate::{error::IndexerServiceError, middleware::prometheus_metrics::MetricLa
3031
///
3132
/// Requires SignedReceipt, MetricLabels and Arc<Context> extensions
3233
pub fn tap_receipt_authorize<T, B>(
33-
tap_manager: Arc<Manager<T>>,
34+
tap_manager: Arc<Manager<T, SignedReceipt, ReceiptAggregateVoucher>>,
3435
failed_receipt_metric: &'static prometheus::CounterVec,
3536
) -> impl AsyncAuthorizeRequest<
3637
B,
@@ -40,7 +41,7 @@ pub fn tap_receipt_authorize<T, B>(
4041
> + Clone
4142
+ Send
4243
where
43-
T: ReceiptStore + Sync + Send + 'static,
44+
T: ReceiptStore<SignedReceipt> + Sync + Send + 'static,
4445
B: Send,
4546
{
4647
move |request: Request<B>| {
@@ -88,12 +89,9 @@ mod tests {
8889
use sqlx::PgPool;
8990
use tap_core::{
9091
manager::Manager,
91-
receipt::{
92-
checks::{Check, CheckError, CheckList, CheckResult},
93-
state::Checking,
94-
ReceiptWithState,
95-
},
92+
receipt::checks::{Check, CheckError, CheckList, CheckResult},
9693
};
94+
use tap_graph::SignedReceipt;
9795
use test_assets::{
9896
assert_while_retry, create_signed_receipt, SignedReceiptRequest, TAP_EIP712_DOMAIN,
9997
};
@@ -105,7 +103,7 @@ mod tests {
105103
auth::tap_receipt_authorize,
106104
prometheus_metrics::{MetricLabelProvider, MetricLabels},
107105
},
108-
tap::IndexerTapContext,
106+
tap::{CheckingReceipt, IndexerTapContext},
109107
};
110108

111109
#[fixture]
@@ -133,11 +131,11 @@ mod tests {
133131

134132
struct MyCheck;
135133
#[async_trait::async_trait]
136-
impl Check for MyCheck {
134+
impl Check<SignedReceipt> for MyCheck {
137135
async fn check(
138136
&self,
139137
_: &tap_core::receipt::Context,
140-
receipt: &ReceiptWithState<Checking>,
138+
receipt: &CheckingReceipt,
141139
) -> CheckResult {
142140
if receipt.signed_receipt().message.nonce == FAILED_NONCE {
143141
Err(CheckError::Failed(anyhow::anyhow!("Failed")))

crates/service/src/middleware/sender.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use axum::{
77
response::Response,
88
};
99
use indexer_monitor::EscrowAccounts;
10-
use tap_core::receipt::SignedReceipt;
10+
use tap_graph::SignedReceipt;
1111
use thegraph_core::alloy::{primitives::Address, sol_types::Eip712Domain};
1212
use tokio::sync::watch;
1313

crates/service/src/middleware/tap_receipt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ mod tests {
3333
};
3434
use axum_extra::headers::Header;
3535
use reqwest::StatusCode;
36-
use tap_core::receipt::SignedReceipt;
36+
use tap_graph::SignedReceipt;
3737
use test_assets::{create_signed_receipt, SignedReceiptRequest};
3838
use tower::ServiceExt;
3939

crates/service/src/service/tap_receipt_header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use axum_extra::headers::{self, Header, HeaderName, HeaderValue};
55
use lazy_static::lazy_static;
66
use prometheus::{register_counter, Counter};
7-
use tap_core::receipt::SignedReceipt;
7+
use tap_graph::SignedReceipt;
88

99
#[derive(Debug, PartialEq)]
1010
pub struct TapReceipt(pub SignedReceipt);

crates/service/src/tap.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use indexer_allocation::Allocation;
77
use indexer_monitor::EscrowAccounts;
88
use receipt_store::{DatabaseReceipt, InnerContext};
99
use sqlx::PgPool;
10-
use tap_core::receipt::checks::ReceiptCheck;
10+
use tap_core::receipt::{checks::ReceiptCheck, state::Checking, ReceiptWithState};
11+
use tap_graph::SignedReceipt;
1112
use thegraph_core::alloy::{primitives::Address, sol_types::Eip712Domain};
1213
use tokio::sync::{
1314
mpsc::{self, Sender},
@@ -26,6 +27,8 @@ mod receipt_store;
2627

2728
pub use checks::value_check::AgoraQuery;
2829

30+
pub type CheckingReceipt = ReceiptWithState<Checking, SignedReceipt>;
31+
2932
const GRACE_PERIOD: u64 = 60;
3033

3134
#[derive(Clone)]
@@ -48,7 +51,7 @@ impl IndexerTapContext {
4851
escrow_accounts: Receiver<EscrowAccounts>,
4952
timestamp_error_tolerance: Duration,
5053
receipt_max_value: u128,
51-
) -> Vec<ReceiptCheck> {
54+
) -> Vec<ReceiptCheck<SignedReceipt>> {
5255
vec![
5356
Arc::new(AllocationEligible::new(indexer_allocations)),
5457
Arc::new(SenderBalanceCheck::new(escrow_accounts)),

0 commit comments

Comments
 (0)