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

Audit the use of substrate connections in Zos #2504

Open
sameh-farouk opened this issue Nov 27, 2024 · 6 comments
Open

Audit the use of substrate connections in Zos #2504

sameh-farouk opened this issue Nov 27, 2024 · 6 comments
Assignees
Milestone

Comments

@sameh-farouk
Copy link
Member

Describe the bug

It seems that the TFChain RPC node is experiencing a higher number of connections than expected. Currently, there are 35 nodes online (as shown on the dashboard) and 179 connections to the TFChain RPC node (source: Bert). While I understand that other services are also connected, I would assume that the majority of usage comes from ZOS nodes. Having five times the number of connections compared to nodes is not expected.

We need to audit the use of substrate connections in Zos and determine:

  • How many are used per node,
  • Whether they are used efficiently, and
  • If they are closed properly.
@Eslam-Nawara
Copy link
Contributor

WIP:
I've been investigating the number of connections used in zos nodes and the sdk

In zos nodes:
there are 3 places a new connection is created at:

In zos tools:
each tool (certify, farmup, update worker) all connection are closed after the services are done using them.

In SDK-GO:

  • activation service: creates and mentains an open substrate connection
  • farmer bot: it opens 6 connections, releases all of them after using them.
  • mon-bot: starts 5 connections (removed one of them).
  • grid client: opens and maintains an open substrate connection, each tf plugin created has one open connection for the life of it.
  • rmb go: opened 2 connections at the same time (removed one of them), the one left is remained open for the life of the peer.

@sameh-farouk
Copy link
Member Author

We need to ensure that multiple clients do not use the same Substrate account simultaneously when sending signed transactions. If two transactions are sent from the same account with the same nonce, only one will be included in the block. This happens because clients cannot account for pending transactions in the pool when querying the account's nonce. As a result, if you want to send multiple valid transactions simultaneously (or within the same block), they must be handled by the same client to avoid nonce conflicts (unless the nonce is incremented manually), otherwise, some transactions will fail or be ignored.

@Eslam-Nawara
Copy link
Contributor

I see that the client always uses one connection every time we run the client. so as long as the user doesn't create two separate plugins and use them simultaneously, then this issue wouldn't happen.

this needs the users themselves to be careful on using the client(they should create one plugin at a time or not use the same mnemonics for farmer bot and a deployment in the same time for instance).

@Eslam-Nawara
Copy link
Contributor

Work Completed

  • removed an unnecessary connection from rmb
  • reused a connection in mon bot so we can minimize the number of connections created

@Eslam-Nawara
Copy link
Contributor

WIP:

  • After more investigation with sameh and omar it sounds like nodes starts a number of connections that can be 5 or more.
  • we also found that the dashboard opens a variable number of connections every time it's open, sometimes they're not closed if the tap is closed
  • sounds like the nodes problem is in rmb sdk go, creating a new router causes the node to open extra 4 connection, so will be investigating the rmb sdk

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

No branches or pull requests

5 participants