-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide an applicative network heartbeat #15
Conversation
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.
hydra-node/src/Hydra/Network.hs
Outdated
@@ -71,6 +80,7 @@ instance ToCBOR tx => ToCBOR (HydraMessage tx) where | |||
ReqSn -> toCBOR ("ReqSn" :: Text) | |||
AckSn -> toCBOR ("AckSn" :: Text) | |||
ConfSn -> toCBOR ("ConfSn" :: Text) | |||
Ping pty -> toCBOR ("ConfSn" :: Text) <> toCBOR pty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong identifier!
Ping pty -> toCBOR ("ConfSn" :: Text) <> toCBOR pty | |
Ping pty -> toCBOR ("Ping" :: Text) <> toCBOR pty |
|
||
broadcast hn3 requestTx | ||
failAfter 1 $ takeMVar node1received `shouldReturn` MessageReceived requestTx | ||
failAfter 1 $ takeMVar node2received `shouldReturn` MessageReceived requestTx |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand.
There was a problem hiding this comment.
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...
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
sendRequest n1 "Init [1, 2, 3]" | ||
waitForResponse 3 [n1] "ReadyToCommit" | ||
|
||
metrics <- getMetrics n1 | ||
metrics `shouldSatisfy` ("hydra_head_events 3" `BS.isInfixOf`) | ||
metrics `shouldSatisfy` ("hydra_head_events 5" `BS.isInfixOf`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 ? Pings are now included?
Remove connectivity check from concrete
HydraNetwork
implementations and implement a genericHeartbeat
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: