Skip to content

Commit 092d501

Browse files
committed
fix grpc
1 parent 30dada4 commit 092d501

File tree

5 files changed

+21
-112
lines changed

5 files changed

+21
-112
lines changed

crates/dips/proto/indexer.proto

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,7 @@ message SubmitAgreementProposalRequest {
2525
bytes agreementId = 1; /// The ID of the agreement to register.
2626
reserved 2 to 19; /// Reserved for future use.
2727

28-
Voucher voucher = 20; /// The voucher of the agreement.
29-
30-
bytes signature = 99; /// The signature of the message.
31-
}
32-
33-
/**
34-
* A voucher of an _indexing agreement_.
35-
*/
36-
message Voucher {
37-
bytes payer = 1; /// The agreement payer.
38-
bytes recipient = 2; /// The voucher recipient address.
39-
bytes service = 3; /// Service address that will initiate the payment collection.
40-
reserved 4 to 9; /// Reserved for future use.
41-
42-
uint32 durationEpochs = 10; /// The duration of the agreement in epochs.
43-
reserved 11 to 19; /// Reserved for future use.
44-
45-
bytes maxInitialAmount = 20; /// The maximum amount, in _wei GRT_, that can be collected for the initial subgraph sync.
46-
bytes minOngoingAmountPerEpoch = 21; /// The maximum amount, in _wei GRT_, that can be collected per epoch (after the initial sync).
47-
reserved 22 to 29; /// Reserved for future use.
48-
49-
uint32 maxEpochsPerCollection = 30; /// The maximum number of epochs that can be collected at once.
50-
uint32 minEpochsPerCollection = 31; /// The minimum number of epochs that can be collected at once.
51-
reserved 32 to 39; /// Reserved for future use.
52-
53-
VoucherMetadata metadata = 50; /// The voucher metadata.
54-
}
55-
56-
57-
/**
58-
* The indexing agreement voucher metadata.
59-
*/
60-
message VoucherMetadata {
61-
bytes deploymentId = 1; /// The Subgraph deployment ID to index.
62-
reserved 2 to 19; /// Reserved for future use.
63-
64-
bytes pricePerBlock = 20; /// The amount to pay per indexed block in _wei GRT per block_.
65-
bytes pricePerEntityPerEpoch = 21; /// The amount to pay per indexed and stored entity in _wei GRT per entity per epoch_.
28+
bytes signed_voucher = 20; /// The voucher of the agreement.
6629
}
6730

6831
/**

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/graphprotocol.indexer.dips.rs

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,57 +9,8 @@ pub struct SubmitAgreementProposalRequest {
99
#[prost(bytes = "vec", tag = "1")]
1010
pub agreement_id: ::prost::alloc::vec::Vec<u8>,
1111
/// / The voucher of the agreement.
12-
#[prost(message, optional, tag = "20")]
13-
pub voucher: ::core::option::Option<Voucher>,
14-
/// / The signature of the message.
15-
#[prost(bytes = "vec", tag = "99")]
16-
pub signature: ::prost::alloc::vec::Vec<u8>,
17-
}
18-
/// *
19-
/// A voucher of an _indexing agreement_.
20-
#[derive(Clone, PartialEq, ::prost::Message)]
21-
pub struct Voucher {
22-
/// / The agreement payer.
23-
#[prost(bytes = "vec", tag = "1")]
24-
pub payer: ::prost::alloc::vec::Vec<u8>,
25-
/// / The voucher recipient address.
26-
#[prost(bytes = "vec", tag = "2")]
27-
pub recipient: ::prost::alloc::vec::Vec<u8>,
28-
/// / Service address that will initiate the payment collection.
29-
#[prost(bytes = "vec", tag = "3")]
30-
pub service: ::prost::alloc::vec::Vec<u8>,
31-
/// / The duration of the agreement in epochs.
32-
#[prost(uint32, tag = "10")]
33-
pub duration_epochs: u32,
34-
/// / The maximum amount, in _wei GRT_, that can be collected for the initial subgraph sync.
35-
#[prost(bytes = "vec", tag = "20")]
36-
pub max_initial_amount: ::prost::alloc::vec::Vec<u8>,
37-
/// / The maximum amount, in _wei GRT_, that can be collected per epoch (after the initial sync).
38-
#[prost(bytes = "vec", tag = "21")]
39-
pub min_ongoing_amount_per_epoch: ::prost::alloc::vec::Vec<u8>,
40-
/// / The maximum number of epochs that can be collected at once.
41-
#[prost(uint32, tag = "30")]
42-
pub max_epochs_per_collection: u32,
43-
/// / The minimum number of epochs that can be collected at once.
44-
#[prost(uint32, tag = "31")]
45-
pub min_epochs_per_collection: u32,
46-
/// / The voucher metadata.
47-
#[prost(message, optional, tag = "50")]
48-
pub metadata: ::core::option::Option<VoucherMetadata>,
49-
}
50-
/// *
51-
/// The indexing agreement voucher metadata.
52-
#[derive(Clone, PartialEq, ::prost::Message)]
53-
pub struct VoucherMetadata {
54-
/// / The Subgraph deployment ID to index.
55-
#[prost(bytes = "vec", tag = "1")]
56-
pub deployment_id: ::prost::alloc::vec::Vec<u8>,
57-
/// / The amount to pay per indexed block in _wei GRT per block_.
5812
#[prost(bytes = "vec", tag = "20")]
59-
pub price_per_block: ::prost::alloc::vec::Vec<u8>,
60-
/// / The amount to pay per indexed and stored entity in _wei GRT per entity per epoch_.
61-
#[prost(bytes = "vec", tag = "21")]
62-
pub price_per_entity_per_epoch: ::prost::alloc::vec::Vec<u8>,
13+
pub signed_voucher: ::prost::alloc::vec::Vec<u8>,
6314
}
6415
/// *
6516
/// A response to a request to propose a new _indexing agreement_ to an _indexer_.

crates/service/src/database/dips.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl AgreementStore for PsqlAgreementStore {
4949
bs,
5050
protocol,
5151
agreement.voucher.service.as_slice(),
52-
agreement.voucher.payee.as_slice(),
52+
agreement.voucher.recipient.as_slice(),
5353
agreement.voucher.payer.as_slice(),
5454
now,
5555
now,

crates/service/src/service.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use axum::{extract::Request, serve, ServiceExt};
99
use clap::Parser;
1010
use indexer_config::{Config, DipsConfig, GraphNodeConfig, SubgraphConfig};
1111
use indexer_dips::{
12-
proto::graphprotocol::indexer::dips::agreement_service_server::{
13-
AgreementService, AgreementServiceServer,
12+
proto::indexer::graphprotocol::indexer::dips::dips_service_server::{
13+
DipsService, DipsServiceServer,
1414
},
1515
server::DipsServer,
1616
};
@@ -165,9 +165,9 @@ pub async fn run() -> anyhow::Result<()> {
165165
.with_graceful_shutdown(shutdown_handler())
166166
.await?)
167167
}
168-
async fn start_dips_server(addr: SocketAddr, service: impl AgreementService) {
168+
async fn start_dips_server(addr: SocketAddr, service: impl DipsService) {
169169
tonic::transport::Server::builder()
170-
.add_service(AgreementServiceServer::new(service))
170+
.add_service(DipsServiceServer::new(service))
171171
.serve(addr)
172172
.await
173173
.expect("unable to start dips grpc");

0 commit comments

Comments
 (0)