diff --git a/crates/dips/build.rs b/crates/dips/build.rs index 198109003..261010956 100644 --- a/crates/dips/build.rs +++ b/crates/dips/build.rs @@ -13,13 +13,5 @@ fn main() { .protoc_arg("--experimental_allow_proto3_optional") .compile_protos(&["proto/indexer.proto"], &["proto/"]) .expect("Failed to compile DIPs indexer RPC proto(s)"); - - tonic_prost_build::configure() - .build_server(true) - .out_dir("src/proto") - .include_file("gateway.rs") - .protoc_arg("--experimental_allow_proto3_optional") - .compile_protos(&["proto/gateway.proto"], &["proto"]) - .expect("Failed to compile DIPs gateway RPC proto(s)"); } } diff --git a/crates/dips/proto/gateway.proto b/crates/dips/proto/gateway.proto deleted file mode 100644 index 47453b7df..000000000 --- a/crates/dips/proto/gateway.proto +++ /dev/null @@ -1,73 +0,0 @@ -syntax = "proto3"; - -package graphprotocol.gateway.dips; - -service GatewayDipsService { - /** - * 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); - - /** - * Collect payment for 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 CollectPayment(CollectPaymentRequest) returns (CollectPaymentResponse); -} - - -/** - * A request to cancel an _indexing agreement_. - * - * See the `DipsService.CancelAgreement` method. - */ -message CancelAgreementRequest { - uint64 version = 1; - bytes signed_cancellation = 2; /// a signed ERC-712 message cancelling an agreement -} - -/** - * A response to a request to cancel an _indexing agreement_. - * - * See the `DipsService.CancelAgreement` method. - */ -message CancelAgreementResponse { - /// Empty response, eventually we may add custom status codes -} - -/** - * A request to collect payment _indexing agreement_. - * - * See the `DipsService.CollectPayment` method. - */ -message CollectPaymentRequest { - uint64 version = 1; - bytes signed_collection = 2; -} - -/** - * A response to a request to collect payment for an _indexing agreement_. - * - * See the `DipsService.CollectAgreement` method. - */ -message CollectPaymentResponse { - uint64 version = 1; - CollectPaymentStatus status = 2; - bytes tap_receipt = 3; -} - -/** - * The status on response to collect an _indexing agreement_. - */ -enum CollectPaymentStatus { - ACCEPT = 0; /// The payment request was accepted. - ERR_TOO_EARLY = 1; /// The payment request was done before min epochs passed - ERR_TOO_LATE = 2; /// The payment request was done after max epochs passed - ERR_AMOUNT_OUT_OF_BOUNDS = 3; /// The payment request is for too large an amount - ERR_UNKNOWN = 99; /// Something else went terribly wrong -} diff --git a/crates/dips/proto/indexer.proto b/crates/dips/proto/indexer.proto index 0521f5a26..6199036f3 100644 --- a/crates/dips/proto/indexer.proto +++ b/crates/dips/proto/indexer.proto @@ -9,11 +9,6 @@ service IndexerDipsService { * 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); } /** @@ -23,7 +18,7 @@ service IndexerDipsService { */ message SubmitAgreementProposalRequest { uint64 version = 1; - bytes signed_voucher = 2; /// An ERC-712 signed indexing agreement voucher + bytes signed_rca = 2; /// ABI-encoded SignedRCA (RecurringCollectionAgreement plus signature). } /** @@ -60,22 +55,3 @@ enum RejectReason { REJECT_REASON_AGREEMENT_EXPIRED = 8; /// The agreement end time has already passed. REJECT_REASON_UNSUPPORTED_METADATA_VERSION = 9; /// The metadata version is not supported. } - -/** - * A request to cancel an _indexing agreement_. - * - * See the `DipsService.CancelAgreement` method. - */ -message CancelAgreementRequest { - uint64 version = 1; - bytes signed_cancellation = 2; /// a signed ERC-712 message cancelling an agreement -} - -/** - * A response to a request to cancel an existing _indexing agreement_. - * - * See the `DipsService.CancelAgreement` method. - */ -message CancelAgreementResponse { - // Empty message, eventually we may add custom status codes -} diff --git a/crates/dips/src/proto/gateway.rs b/crates/dips/src/proto/gateway.rs deleted file mode 100644 index fd13ab498..000000000 --- a/crates/dips/src/proto/gateway.rs +++ /dev/null @@ -1,8 +0,0 @@ -// This file is @generated by prost-build. -pub mod graphprotocol { - pub mod gateway { - pub mod dips { - include!("graphprotocol.gateway.dips.rs"); - } - } -} diff --git a/crates/dips/src/proto/graphprotocol.gateway.dips.rs b/crates/dips/src/proto/graphprotocol.gateway.dips.rs deleted file mode 100644 index 21766fafb..000000000 --- a/crates/dips/src/proto/graphprotocol.gateway.dips.rs +++ /dev/null @@ -1,503 +0,0 @@ -// This file is @generated by prost-build. -/// * -/// -/// A request to cancel an *indexing agreement*. -/// -/// See the `DipsService.CancelAgreement` method. -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct CancelAgreementRequest { - #[prost(uint64, tag = "1")] - pub version: u64, - /// / a signed ERC-712 message cancelling an agreement - #[prost(bytes = "vec", tag = "2")] - pub signed_cancellation: ::prost::alloc::vec::Vec, -} -/// * -/// -/// A response to a request to cancel an *indexing agreement*. -/// -/// See the `DipsService.CancelAgreement` method. -/// -/// / Empty response, eventually we may add custom status codes -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct CancelAgreementResponse {} -/// * -/// -/// A request to collect payment *indexing agreement*. -/// -/// See the `DipsService.CollectPayment` method. -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct CollectPaymentRequest { - #[prost(uint64, tag = "1")] - pub version: u64, - #[prost(bytes = "vec", tag = "2")] - pub signed_collection: ::prost::alloc::vec::Vec, -} -/// * -/// -/// A response to a request to collect payment for an *indexing agreement*. -/// -/// See the `DipsService.CollectAgreement` method. -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct CollectPaymentResponse { - #[prost(uint64, tag = "1")] - pub version: u64, - #[prost(enumeration = "CollectPaymentStatus", tag = "2")] - pub status: i32, - #[prost(bytes = "vec", tag = "3")] - pub tap_receipt: ::prost::alloc::vec::Vec, -} -/// * -/// -/// The status on response to collect an *indexing agreement*. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum CollectPaymentStatus { - /// / The payment request was accepted. - Accept = 0, - /// / The payment request was done before min epochs passed - ErrTooEarly = 1, - /// / The payment request was done after max epochs passed - ErrTooLate = 2, - /// / The payment request is for too large an amount - ErrAmountOutOfBounds = 3, - /// / Something else went terribly wrong - ErrUnknown = 99, -} -impl CollectPaymentStatus { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Accept => "ACCEPT", - Self::ErrTooEarly => "ERR_TOO_EARLY", - Self::ErrTooLate => "ERR_TOO_LATE", - Self::ErrAmountOutOfBounds => "ERR_AMOUNT_OUT_OF_BOUNDS", - Self::ErrUnknown => "ERR_UNKNOWN", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "ACCEPT" => Some(Self::Accept), - "ERR_TOO_EARLY" => Some(Self::ErrTooEarly), - "ERR_TOO_LATE" => Some(Self::ErrTooLate), - "ERR_AMOUNT_OUT_OF_BOUNDS" => Some(Self::ErrAmountOutOfBounds), - "ERR_UNKNOWN" => Some(Self::ErrUnknown), - _ => None, - } - } -} -/// Generated client implementations. -pub mod gateway_dips_service_client { - #![allow( - unused_variables, - dead_code, - missing_docs, - clippy::wildcard_imports, - clippy::let_unit_value, - )] - use tonic::codegen::*; - use tonic::codegen::http::Uri; - #[derive(Debug, Clone)] - pub struct GatewayDipsServiceClient { - inner: tonic::client::Grpc, - } - impl GatewayDipsServiceClient { - /// Attempt to create a new client by connecting to a given endpoint. - pub async fn connect(dst: D) -> Result - where - D: TryInto, - D::Error: Into, - { - let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; - Ok(Self::new(conn)) - } - } - impl GatewayDipsServiceClient - where - T: tonic::client::GrpcService, - T::Error: Into, - T::ResponseBody: Body + std::marker::Send + 'static, - ::Error: Into + std::marker::Send, - { - pub fn new(inner: T) -> Self { - let inner = tonic::client::Grpc::new(inner); - Self { inner } - } - pub fn with_origin(inner: T, origin: Uri) -> Self { - let inner = tonic::client::Grpc::with_origin(inner, origin); - Self { inner } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> GatewayDipsServiceClient> - where - F: tonic::service::Interceptor, - T::ResponseBody: Default, - T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, - >, - , - >>::Error: Into + std::marker::Send + std::marker::Sync, - { - GatewayDipsServiceClient::new(InterceptedService::new(inner, interceptor)) - } - /// Compress requests with the given encoding. - /// - /// This requires the server to support it otherwise it might respond with an - /// error. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.send_compressed(encoding); - self - } - /// Enable decompressing responses. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.accept_compressed(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_decoding_message_size(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_encoding_message_size(limit); - self - } - /// * - /// - /// Cancel an *indexing agreement*. - /// - /// This method allows the indexer to notify the DIPs gateway that the agreement - /// should be canceled. - pub async fn cancel_agreement( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic_prost::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/graphprotocol.gateway.dips.GatewayDipsService/CancelAgreement", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "graphprotocol.gateway.dips.GatewayDipsService", - "CancelAgreement", - ), - ); - self.inner.unary(req, path, codec).await - } - /// * - /// - /// Collect payment for 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. - pub async fn collect_payment( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic_prost::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/graphprotocol.gateway.dips.GatewayDipsService/CollectPayment", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "graphprotocol.gateway.dips.GatewayDipsService", - "CollectPayment", - ), - ); - self.inner.unary(req, path, codec).await - } - } -} -/// Generated server implementations. -pub mod gateway_dips_service_server { - #![allow( - unused_variables, - dead_code, - missing_docs, - clippy::wildcard_imports, - clippy::let_unit_value, - )] - use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with GatewayDipsServiceServer. - #[async_trait] - pub trait GatewayDipsService: std::marker::Send + std::marker::Sync + 'static { - /// * - /// - /// Cancel an *indexing agreement*. - /// - /// This method allows the indexer to notify the DIPs gateway that the agreement - /// should be canceled. - async fn cancel_agreement( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; - /// * - /// - /// Collect payment for 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. - async fn collect_payment( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; - } - #[derive(Debug)] - pub struct GatewayDipsServiceServer { - inner: Arc, - accept_compression_encodings: EnabledCompressionEncodings, - send_compression_encodings: EnabledCompressionEncodings, - max_decoding_message_size: Option, - max_encoding_message_size: Option, - } - impl GatewayDipsServiceServer { - pub fn new(inner: T) -> Self { - Self::from_arc(Arc::new(inner)) - } - pub fn from_arc(inner: Arc) -> Self { - Self { - inner, - accept_compression_encodings: Default::default(), - send_compression_encodings: Default::default(), - max_decoding_message_size: None, - max_encoding_message_size: None, - } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService - where - F: tonic::service::Interceptor, - { - InterceptedService::new(Self::new(inner), interceptor) - } - /// Enable decompressing requests with the given encoding. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.accept_compression_encodings.enable(encoding); - self - } - /// Compress responses with the given encoding, if the client supports it. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.send_compression_encodings.enable(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.max_decoding_message_size = Some(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.max_encoding_message_size = Some(limit); - self - } - } - impl tonic::codegen::Service> for GatewayDipsServiceServer - where - T: GatewayDipsService, - B: Body + std::marker::Send + 'static, - B::Error: Into + std::marker::Send + 'static, - { - type Response = http::Response; - type Error = std::convert::Infallible; - type Future = BoxFuture; - fn poll_ready( - &mut self, - _cx: &mut Context<'_>, - ) -> Poll> { - Poll::Ready(Ok(())) - } - fn call(&mut self, req: http::Request) -> Self::Future { - match req.uri().path() { - "/graphprotocol.gateway.dips.GatewayDipsService/CancelAgreement" => { - #[allow(non_camel_case_types)] - struct CancelAgreementSvc(pub Arc); - impl< - T: GatewayDipsService, - > tonic::server::UnaryService - for CancelAgreementSvc { - type Response = super::CancelAgreementResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::cancel_agreement(&inner, request) - .await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = CancelAgreementSvc(inner); - let codec = tonic_prost::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/graphprotocol.gateway.dips.GatewayDipsService/CollectPayment" => { - #[allow(non_camel_case_types)] - struct CollectPaymentSvc(pub Arc); - impl< - T: GatewayDipsService, - > tonic::server::UnaryService - for CollectPaymentSvc { - type Response = super::CollectPaymentResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::collect_payment(&inner, request) - .await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = CollectPaymentSvc(inner); - let codec = tonic_prost::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - _ => { - Box::pin(async move { - let mut response = http::Response::new( - tonic::body::Body::default(), - ); - let headers = response.headers_mut(); - headers - .insert( - tonic::Status::GRPC_STATUS, - (tonic::Code::Unimplemented as i32).into(), - ); - headers - .insert( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ); - Ok(response) - }) - } - } - } - } - impl Clone for GatewayDipsServiceServer { - fn clone(&self) -> Self { - let inner = self.inner.clone(); - Self { - inner, - accept_compression_encodings: self.accept_compression_encodings, - send_compression_encodings: self.send_compression_encodings, - max_decoding_message_size: self.max_decoding_message_size, - max_encoding_message_size: self.max_encoding_message_size, - } - } - } - /// Generated gRPC service name - pub const SERVICE_NAME: &str = "graphprotocol.gateway.dips.GatewayDipsService"; - impl tonic::server::NamedService for GatewayDipsServiceServer { - const NAME: &'static str = SERVICE_NAME; - } -} diff --git a/crates/dips/src/proto/graphprotocol.indexer.dips.rs b/crates/dips/src/proto/graphprotocol.indexer.dips.rs index 5202021bb..7cce8f90b 100644 --- a/crates/dips/src/proto/graphprotocol.indexer.dips.rs +++ b/crates/dips/src/proto/graphprotocol.indexer.dips.rs @@ -8,9 +8,9 @@ pub struct SubmitAgreementProposalRequest { #[prost(uint64, tag = "1")] pub version: u64, - /// / An ERC-712 signed indexing agreement voucher + /// / ABI-encoded SignedRCA (RecurringCollectionAgreement plus signature). #[prost(bytes = "vec", tag = "2")] - pub signed_voucher: ::prost::alloc::vec::Vec, + pub signed_rca: ::prost::alloc::vec::Vec, } /// * /// @@ -28,28 +28,6 @@ pub struct SubmitAgreementProposalResponse { } /// * /// -/// A request to cancel an *indexing agreement*. -/// -/// See the `DipsService.CancelAgreement` method. -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct CancelAgreementRequest { - #[prost(uint64, tag = "1")] - pub version: u64, - /// / a signed ERC-712 message cancelling an agreement - #[prost(bytes = "vec", tag = "2")] - pub signed_cancellation: ::prost::alloc::vec::Vec, -} -/// * -/// -/// A response to a request to cancel an existing *indexing agreement*. -/// -/// See the `DipsService.CancelAgreement` method. -/// -/// Empty message, eventually we may add custom status codes -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct CancelAgreementResponse {} -/// * -/// /// The response to an *indexing agreement* proposal. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] @@ -280,38 +258,6 @@ pub mod indexer_dips_service_client { ); self.inner.unary(req, path, codec).await } - /// * - /// - /// Request to cancel an existing *indexing agreement*. - pub async fn cancel_agreement( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic_prost::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/graphprotocol.indexer.dips.IndexerDipsService/CancelAgreement", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "graphprotocol.indexer.dips.IndexerDipsService", - "CancelAgreement", - ), - ); - self.inner.unary(req, path, codec).await - } } } /// Generated server implementations. @@ -339,16 +285,6 @@ pub mod indexer_dips_service_server { tonic::Response, tonic::Status, >; - /// * - /// - /// Request to cancel an existing *indexing agreement*. - async fn cancel_agreement( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; } #[derive(Debug)] pub struct IndexerDipsServiceServer { @@ -477,52 +413,6 @@ pub mod indexer_dips_service_server { }; Box::pin(fut) } - "/graphprotocol.indexer.dips.IndexerDipsService/CancelAgreement" => { - #[allow(non_camel_case_types)] - struct CancelAgreementSvc(pub Arc); - impl< - T: IndexerDipsService, - > tonic::server::UnaryService - for CancelAgreementSvc { - type Response = super::CancelAgreementResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::cancel_agreement(&inner, request) - .await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = CancelAgreementSvc(inner); - let codec = tonic_prost::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } _ => { Box::pin(async move { let mut response = http::Response::new( diff --git a/crates/dips/src/proto/mod.rs b/crates/dips/src/proto/mod.rs index 1c4a03c0f..8fd3b83cc 100644 --- a/crates/dips/src/proto/mod.rs +++ b/crates/dips/src/proto/mod.rs @@ -1,12 +1,7 @@ //! Protocol buffer definitions for DIPS gRPC services. //! //! This module re-exports auto-generated protobuf types from prost-build. -//! The `.proto` files define two service interfaces: -//! -//! - **gateway** - Gateway-to-Dipper communication (not used by indexer-rs) -//! - **indexer** - Dipper-to-indexer communication ([`IndexerDipsService`]) -//! -//! The indexer service implements `IndexerDipsService` to receive RCA proposals. +//! Only one service interface remains: `IndexerDipsService`, the +//! Dipper-to-indexer RPC for delivering RCA proposals. -pub mod gateway; pub mod indexer; diff --git a/crates/dips/src/server.rs b/crates/dips/src/server.rs index b3aa1e6c7..d2104361e 100644 --- a/crates/dips/src/server.rs +++ b/crates/dips/src/server.rs @@ -37,8 +37,10 @@ //! //! # Cancellation //! -//! The `cancel_agreement` endpoint is unimplemented. Cancellation is handled -//! on-chain via the RecurringCollector contract, not through this gRPC interface. +//! Cancellation is handled entirely on-chain via the RecurringCollector contract; +//! there is no gRPC method for it. Dipper calls `cancelIndexingAgreementByPayer` +//! directly and indexer-agents observe `IndexingAgreementCanceled` events through +//! the indexing-payments subgraph. use std::{collections::BTreeMap, sync::Arc}; @@ -50,9 +52,8 @@ use crate::{ ipfs::IpfsFetcher, price::PriceCalculator, proto::indexer::graphprotocol::indexer::dips::{ - indexer_dips_service_server::IndexerDipsService, CancelAgreementRequest, - CancelAgreementResponse, ProposalResponse, RejectReason, SubmitAgreementProposalRequest, - SubmitAgreementProposalResponse, + indexer_dips_service_server::IndexerDipsService, ProposalResponse, RejectReason, + SubmitAgreementProposalRequest, SubmitAgreementProposalResponse, }, store::RcaStore, DipsError, @@ -127,7 +128,7 @@ impl IndexerDipsService for DipsServer { ) -> Result, Status> { let SubmitAgreementProposalRequest { version, - signed_voucher, + signed_rca, } = request.into_inner(); // Only accept version 2 @@ -139,19 +140,19 @@ impl IndexerDipsService for DipsServer { } // Basic sanity checks - if signed_voucher.is_empty() { - return Err(Status::invalid_argument("signed_voucher cannot be empty")); + if signed_rca.is_empty() { + return Err(Status::invalid_argument("signed_rca cannot be empty")); } - if signed_voucher.len() > 10_000 { + if signed_rca.len() > 10_000 { return Err(Status::invalid_argument( - "signed_voucher exceeds maximum size of 10KB", + "signed_rca exceeds maximum size of 10KB", )); } // Validate and store RCA - let deployment_id = crate::try_extract_deployment_id(&signed_voucher); - match crate::validate_and_create_rca(self.ctx.clone(), &self.expected_payee, signed_voucher) + let deployment_id = crate::try_extract_deployment_id(&signed_rca); + match crate::validate_and_create_rca(self.ctx.clone(), &self.expected_payee, signed_rca) .await { Ok(agreement_id) => { @@ -176,18 +177,6 @@ impl IndexerDipsService for DipsServer { } } } - - /// Cancel agreement - unimplemented. - /// - /// Cancellation is handled on-chain via the RecurringCollector contract. - async fn cancel_agreement( - &self, - _request: Request, - ) -> Result, Status> { - Err(Status::unimplemented( - "Cancellation is handled on-chain via RecurringCollector contract", - )) - } } #[cfg(test)] @@ -224,7 +213,7 @@ mod tests { }; let request = Request::new(SubmitAgreementProposalRequest { version: 2, - signed_voucher: vec![], + signed_rca: vec![], }); // Act @@ -246,7 +235,7 @@ mod tests { let large_payload = vec![0u8; 10_001]; let request = Request::new(SubmitAgreementProposalRequest { version: 2, - signed_voucher: large_payload, + signed_rca: large_payload, }); // Act @@ -267,7 +256,7 @@ mod tests { }; let request = Request::new(SubmitAgreementProposalRequest { version: 1, - signed_voucher: vec![1, 2, 3], + signed_rca: vec![1, 2, 3], }); // Act @@ -279,27 +268,6 @@ mod tests { assert!(err.message().contains("version 2")); } - #[tokio::test] - async fn test_cancel_unimplemented() { - // Arrange - let ctx = DipsServerContext::for_testing(); - let server = DipsServer { - ctx, - expected_payee: Address::ZERO, - }; - let request = Request::new(CancelAgreementRequest { - version: 2, - signed_cancellation: vec![], - }); - - // Act - let err = server.cancel_agreement(request).await.unwrap_err(); - - // Assert - assert_eq!(err.code(), tonic::Code::Unimplemented); - assert!(err.message().contains("RecurringCollector")); - } - // ========================================================================= // Tests for reject_reason_from_error // =========================================================================