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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ license = "Apache-2.0"
repository = "https://github.com/semiotic-ai/timeline-aggregation-protocol"

[workspace.dependencies]
alloy = { version = "0.11.0", features = ["full"] }
serde = { version = "1.0.217", features = ["derive"] }
rstest = "0.24.0"
anyhow = { version = "1.0.95" }
Expand All @@ -25,4 +24,5 @@ rand = "0.8.5"
jsonrpsee = { version = "0.24.7", features = ["macros", "server"] }
insta = { version = "1.42.0", features = ["json"] }
serde_json = { version = "1.0.137", features = ["raw_value"] }
thegraph-core = "0.12.0"
thiserror = "2.0.11"
3 changes: 1 addition & 2 deletions tap_aggregator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ name = "tap_aggregator"
path = "src/main.rs"

[dependencies]
alloy.workspace = true
alloy-sol-types ={ version = "0.8.21", features = ["eip712-serde"]}
anyhow.workspace = true
axum = { version = "0.7.5", features = [
"http1",
Expand All @@ -36,6 +34,7 @@ serde.workspace = true
serde_json.workspace = true
strum = { version = "0.26.3", features = ["derive"] }
tap_core = { path = "../tap_core", version = "3.0.1" }
thegraph-core = { workspace = true, features = ["alloy-eip712"] }
tokio.workspace = true
tonic = { version = "0.12.3", features = ["transport", "zstd"] }
tower = { version = "0.5.2", features = ["util", "steer"] }
Expand Down
12 changes: 7 additions & 5 deletions tap_aggregator/src/aggregator/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

use std::collections::{hash_set, HashSet};

use alloy::{
dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner,
sol_types::SolStruct,
};
use anyhow::{bail, Ok, Result};
use rayon::prelude::*;
use tap_core::signed_message::{Eip712SignedMessage, SignatureBytes, SignatureBytesExt};
use tap_graph::{Receipt, ReceiptAggregateVoucher};
use thegraph_core::alloy::{
dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner,
sol_types::SolStruct,
};

pub fn check_and_aggregate_receipts(
domain_separator: &Eip712Domain,
Expand Down Expand Up @@ -132,10 +132,12 @@ fn check_receipt_timestamps(
mod tests {
use std::str::FromStr;

use alloy::{dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner};
use rstest::*;
use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain};
use tap_graph::{Receipt, ReceiptAggregateVoucher};
use thegraph_core::alloy::{
dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner,
};

use super::*;

Expand Down
16 changes: 8 additions & 8 deletions tap_aggregator/src/aggregator/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

use std::collections::{hash_set, HashSet};

use alloy::{
dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner,
sol_types::SolStruct,
};
use anyhow::{bail, Ok, Result};
use rayon::prelude::*;
use tap_core::signed_message::{Eip712SignedMessage, SignatureBytes, SignatureBytesExt};
use tap_graph::v2::{Receipt, ReceiptAggregateVoucher};
use thegraph_core::alloy::{
dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner,
sol_types::SolStruct,
};

pub fn check_and_aggregate_receipts(
domain_separator: &Eip712Domain,
Expand Down Expand Up @@ -185,14 +185,14 @@ fn check_receipt_timestamps(

#[cfg(test)]
mod tests {
use alloy::{
use rstest::*;
use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain};
use tap_graph::v2::{Receipt, ReceiptAggregateVoucher};
use thegraph_core::alloy::{
dyn_abi::Eip712Domain,
primitives::{address, Address, Bytes},
signers::local::PrivateKeySigner,
};
use rstest::*;
use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain};
use tap_graph::v2::{Receipt, ReceiptAggregateVoucher};

#[fixture]
fn keys() -> (PrivateKeySigner, Address) {
Expand Down
2 changes: 1 addition & 1 deletion tap_aggregator/src/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ pub mod v1 {
}

pub mod v2 {
use alloy::primitives::Bytes;
use anyhow::anyhow;
use tap_core::signed_message::Eip712SignedMessage;
use thegraph_core::alloy::primitives::Bytes;

tonic::include_proto!("tap_aggregator.v2");

Expand Down
6 changes: 4 additions & 2 deletions tap_aggregator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@

use std::{collections::HashSet, str::FromStr};

use alloy::{dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner};
use anyhow::Result;
use clap::Parser;
use log::{debug, info};
use tap_aggregator::{metrics, server};
use tap_core::tap_eip712_domain;
use thegraph_core::alloy::{
dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner,
};

#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
Expand Down Expand Up @@ -141,7 +143,7 @@ async fn main() -> Result<()> {
}

fn create_eip712_domain(args: &Args) -> Result<Eip712Domain> {
// Transfrom the args into the types expected by Eip712Domain::new().
// Transform the args into the types expected by Eip712Domain::new().

// Transform optional strings into optional Cow<str>.
// Transform optional strings into optional U256.
Expand Down
8 changes: 6 additions & 2 deletions tap_aggregator/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

use std::{collections::HashSet, str::FromStr};

use alloy::{dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner};
use anyhow::Result;
use axum::{error_handling::HandleError, routing::post_service, BoxError, Router};
use hyper::StatusCode;
Expand All @@ -16,6 +15,9 @@ use log::{error, info};
use prometheus::{register_counter, register_int_counter, Counter, IntCounter};
use tap_core::signed_message::Eip712SignedMessage;
use tap_graph::{Receipt, ReceiptAggregateVoucher, SignedReceipt};
use thegraph_core::alloy::{
dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner,
};
use tokio::{net::TcpListener, signal, task::JoinHandle};
use tonic::{codec::CompressionEncoding, service::Routes, Request, Response, Status};
use tower::{layer::util::Identity, make::Shared};
Expand Down Expand Up @@ -493,12 +495,14 @@ fn produce_kafka_records(
mod tests {
use std::{collections::HashSet, str::FromStr};

use alloy::{dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner};
use jsonrpsee::{core::client::ClientT, http_client::HttpClientBuilder, rpc_params};
use rand::{prelude::*, seq::SliceRandom};
use rstest::*;
use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain};
use tap_graph::{Receipt, ReceiptAggregateVoucher};
use thegraph_core::alloy::{
dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner,
};

use crate::server;

Expand Down
2 changes: 1 addition & 1 deletion tap_aggregator/tests/aggregate_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

use std::{collections::HashSet, str::FromStr};

use alloy::{primitives::Address, signers::local::PrivateKeySigner};
use jsonrpsee::{core::client::ClientT, http_client::HttpClientBuilder, rpc_params};
use tap_aggregator::{
grpc::v1::{tap_aggregator_client::TapAggregatorClient, RavRequest},
Expand All @@ -12,6 +11,7 @@ use tap_aggregator::{
};
use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain};
use tap_graph::{Receipt, ReceiptAggregateVoucher};
use thegraph_core::alloy::{primitives::Address, signers::local::PrivateKeySigner};
use tonic::codec::CompressionEncoding;

#[tokio::test]
Expand Down
8 changes: 4 additions & 4 deletions tap_aggregator/tests/aggregate_v1_and_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

use std::collections::HashSet;

use alloy::{
primitives::{address, Address},
signers::local::PrivateKeySigner,
};
use tap_aggregator::{
grpc::{
v1::{tap_aggregator_client::TapAggregatorClient as ClientV1, RavRequest as ReqV1},
Expand All @@ -16,6 +12,10 @@ use tap_aggregator::{
};
use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain};
use tap_graph::{v2::Receipt as ReceiptV2, Receipt as ReceiptV1};
use thegraph_core::alloy::{
primitives::{address, Address},
signers::local::PrivateKeySigner,
};
use tonic::codec::CompressionEncoding;

#[tokio::test]
Expand Down
9 changes: 5 additions & 4 deletions tap_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@ readme = "README.md"
description = "Core Timeline Aggregation Protocol library: a fast, efficient and trustless unidirectional micro-payments system."

[dependencies]
alloy.workspace = true
anyhow.workspace = true
async-trait = "0.1.85"
rand.workspace = true
thiserror.workspace = true
tokio.workspace = true
tap_receipt = { version = "0.1.0", path = "../tap_receipt" }
tap_eip712_message = { version = "0.1.0", path = "../tap_eip712_message" }
tap_graph = { version = "0.2.0", path = "../tap_graph", optional = true }
tap_receipt = { version = "0.1.0", path = "../tap_receipt" }
thegraph-core.workspace = true
thiserror.workspace = true
tokio.workspace = true

[dev-dependencies]
criterion = { version = "0.5.1", features = ["async_std"] }
insta.workspace = true
rstest.workspace = true
serde_json.workspace = true
thegraph-core = { workspace = true, features = ["alloy-signer-mnemonic"] }

[features]
default = ["in_memory"]
Expand Down
4 changes: 3 additions & 1 deletion tap_core/benches/timeline_aggretion_protocol_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@

use std::str::FromStr;

use alloy::{dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner};
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain};
use tap_graph::{Receipt, ReceiptAggregateVoucher};
use thegraph_core::alloy::{
dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner,
};

pub fn create_and_sign_receipt(
domain_separator: &Eip712Domain,
Expand Down
4 changes: 2 additions & 2 deletions tap_core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use std::result::Result as StdResult;

use alloy::primitives::Address;
use thegraph_core::alloy::primitives::Address;
use thiserror::Error as ThisError;

use crate::receipt::ReceiptError;
Expand All @@ -22,7 +22,7 @@ pub enum Error {
InvalidSystemTime { source_error_message: String },
/// `alloy` wallet error
#[error(transparent)]
WalletError(#[from] alloy::signers::Error),
WalletError(#[from] thegraph_core::alloy::signers::Error),

/// `alloy` wallet error
#[error(transparent)]
Expand Down
11 changes: 5 additions & 6 deletions tap_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use std::time::{SystemTime, UNIX_EPOCH};

use alloy::{dyn_abi::Eip712Domain, sol_types::eip712_domain};
use thegraph_core::alloy::{dyn_abi::Eip712Domain, primitives::Address, sol_types::eip712_domain};
use thiserror::Error;

mod error;
Expand Down Expand Up @@ -44,10 +44,7 @@ fn get_current_timestamp_u64_ns() -> Result<u64> {
/// - `version`: "1"
/// - `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: alloy::primitives::Address,
) -> Eip712Domain {
pub fn tap_eip712_domain(chain_id: u64, verifying_contract_address: Address) -> Eip712Domain {
eip712_domain! {
name: "TAP",
version: "1",
Expand All @@ -60,9 +57,11 @@ pub fn tap_eip712_domain(
mod tap_tests {
use std::str::FromStr;

use alloy::{dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner};
use rstest::*;
use tap_graph::{Receipt, ReceiptAggregateVoucher};
use thegraph_core::alloy::{
dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner,
};

use crate::{signed_message::Eip712SignedMessage, tap_eip712_domain};

Expand Down
2 changes: 1 addition & 1 deletion tap_core/src/manager/adapters/rav.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2023-, Semiotic AI, Inc.
// SPDX-License-Identifier: Apache-2.0

use alloy::sol_types::SolStruct;
use async_trait::async_trait;
use thegraph_core::alloy::sol_types::SolStruct;

use crate::signed_message::Eip712SignedMessage;

Expand Down
2 changes: 1 addition & 1 deletion tap_core/src/manager/adapters/signature.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2023-, Semiotic AI, Inc.
// SPDX-License-Identifier: Apache-2.0

use alloy::{dyn_abi::Eip712Domain, primitives::Address, sol_types::SolStruct};
use async_trait::async_trait;
use thegraph_core::alloy::{dyn_abi::Eip712Domain, primitives::Address, sol_types::SolStruct};

use crate::{signed_message::Eip712SignedMessage, Error};

Expand Down
4 changes: 2 additions & 2 deletions tap_core/src/manager/context/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use std::{
sync::{Arc, RwLock},
};

use alloy::primitives::Address;
use async_trait::async_trait;
use tap_graph::{ReceiptAggregateVoucher, SignedRav, SignedReceipt};
use thegraph_core::alloy::primitives::Address;

use crate::{
manager::adapters::*,
Expand Down Expand Up @@ -258,8 +258,8 @@ pub mod checks {
sync::{Arc, RwLock},
};

use alloy::{dyn_abi::Eip712Domain, primitives::Address};
use tap_graph::SignedReceipt;
use thegraph_core::alloy::{dyn_abi::Eip712Domain, primitives::Address};

use crate::{
receipt::{
Expand Down
4 changes: 2 additions & 2 deletions tap_core/src/manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
//! # Ok(0)
//! }
//! }
//! # #[tokio::main]
//! # #[tokio::main(flavor = "current_thread")]
//! # async fn main() {
//! # use alloy::{dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner};
//! # use thegraph_core::alloy::{dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner};
//! # use tap_graph::{Receipt, SignedReceipt};
//! # use tap_core::signed_message::Eip712SignedMessage;
//! # let domain_separator = Eip712Domain::default();
Expand Down
2 changes: 1 addition & 1 deletion tap_core/src/manager/tap_manager.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2023-, Semiotic AI, Inc.
// SPDX-License-Identifier: Apache-2.0

use alloy::{dyn_abi::Eip712Domain, sol_types::SolStruct};
use tap_receipt::rav::Aggregate;
use thegraph_core::alloy::{dyn_abi::Eip712Domain, sol_types::SolStruct};

use super::adapters::{
RavRead, RavStore, ReceiptDelete, ReceiptRead, ReceiptStore, SignatureChecker,
Expand Down
2 changes: 1 addition & 1 deletion tap_core/src/rav_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

//! Request to Tap Aggregator

use alloy::sol_types::SolStruct;
use tap_receipt::rav::AggregationError;
use thegraph_core::alloy::sol_types::SolStruct;

use crate::{
receipt::{
Expand Down
2 changes: 1 addition & 1 deletion tap_core/src/signed_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//!
//! # Example
//! ```rust
//! # use alloy::{dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner};
//! # use thegraph_core::alloy::{dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner};
//! # use tap_graph::{Receipt};
//! # let domain_separator = Eip712Domain::default();
//! use tap_core::signed_message::Eip712SignedMessage;
Expand Down
4 changes: 3 additions & 1 deletion tap_core/tests/manager_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ use std::{
time::{SystemTime, UNIX_EPOCH},
};

use alloy::{dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner};
use anyhow::anyhow;
use rstest::*;
use thegraph_core::alloy::{
dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner,
};

fn get_current_timestamp_u64_ns() -> anyhow::Result<u64> {
Ok(SystemTime::now().duration_since(UNIX_EPOCH)?.as_nanos() as u64)
Expand Down
Loading