Skip to content

Commit 75d877e

Browse files
committed
dips grpc
1 parent ed4721d commit 75d877e

File tree

21 files changed

+1157
-464
lines changed

21 files changed

+1157
-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: 6 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 install protobuf-compiler
5355
- name: Install sqlx
5456
run: cargo install sqlx-cli --no-default-features --features postgres
5557
- name: Run the test sqlx migrations
@@ -116,6 +118,8 @@ jobs:
116118
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
117119
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
118120
if: ${{ !startsWith(github.head_ref, 'renovate/') }}
121+
- name: Install protobuf compiler
122+
run: apt-get install protobuf-compiler
119123
- name: Run sccache-cache
120124
uses: mozilla-actions/sccache-action@9e326ebed976843c9932b3aa0e021c6f50310eb4 # v0.0.6
121125
if: ${{ !startsWith(github.head_ref, 'renovate/') }}
@@ -166,6 +170,8 @@ jobs:
166170
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
167171
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
168172
if: ${{ !startsWith(github.head_ref, 'renovate/') }}
173+
- name: Install protobuf compiler
174+
run: apt-get install protobuf-compiler
169175
- name: Run sccache-cache
170176
uses: mozilla-actions/sccache-action@9e326ebed976843c9932b3aa0e021c6f50310eb4 # v0.0.6
171177
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"

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

crates/dips/proto/dips.proto

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

0 commit comments

Comments
 (0)