Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/license_headers_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ jobs:
-ignore '.github/*.yaml' \
-ignore 'migrations/*.sql' \
-ignore 'crates/dips/src/proto/*' \
-ignore 'crates/dips/proto/*' \
.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ rstest = "0.23.0"
wiremock = "0.6.1"
typed-builder = "0.20.0"
tonic = { version = "0.12.3", features = ["tls-roots", "gzip"] }
tonic-build = { version = "0.12.3", features = ["prost"] }
prost = "0.13.3"
prost = "0.13.4"
prost-types = "0.13.3"
dipper-rpc = { git = "https://github.com/edgeandnode/dipper/", rev = "c8700e2", default-features = false }
tonic-build = "0.12.3"
15 changes: 12 additions & 3 deletions crates/dips/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ fn main() {
println!("cargo:rerun-if-changed=proto");
tonic_build::configure()
.out_dir("src/proto")
.include_file("mod.rs")
.include_file("indexer.rs")
.build_client(false)
.protoc_arg("--experimental_allow_proto3_optional")
.compile_protos(&["proto/dips.proto"], &["proto"])
.expect("Failed to compile dips proto(s)");
.compile_protos(&["proto/indexer.proto"], &["proto/"])
.expect("Failed to compile DIPs indexer RPC proto(s)");

tonic_build::configure()
.out_dir("src/proto")
.include_file("gateway.rs")
.build_server(false)
.protoc_arg("--experimental_allow_proto3_optional")
.compile_protos(&["proto/gateway.proto"], &["proto"])
.expect("Failed to compile DIPs gateway RPC proto(s)");
}
59 changes: 0 additions & 59 deletions crates/dips/proto/dips.proto

This file was deleted.

66 changes: 66 additions & 0 deletions crates/dips/proto/gateway.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
syntax = "proto3";

package graphprotocol.gateway.dips;

service DipsService {
/**
* Cancel an _indexing agreement_.
*
* This method allows the indexer to notify the DIPs gateway that the agreement
* should be canceled.
*/
rpc CancelAgreement(CancelAgreementRequest) returns (CancelAgreementResponse);

/**
* Report the progress of an _indexing agreement_.
*
* This method allows the indexer to report the work completed to the DIPs gateway
* and receive payment for the indexing work done.
*/
rpc ReportProgress(ReportProgressRequest) returns (ReportProgressResponse);
}


/**
* A request to cancel an _indexing agreement_.
*
* See the `DipsService.CancelAgreement` method.
*/
message CancelAgreementRequest {
bytes agreement_id = 1; /// The ID of the agreement to cancel.
reserved 2 to 20; /// Reserved for future use.

bytes signature = 99; /// The signature of the message.
}

/**
* A response to a request to cancel an _indexing agreement_.
*
* See the `DipsService.CancelAgreement` method.
*/
message CancelAgreementResponse {
// Empty message
}


/**
* A request to report the progress of an _indexing agreement_.
*
* See the `DipsService.ReportProgress` method.
*/
message ReportProgressRequest {
bytes agreement_id = 1; /// The ID of the agreement to report progress for.
// TODO(LNSD): Add fields to the message

bytes signature = 99; /// The signature of the message.
}

/**
* A response to a request to report the progress of an _indexing agreement_.
*
* See the `DipsService.ReportProgress` method.
*/
message ReportProgressResponse {
// TODO(LNSD): Add fields to the message
}

67 changes: 67 additions & 0 deletions crates/dips/proto/indexer.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
syntax = "proto3";

package graphprotocol.indexer.dips;

service DipsService {
/**
* Propose a new _indexing agreement_ to an _indexer_.
*
* The _indexer_ can `ACCEPT` or `REJECT` the agreement.
*/
rpc SubmitAgreementProposal(SubmitAgreementProposalRequest) returns (SubmitAgreementProposalResponse);

/**
* Request to cancel an existing _indexing agreement_.
*/
rpc CancelAgreement(CancelAgreementRequest) returns (CancelAgreementResponse);
}

/**
* A request to propose a new _indexing agreement_ to an _indexer_.
*
* See the `DipsService.SubmitAgreementProposal` method.
*/
message SubmitAgreementProposalRequest {
bytes agreementId = 1; /// The ID of the agreement to register.
reserved 2 to 19; /// Reserved for future use.

bytes signed_voucher = 20; /// The voucher of the agreement.
}

