Skip to content

Provide an applicative network heartbeat#15

Merged
18 commits merged into
masterfrom
abailly-iohk/network-heartbeat
Jun 10, 2021
Merged

Provide an applicative network heartbeat#15
18 commits merged into
masterfrom
abailly-iohk/network-heartbeat

Conversation

@ghost

@ghost ghost commented Jun 9, 2021

Copy link
Copy Markdown

Remove connectivity check from concrete HydraNetwork implementations and implement a generic Heartbeat wrapper that independently sends heartbeats/pings across the network for some time.
This also illustrates the "decorator" pattern as exposed in https://github.com/input-output-hk/hydra-poc/blob/master/docs/adr/0007-with-pattern-component-interfaces.md

Next steps:

  • Provide similar component for self-sending messages.

abailly added 11 commits June 4, 2021 14:25
This probably makes the whole HeartbeatMessage / HydraMessage
dichotomy redundant but I keep it for now for the sake of illustrating
map/contramap transformation of messages.
As Heartbeat logic has moved out of Network layer, ensuring messages
are properly broadcasted requires actively retrying until they are
seen on all nodes, as startup time might lead to messages being
dropped.
@ghost ghost requested review from KtorZ and ch1bo June 9, 2021 16:08
Comment thread hydra-node/src/Hydra/Network.hs Outdated
Comment thread hydra-node/src/Hydra/Network.hs
Comment thread hydra-node/src/Hydra/Network/Heartbeat.hs Outdated
Comment thread hydra-node/src/Hydra/Network.hs Outdated
ReqSn -> toCBOR ("ReqSn" :: Text)
AckSn -> toCBOR ("AckSn" :: Text)
ConfSn -> toCBOR ("ConfSn" :: Text)
Ping pty -> toCBOR ("ConfSn" :: Text) <> toCBOR pty

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wrong identifier!

Suggested change
Ping pty -> toCBOR ("ConfSn" :: Text) <> toCBOR pty
Ping pty -> toCBOR ("Ping" :: Text) <> toCBOR pty

Comment thread hydra-node/src/Hydra/Network/Heartbeat.hs Outdated
Comment thread hydra-node/src/Hydra/Network/Ouroboros.hs Outdated
Comment thread hydra-node/test/Hydra/Network/HeartbeatSpec.hs Outdated
Comment thread hydra-node/test/Hydra/Network/HeartbeatSpec.hs Outdated

broadcast hn3 requestTx
failAfter 1 $ takeMVar node1received `shouldReturn` MessageReceived requestTx
failAfter 1 $ takeMVar node2received `shouldReturn` MessageReceived requestTx

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would this not pass anymore? The new assertions do simultaneously broadcast the same message from different senders, right?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not sure I understand.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Make each requestTx different for each node so that we have a narrower shotgun...

Comment thread local-cluster/src/HydraNode.hs Outdated

waitForOtherNodesConnected :: [Int] -> HydraNode -> IO ()
waitForOtherNodesConnected allNodeIds n@HydraNode{hydraNodeId} =
mapM_ (\otherNode -> waitForResponse 10 [n] $ "NodeConnectedToNetwork " <> show otherNode) $ filter (/= hydraNodeId) allNodeIds

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe rename the output to NodeConnectedToPeer?

forever $ do
threadDelay 0.5
st <- atomically $ readTVar heartbeatState
when (st == SendHeartbeat) $ broadcast (Ping me)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Couldn't this exit instead when the heartbeat is stopped? Or do we expect the heartbeat to be restarted?


metrics <- getMetrics n1
metrics `shouldSatisfy` ("hydra_head_events 3" `BS.isInfixOf`)
metrics `shouldSatisfy` ("hydra_head_events 5" `BS.isInfixOf`)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤔 ? Pings are now included?

@ghost ghost merged commit b647bba into master Jun 10, 2021
@ghost ghost deleted the abailly-iohk/network-heartbeat branch June 10, 2021 11:02
This pull request was closed.
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.

3 participants