Skip to content

Commit ef909a1

Browse files
committed
feat: dips grpc
1 parent b08b728 commit ef909a1

File tree

23 files changed

+1191
-475
lines changed

23 files changed

+1191
-475
lines changed

.github/workflows/license_headers_check.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ jobs:
2929
-ignore '.github/workflows/*.yaml' \
3030
-ignore '.github/*.yaml' \
3131
-ignore 'migrations/*.sql' \
32+
-ignore 'crates/dips/src/proto/*' \
3233
.

.github/workflows/tests.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ jobs:
5050
- name: Run sccache-cache
5151
uses: mozilla-actions/sccache-action@054db53350805f83040bf3e6e9b8cf5a139aa7c9 # v0.0.7
5252
if: ${{ !startsWith(github.head_ref, 'renovate/') }}
53+
- name: Install protobuf compiler
54+
run: apt-get update && apt-get install protobuf-compiler -y
5355
- name: Install sqlx
5456
run: cargo install sqlx-cli --no-default-features --features postgres
5557
- name: Run the test sqlx migrations
@@ -78,6 +80,8 @@ jobs:
7880
- name: Run sccache-cache
7981
uses: mozilla-actions/sccache-action@054db53350805f83040bf3e6e9b8cf5a139aa7c9 # v0.0.7
8082
if: ${{ !startsWith(github.head_ref, 'renovate/') }}
83+
- name: Install protobuf compiler
84+
run: apt-get update && apt-get install protobuf-compiler -y
8185
- run: |
8286
rustup component add clippy
8387
# Temporarily allowing dead-code, while denying all other warnings
@@ -116,6 +120,8 @@ jobs:
116120
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
117121
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
118122
if: ${{ !startsWith(github.head_ref, 'renovate/') }}
123+
- name: Install protobuf compiler
124+
run: apt-get update && apt-get install protobuf-compiler -y
119125
- name: Run sccache-cache
120126
uses: mozilla-actions/sccache-action@054db53350805f83040bf3e6e9b8cf5a139aa7c9 # v0.0.7
121127
if: ${{ !startsWith(github.head_ref, 'renovate/') }}
@@ -166,6 +172,8 @@ jobs:
166172
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
167173
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
168174
if: ${{ !startsWith(github.head_ref, 'renovate/') }}
175+
- name: Install protobuf compiler
176+
run: apt-get update && apt-get install protobuf-compiler -y
169177
- name: Run sccache-cache
170178
uses: mozilla-actions/sccache-action@054db53350805f83040bf3e6e9b8cf5a139aa7c9 # v0.0.7
171179
if: ${{ !startsWith(github.head_ref, 'renovate/') }}

Cargo.lock