/**
* A response to a request to propose a new _indexing agreement_ to an _indexer_.
*
* See the `DipsService.SubmitAgreementProposal` method.
*/
message SubmitAgreementProposalResponse {
ProposalResponse response = 1; /// The response to the agreement proposal.
}

/**
* The response to an _indexing agreement_ proposal.
*/
enum ProposalResponse {
ACCEPT = 0; /// The agreement proposal was accepted.
REJECT = 1; /// The agreement proposal was rejected.
}

/**
* A request to cancel an existing _indexing agreement_.
*
* See the `DipsService.CancelAgreement` method.
*/
message CancelAgreementRequest {
bytes agreementId = 1; /// The ID of the agreement to cancel.
reserved 2 to 20; /// Reserved for future use.

bytes signature = 99; /// The signature of the message.
}

/**
* A response to a request to cancel an existing _indexing agreement_.
*
* See the `DipsService.CancelAgreement` method.
*/
message CancelAgreementResponse {
// Empty message
}
33 changes: 14 additions & 19 deletions crates/dips/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,17 @@ sol! {
// should coincide with signer
address payer;
// should coincide with indexer
address payee;
address recipient;
// data service that will initiate payment collection
address service;
// initial indexing amount max

uint32 durationEpochs;

uint256 maxInitialAmount;
uint256 maxOngoingAmountPerEpoch;
// time to accept the agreement, intended to be on the order
// of hours or mins
uint64 deadline;
uint256 minOngoingAmountPerEpoch;

uint32 maxEpochsPerCollection;
uint32 minEpochsPerCollection;
// after which the agreement is complete
uint32 durationEpochs;
bytes metadata;
}

Expand Down Expand Up @@ -152,10 +150,10 @@ impl SignedIndexingAgreementVoucher {
return Err(DipsError::PayerNotAuthorised(payer));
}

if !self.voucher.payee.eq(expected_payee) {
if !self.voucher.recipient.eq(expected_payee) {
return Err(DipsError::UnexpectedPayee {
expected: *expected_payee,
actual: self.voucher.payee,
actual: self.voucher.recipient,
});
}

Expand Down Expand Up @@ -300,11 +298,10 @@ mod test {

let voucher = IndexingAgreementVoucher {
payer: payer_addr,
payee: payee_addr,
recipient: payee_addr,
service: Address(FixedBytes::ZERO),
maxInitialAmount: U256::from(10000_u64),
maxOngoingAmountPerEpoch: U256::from(10000_u64),
deadline: 1000,
minOngoingAmountPerEpoch: U256::from(10000_u64),
maxEpochsPerCollection: 1000,
minEpochsPerCollection: 1000,
durationEpochs: 1000,
Expand Down Expand Up @@ -353,11 +350,10 @@ mod test {

let voucher = IndexingAgreementVoucher {
payer: payer_addr,
payee: payee.address(),
recipient: payee.address(),
service: Address(FixedBytes::ZERO),
maxInitialAmount: U256::from(10000_u64),
maxOngoingAmountPerEpoch: U256::from(10000_u64),
deadline: 1000,
minOngoingAmountPerEpoch: U256::from(10000_u64),
maxEpochsPerCollection: 1000,
minEpochsPerCollection: 1000,
durationEpochs: 1000,
Expand Down Expand Up @@ -395,11 +391,10 @@ mod test {

let voucher = IndexingAgreementVoucher {
payer: payer_addr,
payee: payee_addr,
recipient: payee_addr,
service: Address(FixedBytes::ZERO),
maxInitialAmount: U256::from(10000_u64),
maxOngoingAmountPerEpoch: U256::from(10000_u64),
deadline: 1000,
minOngoingAmountPerEpoch: U256::from(10000_u64),
maxEpochsPerCollection: 1000,
minEpochsPerCollection: 1000,
durationEpochs: 1000,
Expand Down
8 changes: 8 additions & 0 deletions crates/dips/src/proto/gateway.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This file is @generated by prost-build.
pub mod graphprotocol {
pub mod gateway {
pub mod dips {
include!("graphprotocol.gateway.dips.rs");
}
}
}
Loading
Loading