Skip to content

Fixed; multiple-rpc-port-error-bug; #2041

Merged
wentelteefje merged 13 commits intopolkadot-developers:mainfrom
danisvice:fix-rpc-port-error
Aug 18, 2023
Merged

Fixed; multiple-rpc-port-error-bug; #2041
wentelteefje merged 13 commits intopolkadot-developers:mainfrom
danisvice:fix-rpc-port-error

Conversation

@danisvice
Copy link
Copy Markdown
Contributor

@danisvice danisvice commented Aug 13, 2023

PROBLEM
As a user follows the tutorial for simulating a network, an error occurs when copying and pasting the commands to start the blockchain via account Alice and to add a node via account Bob :
error: the argument '--rpc-port <PORT>' cannot be used multiple times

SOLUTION
Fixes #2037
Fixes paritytech/substrate#14741

Add && after the primary --rpc-port options, --rpc-port 9945 and --rpc-port 9946

Run these commands and they initiate the nodes as intended:

Alice:

./target/release/node-template \
--base-path /tmp/alice \
--chain local \
--alice \
--port 30333 \
--rpc-port 9945 && \
--rpc-port 9933 \
--node-key 0000000000000000000000000000000000000000000000000000000000000001 \
--telemetry-url "wss://telemetry.polkadot.io/submit/ 0" \
--validator

Bob:

./target/release/node-template \
--base-path /tmp/bob \
--chain local \
--bob \
--port 30334 \
--rpc-port 9946 && \
--rpc-port 9934 \
--telemetry-url "wss://telemetry.polkadot.io/submit/ 0" \
--validator \
--bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp

@netlify
Copy link
Copy Markdown

netlify bot commented Aug 13, 2023

Deploy Preview for substrate-docs ready!

Name Link
🔨 Latest commit 193de88
🔍 Latest deploy log https://app.netlify.com/sites/substrate-docs/deploys/64df67c0968e980008646e83
😎 Deploy Preview https://deploy-preview-2041--substrate-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@danisvice danisvice changed the title Updated; multiple-rpc-port bug; Fixed; multiple-rpc-port-error-bug; Fixes #2037; Aug 13, 2023
@danisvice danisvice changed the title Fixed; multiple-rpc-port-error-bug; Fixes #2037; Fixed; multiple-rpc-port-error-bug; Aug 13, 2023
@ghe0
Copy link
Copy Markdown

ghe0 commented Aug 15, 2023

The 2nd --rpc-port doesn't do anything. Specifying --rpc-port 9945 is enough to allow the WS to listen on 9945.

@danisvice
Copy link
Copy Markdown
Contributor Author

danisvice commented Aug 15, 2023

The 2nd --rpc-port doesn't do anything. Specifying --rpc-port 9945 is enough to allow the WS to listen on 9945.

Ah, but indeed the second RPC ports are needed because they offer different communication protocols and serve different use cases. RPC (9933, 9934) is typically used for querying data and submitting transactions, while WS(9944, 9945, 9946) are useful for receiving real-time updates from the node.

Common RPC calls to Substrate:

chain_getBlock: Gets information about a specific block.
state_getStorage: Retrieves the value stored at the specified storage key.
author_submitExtrinsic: Submits an extrinsic (transaction) to the Substrate node.
system_health: Checks the health and status of the Substrate node.

Common WebSocket calls to Substrate:

chain_subscribeNewHeads: Subscribes to new block headers as they are added to the blockchain.
chain_subscribeFinalizedHeads: Subscribes to finalized block headers.
state_subscribeStorage: Subscribes to changes in a specific storage key.
author_submitAndWatchExtrinsic: Submits an extrinsic (transaction) and subscribes to its status updates.

@ghe0
Copy link
Copy Markdown

ghe0 commented Aug 16, 2023

Ah, but indeed the second RPC ports are needed because they offer different communication protocols and serve different use cases.

The command you provided does not open two ports in my case. If I run using --rpc-port 9945 && --rpc-port 9933 will open only port 9945. You can check the ports that are listening by running ss -tlnp or netstat -tlnp. You can test this by running the command you specified:

$ ./target/release/node-template \
        --base-path /tmp/alice \
        --chain local \
        --alice \
        --port 30333 \
        --rpc-port 9945 && \
        --rpc-port 9933 \
        --node-key 0000000000000000000000000000000000000000000000000000000000000001 \
        --telemetry-url "wss://telemetry.polkadot.io/submit/ 0" \
        --validator

And after that checking the ports that got opened:

$ ss -tlnp | grep node
LISTEN 0      1024         0.0.0.0:30333      0.0.0.0:*    users:(("node-template",pid=755980,fd=31))
LISTEN 0      1024       127.0.0.1:9945       0.0.0.0:*    users:(("node-template",pid=755980,fd=33))
LISTEN 0      1024       127.0.0.1:9615       0.0.0.0:*    users:(("node-template",pid=755980,fd=34))
LISTEN 0      1024            [::]:30333         [::]:*    users:(("node-template",pid=755980,fd=29))

As you can see, 9933 is nowhere in the list, so the 2nd --rpc-port didn't actually open the 2nd port.

Running the command and specifying port 9945 only once will start the node and will actually allow websocket connections on 9945. This is a recent modification as the node was previously expected to receive the --ws-port parameter which can not be find in the --help at the moment.

You can try running the node with this command:

./target/release/node-template \
        --base-path /tmp/alice \
        --chain local \
        --alice \
        --port 30333 \
        --rpc-port 9945 \
        --node-key 0000000000000000000000000000000000000000000000000000000000000001 \
        --telemetry-url "wss://telemetry.polkadot.io/submit/ 0" \
        --validator

You can test this out by going to this website: https://substrate-developer-hub.github.io/substrate-front-end-template/?rpc=ws://localhost:9945

At the end of the URL, you can see ws://localhost:9945 (the websocket protocol is specified). You can use the developer tools in your browser to actually confirm the websocket is working on localhost:9945:

image

Copy link
Copy Markdown
Contributor

@liamaharon liamaharon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can completely remove the second --rpc-port?

Comment on lines 172 to 173
--rpc-port 9946 && \
--rpc-port 9934 \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--rpc-port 9946 && \
--rpc-port 9934 \
--rpc-port 9946 \

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the input @ghe0. I knew the nodes could start with only rpc port 9945, but I thought the problem was deeper than that, as far configuring the CLI itself and the runtime. Consensus is we move on without rpc ports 9933 && 9934.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think this is fine.

However we need to ensure we update the rest of the docs on this page to match. Please check to make sure we don't mention these removed ports anywhere else, and also mention that both RPC and WS is exposed on --rpc-port.

…rk.md


Network Simulation Functions w/o --rpc-port 9933

Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>
@danisvice danisvice requested a review from liamaharon August 18, 2023 04:40
@wentelteefje wentelteefje merged commit 4fdf99e into polkadot-developers:main Aug 18, 2023
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 this pull request may close these issues.

Bug Substrate tutorial --rpc-port <X> '--rpc-port <port>' cannot be used multiple times

4 participants