Lines changed: 79 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ tokio = "1.40"
2828
prometheus = "0.13.3"
2929
anyhow = { version = "1.0.72" }
3030
thiserror = "1.0.49"
31-
async-trait = "0.1.72"
31+
async-trait = "0.1.83"
3232
eventuals = "0.6.7"
3333
base64 = "0.22.1"
3434
reqwest = { version = "0.12", features = [
@@ -75,3 +75,7 @@ bip39 = "2.0.0"
7575
rstest = "0.23.0"
7676
wiremock = "0.6.1"
7777
typed-builder = "0.20.0"
78+
tonic = { version = "0.12.3", features = ["tls-roots", "gzip"] }
79+
tonic-build = { version = "0.12.3", features = ["prost"] }
80+
prost = "0.13.3"
81+
prost-types = "0.13.3"

Dockerfile.indexer-service-rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ COPY . .
66
# Force SQLx to use the offline mode to statically check the database queries against
77
# the prepared files in the `.sqlx` directory.
88
ENV SQLX_OFFLINE=true
9+
10+
RUN apt-get update && apt-get install -y --no-install-recommends \
11+
protobuf-compiler && rm -rf /var/lib/apt/lists/*
912
RUN cargo build --release --bin indexer-service-rs
1013

1114
########################################################################################
1215

1316
FROM debian:bookworm-slim
1417

1518
RUN apt-get update && apt-get install -y --no-install-recommends \
16-
openssl ca-certificates \
19+
openssl ca-certificates protobuf-compiler \
1720
&& rm -rf /var/lib/apt/lists/*
1821
COPY --from=build /root/target/release/indexer-service-rs /usr/local/bin/indexer-service-rs
1922

Dockerfile.indexer-tap-agent

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ COPY . .
66
# Force SQLx to use the offline mode to statically check the database queries against
77
# the prepared files in the `.sqlx` directory.
88
ENV SQLX_OFFLINE=true
9+
RUN apt-get update && apt-get install -y --no-install-recommends \
10+
protobuf-compiler && rm -rf /var/lib/apt/lists/*
911
RUN cargo build --release --bin indexer-tap-agent
1012

1113
########################################################################################

crates/config/maximal-config-example.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,6 @@ max_receipts_per_request = 10000
150150
0x0123456789abcdef0123456789abcdef01234567 = "https://other.example.com/aggregate-receipts"
151151

152152
[dips]
153+
host = "0.0.0.0"
154+
port = "7601"
153155
allowed_payers = ["0x3333333333333333333333333333333333333333"]
154-

crates/config/src/config.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,25 @@ pub struct TapConfig {
387387
#[derive(Debug, Deserialize)]
388388
#[cfg_attr(test, derive(PartialEq))]
389389
pub struct DipsConfig {
390+
pub host: String,
391+
pub port: String,
392+
pub expected_payee: Address,
390393
pub allowed_payers: Vec<Address>,
391394
pub cancellation_time_tolerance: Option<Duration>,
392395
}
393396

397+
impl Default for DipsConfig {
398+
fn default() -> Self {
399+
DipsConfig {
400+
host: "0.0.0.0".to_string(),
401+
port: "7601".to_string(),
402+
expected_payee: Address::ZERO,
403+
allowed_payers: vec![],
404+
cancellation_time_tolerance: None,
405+
}
406+
}
407+
}
408+
394409
impl TapConfig {
395410
pub fn get_trigger_value(&self) -> u128 {
396411
let grt_wei = self.max_amount_willing_to_lose_grt.get_value();
@@ -420,11 +435,11 @@ pub struct RavRequestConfig {
420435

421436
#[cfg(test)]
422437
mod tests {
423-
use std::{env, fs, path::PathBuf};
438+
use std::{env, fs, path::PathBuf, str::FromStr};
424439

425440
use figment::value::Uncased;
426441
use sealed_test::prelude::*;
427-
use thegraph_core::alloy::primitives::address;
442+
use thegraph_core::alloy::primitives::{Address, FixedBytes};
428443
use tracing_test::traced_test;
429444

430445
use super::{DatabaseConfig, SHARED_PREFIX};
@@ -448,8 +463,11 @@ mod tests {
448463
)
449464
.unwrap();
450465
max_config.dips = Some(crate::DipsConfig {
451-
allowed_payers: vec![address!("3333333333333333333333333333333333333333")],
452-
cancellation_time_tolerance: None,
466+
allowed_payers: vec![Address(
467+
FixedBytes::<20>::from_str("0x3333333333333333333333333333333333333333").unwrap(),
468+
)],
469+
expected_payee: Address::ZERO,
470+
..Default::default()
453471
});
454472

455473
let max_config_file: Config = toml::from_str(

crates/dips/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,13 @@ thiserror.workspace = true
88
anyhow.workspace = true
99
alloy-rlp = "0.3.10"
1010
thegraph-core.workspace = true
11+
tonic.workspace = true
12+
async-trait.workspace = true
13+
prost.workspace = true
14+
prost-types.workspace = true
15+
uuid.workspace = true
16+
base64.workspace = true
17+
tokio.workspace = true
18+
19+
[build-dependencies]
20+
tonic-build = { workspace = true }

crates/dips/build.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
fn main() {
5+
println!("cargo:rerun-if-changed=proto");
6+
tonic_build::configure()
7+
.out_dir("src/proto")
8+
.include_file("mod.rs")
9+
.protoc_arg("--experimental_allow_proto3_optional")
10+
.compile_protos(&["proto/dips.proto"], &["proto"])
11+
.expect("Failed to compile dips proto(s)");
12+
}

0 commit comments

Comments
 (0)