-
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
Simplify and clarify code for local-cluster #25
Conversation
This PR was triggered by this ticket in our board's Red Bin: https://miro.com/app/board/o9J_lRyWcSY=/?moveToWidget=3074457360130079706&cot=14 |
c81b5a6
to
3b6f315
Compare
d9afdd4
to
9a19190
Compare
The local-cluster project was the first code we wrote and some stuff in it are redundant with stuff we wrote later, or ill-named. * Replace local-cluster Logging with Hydra.Logging * Move Ports utility module to Hydra.Network and use its feature there * Rename Lib -> CardanoCluster and Node -> CardanoNode
This does not seem to improve the stability of the tests but it's still better to not have hard coded ports like that lying around.
There is a fixed retry window of 10s in Ouroboros networking code that cannot be configured hence having a 10s timeout runs a high risk of failing because a node which fails to connect won't have the time to reconnect.
c26d3a2
to
af56a16
Compare
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.
Only minor things remain, but can also be merged like this
data WithHost trace = WithHost Host trace | ||
deriving (Show) | ||
|
||
data TraceOuroborosNetwork msg | ||
= TraceSubscriptions (WithIPList (SubscriptionTrace SockAddr)) | ||
| TraceErrorPolicy (WithAddr SockAddr ErrorPolicyTrace) | ||
| TraceAcceptPolicy AcceptConnectionsPolicyTrace |
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.
Seeing the naming convention of ouroboros-network of likely being XXXTrace
for trace types. Shall we adopt that as well? We have at least TraceXXX
and XXXLog
in use.
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.
No change required here, just starting the conversation :)
@@ -254,9 +256,14 @@ withOuroborosNetwork tracer localHost remoteHosts networkCallback between = do | |||
, recvMsgDone = pure () | |||
} | |||
|
|||
data TraceOuroborosNetwork | |||
data WithHost trace = WithHost Host trace |
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.
Isn't hlint warning that this could be a newtype
? if yes, I'd follow that suggestion
| SubscribedTo [String] | ||
| MessageSent Host LByteString | ||
| LogMessageReceived Host Text | ||
| SubscribedTo Host [String] | ||
deriving (Show) |
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.
Could: use the WithHost
type you introduced
parallelBroadcast :: IO () -> [(PortNumber, Network IO Integer, TQueue IO Integer)] -> IO () | ||
parallelBroadcast check [] = check | ||
parallelBroadcast check ((port, network, _) : rest) = | ||
withAsync (fromIntegral port `broadcastFrom` network) $ \_ -> parallelBroadcast check rest |
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.
Could: This function is passing check
around to just have it as "core" to the withAsync
chain.. an alternative (which reads a bit clearer to me, would be to race_ (parallelBroadcast networks) checkQueues
above and consequently:
parallelBroadcast :: IO () -> [(PortNumber, Network IO Integer, TQueue IO Integer)] -> IO () | |
parallelBroadcast check [] = check | |
parallelBroadcast check ((port, network, _) : rest) = | |
withAsync (fromIntegral port `broadcastFrom` network) $ \_ -> parallelBroadcast check rest | |
parallelBroadcast :: [(PortNumber, Network IO Integer, TQueue IO Integer)] -> IO () | |
parallelBroadcast [] = pure () | |
parallelBroadcast [(port, network, _)] = fromIntegral port `broadcastFrom` network | |
parallelBroadcast ((port, network, _) : rest) = | |
withAsync (fromIntegral port `broadcastFrom` network) $ \_ -> parallelBroadcast rest |
@@ -84,6 +82,7 @@ library | |||
, hspec-expectations | |||
, http-conduit | |||
, hydra-prelude | |||
, hydra-node |
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.
As we have this here anyway, I guess I'd prefer the Hydra.Network.Ports to be in hydra-node
instead of the hydra-prelude
. May I move it or WDYT?
@ch1bo All valid points, I will address them after the merge. |
The local-cluster project was the first code we wrote and some stuff in it are redundant with stuff we wrote later, or ill-named.
NetworkSpec
testsThe changes introduced made it even more apparent how flaky our
NetworkSpec
tests were so this PR also fixes that by: