-
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
Open
vgonkivs
wants to merge
4
commits into
celestiaorg:shrex_spec
Choose a base branch
from
vgonkivs:shrex_client_server
base: shrex_spec
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+268
−0
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| - In certain cases (GetNamespaceData), sends non-inclusion proof along with not found | ||
|
|
||
| ### 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** - error during sending a status back the client | ||
| - **SEND RESPONSE ERROR** - error during sending a status back the client | ||
| - **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(or non inclusion proof in case of GetNamespaceData request) | ||
|
|
||
| ## Error Handling | ||
|
|
||
| ### Client Errors | ||
|
|
||
| The client reports errors to its caller: | ||
|
|
||
| - Connection failures | ||
| - Timeouts | ||
|
|
||
| ### 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. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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