Skip to content

Commit 361d067

Browse files
committed
feat: dips grpc
1 parent ed4721d commit 361d067

File tree

22 files changed

+1172
-464
lines changed

22 files changed

+1172
-464
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@9e326ebed976843c9932b3aa0e021c6f50310eb4 # v0.0.6
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@9e326ebed976843c9932b3aa0e021c6f50310eb4 # v0.0.6
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@9e326ebed976843c9932b3aa0e021c6f50310eb4 # v0.0.6
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@9e326ebed976843c9932b3aa0e021c6f50310eb4 # v0.0.6
171179
if: ${{ !startsWith(github.head_ref, 'renovate/') }}

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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ 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 \
12+
&& rm -rf /var/lib/apt/lists/*
913
RUN cargo build --release --bin indexer-service-rs
1014

1115
########################################################################################

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: 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+
}

crates/dips/proto/dips.proto

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
syntax = "proto3";
5+
6+
package graphprotocol.indexer.dips;
7+
8+
service AgreementService {
9+
rpc CreateAgreement(CreateAgreementRequest) returns (CreateAgreementResponse);
10+
rpc CancelAgreement(CancelAgreementRequest) returns (AgreementCanellationResponse);
11+
rpc GetAgreementById(GetAgreementByIdRequest) returns (GetAgreementByIdResponse);
12+
rpc GetPrice(PriceRequest) returns (PriceResponse);
13+
}
14+
15+
message GetAgreementByIdRequest {
16+
17+
}
18+
19+
message GetAgreementByIdResponse {
20+
21+
}
22+
23+
message CreateAgreementRequest {
24+
string id = 1;
25+
bytes signed_voucher = 2;
26+
}
27+
28+
message CancelAgreementRequest {
29+
string id = 1;
30+
bytes signed_voucher = 2;
31+
}
32+
33+
message CreateAgreementResponse {
34+
string uuid = 1;
35+
}
36+
37+
message AgreementCanellationResponse {
38+
string uuid = 1;
39+
}
40+
41+
message PriceRequest {
42+
ProtocolNetwork protocol = 1;
43+
string chain_id = 2;
44+
}
45+
46+
message PriceResponse {
47+
optional Price price = 1;
48+
}
49+
50+
message Price {
51+
string price_per_block = 1;
52+
string chain_id = 2;
53+
ProtocolNetwork protocol = 3;
54+
}
55+
56+
enum ProtocolNetwork {
57+
UNKNOWN = 0;
58+
EVM = 1;
59+
}

0 commit comments

Comments
 (0)