Skip to content

Commit

Permalink
fix grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
mangas committed Jan 30, 2025
1 parent 30dada4 commit 092d501
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 112 deletions.
39 changes: 1 addition & 38 deletions crates/dips/proto/indexer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,44 +25,7 @@ message SubmitAgreementProposalRequest {
bytes agreementId = 1; /// The ID of the agreement to register.
reserved 2 to 19; /// Reserved for future use.

Voucher voucher = 20; /// The voucher of the agreement.

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

/**
* A voucher of an _indexing agreement_.
*/
message Voucher {
bytes payer = 1; /// The agreement payer.
bytes recipient = 2; /// The voucher recipient address.
bytes service = 3; /// Service address that will initiate the payment collection.
reserved 4 to 9; /// Reserved for future use.

uint32 durationEpochs = 10; /// The duration of the agreement in epochs.
reserved 11 to 19; /// Reserved for future use.

bytes maxInitialAmount = 20; /// The maximum amount, in _wei GRT_, that can be collected for the initial subgraph sync.
bytes minOngoingAmountPerEpoch = 21; /// The maximum amount, in _wei GRT_, that can be collected per epoch (after the initial sync).
reserved 22 to 29; /// Reserved for future use.

uint32 maxEpochsPerCollection = 30; /// The maximum number of epochs that can be collected at once.
uint32 minEpochsPerCollection = 31; /// The minimum number of epochs that can be collected at once.
reserved 32 to 39; /// Reserved for future use.

VoucherMetadata metadata = 50; /// The voucher metadata.
}


/**
* The indexing agreement voucher metadata.
*/
message VoucherMetadata {
bytes deploymentId = 1; /// The Subgraph deployment ID to index.
reserved 2 to 19; /// Reserved for future use.

bytes pricePerBlock = 20; /// The amount to pay per indexed block in _wei GRT per block_.
bytes pricePerEntityPerEpoch = 21; /// The amount to pay per indexed and stored entity in _wei GRT per entity per epoch_.
bytes signed_voucher = 20; /// The voucher of the agreement.
}

/**
Expand Down
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
51 changes: 1 addition & 50 deletions crates/dips/src/proto/graphprotocol.indexer.dips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,57 +9,8 @@ pub struct SubmitAgreementProposalRequest {
#[prost(bytes = "vec", tag = "1")]
pub agreement_id: ::prost::alloc::vec::Vec<u8>,
/// / The voucher of the agreement.
#[prost(message, optional, tag = "20")]
pub voucher: ::core::option::Option<Voucher>,
/// / The signature of the message.
#[prost(bytes = "vec", tag = "99")]
pub signature: ::prost::alloc::vec::Vec<u8>,
}
/// *
/// A voucher of an _indexing agreement_.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Voucher {
/// / The agreement payer.
#[prost(bytes = "vec", tag = "1")]
pub payer: ::prost::alloc::vec::Vec<u8>,
/// / The voucher recipient address.
#[prost(bytes = "vec", tag = "2")]
pub recipient: ::prost::alloc::vec::Vec<u8>,
/// / Service address that will initiate the payment collection.
#[prost(bytes = "vec", tag = "3")]
pub service: ::prost::alloc::vec::Vec<u8>,
/// / The duration of the agreement in epochs.
#[prost(uint32, tag = "10")]
pub duration_epochs: u32,
/// / The maximum amount, in _wei GRT_, that can be collected for the initial subgraph sync.
#[prost(bytes = "vec", tag = "20")]
pub max_initial_amount: ::prost::alloc::vec::Vec<u8>,
/// / The maximum amount, in _wei GRT_, that can be collected per epoch (after the initial sync).
#[prost(bytes = "vec", tag = "21")]
pub min_ongoing_amount_per_epoch: ::prost::alloc::vec::Vec<u8>,
/// / The maximum number of epochs that can be collected at once.
#[prost(uint32, tag = "30")]
pub max_epochs_per_collection: u32,
/// / The minimum number of epochs that can be collected at once.
#[prost(uint32, tag = "31")]
pub min_epochs_per_collection: u32,
/// / The voucher metadata.
#[prost(message, optional, tag = "50")]
pub metadata: ::core::option::Option<VoucherMetadata>,
}
/// *
/// The indexing agreement voucher metadata.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct VoucherMetadata {
/// / The Subgraph deployment ID to index.
#[prost(bytes = "vec", tag = "1")]
pub deployment_id: ::prost::alloc::vec::Vec<u8>,
/// / The amount to pay per indexed block in _wei GRT per block_.
#[prost(bytes = "vec", tag = "20")]
pub price_per_block: ::prost::alloc::vec::Vec<u8>,
/// / The amount to pay per indexed and stored entity in _wei GRT per entity per epoch_.
#[prost(bytes = "vec", tag = "21")]
pub price_per_entity_per_epoch: ::prost::alloc::vec::Vec<u8>,
pub signed_voucher: ::prost::alloc::vec::Vec<u8>,
}
/// *
/// A response to a request to propose a new _indexing agreement_ to an _indexer_.
Expand Down
2 changes: 1 addition & 1 deletion crates/service/src/database/dips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl AgreementStore for PsqlAgreementStore {
bs,
protocol,
agreement.voucher.service.as_slice(),
agreement.voucher.payee.as_slice(),
agreement.voucher.recipient.as_slice(),
agreement.voucher.payer.as_slice(),
now,
now,
Expand Down
8 changes: 4 additions & 4 deletions crates/service/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use axum::{extract::Request, serve, ServiceExt};
use clap::Parser;
use indexer_config::{Config, DipsConfig, GraphNodeConfig, SubgraphConfig};
use indexer_dips::{
proto::graphprotocol::indexer::dips::agreement_service_server::{
AgreementService, AgreementServiceServer,
proto::indexer::graphprotocol::indexer::dips::dips_service_server::{
DipsService, DipsServiceServer,
},
server::DipsServer,
};
Expand Down Expand Up @@ -165,9 +165,9 @@ pub async fn run() -> anyhow::Result<()> {
.with_graceful_shutdown(shutdown_handler())
.await?)
}
async fn start_dips_server(addr: SocketAddr, service: impl AgreementService) {
async fn start_dips_server(addr: SocketAddr, service: impl DipsService) {
tonic::transport::Server::builder()
.add_service(AgreementServiceServer::new(service))
.add_service(DipsServiceServer::new(service))
.serve(addr)
.await
.expect("unable to start dips grpc");
Expand Down

0 comments on commit 092d501

Please sign in to comment.