archethic-node icon indicating copy to clipboard operation
archethic-node copied to clipboard

Network Coordinates Weighted Locally

Open samuelmanzanera opened this issue 1 year ago • 0 comments

Is your feature request related to a problem?

The BeaconChain is integrating global network coordinates aggregated on each BeaconChain's summary based on latency and distribution of nodes. However, during the summary interval (daily based on the mainnet), the closest nodes are not adapted based on the current exchanges over time. This reduces the accuracy of the network patch and closest nodes definition.

Describe the solution you'd like

We should have an implementation such as Vivaldi algorithm, to support weighted network coordinates based on the remote connections exchanges and latency to adjust the network coordinates locally.

With the real time RTT of nodes, the network coordinates will adjust to the moving RTT.

RTT changes

This is calculated after every interaction between the node and other nodes or when there is a significant change in RTT.

Node X RTT RTT'
Node 1 RTT1 RTT1’ = (RTT1/RTTr)*√[(Xx-Xr)^2 + (Yx-Yr)^2]
Node 1 RTT2 RTT2’ = (RTT2/RTTr)*√[(Xx-Xr)^2 + (Yx-Yr)^2]
... ... ...
Node r RTTr RTTr’ = √[(Xx-Xr)^2 + (Yx-Yr)^2]
Node x RTTx = 0 -
... ... ...
Node n RTTn RTT1’ = (RTTn/RTTr)*√[(Xx-Xr)^2 + (Yx-Yr)^2]

Node r being a random node chosen locally, which might change on regular basis (ie. beacon chain slot, or each P2P exchange depending on the complexity of execution from the algorithm)

X,Y coordinates conversion backed can be reduced on the 1st and 2nd digits as condensed coordinate based on ratio.

Weighed coordinates

Node X Theta / angle (θ) Weighted Coordinates (Xw, Yw)
Node 1 θ1 = tan-1 [(Y1 - Yx) / (X1 - Xx)] (Xx + RTT1’Cosθ1 , Yx + RTT1Sinθ1)
Node 1 θ2 = tan-1 [(Y2 - Yx) / (X2 - Xx)] (Xx + RTT2’Cosθ2 , Yx + RTT2Sinθ2)
Node 1 θ3 = tan-1 [(Y3 - Yx) / (X3 - Xx)] (Xx + RTT3’Cosθ3 , Yx + RTT3Sinθ3)
... ... ...
Node x 0 (Xx, Yy)
... ... ...
Node n θn = tan-1 [(Yn - Yx) / (Xn - Xx)] (Xx + RTTnCosθn , Yx + RTTnSinθn)

Calculate the θ i.e the angle between nodes, and add the changes of the new RTT’ (i.e the live RTT) to θ, this will give the new (Xw,Yw) coordinates.

We can then convert the new (Xw, Yw) coordinates to network patch

Additional context

@internet-zero

Epic: #155

samuelmanzanera avatar May 30 '23 12:05 samuelmanzanera