freenet / freenet-core

Declare your digital independence
https://freenet.org/
Apache License 2.0
2.28k stars 81 forks source link

Improve network monitor #1166

Open alexisbatyk opened 4 months ago

alexisbatyk commented 4 months ago

It'll be sending more data to network monitor. Creating more types and displaying it better in the web app.

There was a PR associated with this task. Im continuing with it. https://github.com/freenet/freenet-core/pull/1052

Frontend - Typescript

Backend

Do we need these?

added on 29/08

Contract Ring

Transaction Tree

Main Nodes Ring Enhancement

sketch https://excalidraw.com/#json=g2UXiuA2T-P3gg9LY1JdR,Pjg-xsQFuxMNQGGphbxAKA

alexisbatyk commented 4 months ago

TODO: improve node ring, improve clear filters button, add timestamp column in Rust code when sending Events to network-metricts-server, add that column to frontend UI and by clicking order by that

alexisbatyk commented 4 months ago

node ring improvement: show the distance and distribution of nodes around the ring where an X contract is stored.

alexisbatyk commented 4 months ago

1 The node ring is going to be place on the landing page. Below the peers histogram. 2 It's going to have 2 toggle buttons, to enable or disable each of the data groups (node peers or contracts). You'll we able to see peers and/or contracts at the same time.

3 One pink point for each peer, one segment between each peer when there are two connected.

4 An orange dot for each contract real localization and a light green dot for each contract cached localization. There'll be a segment between a real and a cached localization of the same contract to represent that relation.

5 Look for a clustering algorithm to transform a closely distributed group of peers on the ring into just 1 point. That will be a nucleus. That nucleus data will include how many peers are on it and how many connections exists between them, that will reflect the amount of points that the cluster has. Also It'll have the number of peers connecting to others clusters.

6 This clustering will be graphically represented by transforming one group of near points into one big circle. The circumference will reflect the amount of points on it. The color of the big circle will be the way to indicate the density of internal connections. Red, yellow and green for low, medium and high.

7 To represent the amount of connections of peers from cluster A to cluster B will be through the segment width.

8 For contracts the clustering will happen when they are closely situated. This group of positions will be a nucleus, including into its data how many contracts are on it.

9 It will be represented with a big or small circle depending on how many points are included.

Ideally a peer nucleus will be very close to a contract nucleus. And should have similar size.

alexisbatyk commented 4 months ago

Add pagination to tables.

alexisbatyk commented 4 months ago

Add contracts_data to ServerState in network_metrics_server.rs in fdev. Store contract data on fn save_record when pushing a new event.

alexisbatyk commented 3 months ago

Add BroadcastEmitted / BroadcastReceived to transactions and contracts table

alexisbatyk commented 3 months ago

I've spent some time working on these:

The problem this intended to solve When parsing a fbs message both in networ_metrics_server (backend) and network_monitor (frontend) we do it on a try and fail way:

msg
  - try to parse with parser A
      if failed push error message to error_messages
      if ok -> return with content
  - try to parse with parser B
      if failed push error message to error_messages
      if ok -> return with content
  - try to parse with parser C
      if failed push error message to error_messages
      if ok -> return with content

if error_messages.len > 1 {
  print error_messages;
}

Fixed would be: have a wrapper type with content_type and content properties that will let us know which parser to use

parse msg with wrapper type
match content_type {
    "type_A": try to parse with parser A
    "type_B": try to parse with parser B
    "type_C": try to parse with parser C
}

so if is type_A and doesnt work well with parser A will immediately raise that error and will not be wasting time.

right now there are just 2 parsers, PeerChanges and ContractChanges.

Is it worth it to spend time on this?

alexisbatyk commented 3 months ago

This happens on the network_metrics_server (backend) on crates/fdev/network_metrics_server.rs@113 at async fn push_interface

on the frontend is on network-monitor/src/app.ts@36 at function handleChanges

iduartgomez commented 3 months ago

so if is type_A and doesnt work well with parser A will immediately raise that error and will not be wasting time. right now there are just 2 parsers, PeerChanges and ContractChanges. Is it worth it to spend time on this?

I think it makes sense if we are going to keep making changes or adding more message types in the future, I am in favour of doing the change as it shouldn't be that bad and will clean up code

alexisbatyk commented 3 months ago

Understood, will do it!