Skip to content

Commit 6bab2ef

Browse files
authored
refactor: update dips (#590)
1 parent 496968b commit 6bab2ef

File tree

16 files changed

+560
-526
lines changed

16 files changed

+560
-526
lines changed

.github/workflows/license_headers_check.yml

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

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ rstest = "0.23.0"
7777
wiremock = "0.6.1"
7878
typed-builder = "0.20.0"
7979
tonic = { version = "0.12.3", features = ["tls-roots", "gzip"] }
80-
tonic-build = { version = "0.12.3", features = ["prost"] }
81-
prost = "0.13.3"
80+
prost = "0.13.4"
8281
prost-types = "0.13.3"
82+
dipper-rpc = { git = "https://github.com/edgeandnode/dipper/", rev = "c8700e2", default-features = false }
83+
tonic-build = "0.12.3"

crates/dips/build.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,17 @@ fn main() {
55
println!("cargo:rerun-if-changed=proto");
66
tonic_build::configure()
77
.out_dir("src/proto")
8-
.include_file("mod.rs")
8+
.include_file("indexer.rs")
9+
.build_client(false)
910
.protoc_arg("--experimental_allow_proto3_optional")
10-
.compile_protos(&["proto/dips.proto"], &["proto"])
11-
.expect("Failed to compile dips proto(s)");
11+
.compile_protos(&["proto/indexer.proto"], &["proto/"])
12+
.expect("Failed to compile DIPs indexer RPC proto(s)");
13+
14+
tonic_build::configure()
15+
.out_dir("src/proto")
16+
.include_file("gateway.rs")
17+
.build_server(false)
18+
.protoc_arg("--experimental_allow_proto3_optional")
19+
.compile_protos(&["proto/gateway.proto"], &["proto"])
20+
.expect("Failed to compile DIPs gateway RPC proto(s)");
1221
}

crates/dips/proto/dips.proto

Lines changed: 0 additions & 59 deletions
This file was deleted.

crates/dips/proto/gateway.proto

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
syntax = "proto3";
2+
3+
package graphprotocol.gateway.dips;
4+
5+
service DipsService {
6+
/**
7+
* Cancel an _indexing agreement_.
8+
*
9+
* This method allows the indexer to notify the DIPs gateway that the agreement
10+
* should be canceled.
11+
*/
12+
rpc CancelAgreement(CancelAgreementRequest) returns (CancelAgreementResponse);
13+
14+
/**
15+
* Report the progress of an _indexing agreement_.
16+
*
17+
* This method allows the indexer to report the work completed to the DIPs gateway
18+
* and receive payment for the indexing work done.
19+
*/
20+
rpc ReportProgress(ReportProgressRequest) returns (ReportProgressResponse);
21+
}
22+
23+
24+
/**
25+
* A request to cancel an _indexing agreement_.
26+
*
27+
* See the `DipsService.CancelAgreement` method.
28+
*/
29+
message CancelAgreementRequest {
30+
bytes agreement_id = 1; /// The ID of the agreement to cancel.
31+
reserved 2 to 20; /// Reserved for future use.
32+
33+
bytes signature = 99; /// The signature of the message.
34+
}
35+
36+
/**
37+
* A response to a request to cancel an _indexing agreement_.
38+
*
39+
* See the `DipsService.CancelAgreement` method.
40+
*/
41+
message CancelAgreementResponse {
42+
// Empty message
43+
}
44+
45+
46+
/**
47+
* A request to report the progress of an _indexing agreement_.
48+
*
49+
* See the `DipsService.ReportProgress` method.
50+
*/
51+
message ReportProgressRequest {
52+
bytes agreement_id = 1; /// The ID of the agreement to report progress for.
53+
// TODO(LNSD): Add fields to the message
54+
55+
bytes signature = 99; /// The signature of the message.
56+
}
57+
58+
/**
59+
* A response to a request to report the progress of an _indexing agreement_.
60+
*
61+
* See the `DipsService.ReportProgress` method.
62+
*/
63+
message ReportProgressResponse {
64+
// TODO(LNSD): Add fields to the message
65+
}
66+

crates/dips/proto/indexer.proto

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
syntax = "proto3";
2+
3+
package graphprotocol.indexer.dips;
4+
5+
service DipsService {
6+
/**
7+
* Propose a new _indexing agreement_ to an _indexer_.
8+
*
9+
* The _indexer_ can `ACCEPT` or `REJECT` the agreement.
10+
*/
11+
rpc SubmitAgreementProposal(SubmitAgreementProposalRequest) returns (SubmitAgreementProposalResponse);
12+
13+
/**
14+
* Request to cancel an existing _indexing agreement_.
15+
*/
16+
rpc CancelAgreement(CancelAgreementRequest) returns (CancelAgreementResponse);
17+
}
18+
19+
/**
20+
* A request to propose a new _indexing agreement_ to an _indexer_.
21+
*
22+
* See the `DipsService.SubmitAgreementProposal` method.
23+
*/
24+
message SubmitAgreementProposalRequest {
25+
bytes agreementId = 1; /// The ID of the agreement to register.
26+
reserved 2 to 19; /// Reserved for future use.
27+
28+
bytes signed_voucher = 20; /// The voucher of the agreement.
29+
}
30+
31+
/**
32+
* A response to a request to propose a new _indexing agreement_ to an _indexer_.
33+
*
34+
* See the `DipsService.SubmitAgreementProposal` method.
35+
*/
36+
message SubmitAgreementProposalResponse {
37+
ProposalResponse response = 1; /// The response to the agreement proposal.
38+
}
39+
40+
/**
41+
* The response to an _indexing agreement_ proposal.
42+
*/
43+
enum ProposalResponse {
44+
ACCEPT = 0; /// The agreement proposal was accepted.
45+
REJECT = 1; /// The agreement proposal was rejected.
46+
}
47+
48+
/**
49+
* A request to cancel an existing _indexing agreement_.
50+
*
51+
* See the `DipsService.CancelAgreement` method.
52+
*/
53+
message CancelAgreementRequest {
54+
bytes agreementId = 1; /// The ID of the agreement to cancel.
55+
reserved 2 to 20; /// Reserved for future use.
56+
57+
bytes signature = 99; /// The signature of the message.
58+
}
59+
60+
/**
61+
* A response to a request to cancel an existing _indexing agreement_.
62+
*
63+
* See the `DipsService.CancelAgreement` method.
64+
*/
65+
message CancelAgreementResponse {
66+
// Empty message
67+
}

crates/dips/src/lib.rs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,17 @@ sol! {
3838
// should coincide with signer
3939
address payer;
4040
// should coincide with indexer
41-
address payee;
41+
address recipient;
4242
// data service that will initiate payment collection
4343
address service;
44-
// initial indexing amount max
44+
45+
uint32 durationEpochs;
46+
4547
uint256 maxInitialAmount;
46-
uint256 maxOngoingAmountPerEpoch;
47-
// time to accept the agreement, intended to be on the order
48-
// of hours or mins
49-
uint64 deadline;
48+
uint256 minOngoingAmountPerEpoch;
49+
5050
uint32 maxEpochsPerCollection;
5151
uint32 minEpochsPerCollection;
52-
// after which the agreement is complete
53-
uint32 durationEpochs;
5452
bytes metadata;
5553
}
5654

@@ -152,10 +150,10 @@ impl SignedIndexingAgreementVoucher {
152150
return Err(DipsError::PayerNotAuthorised(payer));
153151
}
154152

155-
if !self.voucher.payee.eq(expected_payee) {
153+
if !self.voucher.recipient.eq(expected_payee) {
156154
return Err(DipsError::UnexpectedPayee {
157155
expected: *expected_payee,
158-
actual: self.voucher.payee,
156+
actual: self.voucher.recipient,
159157
});
160158
}
161159

@@ -300,11 +298,10 @@ mod test {
300298

301299
let voucher = IndexingAgreementVoucher {
302300
payer: payer_addr,
303-
payee: payee_addr,
301+
recipient: payee_addr,
304302
service: Address(FixedBytes::ZERO),
305303
maxInitialAmount: U256::from(10000_u64),
306-
maxOngoingAmountPerEpoch: U256::from(10000_u64),
307-
deadline: 1000,
304+
minOngoingAmountPerEpoch: U256::from(10000_u64),
308305
maxEpochsPerCollection: 1000,
309306
minEpochsPerCollection: 1000,
310307
durationEpochs: 1000,
@@ -353,11 +350,10 @@ mod test {
353350

354351
let voucher = IndexingAgreementVoucher {
355352
payer: payer_addr,
356-
payee: payee.address(),
353+
recipient: payee.address(),
357354
service: Address(FixedBytes::ZERO),
358355
maxInitialAmount: U256::from(10000_u64),
359-
maxOngoingAmountPerEpoch: U256::from(10000_u64),
360-
deadline: 1000,
356+
minOngoingAmountPerEpoch: U256::from(10000_u64),
361357
maxEpochsPerCollection: 1000,
362358
minEpochsPerCollection: 1000,
363359
durationEpochs: 1000,
@@ -395,11 +391,10 @@ mod test {
395391

396392
let voucher = IndexingAgreementVoucher {
397393
payer: payer_addr,
398-
payee: payee_addr,
394+
recipient: payee_addr,
399395
service: Address(FixedBytes::ZERO),
400396
maxInitialAmount: U256::from(10000_u64),
401-
maxOngoingAmountPerEpoch: U256::from(10000_u64),
402-
deadline: 1000,
397+
minOngoingAmountPerEpoch: U256::from(10000_u64),
403398
maxEpochsPerCollection: 1000,
404399
minEpochsPerCollection: 1000,
405400
durationEpochs: 1000,

crates/dips/src/proto/gateway.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// This file is @generated by prost-build.
2+
pub mod graphprotocol {
3+
pub mod gateway {
4+
pub mod dips {
5+
include!("graphprotocol.gateway.dips.rs");
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)