-
Notifications
You must be signed in to change notification settings - Fork 631
[DEVOPS-1131] automated proposal scripting #3916
Conversation
cluster/demo/Main.hs
Outdated
@@ -73,6 +73,7 @@ main = void $ do | |||
|
|||
handles <- forM cluster $ \case | |||
RunningCoreNode (NodeName nodeId) env handle -> do | |||
-- todo, dont mapm over chars |
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.
Sorry, I do not understand that comment.
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.
putTextLn
will run mapM
over the string, and print it a single byte at a time, which wastes cpu and heavily interleaves the words when running in parallel
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.
putStrLn
does that for String
, but i suspect putTextLn
does something smarter.
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.
i added the comment after observing that kind of interleaving on the console output
script-runner/AutomatedTestRunner.hs
Outdated
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE RecordWildCards #-} |
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.
Probably want to drop that extension.
In some situations its fine, but in others its a real hinderance to readability and understandability and there is no way to tell the compiler to allow the relatively benign uses and disallow the bad uses.
script-runner/AutomatedTestRunner.hs
Outdated
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE RecordWildCards #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE NamedFieldPuns #-} |
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.
We mentioned that in Slack. If its not needed any longer, its probably best to remove it (same with other extensions)
script-runner/AutomatedTestRunner.hs
Outdated
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
|
||
module AutomatedTestRunner (Example, getGenesisConfig, loadNKeys, doUpdate, onStartup, on, getScript, runScript, NodeType(..), startNode) where |
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.
Probably need to run stylish-haskell on that.
script-runner/AutomatedTestRunner.hs
Outdated
, sbEpochSlots :: SlotCount | ||
, sbGenesisConfig :: Config | ||
} | ||
data NodeType = Core { ntIdex :: Integer } |
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.
If a data type has a single file, it should be a newtype
:).
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.
it will become a sum type soon, to support relay and maybe wallet nodes
script-runner/AutomatedTestRunner.hs
Outdated
runRealMode updateConfiguration genesisConfig txpConfig nr thing2 | ||
|
||
workers :: (HasConfigurations, TestScript a) => Genesis.Config -> InputParams2 a -> [ (Text, Diffusion AuxxMode -> AuxxMode ()) ] | ||
workers genesisConfig InputParams2{ip2EventChan,ip2Script,ip2ReplyChan} = |
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.
I would actually write that as:
workers genesisConfig (InputParams2 ip2EventChan ip2Script ip2ReplyChan) =
which i thing is a little less noisy. I would also tend to use shorter names for what are local variables.
script-runner/AutomatedTestRunner.hs
Outdated
getGenesisConfig :: Example Config | ||
getGenesisConfig = do | ||
oldsb <- get | ||
pure $ sbGenesisConfig oldsb |
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.
I would write that as:
sbGenesisConfig <$> get
to remove a local variable.
script-runner/AutomatedTestRunner.hs
Outdated
sbScript = script | ||
} | ||
put newsb | ||
pure () |
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.
The type of put newsb
should probably be Example ()
so the pure ()
can be dropped.
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.
it already is, the pure ()
was just a left-over, from when the function was entirely empty and ghc complained about an empty do block
script-runner/AutomatedTestRunner.hs
Outdated
startNode :: NodeType -> IO NodeHandle | ||
startNode (Core idx) = do | ||
let | ||
_params = [ "--configuration-file", "../lib/configuration.yaml" |
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.
Redundant?
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.
that code isnt written yet
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.
Ah ok, fair enough. If you put:
-- TODO: ....
then i won't ask about it :)
script-runner/AutomatedTestRunner.hs
Outdated
, "--keyfile", "poc-state/secret" <> (show idx) <> ".key" | ||
] | ||
later <- async $ do | ||
pure () |
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.
Wat?
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.
also unfinished code, its supposed to spawn a node, and block until it exits
i just needed a dummy ASync
for now, so the return type is right, for when that does get done
|
||
printBlock :: FilePath -> IO () | ||
printBlock filename = do | ||
raw <- LBS.readFile filename |
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.
Should probably avoid lazy ByteString
especially for reading a file. Lazy I/O is a bit a of a trap.
If you need raw
to be an LBS
; then maybe (untested):
raw <- LBS.fromChunks . (:[]) <$> BS.readFile filename
let | ||
blockraw :: LBS.ByteString | ||
_undoraw :: LBS.ByteString | ||
Right ("", (blockraw, _undoraw)) = deserialiseFromBytes decode raw |
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.
Rather than the pattern match you should try (not tested but something like this should work):
Right ("", blockraw) = fst <$> deserialiseFromBytes decode raw
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.
this whole file is more of a demo on how to parse blocks rather then code intended to be used in production, so i was letting the pattern match be a bit more messy
script-runner/BrickUITypes.hs
Outdated
|
||
data CustomEvent = CESlotStart SlotStart | ||
| CENodeInfo NodeInfo | ||
| QuitEvent 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.
I would format that as:
data CustomEvent
= CESlotStart SlotStart
| CENodeInfo NodeInfo
| QuitEvent
deriving Show
script-runner/Poc.hs
Outdated
|
||
main :: IO () | ||
main = do | ||
_corenodes <- forM (range (0,3)) $ \node -> startNode (Core 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.
??
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.
unfinished code, it should perform a rolling restart of the core nodes, using the handles startNode
returned, at a future point in time
752819f
to
d20b5c0
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.
LGTM! Probably want to manually clean up the commit history before letting bors merge it.
bf314d8
to
81f8f8e
Compare
9c7c305
to
e5aa356
Compare
88ee923
to
c529884
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.
Looks great for a first version. I noted a few quibbles, nothing major, but some questions.
@cleverca22 I just pushed a commit which modifies variable names to be hopefully more descriptive. It's hard to figure out exactly what's going on, though 🤷♂️ (due to the complexity of |
0f776d0
to
ae217c7
Compare
bors try |
tryBuild failed |
@cleverca22 I rebased, fixed the merge type-errors, fixed some compiler complaints, and force-pushed. This should pass CI / satisfy bors. |
ce7352b
to
315b968
Compare
315b968
to
3adf047
Compare
bors r+ |
bors p=1 |
3916: [DEVOPS-1131] automated proposal scripting r=mhuesch a=cleverca22 ## Description <!--- A brief description of this PR and the problem is trying to solve --> ## Linked issue <!--- Put here the relevant issue from YouTrack --> 4050: Internal Endpoints Disclaimer r=KtorZ a=KtorZ ## Description <!--- A brief description of this PR and the problem is trying to solve --> As a follow-up from the discussion in cardano-foundation/cardano-wallet#151 (comment), we will add a proper disclaimer in the documentation about the internal endpoints. ## Linked issue <!--- Put here the relevant issue from YouTrack --> cardano-foundation/cardano-wallet#228 4054: Update CHANGELOG about changes in 1.5 (for the wallet backend) r=KtorZ a=KtorZ ## Description <!--- A brief description of this PR and the problem is trying to solve --> ## Linked issue <!--- Put here the relevant issue from YouTrack --> Co-authored-by: Michael Bishop <[email protected]> Co-authored-by: Michael Hueschen <[email protected]> Co-authored-by: KtorZ <[email protected]>
Build succeeded |
Description
Linked issue
Type of change
Developer checklist
Testing checklist
QA Steps
Screenshots (if available)
How to merge
Send the message
bors r+
to merge this PR. For more information, seedocs/how-to/bors.md
.