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

WIP [CDEC-369] Remove HasProtocolConstants in favour of parameters #3133

Closed
wants to merge 1 commit into from

Conversation

ruhatch
Copy link
Contributor

@ruhatch ruhatch commented Jun 26, 2018

Description

Remove the HasProtocolConstants constraint and replace it with explicit parameters. For testing code we use the dummyProtocolConstants defined in Test.Pos.Core.Dummy.

Reviewers please keep a keen eye out for minBound and maxBound changes!

Spent the day rebasing and cleaning this up. Still not ready for review.

Linked issue

CDEC-369

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.

Testing checklist

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

QA Steps

Screenshots (if available)

Copy link
Contributor

@parsonsmatt parsonsmatt left a comment

Choose a reason for hiding this comment

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

This is kinda huge and I see a commit was pushed while I was reviewing. Ping me when you're ready for a review?

@@ -113,6 +116,7 @@ createCommandProcs mpm hasAuxxMode printAction mDiffusion = rights . fix $ \comm
},

let name = "addr-hd" in
needsProtocolConstants name >>= \pc ->
Copy link
Contributor

Choose a reason for hiding this comment

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

is someone afraid of do notation? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point - I might leave this for another PR though, because this whole function is a mess!

instance MonadAuxxMode m => ToLeft m Address PublicKey where
toLeft = either return makePubKeyAddressAuxx
-- instance MonadAuxxMode m => ToLeft m Address PublicKey where
-- toLeft = either return makePubKeyAddressAuxx
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be deleted?

@ruhatch ruhatch force-pushed the ruhatch/CDEC-369 branch 2 times, most recently from e45a837 to 5bb83d3 Compare June 26, 2018 17:21
erikd
erikd previously requested changes Jun 26, 2018
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.

Sorry, too many semantically null changes in this as it is. Its already a large PR.

auxx/Main.hs Outdated

cArgs@CLI.CommonNodeArgs {..} = aoCommonNodeArgs
conf = CLI.configurationOptions (CLI.commonArgs cArgs)
nArgs =
CLI.NodeArgs {behaviorConfigPath = Nothing}
nArgs = CLI.NodeArgs {behaviorConfigPath = Nothing}
Copy link
Member

Choose a reason for hiding this comment

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

Up above there was:

     sscParams = CLI.gtSscParams cArgs vssSK (npBehaviorConfig nodeParams)

which was wibbled onto two lines and here we have two lines wibbled onto one.

Both changes are just noise with zero semantic change. We should try to keep these semantically null changes out of our PRs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm - so I was working on the function and it needed formatting both because of my changes and it was poorly laid out before. I know that the change isn't semantic but this seems like the best time to make this kind of change. I'm not going to go through and change the whole codebase, but while I'm already touching a function it seems reasonable to format the whole thing, no?

printTipDifficulty = do
tipDifficulty <- view difficultyL <$> DB.getTipHeader
logInfo $ sformat ("Our tip's difficulty is "%build) tipDifficulty
logInfo $ sformat ("Our tip's difficulty is " % build) tipDifficulty
Copy link
Member

Choose a reason for hiding this comment

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

I personally don't like the lack of whitespace around the % operator, but Serokell's coding guidelines explicit state that the original version is the right one and the existing code base complies. If we decide to change this it should probably be something enforced by stylish-haskell.

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 is fair enough. It's not something that we can enforce using stylish-haskell as far as I'm aware, but I'm happy to revert it if we want to keep it consistent.

def
(NE.fromList allAddresses)
(map TxOutAux outputs)
curPk
Copy link
Member

Choose a reason for hiding this comment

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

The original line was obvious too long because we can't see the end of the line in the Github diff.

I would probably have formatted that as:

            (txAux, _) <- lift $ prepareMTx pm epochSlots getSigner mempty def
                                   NE.fromList allAddresses) (map TxOutAux outputs) curPk

which is still under 100 chars wide.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure see the problem here!

Right tx -> logInfo $ sformat ("Submitted transaction: "%txaF) tx
Left err -> logError
$ sformat ("Error: " % stext) (toText $ displayException err)
Right tx -> logInfo $ sformat ("Submitted transaction: " % txaF) tx
Copy link
Member

Choose a reason for hiding this comment

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

If this change was simply to get the max line width under 80 chars, i would suggest this is a perfect example of why the line width should stay at 100.

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'm not sure that's a valid argument. The line width wasn't supposed to be 100 anyway, so this is just a change to conform to the style guide. Had the line been incorrectly as 102 when we wanted 100, the fact we have to change it isn't an argument for col width 102!

@ruhatch ruhatch requested a review from vincenthz as a code owner June 27, 2018 22:29
@ruhatch ruhatch force-pushed the ruhatch/CDEC-369 branch 2 times, most recently from a32025e to da9fc0f Compare June 27, 2018 23:26
@erikd erikd dismissed their stale review July 1, 2018 20:55

Fixing it and taking over this PR because @ruhatch is on leave.

@erikd erikd changed the title [CDEC-369] Remove HasProtocolConstants in favour of parameters WIP [CDEC-369] Remove HasProtocolConstants in favour of parameters Jul 2, 2018
@ruhatch
Copy link
Contributor Author

ruhatch commented Aug 24, 2018

This has been revived as this PR

@ruhatch ruhatch closed this Aug 24, 2018
@ruhatch ruhatch deleted the ruhatch/CDEC-369 branch August 24, 2018 20:44
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.

3 participants