Joining an existing network with a node with an already used node IP:Port should fail
For example, if a node crashes and is restarted with the same IP:Port (--node-address <ip>:<port>), the new node would get node-to-node messages for both itself and the previous node, resulting in many "Invalid authenticated node2node message" in the log of the new node.
One way around this is to remove the previous node via member governance (i.e. memberclient retire_node --node-id ...).
A more user-friendly way would be to prevent nodes to join if they have the same network parameters as an already active node (either PENDING or TRUSTED). We should make sure to document this in our user-facing documentation as well.
Looks like I hit this issue in the latest commit as well.
----------------- ccf-0 (Node that rejoins)
./cchost --enclave-file=libloggingenc.so.signed --consensus raft --enclave-type=debug --ledger-file=ccf4q.ledger --node-cert-file=node_cert.pem --quo
te-file=quote.bin --host-log-level=info --raft-election-timeout-ms=100000 --raft-timeout-ms=500 --node-address=10.240.0.75:3100 --rpc-address=10.240.0.75:3200 join --network-cert-file=network_cert.pem --target-rpc-address 10.240.0.69:3200
2020-01-29T11:54:00.833490Z [info ] /tmp/CCF/src/host/main.cpp:376 | Creating new node - joining existing network at 10.240.0.69:3200
2020-01-29T11:54:00.526132Z [info ] /tmp/CCF/src/host/main.cpp:399 | Created new node
2020-01-29T11:54:00.535072Z -0.451 [info ] /tmp/CCF/src/node/nodestate.h:1089 | Node TLS connections now accepted
2020-01-29T11:55:30.239394Z -3.246 [fail ] /tmp/CCF/src/node/nodestate.h:444 | An error occurred while joining the network {"error":{"code":-32011,"message":"[RPC_NOT_FORWARDED]: RPC could not be forwarded to primary."},"id":87,"jsonrpc":"2.0"}
2020-01-29T11:55:31.386926Z -3.288 [fail ] /tmp/CCF/src/node/nodestate.h:444 | An error occurred while joining the network {"error":{"code":-32011,"message":"[RPC_NOT_FORWARDED]: RPC could not be forwarded to primary."},"id":88,"jsonrpc":"2.0"}
2020-01-29T11:55:32.318928Z -3.329 [fail ] /tmp/CCF/src/node/nodestate.h:444 | An error occurred while joining the network {"error":{"code":-32011,"message":"[RPC_NOT_FORWARDED]: RPC could not be forwarded to primary."},"id":89,"jsonrpc":"2.0"}
...
...
2020-01-29T11:58:32.110928Z -9.889 [fail ] /tmp/CCF/src/node/nodestate.h:444 | An error occurred while joining the network {"error":{"code":-32011,"message":"[RPC_NOT_FORWARDED]: RPC could not be forwarded to primary."},"id":261,"jsonrpc":"2.0"}
2020-01-29T11:58:33.869330Z -9.926 [fail ] /tmp/CCF/src/node/nodestate.h:444 | An error occurred while joining the network {"error":{"code":-32011,"message":"[RPC_NOT_FORWARDED]: RPC could not be forwarded to primary."},"id":262,"jsonrpc":"2.0"}
2020-01-29T11:58:34.238934Z -9.976 [fail ] /tmp/CCF/src/node/nodestate.h:444 | An error occurred while joining the network {"error":{"code":-32011,"message":"[RPC_NOT_FORWARDED]: RPC could not be forwarded to primary."},"id":263,"jsonrpc":"2.0"}
2020-01-29T11:58:36.431493Z -10.078 [info ] /tmp/CCF/src/node/nodestate.h:464 | Joining at version 1, public_only: false
2020-01-29T11:58:36.438926Z -10.085 [info ] /tmp/CCF/src/node/nodestate.h:1105 | Network TLS connections now accepted
2020-01-29T11:58:36.438938Z -10.085 [info ] /tmp/CCF/src/node/nodestate.h:500 | Node has now joined the network as node 3: all domains
2020-01-29T11:58:36.511972Z -10.122 [info ] /tmp/CCF/src/node/channels.h:279 | node2node channel with 1 is now established
2020-01-29T11:58:36.698937Z -10.047 [info ] p/CCF/src/consensus/raft/raft.h:1042 | Becoming follower 3: 4
2020-01-29T11:58:36.755031Z -10.049 [info ] p/CCF/src/consensus/raft/raft.h:1228 | Added node 0
2020-01-29T11:58:36.755046Z -10.049 [info ] p/CCF/src/consensus/raft/raft.h:1234 | Removed self 3
2020-01-29T11:58:36.756524Z -10.051 [info ] mp/CCF/src/consensus/raft/raft.h:664 | Deserialising signature at 2
2020-01-29T11:58:36.759340Z -10.054 [info ] p/CCF/src/consensus/raft/raft.h:1228 | Added node 1
2020-01-29T11:58:36.759351Z -10.054 [info ] p/CCF/src/consensus/raft/raft.h:1234 | Removed self 3
2020-01-29T11:58:36.767741Z -10.062 [info ] mp/CCF/src/consensus/raft/raft.h:664 | Deserialising signature at 4
2020-01-29T11:58:36.767828Z -10.062 [info ] p/CCF/src/consensus/raft/raft.h:1234 | Removed self 3
2020-01-29T11:58:36.767983Z -10.062 [info ] p/CCF/src/consensus/raft/raft.h:1228 | Added node 2
2020-01-29T11:58:36.767991Z -10.062 [info ] p/CCF/src/consensus/raft/raft.h:1234 | Removed self 3
2020-01-29T11:58:36.782930Z -10.077 [info ] mp/CCF/src/consensus/raft/raft.h:664 | Deserialising signature at 6
2020-01-29T11:58:36.782965Z -10.077 [info ] p/CCF/src/consensus/raft/raft.h:1234 | Removed self 3
2020-01-29T11:58:36.785245Z -10.079 [info ] mp/CCF/src/consensus/raft/raft.h:664 | Deserialising signature at 8'
------------------ ccf-1
./cchost --enclave-file=libloggingenc.so.signed --consensus raft --enclave-type=debug --ledger-file=ccf4q.ledger --node-cert-file=node_cert.pem --quote-file=quote.bin --host-log-level=info --raft-election-timeout-ms=100000 --raft-timeout-ms=500 --node-address=10.240.0.69:3100 --rpc-address=10.240.0.69:3200 join --network-cert-file=network_cert.pem --target-rpc-address 10.240.0.84:3200
2020-01-29T11:49:26.386770Z [info ] /tmp/CCF/src/host/main.cpp:376 | Creating new node - joining existing network at 10.240.0.84:3200
2020-01-29T11:49:26.940611Z [info ] /tmp/CCF/src/host/main.cpp:399 | Created new node
2020-01-29T11:49:26.943112Z -0.556 [info ] /tmp/CCF/src/node/nodestate.h:1089 | Node TLS connections now accepted
2020-01-29T11:49:28.598581Z -0.088 [info ] /tmp/CCF/src/node/nodestate.h:464 | Joining at version 1, public_only: false
2020-01-29T11:49:28.618525Z -0.108 [info ] /tmp/CCF/src/node/nodestate.h:1105 | Network TLS connections now accepted
2020-01-29T11:49:28.620202Z -0.110 [info ] /tmp/CCF/src/node/nodestate.h:500 | Node has now joined the network as node 1: all domains
2020-01-29T11:49:28.708799Z -0.189 [info ] /tmp/CCF/src/node/channels.h:279 | node2node channel with 0 is now established
2020-01-29T11:49:29.924430Z -0.109 [info ] p/CCF/src/consensus/raft/raft.h:1042 | Becoming follower 1: 2
2020-01-29T11:49:29.104033Z -0.111 [info ] p/CCF/src/consensus/raft/raft.h:1228 | Added node 0
2020-01-29T11:49:29.104051Z -0.111 [info ] p/CCF/src/consensus/raft/raft.h:1234 | Removed self 1
2020-01-29T11:49:29.118928Z -0.126 [info ] mp/CCF/src/consensus/raft/raft.h:664 | Deserialising signature at 2
2020-01-29T11:49:29.126662Z -0.133 [info ] mp/CCF/src/consensus/raft/raft.h:664 | Deserialising signature at 4
2020-01-29T11:52:54.303036Z -9.116 [info ] p/CCF/src/consensus/raft/raft.h:1228 | Added node 2
2020-01-29T11:52:54.345127Z -9.118 [info ] mp/CCF/src/consensus/raft/raft.h:664 | Deserialising signature at 6
2020-01-29T11:55:30.214930Z -14.953 [info ] mp/CCF/src/consensus/raft/raft.h:985 | Becoming candidate 1: 3
2020-01-29T11:55:30.215100Z -14.953 [info ] mp/CCF/src/consensus/raft/raft.h:790 | Send request vote from 1 to 2
2020-01-29T11:55:30.215176Z -14.953 [info ] mp/CCF/src/consensus/raft/raft.h:790 | Send request vote from 1 to 0
2020-01-29T11:55:30.309278Z -14.937 [info ] /tmp/CCF/src/node/channels.h:279 | node2node channel with 2 is now established
2020-01-29T11:56:08.212754Z -16.278 [info ] mp/CCF/src/consensus/raft/raft.h:884 | Send request vote response from 1 to 2: false
2020-01-29T11:58:35.869300Z -21.580 [info ] mp/CCF/src/consensus/raft/raft.h:985 | Becoming candidate 1: 4
2020-01-29T11:58:35.869570Z -21.580 [info ] mp/CCF/src/consensus/raft/raft.h:790 | Send request vote from 1 to 2
2020-01-29T11:58:35.870390Z -21.580 [info ] mp/CCF/src/consensus/raft/raft.h:790 | Send request vote from 1 to 0
2020-01-29T11:58:35.989500Z -21.571 [info ] mp/CCF/src/consensus/raft/raft.h:963 | Recv request vote response to 1 from 2: they voted yes
2020-01-29T11:58:35.990390Z -21.571 [info ] p/CCF/src/consensus/raft/raft.h:1006 | Becoming leader 1: 4
2020-01-29T11:58:36.394983Z -22.766 [info ] /CCF/src/node/rpc/nodefrontend.h:116 | Node 3 added as TRUSTED
2020-01-29T11:58:36.398524Z -22.769 [info ] p/CCF/src/consensus/raft/raft.h:1228 | Added node 3
2020-01-29T11:58:36.419001Z -21.882 [info ] /tmp/CCF/src/node/history.h:546 | Issuing signature at 8
2020-01-29T11:58:36.546945Z -21.660 [info ] /tmp/CCF/src/node/channels.h:279 | node2node channel with 3 is now established
2020-01-29T11:58:36.834928Z -21.658 [fail ] mp/CCF/src/consensus/raft/raft.h:719 | Invalid authenticated node2node message from node 3 (size: 0)
----------------- ccf-2
./cchost --enclave-file=libloggingenc.so.signed --consensus raft --enclave-type=debug --ledger-file=ccf4q.ledger --node-cert-file=node_cert.pem --quote-file=quote.bin --host-log-level=info --raft-election-timeout-ms=100000 --raft-timeout-ms=500 --node-address=10.240.0.92:3100 --rpc-address=10.240.0.92:3200 join --network-cert-file=network_cert.pem --target-rpc-address 10.240.0.69:3200
2020-01-29T11:52:51.883379Z [info ] /tmp/CCF/src/host/main.cpp:376 | Creating new node - joining existing network at 10.240.0.69:3200
2020-01-29T11:52:52.642319Z [info ] /tmp/CCF/src/host/main.cpp:399 | Created new node
2020-01-29T11:52:52.649369Z -0.766 [info ] /tmp/CCF/src/node/nodestate.h:1089 | Node TLS connections now accepted
2020-01-29T11:52:54.258309Z -0.055 [info ] /tmp/CCF/src/node/nodestate.h:464 | Joining at version 1, public_only: false
2020-01-29T11:52:54.285012Z -0.081 [info ] /tmp/CCF/src/node/nodestate.h:1105 | Network TLS connections now accepted
2020-01-29T11:52:54.285068Z -0.081 [info ] /tmp/CCF/src/node/nodestate.h:500 | Node has now joined the network as node 2: all domains
2020-01-29T11:52:54.318463Z -0.088 [info ] /tmp/CCF/src/node/channels.h:279 | node2node channel with 0 is now established
2020-01-29T11:52:54.836495Z -0.070 [info ] p/CCF/src/consensus/raft/raft.h:1042 | Becoming follower 2: 2
2020-01-29T11:52:54.916001Z -0.072 [info ] p/CCF/src/consensus/raft/raft.h:1228 | Added node 0
2020-01-29T11:52:54.916050Z -0.072 [info ] p/CCF/src/consensus/raft/raft.h:1234 | Removed self 2
2020-01-29T11:52:54.930946Z -0.087 [info ] mp/CCF/src/consensus/raft/raft.h:664 | Deserialising signature at 2
2020-01-29T11:52:54.931012Z -0.087 [info ] p/CCF/src/consensus/raft/raft.h:1228 | Added node 1
2020-01-29T11:52:54.931020Z -0.087 [info ] p/CCF/src/consensus/raft/raft.h:1234 | Removed self 2
2020-01-29T11:52:54.937425Z -0.094 [info ] mp/CCF/src/consensus/raft/raft.h:664 | Deserialising signature at 4
2020-01-29T11:52:54.950975Z -0.107 [info ] mp/CCF/src/consensus/raft/raft.h:664 | Deserialising signature at 6
2020-01-29T11:55:30.270932Z -5.735 [info ] /tmp/CCF/src/node/channels.h:279 | node2node channel with 1 is now established
2020-01-29T11:56:08.202935Z -7.049 [info ] mp/CCF/src/consensus/raft/raft.h:985 | Becoming candidate 2: 3
2020-01-29T11:56:08.202971Z -7.049 [info ] mp/CCF/src/consensus/raft/raft.h:790 | Send request vote from 2 to 1
2020-01-29T11:56:08.203065Z -7.049 [info ] mp/CCF/src/consensus/raft/raft.h:790 | Send request vote from 2 to 0
2020-01-29T11:56:08.242943Z -7.059 [info ] mp/CCF/src/consensus/raft/raft.h:956 | Recv request vote response to 2 from 1: they voted no
2020-01-29T11:58:35.966860Z -12.322 [info ] p/CCF/src/consensus/raft/raft.h:1042 | Becoming follower 2: 4
2020-01-29T11:58:35.967700Z -12.322 [info ] mp/CCF/src/consensus/raft/raft.h:884 | Send request vote response from 2 to 1: true
2020-01-29T11:58:36.419128Z -12.380 [info ] p/CCF/src/consensus/raft/raft.h:1228 | Added node 3
2020-01-29T11:58:36.742929Z -12.430 [info ] mp/CCF/src/consensus/raft/raft.h:664 | Deserialising signature at 8
The issue is not repeated. But it is a flavour of this issue.
If a node rejoins with a different IP address, the previous node (still being considered a part of the network) is causing "Invalid authenticated node2node message"
As discussed with @iqsarv, the "Invalid authenticated node2node message" only appears once in the following scenario:
node-0, node-1, node-2 formed a network
node-0 was primary
node-0 is killed
restarted in a different VM with different IP
it joined as node-3
node-1 became primary and started sending Invalid authenticated node2node message
I have already observed this as part of the recovery test and I don't think it is critical. I'll investigate.