0

I need a RPC port to deploy Ethereum smart contracts into my parachain's EVM. and the EVM endpoint would look like http://127.0.0.1:xxxx

My current network file:

[relaychain]
default_image = "docker.io/parity/polkadot:{{POLKADOT_VERSION}}"
default_command = "polkadot"
default_args = [ "-lparachain=debug" ]
chain = "rococo-local"

  [[relaychain.nodes]]
  name = "alice"
  validator = true

  [[relaychain.nodes]]
  name = "bob"
  validator = true

[[parachains]]
id = 2000
cumulus_based = true

  [parachains.collator]
  name = "collator01"
  image = "{{COLLATOR_URL}}"
  command = "parachain-collator"
  args = ["-lparachain=debug"]
  
[types.Header]
number = "u64"
parent_hash = "Hash"
post_state = "Hash"

Now when I run Zombienet, I got this from the console log:

parachain-collator --name collator01 --node-key 5e123980fad4770d9ab5b7df7bbee8499943822a8555d11995e8203210065342 --chain /tmp/zombie-7777a966fceaf2c9ff0d46f9a5d9aa5a_-38485-NbMcMKykG6mQ/collator01/cfg/rococo-local-2000.json --base-path /tmp/zombie-7777a966fceaf2c9ff0d46f9a5d9aa5a_-38485-NbMcMKykG6mQ/collator01/data --listen-addr /ip4/0.0.0.0/tcp/33493/ws --rpc-port 42567 --ws-port 32777 --prometheus-external --prometheus-port 38427 --rpc-cors all --unsafe-rpc-external --rpc-methods unsafe --unsafe-ws-external --collator --force-authoring -lparachain=debug -- --chain /tmp/zombie-7777a966fceaf2c9ff0d46f9a5d9aa5a_-38485-NbMcMKykG6mQ/collator01/cfg/rococo-local.json --execution wasm --port 35237 --ws-port 42705 --rpc-port 46031

I see there are two RPC ports: --rpc-port 42567 and --rpc-port 46031

Which one should I use to deploy Ethereum smart contracts into my parachain's EVM ?

How can I get such port number programmatically in my JS script? I guess it is somewhere below?

const { wsUri, userDefinedTypes } = networkInfo.nodesByName[nodeName];
    const api = await zombie.connect(wsUri, userDefinedTypes);
    const validator = await api.query.session.validators();

After printing out the run function arguments of nodeName, networkInfo, args, I got those:

nodeName: alice
networkInfo: {
  tmpDir: '/tmp/zombie-1125ee14af7d14ea72ebc09edb1a453d_-61203-NLdisHdTEY63',
  chainSpecPath: '/tmp/zombie-1125ee14af7d14ea72ebc09edb1a453d_-61203-NLdisHdTEY63/rococo-local.json',
  relay: [
    {
      name: 'alice',
      wsUri: 'ws://127.0.0.1:34997',
      prometheusUri: 'http://127.0.0.1:40159/metrics',
      userDefinedTypes: [Object: null prototype]
    },
    {
      name: 'bob',
      wsUri: 'ws://127.0.0.1:44399',
      prometheusUri: 'http://127.0.0.1:42067/metrics',
      userDefinedTypes: [Object: null prototype]
    }
  ],
  paras: {
    '2000': {
      chainSpecPath: '/tmp/zombie-1125ee14af7d14ea72ebc09edb1a453d_-61203-NLdisHdTEY63/rococo-local-2000.json',
      nodes: [Array]
    }
  },
  nodesByName: {
    alice: {
      name: 'alice',
      wsUri: 'ws://127.0.0.1:34997',
      prometheusUri: 'http://127.0.0.1:40159/metrics',
      userDefinedTypes: [Object: null prototype]
    },
    bob: {
      name: 'bob',
      wsUri: 'ws://127.0.0.1:44399',
      prometheusUri: 'http://127.0.0.1:42067/metrics',
      userDefinedTypes: [Object: null prototype]
    },
    collator01: {
      name: 'collator01',
      wsUri: 'ws://127.0.0.1:42071',
      prometheusUri: 'http://127.0.0.1:41243/metrics',
      userDefinedTypes: [Object: null prototype],
      parachainId: 2000
    }
  }
}
args: []

I could not find the RPC port or URL!

Why are these ports random? Can we predetermine the collator RPC port?

From this https://github.com/paritytech/zombienet/blob/main/docs/src/network-definition-spec.md, it seems I can set the node RPC port, but not collator RPC port!??

2 Answers 2

2

There are two nodes inside a collator. One is the relaychain the other is the parachain.

When you type ./collator --rpc-port xxx -- --rpc-port xxx.

The first parameter(the one before the --) apply to the parachain, the second parameter apply to the relaychain.

If you want to interact with your parachain, use the first port.

3
  • Thank you. The first port works! now. How can I insert the RPC port I want so it is not random?
    – Russo
    Commented Aug 31, 2022 at 14:21
  • 1
    If you don't specify --rpc-port then it is random.
    – AurevoirXavier
    Commented Aug 31, 2022 at 15:39
  • Specify it by rpc_port = 6969 in the parachain in the network file
    – Russo
    Commented Sep 2, 2022 at 5:31
1

You need to specify the --rpc-port in your network file in Zombienet tests.

See how I can specify port 6969 to be my collator RPC port:

  [parachains.collator]
  name = "collator01"
  image = "{{COLLATOR_URL}}"
  command = "parachain-collator"
  args = ["-lparachain=debug"]
  rpc_port = 6969

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.