Skip to content

Commit dcd4aa8

Browse files
committed
refactor: move dips to grpc
1 parent ed4721d commit dcd4aa8

File tree

22 files changed

+1169
-464
lines changed

22 files changed

+1169
-464
lines changed

.github/workflows/license_headers_check.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ jobs:
2929
-ignore '.github/workflows/*.yaml' \
3030
-ignore '.github/*.yaml' \
3131
-ignore 'migrations/*.sql' \
32+
-ignore 'crates/dips/proto/*.proto' \
33+
-ignore 'crates/dips/src/proto/*.rs' \
3234
.

.github/workflows/tests.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ jobs:
5050
- name: Run sccache-cache
5151
uses: mozilla-actions/sccache-action@9e326ebed976843c9932b3aa0e021c6f50310eb4 # v0.0.6
5252
if: ${{ !startsWith(github.head_ref, 'renovate/') }}
53+
- name: Install protobuf
54+
run: |
55+
apt-get update && apt-get install protobuf-compiler -y
5356
- name: Install sqlx
5457
run: cargo install sqlx-cli --no-default-features --features postgres
5558
- name: Run the test sqlx migrations
@@ -66,6 +69,9 @@ jobs:
6669
DATABASE_URL: postgres://postgres@postgres:5432
6770
SQLX_OFFLINE: true
6871
steps:
72+
- name: Install protobuf
73+
run: |
74+
apt-get update && apt-get install protobuf-compiler -y
6975
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
7076
- name: Cache dependencies
7177
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5

Cargo.lock

Lines changed: 77 additions & 0 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
@@ -38,7 +38,7 @@ tokio = "1.40"
3838
prometheus = "0.13.3"
3939
anyhow = { version = "1.0.72" }
4040
thiserror = "1.0.49"
41-
async-trait = "0.1.72"
41+
async-trait = "0.1.83"
4242
eventuals = "0.6.7"
4343
base64 = "0.22.1"
4444
reqwest = { version = "0.12", features = [
@@ -78,3 +78,7 @@ bip39 = "2.0.0"
7878
rstest = "0.23.0"
7979
wiremock = "0.6.1"
8080
typed-builder = "0.20.0"
81+
tonic = { version = "0.12.3", features = ["tls-roots", "gzip"] }
82+
tonic-build = { version = "0.12.3", features = ["prost"] }
83+
prost = "0.13.3"
84+
prost-types = "0.13.3"

Dockerfile.indexer-service-rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ 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-service-rs
1012

1113
########################################################################################
1214

1315
FROM debian:bookworm-slim
1416

1517
RUN apt-get update && apt-get install -y --no-install-recommends \
16-
openssl ca-certificates \
18+
openssl ca-certificates protobuf-compiler \
1719
&& rm -rf /var/lib/apt/lists/*
1820
COPY --from=build /root/target/release/indexer-service-rs /usr/local/bin/indexer-service-rs
1921

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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,7 @@ max_receipts_per_request = 10000
147147
0x0123456789abcdef0123456789abcdef01234567 = "https://other.example.com/aggregate-receipts"
148148

149149
[dips]
150+
host = "0.0.0.0"
151+
port = "7601"
150152
allowed_payers = ["0x3333333333333333333333333333333333333333"]
153+
expected_payee = "0x0000000000000000000000000000000000000000"

crates/config/src/config.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,25 @@ pub struct TapConfig {
386386
#[derive(Debug, Deserialize)]
387387
#[cfg_attr(test, derive(PartialEq))]
388388
pub struct DipsConfig {
389+
pub host: String,
390+
pub port: String,
391+
pub expected_payee: Address,
389392
pub allowed_payers: Vec<Address>,
390393
pub cancellation_time_tolerance: Option<Duration>,
391394
}
392395

396+
impl Default for DipsConfig {
397+
fn default() -> Self {
398+
DipsConfig {
399+
host: "0.0.0.0".to_string(),
400+
port: "7601".to_string(),
401+
expected_payee: Address::ZERO,
402+
allowed_payers: vec![],
403+
cancellation_time_tolerance: None,
404+
}
405+
}
406+
}
407+
393408
impl TapConfig {
394409
pub fn get_trigger_value(&self) -> u128 {
395410
let grt_wei = self.max_amount_willing_to_lose_grt.get_value();
@@ -450,7 +465,8 @@ mod tests {
450465
allowed_payers: vec![thegraph_core::Address(
451466
FixedBytes::<20>::from_str("0x3333333333333333333333333333333333333333").unwrap(),
452467
)],
453-
cancellation_time_tolerance: None,
468+
expected_payee: thegraph_core::Address::ZERO,
469+
..Default::default()
454470
});
455471

456472
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
@@ -10,3 +10,13 @@ anyhow.workspace = true
1010
alloy-sol-types = "=0.8.13"
1111
alloy-rlp = "0.3.9"
1212
thegraph-core.workspace = true
13+
tonic.workspace = true
14+
async-trait.workspace = true
15+
prost.workspace = true
16+
prost-types.workspace = true
17+
uuid.workspace = true
18+
base64.workspace = true
19+
tokio.workspace = true
20+
21+
[build-dependencies]
22+
tonic-build = { workspace = true }

crates/dips/build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fn main() {
2+
println!("cargo:rerun-if-changed=proto");
3+
tonic_build::configure()
4+
.out_dir("src/proto")
5+
.include_file("mod.rs")
6+
.protoc_arg("--experimental_allow_proto3_optional")
7+
.compile_protos(&["proto/dips.proto"], &["proto"])
8+
.expect("Failed to compile dips proto(s)");
9+
}

0 commit comments

Comments
 (0)