Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,17 @@ 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.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"] }
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"] }
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"
4 changes: 2 additions & 2 deletions tap_aggregator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions tap_aggregator/src/aggregator/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions tap_aggregator/src/aggregator/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down
9 changes: 8 additions & 1 deletion tap_aggregator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -163,9 +163,16 @@ fn create_eip712_domain(args: &Args) -> Result<Eip712Domain> {
// Transform optional strings into optional Address.
let verifying_contract: Option<Address> = 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,
))
}
4 changes: 2 additions & 2 deletions tap_aggregator/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions tap_aggregator/tests/aggregate_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions tap_aggregator/tests/aggregate_v1_and_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion tap_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
30 changes: 25 additions & 5 deletions tap_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,35 @@ fn get_current_timestamp_u64_ns() -> Result<u64> {
/// 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,
}
Expand All @@ -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) {
Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions tap_core/tests/manager_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -66,7 +66,7 @@ fn sender_ids(signer: PrivateKeySigner) -> (PrivateKeySigner, Vec<Address>) {

#[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 {
Expand Down
4 changes: 2 additions & 2 deletions tap_core/tests/rav_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions tap_core/tests/receipt_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions tap_core/tests/received_receipt_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -53,7 +53,7 @@ fn sender_ids(signer: PrivateKeySigner) -> (PrivateKeySigner, Vec<Address>) {

#[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 {
Expand Down
4 changes: 2 additions & 2 deletions tap_integration_tests/tests/showcase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -121,7 +121,7 @@ fn sender_ids() -> Vec<Address> {
// 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.
Expand Down