Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

[DEVOPS-1131] automated proposal scripting #3916

Merged
merged 8 commits into from
Jan 31, 2019
Merged

[DEVOPS-1131] automated proposal scripting #3916

merged 8 commits into from
Jan 31, 2019

Conversation

cleverca22
Copy link
Contributor

Description

Linked issue

Type of change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • 🛠 New feature (non-breaking change which adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)
  • 🏭 Refactoring that does not change existing functionality but does improve things like code readability, structure etc
  • 🔨 New or improved tests for existing code
  • ⛑ git-flow chore (backport, hotfix, etc)

Developer checklist

  • I have read the style guide document, and my code follows the code style of this project.
  • If my code deals with exceptions, it follows the guidelines.
  • I have updated any documentation accordingly, if needed. Documentation changes can be reflected in opening a PR on cardanodocs.com, amending the inline Haddock comments, any relevant README file or one of the document listed in the docs directory.
  • CHANGELOG entry has been added and is linked to the correct PR on GitHub.

Testing checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.

QA Steps

Screenshots (if available)

How to merge

Send the message bors r+ to merge this PR. For more information, see
docs/how-to/bors.md.

@cleverca22 cleverca22 added the wip label Nov 30, 2018
@@ -73,6 +73,7 @@ main = void $ do

handles <- forM cluster $ \case
RunningCoreNode (NodeName nodeId) env handle -> do
-- todo, dont mapm over chars
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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

{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
Copy link
Member

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.

{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE NamedFieldPuns #-}
Copy link
Member

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)

{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE NamedFieldPuns #-}

module AutomatedTestRunner (Example, getGenesisConfig, loadNKeys, doUpdate, onStartup, on, getScript, runScript, NodeType(..), startNode) where
Copy link
Member

@erikd erikd Nov 30, 2018

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.

, sbEpochSlots :: SlotCount
, sbGenesisConfig :: Config
}
data NodeType = Core { ntIdex :: Integer }
Copy link
Member

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 :).

Copy link
Contributor Author

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

runRealMode updateConfiguration genesisConfig txpConfig nr thing2

workers :: (HasConfigurations, TestScript a) => Genesis.Config -> InputParams2 a -> [ (Text, Diffusion AuxxMode -> AuxxMode ()) ]
workers genesisConfig InputParams2{ip2EventChan,ip2Script,ip2ReplyChan} =
Copy link
Member

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.

getGenesisConfig :: Example Config
getGenesisConfig = do
oldsb <- get
pure $ sbGenesisConfig oldsb
Copy link
Member

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.

sbScript = script
}
put newsb
pure ()
Copy link
Member

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.

Copy link
Contributor Author

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

startNode :: NodeType -> IO NodeHandle
startNode (Core idx) = do
let
_params = [ "--configuration-file", "../lib/configuration.yaml"
Copy link
Member

Choose a reason for hiding this comment

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

Redundant?

Copy link
Contributor Author

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

Copy link
Member

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 :)

, "--keyfile", "poc-state/secret" <> (show idx) <> ".key"
]
later <- async $ do
pure ()
Copy link
Member

Choose a reason for hiding this comment

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

Wat?

Copy link
Contributor Author

@cleverca22 cleverca22 Nov 30, 2018

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
Copy link
Member

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
Copy link
Member

@erikd erikd Nov 30, 2018

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

Copy link
Contributor Author

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


data CustomEvent = CESlotStart SlotStart
| CENodeInfo NodeInfo
| QuitEvent deriving Show
Copy link
Member

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


main :: IO ()
main = do
_corenodes <- forM (range (0,3)) $ \node -> startNode (Core node)
Copy link
Member

Choose a reason for hiding this comment

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

??

Copy link
Contributor Author

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

Copy link
Member

@erikd erikd left a 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.

@cleverca22 cleverca22 force-pushed the devops-1131 branch 4 times, most recently from 9c7c305 to e5aa356 Compare December 18, 2018 17:16
@cleverca22 cleverca22 force-pushed the devops-1131 branch 2 times, most recently from 88ee923 to c529884 Compare January 16, 2019 22:47
Copy link
Contributor

@mhuesch mhuesch left a 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.

@mhuesch
Copy link
Contributor

mhuesch commented Jan 17, 2019

@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 auxx, not from your changes)

@cleverca22
Copy link
Contributor Author

bors try

iohk-bors bot added a commit that referenced this pull request Jan 22, 2019
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jan 22, 2019

try

Build failed

@mhuesch
Copy link
Contributor

mhuesch commented Jan 24, 2019

@cleverca22 I rebased, fixed the merge type-errors, fixed some compiler complaints, and force-pushed. This should pass CI / satisfy bors.

@cleverca22 cleverca22 force-pushed the devops-1131 branch 2 times, most recently from ce7352b to 315b968 Compare January 31, 2019 14:36
@cleverca22 cleverca22 removed the wip label Jan 31, 2019
@mhuesch
Copy link
Contributor

mhuesch commented Jan 31, 2019

bors r+

@disassembler
Copy link
Contributor

bors p=1

iohk-bors bot added a commit that referenced this pull request Jan 31, 2019
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]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jan 31, 2019

@iohk-bors iohk-bors bot merged commit 269b160 into develop Jan 31, 2019
@iohk-bors iohk-bors bot deleted the devops-1131 branch January 31, 2019 21:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants