From 73bb550f60d3f0d8aebc3e26aaf5862df092a98e Mon Sep 17 00:00:00 2001 From: Joseph Livesey Date: Sat, 16 Aug 2025 20:15:34 -0400 Subject: [PATCH 1/3] feat: make domain version injectable Signed-off-by: Joseph Livesey --- Cargo.toml | 1 + tap_aggregator/Cargo.toml | 2 +- tap_aggregator/src/aggregator/v1.rs | 4 +-- tap_aggregator/src/aggregator/v2.rs | 4 +-- tap_aggregator/src/main.rs | 9 ++++++- tap_aggregator/src/server.rs | 4 +-- tap_aggregator/tests/aggregate_test.rs | 4 +-- tap_aggregator/tests/aggregate_v1_and_v2.rs | 4 +-- tap_core/src/lib.rs | 30 +++++++++++++++++---- tap_core/tests/manager_test.rs | 4 +-- tap_core/tests/rav_test.rs | 4 +-- tap_core/tests/receipt_test.rs | 4 +-- tap_core/tests/received_receipt_test.rs | 4 +-- tap_integration_tests/tests/showcase.rs | 4 +-- 14 files changed, 55 insertions(+), 27 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c0cf1468..2adb4a66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,6 +55,7 @@ thiserror = "2.0.12" tokio = { version = "1.44.2", features = ["macros", "signal"] } tonic = { version = "0.14.1", features = ["transport", "zstd"] } tonic-build = "0.14.1" +tonic-prost = "0.14.1" tonic-prost-build = "0.14.1" tower = { version = "0.5.2", features = ["util", "steer"] } tracing-subscriber = "0.3.19" diff --git a/tap_aggregator/Cargo.toml b/tap_aggregator/Cargo.toml index 3cb871e1..461df847 100644 --- a/tap_aggregator/Cargo.toml +++ b/tap_aggregator/Cargo.toml @@ -36,7 +36,7 @@ tap_graph.workspace = true thegraph-core = { workspace = true, features = ["alloy-eip712"] } tokio.workspace = true tonic.workspace = true -tonic-prost = "0.14.1" +tonic-prost.workspace = true tower = { workspace = true, features = ["util", "steer", "limit"] } tracing-subscriber.workspace = true diff --git a/tap_aggregator/src/aggregator/v1.rs b/tap_aggregator/src/aggregator/v1.rs index c7556a57..fa9e5e7a 100644 --- a/tap_aggregator/src/aggregator/v1.rs +++ b/tap_aggregator/src/aggregator/v1.rs @@ -133,7 +133,7 @@ mod tests { use std::str::FromStr; use rstest::*; - use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain}; + use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain, TapVersion}; use tap_graph::{Receipt, ReceiptAggregateVoucher}; use thegraph_core::alloy::{ dyn_abi::Eip712Domain, @@ -162,7 +162,7 @@ mod tests { #[fixture] fn domain_separator() -> Eip712Domain { - tap_eip712_domain(1, Address::from([0x11u8; 20])) + tap_eip712_domain(1, Address::from([0x11u8; 20]), TapVersion::V1) } #[rstest] diff --git a/tap_aggregator/src/aggregator/v2.rs b/tap_aggregator/src/aggregator/v2.rs index c5f15ace..9172815d 100644 --- a/tap_aggregator/src/aggregator/v2.rs +++ b/tap_aggregator/src/aggregator/v2.rs @@ -188,7 +188,7 @@ fn check_receipt_timestamps( #[cfg(test)] mod tests { use rstest::*; - use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain}; + use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain, TapVersion}; use tap_graph::v2::{Receipt, ReceiptAggregateVoucher}; use thegraph_core::alloy::{ dyn_abi::Eip712Domain, @@ -229,7 +229,7 @@ mod tests { } #[fixture] fn domain_separator() -> Eip712Domain { - tap_eip712_domain(1, Address::from([0x11u8; 20])) + tap_eip712_domain(1, Address::from([0x11u8; 20]), TapVersion::V2) } #[rstest] diff --git a/tap_aggregator/src/main.rs b/tap_aggregator/src/main.rs index 4ab3a67b..f0cce1d2 100644 --- a/tap_aggregator/src/main.rs +++ b/tap_aggregator/src/main.rs @@ -9,7 +9,7 @@ use anyhow::Result; use clap::Parser; use log::{debug, info}; use tap_aggregator::{metrics, server}; -use tap_core::tap_eip712_domain; +use tap_core::{tap_eip712_domain, TapVersion}; use thegraph_core::alloy::{ dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner, }; @@ -163,9 +163,16 @@ fn create_eip712_domain(args: &Args) -> Result { // Transform optional strings into optional Address. let verifying_contract: Option
= args.domain_verifying_contract; + // Determine TAP version from domain_version argument + let version = match args.domain_version.as_deref() { + Some("2") => TapVersion::V2, + _ => TapVersion::V1, // Default to V1 + }; + // Create the EIP-712 domain separator. Ok(tap_eip712_domain( chain_id.unwrap_or(1), verifying_contract.unwrap_or_default(), + version, )) } diff --git a/tap_aggregator/src/server.rs b/tap_aggregator/src/server.rs index b58d1e63..0c473254 100644 --- a/tap_aggregator/src/server.rs +++ b/tap_aggregator/src/server.rs @@ -627,7 +627,7 @@ mod tests { use jsonrpsee::{core::client::ClientT, http_client::HttpClientBuilder, rpc_params}; use rstest::*; - use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain}; + use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain, TapVersion}; use tap_graph::{Receipt, ReceiptAggregateVoucher}; use thegraph_core::alloy::{ dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner, @@ -659,7 +659,7 @@ mod tests { #[fixture] fn domain_separator() -> Eip712Domain { - tap_eip712_domain(1, Address::from([0x11u8; 20])) + tap_eip712_domain(1, Address::from([0x11u8; 20]), TapVersion::V1) } #[fixture] diff --git a/tap_aggregator/tests/aggregate_test.rs b/tap_aggregator/tests/aggregate_test.rs index eced28c9..1e3b58aa 100644 --- a/tap_aggregator/tests/aggregate_test.rs +++ b/tap_aggregator/tests/aggregate_test.rs @@ -9,14 +9,14 @@ use tap_aggregator::{ jsonrpsee_helpers::JsonRpcResponse, server, }; -use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain}; +use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain, TapVersion}; use tap_graph::{Receipt, ReceiptAggregateVoucher}; use thegraph_core::alloy::{primitives::Address, signers::local::PrivateKeySigner}; use tonic::codec::CompressionEncoding; #[tokio::test] async fn aggregation_test() { - let domain_separator = tap_eip712_domain(1, Address::ZERO); + let domain_separator = tap_eip712_domain(1, Address::ZERO, TapVersion::V1); let wallet = PrivateKeySigner::random(); diff --git a/tap_aggregator/tests/aggregate_v1_and_v2.rs b/tap_aggregator/tests/aggregate_v1_and_v2.rs index 3ea4d9b2..17b2f301 100644 --- a/tap_aggregator/tests/aggregate_v1_and_v2.rs +++ b/tap_aggregator/tests/aggregate_v1_and_v2.rs @@ -10,7 +10,7 @@ use tap_aggregator::{ }, server, }; -use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain}; +use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain, TapVersion}; use tap_graph::{v2::Receipt as ReceiptV2, Receipt as ReceiptV1}; use thegraph_core::alloy::{ primitives::{address, Address, FixedBytes}, @@ -20,7 +20,7 @@ use tonic::codec::CompressionEncoding; #[tokio::test] async fn aggregation_test() { - let domain_separator = tap_eip712_domain(1, Address::ZERO); + let domain_separator = tap_eip712_domain(1, Address::ZERO, TapVersion::V2); let wallet = PrivateKeySigner::random(); diff --git a/tap_core/src/lib.rs b/tap_core/src/lib.rs index 2ec4c62f..217aa6a8 100644 --- a/tap_core/src/lib.rs +++ b/tap_core/src/lib.rs @@ -39,15 +39,35 @@ fn get_current_timestamp_u64_ns() -> Result { /// You can take a look on deployed [TAPVerfiers](https://github.com/semiotic-ai/timeline-aggregation-protocol-contracts/blob/4dc87fc616680c924b99dbaf285bdd449c777261/src/TAPVerifier.sol) /// contracts [here](https://github.com/semiotic-ai/timeline-aggregation-protocol-contracts/blob/4dc87fc616680c924b99dbaf285bdd449c777261/addresses.json) /// +/// TAP protocol version for EIP-712 domain separator +#[derive(Debug, Clone, Copy)] +pub enum TapVersion { + V1, + V2, +} + +impl TapVersion { + pub fn as_str(&self) -> &'static str { + match self { + TapVersion::V1 => "1", + TapVersion::V2 => "2", + } + } +} + /// The domain separator is defined as: /// - `name`: "TAP" -/// - `version`: "1" +/// - `version`: "1" or "2" depending on protocol version /// - `chain_id`: The chain ID of the chain where the domain separator is deployed. /// - `verifying_contract`: The address of the contract that is verifying the signature. -pub fn tap_eip712_domain(chain_id: u64, verifying_contract_address: Address) -> Eip712Domain { +pub fn tap_eip712_domain( + chain_id: u64, + verifying_contract_address: Address, + version: TapVersion, +) -> Eip712Domain { eip712_domain! { name: "TAP", - version: "1", + version: version.as_str(), chain_id: chain_id, verifying_contract: verifying_contract_address, } @@ -63,7 +83,7 @@ mod tap_tests { dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner, }; - use crate::{signed_message::Eip712SignedMessage, tap_eip712_domain}; + use crate::{signed_message::Eip712SignedMessage, tap_eip712_domain, TapVersion}; #[fixture] fn keys() -> (PrivateKeySigner, Address) { @@ -85,7 +105,7 @@ mod tap_tests { #[fixture] fn domain_separator() -> Eip712Domain { - tap_eip712_domain(1, Address::from([0x11u8; 20])) + tap_eip712_domain(1, Address::from([0x11u8; 20]), TapVersion::V1) } #[rstest] diff --git a/tap_core/tests/manager_test.rs b/tap_core/tests/manager_test.rs index e44badbd..de624a33 100644 --- a/tap_core/tests/manager_test.rs +++ b/tap_core/tests/manager_test.rs @@ -31,7 +31,7 @@ use tap_core::{ Context, ReceiptWithState, }, signed_message::Eip712SignedMessage, - tap_eip712_domain, + tap_eip712_domain, TapVersion, }; use tap_graph::{Receipt, ReceiptAggregateVoucher, SignedReceipt}; @@ -66,7 +66,7 @@ fn sender_ids(signer: PrivateKeySigner) -> (PrivateKeySigner, Vec
) { #[fixture] fn domain_separator() -> Eip712Domain { - tap_eip712_domain(1, Address::from([0x11u8; 20])) + tap_eip712_domain(1, Address::from([0x11u8; 20]), TapVersion::V1) } struct ContextFixture { diff --git a/tap_core/tests/rav_test.rs b/tap_core/tests/rav_test.rs index f6c1a574..927a3a7d 100644 --- a/tap_core/tests/rav_test.rs +++ b/tap_core/tests/rav_test.rs @@ -15,7 +15,7 @@ use tap_core::{ }, receipt::checks::StatefulTimestampCheck, signed_message::Eip712SignedMessage, - tap_eip712_domain, + tap_eip712_domain, TapVersion, }; use tap_graph::{Receipt, ReceiptAggregateVoucher}; #[allow(deprecated)] @@ -27,7 +27,7 @@ use thegraph_core::alloy::{ #[fixture] fn domain_separator() -> Eip712Domain { - tap_eip712_domain(1, Address::from([0x11u8; 20])) + tap_eip712_domain(1, Address::from([0x11u8; 20]), TapVersion::V1) } #[fixture] diff --git a/tap_core/tests/receipt_test.rs b/tap_core/tests/receipt_test.rs index a9000567..174139ab 100644 --- a/tap_core/tests/receipt_test.rs +++ b/tap_core/tests/receipt_test.rs @@ -12,7 +12,7 @@ use tap_core::{ manager::{adapters::ReceiptStore, context::memory::InMemoryContext}, receipt::{checks::StatefulTimestampCheck, state::Checking, ReceiptWithState}, signed_message::Eip712SignedMessage, - tap_eip712_domain, + tap_eip712_domain, TapVersion, }; use tap_graph::{Receipt, SignedReceipt}; use thegraph_core::alloy::{ @@ -21,7 +21,7 @@ use thegraph_core::alloy::{ #[fixture] fn domain_separator() -> Eip712Domain { - tap_eip712_domain(1, Address::from([0x11u8; 20])) + tap_eip712_domain(1, Address::from([0x11u8; 20]), TapVersion::V1) } #[fixture] diff --git a/tap_core/tests/received_receipt_test.rs b/tap_core/tests/received_receipt_test.rs index d7972fbc..5a98360a 100644 --- a/tap_core/tests/received_receipt_test.rs +++ b/tap_core/tests/received_receipt_test.rs @@ -15,7 +15,7 @@ use tap_core::{ Context, ReceiptWithState, }, signed_message::Eip712SignedMessage, - tap_eip712_domain, + tap_eip712_domain, TapVersion, }; use tap_graph::{Receipt, SignedReceipt}; use thegraph_core::alloy::{ @@ -53,7 +53,7 @@ fn sender_ids(signer: PrivateKeySigner) -> (PrivateKeySigner, Vec
) { #[fixture] fn domain_separator() -> Eip712Domain { - tap_eip712_domain(1, Address::from([0x11u8; 20])) + tap_eip712_domain(1, Address::from([0x11u8; 20]), TapVersion::V1) } struct ContextFixture { diff --git a/tap_integration_tests/tests/showcase.rs b/tap_integration_tests/tests/showcase.rs index 37639145..23572239 100644 --- a/tap_integration_tests/tests/showcase.rs +++ b/tap_integration_tests/tests/showcase.rs @@ -23,7 +23,7 @@ use tap_core::{ manager::context::memory::{checks::get_full_list_of_checks, *}, receipt::checks::{CheckList, StatefulTimestampCheck}, signed_message::{Eip712SignedMessage, MessageId}, - tap_eip712_domain, + tap_eip712_domain, TapVersion, }; use tap_graph::{Receipt, SignedRav, SignedReceipt}; use thegraph_core::alloy::{ @@ -121,7 +121,7 @@ fn sender_ids() -> Vec
{ // Domain separator is used to sign receipts/RAVs according to EIP-712 #[fixture] fn domain_separator() -> Eip712Domain { - tap_eip712_domain(1, Address::from([0x11u8; 20])) + tap_eip712_domain(1, Address::from([0x11u8; 20]), TapVersion::V1) } // Query price will typically be set by the Indexer. It's assumed to be part of the Indexer service. From d6f04576d83a9284894aefe4468cb07c08d98f62 Mon Sep 17 00:00:00 2001 From: Joseph Livesey Date: Sat, 16 Aug 2025 20:30:15 -0400 Subject: [PATCH 2/3] build: bump tap-core to 5.0.0 Signed-off-by: Joseph Livesey --- Cargo.toml | 10 +++++----- tap_core/Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2adb4a66..eea83652 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,11 +45,11 @@ serde = { version = "1.0.219", features = ["derive"] } serde_json = { version = "1.0.140", features = ["raw_value"] } strum = { version = "0.27.1", features = ["derive"] } rstest = "0.25.0" -tap_aggregator = { version = "0.5.4", path = "tap_aggregator" } -tap_eip712_message = { version = "0.2.1", path = "tap_eip712_message" } -tap_core = { version = "4.1.2", path = "tap_core" } -tap_graph = { version = "0.3.2", path = "tap_graph", features = ["v2"] } -tap_receipt = { version = "1.1.2", path = "tap_receipt" } +tap_aggregator = { version = "0.5.8", path = "tap_aggregator" } +tap_eip712_message = { version = "0.2.2", path = "tap_eip712_message" } +tap_core = { version = "5.0.0", path = "tap_core" } +tap_graph = { version = "0.3.4", path = "tap_graph", features = ["v2"] } +tap_receipt = { version = "1.1.3", path = "tap_receipt" } thegraph-core = "0.15.1" thiserror = "2.0.12" tokio = { version = "1.44.2", features = ["macros", "signal"] } diff --git a/tap_core/Cargo.toml b/tap_core/Cargo.toml index 5c969e49..7e650d35 100644 --- a/tap_core/Cargo.toml +++ b/tap_core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tap_core" -version = "4.1.4" +version = "5.0.0" edition.workspace = true license.workspace = true repository.workspace = true From eb049a52440cf33656e6c27377652a167504006e Mon Sep 17 00:00:00 2001 From: Joseph Livesey Date: Sat, 16 Aug 2025 20:33:54 -0400 Subject: [PATCH 3/3] build: bump tap-aggregator to 0.5.9 Signed-off-by: Joseph Livesey --- Cargo.toml | 2 +- tap_aggregator/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index eea83652..e94ae4bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ serde = { version = "1.0.219", features = ["derive"] } serde_json = { version = "1.0.140", features = ["raw_value"] } strum = { version = "0.27.1", features = ["derive"] } rstest = "0.25.0" -tap_aggregator = { version = "0.5.8", path = "tap_aggregator" } +tap_aggregator = { version = "0.5.9", path = "tap_aggregator" } tap_eip712_message = { version = "0.2.2", path = "tap_eip712_message" } tap_core = { version = "5.0.0", path = "tap_core" } tap_graph = { version = "0.3.4", path = "tap_graph", features = ["v2"] } diff --git a/tap_aggregator/Cargo.toml b/tap_aggregator/Cargo.toml index 461df847..0c51c3e6 100644 --- a/tap_aggregator/Cargo.toml +++ b/tap_aggregator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tap_aggregator" -version = "0.5.8" +version = "0.5.9" edition.workspace = true license.workspace = true repository.workspace = true