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
896 changes: 486 additions & 410 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions common/src/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use regex::Regex;

/// There is no convenient function for filtering GraphQL executable documents
/// For sake of simplicity, use regex to filter graphql query string
/// Return original string if the query is okay, otherwise error out with
/// unsupported fields
/// Return original string if the query is okay, otherwise error out with unsupported fields
pub fn filter_supported_fields(
query: &str,
supported_root_fields: &HashSet<&str>,
Expand Down
22 changes: 9 additions & 13 deletions common/src/indexer_service/http/indexer_service.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
// SPDX-License-Identifier: Apache-2.0

use std::{
collections::HashMap, error::Error, fmt::Debug, net::SocketAddr, path::PathBuf, sync::Arc,
time::Duration,
};

use alloy::dyn_abi::Eip712Domain;
use alloy::sol_types::eip712_domain;
use anyhow;
use axum::extract::MatchedPath;
use axum::extract::Request as ExtractRequest;
Expand All @@ -25,7 +19,11 @@ use prometheus::TextEncoder;
use reqwest::StatusCode;
use serde::{de::DeserializeOwned, Serialize};
use sqlx::postgres::PgPoolOptions;
use tap_core::{manager::Manager, receipt::checks::CheckList};
use std::{
collections::HashMap, error::Error, fmt::Debug, net::SocketAddr, path::PathBuf, sync::Arc,
time::Duration,
};
use tap_core::{manager::Manager, receipt::checks::CheckList, tap_eip712_domain};
use thegraph_core::{Address, Attestation, DeploymentId};
use thiserror::Error;
use tokio::net::TcpListener;
Expand Down Expand Up @@ -293,12 +291,10 @@ impl IndexerService {
.connect(&options.config.database.postgres_url)
.await?;

let domain_separator = eip712_domain! {
name: "TAP",
version: "1",
chain_id: options.config.tap.chain_id,
verifying_contract: options.config.tap.receipts_verifier_address,
};
let domain_separator = tap_eip712_domain(
options.config.tap.chain_id,
options.config.tap.receipts_verifier_address,
);
let indexer_context =
IndexerTapContext::new(database.clone(), domain_separator.clone()).await;
let timestamp_error_tolerance =
Expand Down
1 change: 0 additions & 1 deletion common/src/tap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ mod receipt_store;

pub struct IndexerTapContext {
domain_separator: Arc<Eip712Domain>,

receipt_producer: Sender<DatabaseReceipt>,
cancelation_token: CancellationToken,
}
Expand Down
20 changes: 8 additions & 12 deletions common/src/tap/checks/receipt_max_val_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,20 @@ impl Check for ReceiptMaxValueCheck {
}
#[cfg(test)]
mod tests {
use std::str::FromStr;
use std::time::Duration;
use std::time::SystemTime;

use alloy::dyn_abi::Eip712Domain;
use alloy::primitives::Address;
use alloy::signers::local::coins_bip39::English;
use alloy::signers::local::MnemonicBuilder;
use alloy::signers::local::PrivateKeySigner;
use alloy::sol_types::eip712_domain;
use std::str::FromStr;
use std::time::Duration;
use std::time::SystemTime;

use super::*;
use crate::tap::Eip712Domain;
use tap_core::{
receipt::{checks::Check, state::Checking, Receipt, ReceiptWithState},
signed_message::EIP712SignedMessage,
tap_eip712_domain,
};

fn create_signed_receipt_with_custom_value(value: u128) -> ReceiptWithState<Checking> {
Expand All @@ -60,12 +59,9 @@ mod tests {
.unwrap()
.build()
.unwrap();
let eip712_domain_separator: Eip712Domain = eip712_domain! {
name: "TAP",
version: "1",
chain_id: 1,
verifying_contract: Address:: from([0x11u8; 20]),
};

let eip712_domain_separator: Eip712Domain =
tap_eip712_domain(1, Address::from([0x11u8; 20]));

let timestamp = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
Expand Down
12 changes: 4 additions & 8 deletions common/src/tap/checks/timestamp_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ mod tests {
use std::str::FromStr;

use alloy::{
dyn_abi::Eip712Domain,
primitives::Address,
signers::local::{coins_bip39::English, MnemonicBuilder, PrivateKeySigner},
sol_types::eip712_domain,
};

use super::*;
use crate::tap::Eip712Domain;
use tap_core::{
receipt::{checks::Check, state::Checking, Receipt, ReceiptWithState},
signed_message::EIP712SignedMessage,
tap_eip712_domain,
};

fn create_signed_receipt_with_custom_timestamp(
Expand All @@ -69,12 +69,8 @@ mod tests {
.unwrap()
.build()
.unwrap();
let eip712_domain_separator: Eip712Domain = eip712_domain! {
name: "TAP",
version: "1",
chain_id: 1,
verifying_contract: Address:: from([0x11u8; 20]),
};
let eip712_domain_separator: Eip712Domain =
tap_eip712_domain(1, Address::from([0x11u8; 20]));
let value: u128 = 1234;
let nonce: u64 = 10;
let receipt = EIP712SignedMessage::new(
Expand Down
12 changes: 5 additions & 7 deletions common/src/test_vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use alloy::{
dyn_abi::Eip712Domain,
primitives::U256,
signers::local::{coins_bip39::English, MnemonicBuilder, PrivateKeySigner},
sol_types::eip712_domain,
};
use lazy_static::lazy_static;
use tap_core::{
receipt::{Receipt, SignedReceipt},
signed_message::EIP712SignedMessage,
tap_eip712_domain,
};
use thegraph_core::{Address, DeploymentId};

Expand Down Expand Up @@ -252,12 +252,10 @@ lazy_static! {
(wallet, address)
};

pub static ref TAP_EIP712_DOMAIN: Eip712Domain = eip712_domain! {
name: "TAP",
version: "1",
chain_id: 1,
verifying_contract: Address::from([0x11u8; 20]),
};
pub static ref TAP_EIP712_DOMAIN: Eip712Domain = tap_eip712_domain(
1,
Address::from([0x11u8; 20])
);
}

/// Function to generate a signed receipt using the TAP_SIGNER wallet.
Expand Down
1 change: 0 additions & 1 deletion tap-agent/src/agent/sender_allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@ impl SenderAllocationState {

/// Request a RAV from the sender's TAP aggregator. Only one RAV request will be running at a
/// time through the use of an internal guard.

async fn rav_requester_single(&mut self) -> Result<SignedRAV, RavError> {
tracing::trace!("rav_requester_single()");
let RAVRequest {
Expand Down
13 changes: 6 additions & 7 deletions tap-agent/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
// SPDX-License-Identifier: Apache-2.0

use alloy::{dyn_abi::Eip712Domain, sol_types::eip712_domain};
use alloy::dyn_abi::Eip712Domain;
use lazy_static::lazy_static;
use tap_core::tap_eip712_domain;

use crate::config::Config;

lazy_static! {
pub static ref CONFIG: Config = Config::from_cli().expect("Failed to load configuration");
pub static ref EIP_712_DOMAIN: Eip712Domain = eip712_domain! {
name: "TAP",
version: "1",
chain_id: CONFIG.receipts.receipts_verifier_chain_id,
verifying_contract: CONFIG.receipts.receipts_verifier_address,
};
pub static ref EIP_712_DOMAIN: Eip712Domain = tap_eip712_domain(
CONFIG.receipts.receipts_verifier_chain_id,
CONFIG.receipts.receipts_verifier_address,
);
}

pub mod agent;
Expand Down
10 changes: 3 additions & 7 deletions tap-agent/src/tap/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::str::FromStr;
use alloy::{
primitives::hex::ToHexExt,
signers::local::{coins_bip39::English, MnemonicBuilder, PrivateKeySigner},
sol_types::eip712_domain,
};
use bigdecimal::num_bigint::BigInt;

Expand All @@ -19,6 +18,7 @@ use tap_core::{
rav::{ReceiptAggregateVoucher, SignedRAV},
receipt::{state::Checking, Receipt, ReceiptWithState, SignedReceipt},
signed_message::EIP712SignedMessage,
tap_eip712_domain,
};
use thegraph_core::Address;

Expand All @@ -32,12 +32,8 @@ lazy_static! {
pub static ref SENDER_3: (PrivateKeySigner, Address) = wallet(4);
pub static ref SIGNER: (PrivateKeySigner, Address) = wallet(2);
pub static ref INDEXER: (PrivateKeySigner, Address) = wallet(3);
pub static ref TAP_EIP712_DOMAIN_SEPARATOR: Eip712Domain = eip712_domain! {
name: "TAP",
version: "1",
chain_id: 1,
verifying_contract: Address:: from([0x11u8; 20]),
};
pub static ref TAP_EIP712_DOMAIN_SEPARATOR: Eip712Domain =
tap_eip712_domain(1, Address::from([0x11u8; 20]),);
}

/// Fixture to generate a RAV using the wallet from `keys()`
Expand Down
Loading