Consensys / tessera

Tessera - Enterprise Implementation of Quorum's transaction manager
https://docs.tessera.consensys.net/
Apache License 2.0
178 stars 108 forks source link

peer {} misconfiguration not flagged #1393

Open macfarla opened 2 years ago

macfarla commented 2 years ago

I have 3 tessera nodes. If I configure the peering so that node3 has 2 peers (node 1 and node2) configured:

   "peer": [
       { "url": "http://localhost:8082" ,
        "url": "http://localhost:8081" }
   ],

If I start node3 only, it only logs attempt to connect to the final item in the list - it seems to be parsing the list of strings as a single json object.

2022-02-09 14:12:53.109 [pool-4-thread-1] INFO c.q.t.p.p.PartyInfoBroadcaster - Started PartyInfo polling round 2022-02-09 14:12:53.110 [pool-4-thread-1] INFO c.q.t.p.p.PartyInfoBroadcaster - Finished PartyInfo polling round 2022-02-09 14:12:53.111 [pool-3-thread-1] WARN c.q.t.p.p.PartyInfoBroadcaster - Failed to connect to node http://localhost:8081/, due to java.net.ConnectException: Connection refused (Connection refused)

And if the three nodes are running, node3 only connects to node1 (last item in the list)

However, if I put this into the peers config (note {} for each peer ), it works as expected ie all three peer with each other

   "peer": [
       { "url": "http://localhost:8082" },
        { "url": "http://localhost:8081" }
   ],

Would be nice to flag this misconfiguration to the user on startup.

baptiste-b-pegasys commented 2 years ago

Indeed the second definition is the one that works.

[ ] is for a list of values, while { } contains keys/values pairs "key":value, where key is unique.

{"a":xxx,"a":"yyy"} has a conflict in the key, the yyy value might be taken as it redefines the value.

namtruong commented 2 years ago

{ } indicates a json object

Your configuration

{ "url": "http://localhost:8082" , "url": "http://localhost:8081" }

is not a list of strings and not a valid json object (contains duplicate key)

Correct json should be

"peer": [ { "url": "http://localhost:9001" }, { "url": "http://localhost:9002" } ]

macfarla commented 2 years ago

if it's not valid json I should get an error though?

baptiste-b-pegasys commented 2 years ago

it is a valid JSON syntax, but it is not useful the way it is used.

The JSON parser will not raise an error, but we could had some more intelligent JSON verifier if such exists.