corda / corda-gradle-plugins

Gradle plugins used by Corda and Cordapps
Other
24 stars 36 forks source link

dockerForm task generates invalid corda nodeInfo objects? #400

Open davidawad opened 3 years ago

davidawad commented 3 years ago

I have a config for Party C (in this case) that I'm running through the dockerForm task.

node {
   name "O=PartyC,L=New York,C=US"
   p2pPort 10004
   p2pAddress "34.239.158.190"
   rpcSettings {
       address("0.0.0.0:10014")
       adminAddress("0.0.0.0:10044")
   }
   sshdPort 2224
   rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
}

When I used this config on my local machine to generate a config to be run on ANOTHER machine, I noticed that the the node-info file generated expects all docker containers to be on the same machine.

If we look at the additional node info struct on the other side we get something like this which contains the invalid hostname of partyc, but in fact if this node config folder was copied onto another machine it can't resolve.

$java -jar corda-tools-blob-inspector-4.7.jar additional-node-infos/nodeInfo-2D1CA190724B008EF2466321520ABFD47CE0A9EC94FE17B034DE975A056082F3
net.corda.nodeapi.internal.SignedNodeInfo
---
raw:
  class: "net.corda.core.node.NodeInfo"
  deserialized:
    addresses:
    - "partyc:10004"
    legalIdentitiesAndCerts:
    - "O=PartyC, L=New York, C=US"
    platformVersion: 8
    serial: 1616002976601
signatures:
- !!binary |-
  P3VG+gyQ4909whdsoENUwaAhwiYt+mqJE+5PK+7aE9wOlIoFWUy9GMoMVjATLLLQeFNDVGi7tJT2\nNijpDYkQAw==

note that there's a partyc as the hostname and not the actual IP I provided in the p2pAddress.

chrisr3 commented 3 years ago

This seems to be a deliberate consequence of the following lines in Node.installDockerConfig():

val dockerConf = config
        .withValue("p2pAddress", ConfigValueFactory.fromAnyRef("$containerName:$p2pPort"))
        .withValue("rpcSettings.address", ConfigValueFactory.fromAnyRef("$containerName:${rpcSettings.port}"))
        .withValue("rpcSettings.adminAddress", ConfigValueFactory.fromAnyRef("$containerName:${rpcSettings.adminPort}"))
        ...

so partyc is the container name and not the hostname.

palade commented 3 years ago

docker-compose relies on aliases to map the containers to IP addresses internally (https://docs.docker.com/compose/networking/). However you should still be able to run the nodes using their generated Dockerform configuration on another machine. The host paths need to be updated in docker-compose.yml file because absolute file paths are used to map content from host to the container. Other than this update the configuration should be same. Make sure that the nodes is the same as on the machine where it was generated.