Skip to content
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

RFC: Protocol Messages #1

Merged
merged 32 commits into from
Jun 29, 2020
Merged
Changes from 6 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions text/0001-protocol-messages/0001-protocol-messages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
+ Feature name:`New Protocol Messages`
+ Start date: 2019-12-19
+ RFC PR: [iotaledger/protocol-rfcs#0001](https://github.com/iotaledger/protocol-rfcs/pull/0001)
+ Node software implementation issues:
- [iotaledger/iri#1072](https://github.com/iotaledger/iri/issues/1072)


# Summary
Defines the changes that were introduced during the network rewrite. [iotaledger/iri#1072](https://github.com/iotaledger/iri/issues/1072). This is mainly the introduction of new TLV (type-length-value) messages. A header was added to each message, allowing us to create different message types and support different versiond of the protocol. A handshake message was also inroduced to help establish manageable connections with neighbors.
luca-moser marked this conversation as resolved.
Show resolved Hide resolved

Will also define the STING protocol introduced by the Hornet team. It seperates between transaction requests and broadcasts, allows to request milestones by index, and introduces the concept of heartbeats.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "Broadcast" in favor of saying something like: "It separates between transactions and transaction request, .."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


Here is a table summarizing all the new message types. The 3-6 types are part of STING:

| Type # | Message Type |
| ------ | ------------ |
| 1 | Handshake |
| 2 | Legacy Tx Gossip |
| 3 | Milestone Request|
| 4 | Transaction Broadcast |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saying "Broadcast" implies that this msg type is only used for broadcasting, however that's not true. During syncing while the node requests txs, nodes respond with this msg type (which has nothing to do with broadcasting). Remove the "Broadcast" part.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, you don't want to call replies broadcasts
I agree it is confusing

| 5 | Transaction Request |
| 6 | Heartbeats |
GalRogozinski marked this conversation as resolved.
Show resolved Hide resolved

# Motivation

***The network rewrite change***
1. Ability to kick-out a compromised/malfunctioning neighbor while preserving overall architecture performance. This means that a malfunctioning neighbor will only affect its own relationship with the node and will not affect how then node treats other neighbors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing dot at the end of the bullet point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


2. Drop support for UDP which is in practice slow (due to lack of congestion control) and not so reliable. Only utilize TCP.

3. Enabling possibility to enforce global and per neighbor rate limits in both ingress and egress direction.

5. Enabling prioritization of message types.

6. Enabling the addition of new message types and versioning the protocol. Thus paving the way for STING.


***STING (Still TrInary Network Gossip)***
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please just call it STING as it does not stand for "Still TrInary Network Gossip".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotta find some acronym for it :-P

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STeady Interval Network Gossip? This would refer to the heartbeat message sent upon solidification of a new milestone or pruning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it
let see if @luca-moser likes it


1. Allow for faster syncing by
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • "broadcasts of transactions" is the wrong term
  • Heartbearts -> heartbeats messages (with or without 'messages')

Make the a/b/c separate indented list items to make them easier to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried for a good number of minutes to make this indented and gave up
It only gets indented on HackMD...

If you know how to do it please show me

a. Seperating between requests and broadcasts of transactions.
b. Allowing to request specific milestones by index.
c. Sharing between nodes information on the milestones in their databases via Heartbeats

2. Eliminates fragmentation of request messages.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made it clearer I hope





# Detailed design

## **TLV Messages - Protocol Version 1**
The network rewrite introduces a new breaking protocol between nodes which works with type-length-value (TLV) denoted messages. Meaning that each sent message is composed of a header follwed by the message itself.

| Order | Name | Length (byte) | Desc |
| ----- | ---- | ------------- | ---- |
| 1 | Header | 3 | Metadata of message |
| 2 |Message | Var | Message itself |

#### Header
Each message in the protocol is denoted by a 3 byte header:

| Order | Name | Length (byte) | Desc |
| ----- | ---- | ------------- | ---- |
| 1 | Type | 1 | Type of message |
| 2 |Length| 2 | Length of message (65 KB max)|
Wollac marked this conversation as resolved.
Show resolved Hide resolved
Wollac marked this conversation as resolved.
Show resolved Hide resolved

#### Handshake
The handshake message is the first message which must be sent and received to/from a neighbor. It is used to construct the identity of the neighbor. If the advertised server socket port, coordinator address or mwm does not correspond to the receiving node’s configuration, the connection is dropped. It also sends its support for message types as a bitmap. Each index of the bitmap corresponds to a message type. If the bit on that index is turned on, then the corresponding message type is supported by the node. For example, `[01101110, 01010001]` denotes that this node supports message types 2, 3, 4, 6, 7, 9, 13 and 15. Thus, the length of the bitmap depends on the number of message types supported. The nodes can use that information to know what message types can be realyed to the peers.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explanation of the supported versions is wrong. It's not about message types but versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I wanted to do a change earlier but it didn't catch

will fix

Wollac marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, [01101110, 01010001] denotes that this node supports message types 2, 3, 4, 6, 7, 9, 13 and 15.

Doesn't this bit array has the indices 2,3,5,6,7,10,12,16 set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, but it is not your fault for not understanding. My explanation wasn't clear.
Tell me if it is better now

Wollac marked this conversation as resolved.
Show resolved Hide resolved


| Order | Description | Length (bytes) |
| ----- | ----------- | -------------- |
| 1 | Neighbor's server socket port number, range 1024-65535| 2 |
Wollac marked this conversation as resolved.
Show resolved Hide resolved
| 2 | Timestamp in milliseconds - when the handshake packet was constructed, in order to display the latency to/from the neighbor | 8|
Wollac marked this conversation as resolved.
Show resolved Hide resolved
| 3 | Neighbor's used coordinator address | 49 |
Wollac marked this conversation as resolved.
Show resolved Hide resolved
| 4 | Own used minimum weight magnitude | 1 |
| 5 | Supported message types | variable |
Wollac marked this conversation as resolved.
Show resolved Hide resolved


#### Transaction Gossip
Contains the tx data and a hash of a requested tx. Encodes 5 trits in a byte. If the requested hash corresponds to the hash of the tx data, the receiving node is instructed to send back a random tip.
Wollac marked this conversation as resolved.
Show resolved Hide resolved
The total size of this message varies between 341-1653 bytes due to signature message fragment compaction.

##### Signature Message Fragment Compaction
The byte encoded tx data is truncated by removing all suffix 0 bytes (9 trytes) from the signature message fragment before transmission. This can reduce the size up to 81.7%. Spam transactions, however, can prevent this reduction easily by adding data at the end of the signature message fragment).



| Order | Description | Length (bytes) |
| ----- | ----------- | ---------------- |
| 1 | Transaction Data | 292 - 1604 |
| 2 | Requested Hash | 49 |
Wollac marked this conversation as resolved.
Show resolved Hide resolved


## STING (Still TrInary Network Gossip) - Protocol Version 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "(Still TrInary Network Gossip)"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


STING is an extension to the IOTA protocol. It breaks the transaction gossip into Transaction Broadcast and Transaction Request. Besides that it adds the Milestone Request and Heartbeat messages.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "Broadcast"


#### Milestone Request

Requests a range of milestones by index. Expects to receive in response the milestone bundle for the specified index.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It requests a single milestone and not a range of milestones. Milestone being the complete bundle.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops


| Order | Description | Length (bytes) |
| ----- | ----------- | ---------------- |
| 1 | Milestone Index encoded in Big Endian | 4 |
Wollac marked this conversation as resolved.
Show resolved Hide resolved

#### Transaction Broadcast
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "Broadcast"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


Broadcasts the transaction trytes with a 5 trits to a byte encoding. Doesn't expect any message in return. The size remains dynamic to due to signature message compaction.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Broadcast" implies it is always sent to many recipients but this text should simply describe that this particular message type encapsulates a single transaction. That it is used in broadcasting new transactions shouldn't define this message type's name. In HORNET we simply call it "Transaction Message"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

GalRogozinski marked this conversation as resolved.
Show resolved Hide resolved


| Order | Description | Length (bytes) |
| ----- | ----------- | ---------------- |
| 1 | Transaction Data | 292 - 1604 |

#### Transaction Request

Request a transaction by its 81 trytes hash encoded in bytes.

| Order | Description | Length (bytes) |
| ----- | ----------- | ---------------- |
| 1 | Transaction Hash | 49 |


#### Heartbeat

Relays the neighbor last and first solid milestone indexes. The first one depends on what the pruning. This is used to help a syncing node know what data their neighbor has.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description is not correct. A heartbeat message contains the peer's indexes about the solid milestone and the milestone at which it pruned at. This allows a node to assess whether a given connected peer should have a transaction it needs to sync up.

It should also be noted in the RFC that the heartbeat message is sent every time the solid milestone is updated or pruning was done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was but I made it clearer now I hope

Added the extra info


|Order | Description | Length (bytes) |
| ---- | ------------- | ------------- |
| 1 | First solid milestone index | 4 (Big Endian)|
Wollac marked this conversation as resolved.
Show resolved Hide resolved
| 2 | Last solid milestone index | 4 (Big Endian) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are reversed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch