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

Add version p2p request #931

Closed
tonymorony opened this issue May 4, 2021 · 11 comments · Fixed by #1095
Closed

Add version p2p request #931

tonymorony opened this issue May 4, 2021 · 11 comments · Fixed by #1095
Assignees

Comments

@tonymorony
Copy link

tonymorony commented May 4, 2021

part of: #654 idea implementation
should allow us to make a s5 scoring-crawler that will check ops mm2 version from time to time via p2p port

@artemii235
Copy link
Member

artemii235 commented Jun 15, 2021

  • Add P2P request that returns the version of the MM2 node. Please take https://github.com/KomodoPlatform/atomicDEX-API/blob/mm2.1/mm2src/lp_ordermatch.rs#L399 as an example. It most likely should be added to the separate network behavior like NetworkCrawler as it seems that existing protocols won't match this purpose.
  • The crawler takes the predefined IPs of the nodes and check their versions. It doesn't have to discover the peers at least in the beginning.
  • Looks like it's worth saving the requests history to SQLite database, which we will later use to collect statistics and calculate notary ratings.

@shamardy
Copy link
Collaborator

shamardy commented Jul 2, 2021

@tonymorony I think we would need the NN operators mm2 nodes addresses/IPs and PeerIds to add to the mm2 config

@tonymorony
Copy link
Author

@tonymorony I think we would need the NN operators mm2 nodes addresses/IPs and PeerIds to add to the mm2 config

sure, we'll start this information collecting shortly

artemii235 pushed a commit that referenced this issue Aug 11, 2021
* version p2p request

* fix wasm errors

* first review fixes

* second review fixes

* fix wasm errors

* avoid reserved peers disconnect in maintain relays
@artemii235
Copy link
Member

The PR with this feature is merged to dev. @shamardy Could you please provide new RPC examples and testing instructions to @tonymorony?

@shamardy
Copy link
Collaborator

There are 3 new RPCs, these are add_node_to_version_stat, remove_node_from_version_stat and start_version_stat_collection.

we typically start with add_node_to_version_stat to add the mm2 node info. that are required to collect stats about it to the sqlite database, this info. can be found in a table called nodes. An example of this would be:

{
  "method":"add_node_to_version_stat",
  "params":{
    "name": "node_name", (required, this is the name of the node that will be used in the database to identify it)
    "address": "127.0.0.1", (required, the address of the node that will be used to dial it)
    "peer_id": "12D3KooWMKkKb2r8GHTYcLFKEEJXtB3E8s4qJBush6d26TgRWyBd", (required, the peer id of the mm2 node)
    "mmrpc": "2.0" (required, RPC version as this method uses RPC version 2)
  }
}

after adding all the nodes' that we want to run stats collecting for to the database, we can start collecting stats in the database table stats_nodes using start_version_stat_collection, an example of this would be:

{
  "method":"start_version_stat_collection",
  "params":{
    "interval": 3600, (required, integer, this is used to specify the interval at which we collect the version stats. In this example we collect it every 1 hour)
    "mmrpc": "2.0" (required, RPC version as this method uses RPC version 2)
  }
}

note: we can add/remove nodes from stats collecting while the version stats collection loop is running using the add and remove methods, this will start/stop collecting version stats for these nodes starting from the next iteration of the loop. To disable stats collection for a certain node we use remove_node_from_version_stat, an example of this would be:

{
  "method":"remove_node_from_version_stat",
  "params":{
    "name": "node_name", (required, the name of the node is the only thing required to remove it as it should be a unique identifier for the node)
    "mmrpc": "2.0" (required, RPC version as this method uses RPC version 2)
  }
}

@tonymorony if there is anything that is unclear or if there are any questions please ask me right away.

@tonymorony
Copy link
Author

@shamardy sorry for the delay with testing, proceed to test on https://github.com/KomodoPlatform/atomicDEX-API/releases/tag/beta-2.1.4178 version (as I understand p2p version was merged into dev and mm2.1 synced with dev after it), but getting an error that method not found:

curl --url "http://127.0.0.1:7783" --data "{\"method\":\"add_node_to_version_stat\",\"userpass\":\"$userpass\",\"params\":{\"name\": \"seed1\",\"address\": \"168.119.236.241\",\"peer_id\": \"12D3KooWEsuiKcQaBaKEzuMtT6uFjs89P1E8MK3wGRZbeuCbCw6P\",\"mmrpc\": \"2.0\"}}"
{"error":"rpc:173] dispatcher_legacy:153] No such method: String(\"add_node_to_version_stat\")"}

is there a pb in my request?

@tonymorony tonymorony self-assigned this Sep 16, 2021
@artemii235
Copy link
Member

@tonymorony There is an error in examples: the mmrpc key should be outside of the params object. E.g. https://developers.atomicdex.io/basic-docs/atomicdex/atomicdex-api-20/mmrpc-20.html#command

@tonymorony
Copy link
Author

tonymorony commented Sep 16, 2021

thanks, @artemii235 !

RPC calls works as expected:

SELECT * FROM nodes;
1|seed1|168.119.236.241|12D3KooWEsuiKcQaBaKEzuMtT6uFjs89P1E8MK3wGRZbeuCbCw6P
 SELECT * FROM stats_nodes;
1|seed1|2.1.4178_mm2.1_fa01207ab_Linux_Release|1631789457|
...

after removal

SELECT * from nodes;

working RPC call examples:

curl --url "http://127.0.0.1:7783" --data "{\"mmrpc\": \"2.0\",\"method\":\"add_node_to_version_stat\",\"userpass\":\"$userpass\",\"params\":{\"name\": \"seed1\",\"address\": \"168.119.236.241\",\"peer_id\": \"12D3KooWEsuiKcQaBaKEzuMtT6uFjs89P1E8MK3wGRZbeuCbCw6P\"}}"
{"mmrpc":"2.0","result":"success","id":null}


curl --url "http://127.0.0.1:7783" --data "{\"mmrpc\": \"2.0\",\"method\":\"start_version_stat_collection\",\"userpass\":\"$userpass\",\"params\":{\"interval\": 60}}"

curl --url "http://127.0.0.1:7783" --data "{\"mmrpc\": \"2.0\",\"method\":\"remove_node_from_version_stat\",\"userpass\":\"$userpass\",\"params\":{\"name\": \"seed1\"}}"

@smk762 there are 3 points outstanding:

  • add valid RPC calls into documentation

  • collect all IPs/domains and needs from NNs

  • build a score counting API that reading data from stats_nodes table of MM2.db

@smk762
Copy link

smk762 commented Oct 5, 2021

I just hit an error with start_version_stat_collection after entering an invalid Peer ID earlier via the add_node_to_version_stat method.

{"mmrpc":"2.0","error":"Error on parse peer id decoding multihash failed","error_path":"lp_stats","error_trace":"lp_stats:189]","error_type":"PeerIdParseError","error_data":"decoding multihash failed","id":null}

Could we move this validation to the add_node_to_version_stat method to avoid bad Peer IDs entering the database?

@shamardy
Copy link
Collaborator

shamardy commented Oct 5, 2021

@smk762 the above PR should fix the Peer ID validation problem

@smk762
Copy link

smk762 commented Jun 29, 2022

Scoring is now on display at http://stats.kmd.io/atomicdex/seednode_version/
Notary setup repo/docs at https://github.com/smk762/nn_mm2_seed/blob/main/README.md#wss-setup
Stats currently defined to use commit b8598439a as release does not yet include wss.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants