-
Notifications
You must be signed in to change notification settings - Fork 1k
Shrex client server specification #4665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: shrex_spec
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| # SHREX Client/Server Specification | ||
|
|
||
| ## Abstract | ||
|
|
||
| This specification defines a request-response protocol that enables nodes to retrieve data from peers. The protocol provides a simple interface for requesting specific data and receiving responses. | ||
|
|
||
| ## Overview | ||
|
|
||
| It implements a client-server architecture for data exchange: | ||
|
|
||
| - **SHREX Client**: Makes requests to retrieve data from a specific peer | ||
| - **SHREX Server**: Responds to requests by serving data from local storage | ||
|
|
||
| ## Client | ||
|
|
||
| The SHREX client is responsible for: | ||
|
|
||
| - Connecting to a specified peer | ||
| - Sending a data request | ||
| - Receiving and validating the status response | ||
| - Returning the result to the caller | ||
|
|
||
| ### Input and Output | ||
|
|
||
| **Input**: | ||
|
|
||
| - Target peer ID | ||
| - Request parameters (height, type-specific data) | ||
|
|
||
| **Output**: | ||
|
|
||
| - Retrieved data (on success) | ||
| - Error information (on failure) | ||
|
|
||
| ### Request Flow | ||
|
|
||
| ```text | ||
| ┌──────────┐ ┌────────────┐ ┌────────┐ | ||
| │ Getter │ │ Client │ │ Server │ | ||
| └────┬─────┘ └─────┬──────┘ └───┬────┘ | ||
| │ │ │ | ||
| │ Request(peer, data) │ │ | ||
| ├────────────────────>│ │ | ||
| │ │ │ | ||
| │ │ Connect │ | ||
| │ ├───────────────────>│ | ||
| │ │ │ | ||
| │ │ Send Request │ | ||
| │ ├───────────────────>│ | ||
| │ │ │ | ||
| │ │ Receive Status │ | ||
| │ │<───────────────────┤ | ||
| │ │ │ | ||
| │ │ Receive Data │ | ||
| │ │<───────────────────┤ | ||
| │ │ │ | ||
| │ Return Data/Error │ │ | ||
| │<────────────────────┤ │ | ||
| │ │ │ | ||
| ``` | ||
|
|
||
| ## Server | ||
|
|
||
| - Accepting incoming connections | ||
| - Reading and validating requests | ||
| - Retrieving data from local storage | ||
| - Sending responses back to clients | ||
|
|
||
| ### Request Handling | ||
|
|
||
| ```text | ||
| Incoming Request | ||
| │ | ||
| ▼ | ||
| ┌──────────────┐ | ||
| │ Validate │ | ||
| │ Request │ | ||
| └──────┬───────┘ | ||
| │ | ||
| ┌───────┴────────┐ | ||
| │ │ | ||
| Invalid Valid | ||
| │ │ | ||
| ▼ ▼ | ||
| ┌──────────┐ ┌─────────────┐ | ||
| │ Reject │ │ Get Data │ | ||
| └──────────┘ │ from Store │ | ||
| └──────┬──────┘ | ||
| │ | ||
| ┌───────┴────────┐ | ||
| │ │ | ||
| Found Not Found | ||
| │ │ | ||
| ▼ ▼ | ||
| ┌──────────┐ ┌──────────┐ | ||
| │ Send OK │ │ Send NOT │ | ||
| │ + Data │ │ FOUND │ | ||
| └──────────┘ └──────────┘ | ||
| ``` | ||
|
|
||
| ## Response Format | ||
|
|
||
| All server responses follow a two-phase pattern: | ||
|
|
||
| 1. **Status Message**: Indicates whether the request can be fulfilled | ||
| - **OK**: Data is available and will follow | ||
| - **READ REQUEST ERROR** - error happened during reading a request from the stream | ||
| - **SEND STATUS ERROR** - errod during sending a status back the client | ||
vgonkivs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - **SEND RESPONSE ERROR** - errod during sending a status back the client | ||
vgonkivs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - **BAD REQUEST** - request did not pass validation | ||
| - **NOT FOUND**: Requested data is not available | ||
| - **INTERNAL ERROR**: Server encountered an error | ||
|
|
||
| 2. **Data (if OK)**: The actual requested data | ||
|
||
|
|
||
| ## Error Handling | ||
|
|
||
| ### Client Errors | ||
|
|
||
| The client reports errors to its caller: | ||
|
|
||
| - Connection failures | ||
| - Timeouts | ||
| - Invalid data | ||
|
||
|
|
||
| ### Server Errors | ||
|
|
||
| The server handles errors by: | ||
|
|
||
| - Sending appropriate status codes | ||
| - Rejecting invalid requests | ||
|
|
||
| ## Resource Protection | ||
|
|
||
| The protocol includes mechanisms to protect node resources: | ||
|
|
||
| - **Timeouts**: Requests have time limits to prevent resource exhaustion | ||
| - **Validation**: Invalid requests are rejected early to save resources | ||
|
|
||
| ## Requirements Language | ||
|
|
||
| The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in certain cases (ND), not found comes with data too (non incl proof)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually false. Server sends "OK" along with non-inclusion proof