-
Notifications
You must be signed in to change notification settings - Fork 622
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
Network debug page assumes that debug RPC port is 3030 #8583
Comments
The main issue is that the href (link that appears once you click on it), will always go to 3030/debug instead of the proper values of 3031/debug, 3032/debug etc. |
20230404: Debug Page RPC PortOverviewGithub Issue Code Commit Google Doc Problem StatementDebug pages work by a separate web server making a RPC call to the node it is on. However, it is currently hard-coding the RPC address to 3030, which does not work for localnet. As a result, developers have to manually type the RPC address to view the debug pages from each node’s perspective of debugging information in localnet. Background: Network Address and RPC AddressThere are currently 2 types of addresses
Code assumes each node always uses port numbers:
However, this assumption is only practical if each node runs on a separate computer as they do not share port number space. For localnet, we run multiple processes on the same computer, hence, the ports cannot all be 3030 or 24567 as it will result in a clash with other processes. Each node on localnet set up their addresses on different ports with a simple increment:
Technical ChallengesLack of peer’s RPC addressDetect other node’s RPC: The main issue here is there’s currently no information being sent between nodes on their rpc address as they only share their network addresses Each node only contains minimal information from other nodes (to reduce network bandwidth)
Possible SolutionsFeel free to skip and jump straight to the chosen solution: Solution 5 Solution 1: Always Include rpc port in Peer InfoCurrently, the PeerInfo does not include rpc port, simply include it in order for other nodes to be aware
Drawbacks:
Solution 2: Optionally Include rpc port in Peer InfoSimilar to Solution1, but only include rpc port into PeerInfo as an optional parameter if it’s localnet. Drawbacks:
Solution 3: Expose API for RPC PortCreate a new API to be able to fetch each node’s RPC port in the status code
Also, a new technical challenge would be the chicken-egg problem. The node will need access to another node’s json RPC port in order to call it’s json RPC port. Drawbacks:
Solution 4: Hard-code paths to localnet’s configurationsDuring localnet, all nodes config.json will be available for read on the same computer. The config.json contains the rpc ports of each node
Drawbacks:
Solution 5: Assume default ports are usedJust assume the ports for localnet are always set as:
Then, perform simple arithmetic to infer a node’s RPC address from it’s network address
Drawbacks:
Mitigations for drawback
TestsI only performed manual testing as there’s no quick way to write unit tests for our current frontend debug pages code. Also, the old debug pages are going to be deprecate so no point investing time into testing the old debug page.
|
* Fix debug rpc ports localnet #8583 <h1> Problem </h1> This is only an issue on localnet and not production (mainnet, testnet) Hence, prefer having this fix within the frontend webserver itself. Alternatively, could have an optional approach for nodes to fetch rpc address from each peer. However, this introduces both complexity and additional bandwidth that will only be useful for localnet testing. <h1> Solution </h1> The code currently uses the assumption on the ports that the nodes will be started in the ranges: - Network address : 24567 + [0, numNodes - 1] - RPC address: 3030 + [0, numNodes - 1] - Reference: https://github.com/near/nearup/blob/0b9a7b60236f3164dd32677b6fa58c531a586200/nearuplib/localnet.py#L93-L94 If this assumption is ever violated in future, only the debug pages would break and can easily be fixed without affecting the actual core network itself. <h1> Testing </h1> - Ran linter ``` npm run lint ``` - Open both old and new debug pages and manually click on the links ``` cd nearcore make debug nearup run localnet --binary-path ~/Github/near/nearcore/target/debug/ open http://localhost:3030/debug cd nearcore/tools/debug-ui npm install npm start open http://localhost:3000/localhost:3030/cluster ``` * Updated typo from 'will be' to 'will are' * Address 1st code review comments - Added conditional to only perform arithmetic for localnet nodes. - Remove any mention of nearup - use DEFAULT_UPPER_CASE for constants instead of lower_case_assumption - - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const - Remove link to 24567 as irrelevant (used for PING) - Include comment on how peer_rpc_address aren't shared in PeerInfo * Updated comments to be more concise * Fix debug rpc ports localnet #8583 <h1> Problem </h1> This is only an issue on localnet and not production (mainnet, testnet) Hence, prefer having this fix within the frontend webserver itself. Alternatively, could have an optional approach for nodes to fetch rpc address from each peer. However, this introduces both complexity and additional bandwidth that will only be useful for localnet testing. <h1> Solution </h1> The code currently uses the assumption on the ports that the nodes will be started in the ranges: - Network address : 24567 + [0, numNodes - 1] - RPC address: 3030 + [0, numNodes - 1] - Reference: https://github.com/near/nearup/blob/0b9a7b60236f3164dd32677b6fa58c531a586200/nearuplib/localnet.py#L93-L94 If this assumption is ever violated in future, only the debug pages would break and can easily be fixed without affecting the actual core network itself. <h1> Testing </h1> - Ran linter ``` npm run lint ``` - Open both old and new debug pages and manually click on the links ``` cd nearcore make debug nearup run localnet --binary-path ~/Github/near/nearcore/target/debug/ open http://localhost:3030/debug cd nearcore/tools/debug-ui npm install npm start open http://localhost:3000/localhost:3030/cluster ``` * Address 1st code review comments - Added conditional to only perform arithmetic for localnet nodes. - Remove any mention of nearup - use DEFAULT_UPPER_CASE for constants instead of lower_case_assumption - - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const - Remove link to 24567 as irrelevant (used for PING) - Include comment on how peer_rpc_address aren't shared in PeerInfo - only check 127.0.0.1 for localnet to dive into localnet only code paths
* Fix debug rpc ports localnet near#8583 <h1> Problem </h1> This is only an issue on localnet and not production (mainnet, testnet) Hence, prefer having this fix within the frontend webserver itself. Alternatively, could have an optional approach for nodes to fetch rpc address from each peer. However, this introduces both complexity and additional bandwidth that will only be useful for localnet testing. <h1> Solution </h1> The code currently uses the assumption on the ports that the nodes will be started in the ranges: - Network address : 24567 + [0, numNodes - 1] - RPC address: 3030 + [0, numNodes - 1] - Reference: https://github.com/near/nearup/blob/0b9a7b60236f3164dd32677b6fa58c531a586200/nearuplib/localnet.py#L93-L94 If this assumption is ever violated in future, only the debug pages would break and can easily be fixed without affecting the actual core network itself. <h1> Testing </h1> - Ran linter ``` npm run lint ``` - Open both old and new debug pages and manually click on the links ``` cd nearcore make debug nearup run localnet --binary-path ~/Github/near/nearcore/target/debug/ open http://localhost:3030/debug cd nearcore/tools/debug-ui npm install npm start open http://localhost:3000/localhost:3030/cluster ``` * Updated typo from 'will be' to 'will are' * Address 1st code review comments - Added conditional to only perform arithmetic for localnet nodes. - Remove any mention of nearup - use DEFAULT_UPPER_CASE for constants instead of lower_case_assumption - - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const - Remove link to 24567 as irrelevant (used for PING) - Include comment on how peer_rpc_address aren't shared in PeerInfo * Updated comments to be more concise * Fix debug rpc ports localnet near#8583 <h1> Problem </h1> This is only an issue on localnet and not production (mainnet, testnet) Hence, prefer having this fix within the frontend webserver itself. Alternatively, could have an optional approach for nodes to fetch rpc address from each peer. However, this introduces both complexity and additional bandwidth that will only be useful for localnet testing. <h1> Solution </h1> The code currently uses the assumption on the ports that the nodes will be started in the ranges: - Network address : 24567 + [0, numNodes - 1] - RPC address: 3030 + [0, numNodes - 1] - Reference: https://github.com/near/nearup/blob/0b9a7b60236f3164dd32677b6fa58c531a586200/nearuplib/localnet.py#L93-L94 If this assumption is ever violated in future, only the debug pages would break and can easily be fixed without affecting the actual core network itself. <h1> Testing </h1> - Ran linter ``` npm run lint ``` - Open both old and new debug pages and manually click on the links ``` cd nearcore make debug nearup run localnet --binary-path ~/Github/near/nearcore/target/debug/ open http://localhost:3030/debug cd nearcore/tools/debug-ui npm install npm start open http://localhost:3000/localhost:3030/cluster ``` * Address 1st code review comments - Added conditional to only perform arithmetic for localnet nodes. - Remove any mention of nearup - use DEFAULT_UPPER_CASE for constants instead of lower_case_assumption - - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const - Remove link to 24567 as irrelevant (used for PING) - Include comment on how peer_rpc_address aren't shared in PeerInfo - only check 127.0.0.1 for localnet to dive into localnet only code paths
Closing as code is merged |
* Fix debug rpc ports localnet #8583 <h1> Problem </h1> This is only an issue on localnet and not production (mainnet, testnet) Hence, prefer having this fix within the frontend webserver itself. Alternatively, could have an optional approach for nodes to fetch rpc address from each peer. However, this introduces both complexity and additional bandwidth that will only be useful for localnet testing. <h1> Solution </h1> The code currently uses the assumption on the ports that the nodes will be started in the ranges: - Network address : 24567 + [0, numNodes - 1] - RPC address: 3030 + [0, numNodes - 1] - Reference: https://github.com/near/nearup/blob/0b9a7b60236f3164dd32677b6fa58c531a586200/nearuplib/localnet.py#L93-L94 If this assumption is ever violated in future, only the debug pages would break and can easily be fixed without affecting the actual core network itself. <h1> Testing </h1> - Ran linter ``` npm run lint ``` - Open both old and new debug pages and manually click on the links ``` cd nearcore make debug nearup run localnet --binary-path ~/Github/near/nearcore/target/debug/ open http://localhost:3030/debug cd nearcore/tools/debug-ui npm install npm start open http://localhost:3000/localhost:3030/cluster ``` * Updated typo from 'will be' to 'will are' * Address 1st code review comments - Added conditional to only perform arithmetic for localnet nodes. - Remove any mention of nearup - use DEFAULT_UPPER_CASE for constants instead of lower_case_assumption - - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const - Remove link to 24567 as irrelevant (used for PING) - Include comment on how peer_rpc_address aren't shared in PeerInfo * Updated comments to be more concise * Fix debug rpc ports localnet #8583 <h1> Problem </h1> This is only an issue on localnet and not production (mainnet, testnet) Hence, prefer having this fix within the frontend webserver itself. Alternatively, could have an optional approach for nodes to fetch rpc address from each peer. However, this introduces both complexity and additional bandwidth that will only be useful for localnet testing. <h1> Solution </h1> The code currently uses the assumption on the ports that the nodes will be started in the ranges: - Network address : 24567 + [0, numNodes - 1] - RPC address: 3030 + [0, numNodes - 1] - Reference: https://github.com/near/nearup/blob/0b9a7b60236f3164dd32677b6fa58c531a586200/nearuplib/localnet.py#L93-L94 If this assumption is ever violated in future, only the debug pages would break and can easily be fixed without affecting the actual core network itself. <h1> Testing </h1> - Ran linter ``` npm run lint ``` - Open both old and new debug pages and manually click on the links ``` cd nearcore make debug nearup run localnet --binary-path ~/Github/near/nearcore/target/debug/ open http://localhost:3030/debug cd nearcore/tools/debug-ui npm install npm start open http://localhost:3000/localhost:3030/cluster ``` * Address 1st code review comments - Added conditional to only perform arithmetic for localnet nodes. - Remove any mention of nearup - use DEFAULT_UPPER_CASE for constants instead of lower_case_assumption - - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const - Remove link to 24567 as irrelevant (used for PING) - Include comment on how peer_rpc_address aren't shared in PeerInfo - only check 127.0.0.1 for localnet to dive into localnet only code paths
The NetworkInfo debug page assumes that the debug RPC port for connected peers is always 3030, and that the RPC address is the same as the node's network address:
nearcore/chain/jsonrpc/res/network_info.js
Line 43 in 2a2b5d6
Localnet nodes spawned using nearup work differently (link):
The NetworkInfo page should be modified to handle localnet setups correctly.
This new debug UI will need to be updated as well:
nearcore/tools/debug-ui/src/utils.tsx
Line 48 in 907538f
The text was updated successfully, but these errors were encountered: