Skip to content

Commit

Permalink
feat: add dips graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
mangas committed Oct 30, 2024
1 parent b996e8b commit c990e2e
Show file tree
Hide file tree
Showing 16 changed files with 1,820 additions and 331 deletions.
1,190 changes: 871 additions & 319 deletions Cargo.lock

Large diffs are not rendered by default.

19 changes: 13 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
[workspace]
members = ["common", "config", "service", "tap-agent"]
members = ["common", "config", "dips", "service", "tap-agent"]
resolver = "2"

[profile.dev.package."*"]
opt-level = 3

[workspace.dependencies]
alloy = { version = "0.2.1", features = [
alloy = { version = "0.4.2", features = [
"kzg",
"signer-mnemonic",
"dyn-abi",
"sol-types",
"signer-local",
"eip712",
"rlp",
"signers",
], default-features = false }
clap = "4.4.3"
lazy_static = "1.4.0"
axum = { version = "0.7.5", default-features = false }
tokio = "1.39.2"
axum = { version = "0.7.7", default-features = false }
tokio = "1.40"
prometheus = "0.13.3"
anyhow = { version = "1.0.72" }
thiserror = "1.0.49"
async-trait = "0.1.72"
eventuals = "0.6.7"
base64 = "0.22.1"
reqwest = { version = "0.12", features = [
"charset",
"h2",
Expand All @@ -38,13 +45,13 @@ sqlx = { version = "0.8.2", features = [
tracing = { version = "0.1.40", default-features = false }
bigdecimal = "0.4.3"
build-info = "0.0.39"
tap_core = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", rev = "ff856d9", default-features = false }
tap_core = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", rev = "c26e552", default-features = false }
tracing-subscriber = { version = "0.3", features = [
"json",
"env-filter",
"ansi",
], default-features = false }
thegraph-core = { git = "https://github.com/edgeandnode/toolshed", rev = "85ee00b", features = [
thegraph-core = { git = "https://github.com/edgeandnode/toolshed", tag = "thegraph-core-v0.7.0", features = [
"subgraph-client",
] }
thegraph-graphql-http = "0.2.0"
Expand Down
77 changes: 77 additions & 0 deletions common/src/indexer_service/http/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
// SPDX-License-Identifier: Apache-2.0

use std::{net::SocketAddr, time::Duration};

use serde::{Deserialize, Serialize};
use thegraph_core::{Address, DeploymentId};

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct DatabaseConfig {
pub postgres_url: String,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SubgraphConfig {
#[serde(default)]
pub serve_subgraph: bool,
pub serve_auth_token: Option<String>,

pub deployment: Option<DeploymentId>,
pub query_url: String,
pub query_auth_token: Option<String>,
pub syncing_interval: u64,
pub recently_closed_allocation_buffer_seconds: u64,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ServerConfig {
pub host_and_port: SocketAddr,
pub metrics_host_and_port: SocketAddr,
pub url_prefix: String,
pub free_query_auth_token: Option<String>,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct IndexerServiceConfig {
pub indexer: IndexerConfig,
pub server: ServerConfig,
pub database: DatabaseConfig,
pub graph_node: Option<GraphNodeConfig>,
pub network_subgraph: SubgraphConfig,
pub escrow_subgraph: SubgraphConfig,
pub graph_network: GraphNetworkConfig,
pub tap: TapConfig,
pub dips: IndexerDipsConfig,
}

#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct IndexerDipsConfig {
pub allowed_payers: Vec<Address>,
pub cancel_voucher_time_tolerance: Option<Duration>,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct GraphNodeConfig {
pub status_url: String,
pub query_base_url: String,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct GraphNetworkConfig {
pub chain_id: u64,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct IndexerConfig {
pub indexer_address: Address,
pub operator_mnemonic: String,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct TapConfig {
pub chain_id: u64,
pub receipts_verifier_address: Address,
pub timestamp_error_tolerance: u64,
pub receipt_max_value: u128,
}
3 changes: 3 additions & 0 deletions config/maximal-config-example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,6 @@ max_receipts_per_request = 10000
# Key-Value of all senders and their aggregator endpoints
0xdeadbeefcafebabedeadbeefcafebabedeadbeef = "https://example.com/aggregate-receipts"
0x0123456789abcdef0123456789abcdef01234567 = "https://other.example.com/aggregate-receipts"

[dips]
allowed_payers = ["0x3333333333333333333333333333333333333333"]
3 changes: 3 additions & 0 deletions config/minimal-config-example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ receipts_verifier_address = "0x2222222222222222222222222222222222222222"
# Key-Value of all senders and their aggregator endpoints
0xdeadbeefcafebabedeadbeefcafebabedeadbeef = "https://example.com/aggregate-receipts"
0x0123456789abcdef0123456789abcdef01234567 = "https://other.example.com/aggregate-receipts"

[dips]
allowed_payers = ["0x3333333333333333333333333333333333333333"]
8 changes: 8 additions & 0 deletions config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct Config {
pub blockchain: BlockchainConfig,
pub service: ServiceConfig,
pub tap: TapConfig,
pub dips: DipsConfig,
}

// Newtype wrapping Config to be able use serde_ignored with Figment
Expand Down Expand Up @@ -362,6 +363,13 @@ pub struct TapConfig {
pub sender_aggregator_endpoints: HashMap<Address, Url>,
}

#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(test, derive(PartialEq))]
pub struct DipsConfig {
pub allowed_payers: Vec<Address>,
pub cancellation_time_tolerance: Option<Duration>,
}

impl TapConfig {
pub fn get_trigger_value(&self) -> u128 {
let grt_wei = self.max_amount_willing_to_lose_grt.get_value();
Expand Down
19 changes: 19 additions & 0 deletions dips/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "indexer-dips"
version = "0.1.0"
edition = "2021"

[dependencies]
alloy.workspace = true
thiserror.workspace = true
anyhow.workspace = true
alloy-sol-types = "=0.8.7"
# alloy-signer = { version = "0.4", features = ["eip712"] }
alloy-rlp = "0.3.8"
thegraph-core.workspace = true

# alloy-signer = "0.4.2"
# alloy-rlp = "0.3.8"

# [dev-dependencies]
# alloy-signer-local = "=0.4.0"
Loading

0 comments on commit c990e2e

Please sign in to comment.