diff --git a/crates/dips/proto/indexer.proto b/crates/dips/proto/indexer.proto index b1ab0451..07763f10 100644 --- a/crates/dips/proto/indexer.proto +++ b/crates/dips/proto/indexer.proto @@ -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. } /** diff --git a/crates/dips/src/lib.rs b/crates/dips/src/lib.rs index 2c369b87..62b8268e 100644 --- a/crates/dips/src/lib.rs +++ b/crates/dips/src/lib.rs @@ -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; } @@ -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, }); } @@ -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, @@ -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, @@ -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, diff --git a/crates/dips/src/proto/graphprotocol.indexer.dips.rs b/crates/dips/src/proto/graphprotocol.indexer.dips.rs index 797191f0..d01d4be9 100644 --- a/crates/dips/src/proto/graphprotocol.indexer.dips.rs +++ b/crates/dips/src/proto/graphprotocol.indexer.dips.rs @@ -9,57 +9,8 @@ pub struct SubmitAgreementProposalRequest { #[prost(bytes = "vec", tag = "1")] pub agreement_id: ::prost::alloc::vec::Vec, /// / The voucher of the agreement. - #[prost(message, optional, tag = "20")] - pub voucher: ::core::option::Option, - /// / The signature of the message. - #[prost(bytes = "vec", tag = "99")] - pub signature: ::prost::alloc::vec::Vec, -} -/// * -/// 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, - /// / The voucher recipient address. - #[prost(bytes = "vec", tag = "2")] - pub recipient: ::prost::alloc::vec::Vec, - /// / Service address that will initiate the payment collection. - #[prost(bytes = "vec", tag = "3")] - pub service: ::prost::alloc::vec::Vec, - /// / 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, - /// / 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, - /// / 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, -} -/// * -/// 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, - /// / 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, - /// / 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, + pub signed_voucher: ::prost::alloc::vec::Vec, } /// * /// A response to a request to propose a new _indexing agreement_ to an _indexer_. diff --git a/crates/service/src/database/dips.rs b/crates/service/src/database/dips.rs index b90bd367..173750ab 100644 --- a/crates/service/src/database/dips.rs +++ b/crates/service/src/database/dips.rs @@ -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, diff --git a/crates/service/src/service.rs b/crates/service/src/service.rs index 9d20f0d9..70d060f5 100644 --- a/crates/service/src/service.rs +++ b/crates/service/src/service.rs @@ -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, }; @@ -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");