Skip to content

Commit

Permalink
fix: resolve PR concerns
Browse files Browse the repository at this point in the history
  • Loading branch information
KolbyML committed Oct 22, 2024
1 parent a603389 commit cedecda
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 121 deletions.
9 changes: 3 additions & 6 deletions ping-payload-extensions/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ This is a list and short description of all the extensions

| Type number | Name | Supported sub-networks | Short Description | Is this call Required to Implement |
|---|---|---|---|---|
| [1](extensions/type-1.md) | History Distance | History | Allows you to get the radius and other nodes metadata | Yes |
| [2](extensions/type-2.md) | State Distance | State | Allows you to get the state nodes radius | Yes |
| [3](extensions/type-3.md) | Beacon Distance | Beacon | Allows you to get the beacon nodes radius | Yes |
| [4](extensions/type-4.md) | Portal Canonical Transaction Distance | Portal Canonical Transaction | Allows you to get the Portal Canonical Transaction nodes radius | Yes |
| [5](extensions/type-5.md) | Transaction Gossip Distance | Transaction Gossip | Allows you to get the Transaction Gossip nodes radius | Yes |
| [10](extensions/type-10.md) | Client Info | All | It will return you something like `trin/0.1.1-2b00d730/linux-x86_64/rustc1.81.0` | Yes |
| [1](extensions/type-1.md) | Basic Radius Payload | State, Beacon, Canonical Transaction Index, Transaction Gossip | Provides the nodes Radius | Yes |
| [2](extensions/type-2.md) | History Radius Payload | History | Provides the nodes radius and ephemeral header count | Yes |
| [3](extensions/type-3.md) | Client Info | All | It will return you something like `trin/0.1.1-2b00d730/linux-x86_64/rustc1.81.0` | Yes |
17 changes: 9 additions & 8 deletions ping-payload-extensions/extensions/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@

[Description]

## version [Version Number]

[Version Description]

Ping payload
```python

[Payload] = SSZ.serialize(Container([Key Value Pairs]))


[Container Name] = Container(
type: [Type Number],
version: [Type Version],
payload: Container([Payload Description])
payload: [Payload]
)
```

Pong payload
```python

[Payload] = SSZ.serialize(Container([Key Value Pairs]))

[Container Name] = Container(
type: [Type Number],
version: [Type Version],
payload: Container([Payload Description])
payload: [Payload]
)
```
23 changes: 7 additions & 16 deletions ping-payload-extensions/extensions/type-1.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
# Portal History Network Distance
# Basic Radius Payload

This payload is only supposed to be used for the history network

## version 1
A basic Ping/Pong payload which only contains the nodes radius

Ping and Pong Payload
```python
HistoryNetworkDistanceV1 = Container(
type: 1,
version: 1,
payload: Container(data_radius: uint256)
)
```

## version 2
Ping and Pong Payload
```python
HistoryNetworkDistanceV2 = Container(
basic_radius = SSZ.serialize(Container(data_radius: U256))

BasicRadiusPayload = Container(
type: 1,
version: 2,
payload: Container(data_radius: uint256, ephemeral_header_count: uint16)
payload: basic_radius
)
```

34 changes: 0 additions & 34 deletions ping-payload-extensions/extensions/type-10.md

This file was deleted.

18 changes: 9 additions & 9 deletions ping-payload-extensions/extensions/type-2.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Portal State Network Distance
# History Radius Payload

This payload is only supposed to be used for the state network
A specialized radius payload for the history network which contains field for how many ephemeral headers the node holds.

## version 1

Ping and Pong payload
Ping and Pong Payload
```python
StateNetworkDistanceV1 = Container(
type: 2,
version: 1,
payload: Container(data_radius: uint256)

history_radius = SSZ.serialize(Container(data_radius: U256, ephemeral_header_count=U16))

HistoryRadiusPayload = Container(
type: 1,
payload: history_radius
)
```
32 changes: 26 additions & 6 deletions ping-payload-extensions/extensions/type-3.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
# Portal Beacon Network Distance
# Get Client info

This payload is only supposed to be used for the beacon network
This payload is only supposed to be usable from all Networks. This payload allows you to figure out peer's client info. Which will be useful for censuses.


### Type Specifications

Client info are ASCII hex encoded strings.

Client info strings consist of 4 parts
- client name (e.x. `trin`,`fluffy`)
- client version + short commit (e.x. `0.1.1-2b00d730`)
- operating system + cpu archtecture (e.x. `linux-x86_64`)
- programming language + language version (e.x. `rustc1.81.0`)

Example
- String: `trin/0.1.1-2b00d730/linux-x86_64/rustc1.81.0`
- Hex encoding: `0x7472696E2F302E312E312D32623030643733302F6C696E75782D7838365F36342F7275737463312E38312E30`


Max length of a client info we should accept
- MAX_CLIENT_INFO_BYTE_LENGTH = 200

## version 1

Ping and Pong payload
```python
BeaconNetworkDistanceV1 = Container(

client_info = SSZ.serialize(Container(client_info: ByteList[MAX_CLIENT_INFO_BYTE_LENGTH]))

ClientInfoPayload = Container(
type: 3,
version: 1,
payload: Container(data_radius: uint256)
payload: client_info
)
```
14 changes: 0 additions & 14 deletions ping-payload-extensions/extensions/type-4.md

This file was deleted.

14 changes: 0 additions & 14 deletions ping-payload-extensions/extensions/type-5.md

This file was deleted.

37 changes: 23 additions & 14 deletions ping-payload-extensions/ping-custom-payload-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Ping Custom Payload Extensions. A versioned type prefixed format where we can up

# Type's

There are 4_294_967_296 unique type ids.
There are 65536 unique type ids.

Types 0-10_000 and 4_294_957_295-4_294_967_296 are reserved for for future upgrades.
Types 0-10_000 and 65436-65535 are reserved for for future upgrades.

The rest are first come first serve, but they should still be defined in this repo to avoid overlaps.

Expand All @@ -26,15 +26,13 @@ All payloads used in the Ping `custom_payload` MUST follow the `Ping Custom Payl
## Custom Payload Extensions Format

- **type**: what payload type is it
- **verison**: what version of the type it is
- **payload**: a ssz container which contents are specified by the type and version field
- **payload**: a ssz ByteList of max length 1100 which contents are specified the type field


```python
CustomPayloadExtensionsFormat = Container(
type: Bytes4,
version: Bytes4,
payload: Container(inner payload is defined by type and version)
type: u16,
payload: ByteList[max_length=1100]
)
```

Expand All @@ -53,15 +51,26 @@ Pong payload
# Max ASCII hex encoded strings length
MAX_ERROR_BYTE_LENGTH = 300

CustomPayloadExtensionsFormat = Container(
type: 4_294_967_295,
version: 1,
payload: Container(error_code: Bytes4, message: ByteList[MAX_ERROR_BYTE_LENGTH])
error_payload = SSZ.serialize(Container(error_code: u16, message: ByteList[MAX_ERROR_BYTE_LENGTH]))

ErrorPayload = Container(
type: 65535,
payload: error_payload
)
```

### Error Code's

- 0: Extension not supported
- 1: Requested data not found
- 2: System error
#### 0: Extension not supported
This code should be returned if the extension isn't supported. This error should only be returned if
- The extension isn't supported
- The extension isn't a required extension for specified Portal Network.

#### 1: Requested data not found
This error code is for if an extension is asking for something and it doesn't exist.

#### 2: Failed to decode payload
Wasn't able to decode the payload

#### 3: System error
A critical error happened and the ping can't be processed

0 comments on commit cedecda

Please sign in to comment.