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

[release/1.3.1] [CO-354] Override RequiresNetworkMagic from CoreConfiguration #3659

Merged
merged 4 commits into from
Sep 26, 2018

Conversation

intricate
Copy link
Contributor

Description

Linked issue

https://iohk.myjetbrains.com/youtrack/issue/CO-354

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.

@intricate intricate added the wip label Sep 24, 2018
@intricate intricate self-assigned this Sep 24, 2018
@intricate intricate force-pushed the intricate+mhuesch/CO-354/core-config-rnm branch 2 times, most recently from 174fbf8 to e6a679f Compare September 24, 2018 21:20
@intricate intricate requested a review from mhuesch September 24, 2018 21:36
@intricate intricate force-pushed the intricate+mhuesch/CO-354/core-config-rnm branch 4 times, most recently from d8a0928 to d8ebf20 Compare September 24, 2018 22:51
@intricate intricate force-pushed the intricate+mhuesch/CO-354/core-config-rnm branch from d8ebf20 to fd4b172 Compare September 24, 2018 23:21
mhuesch
mhuesch previously approved these changes Sep 24, 2018
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.

LGTM. Should we get another review, though?

parseJSON = withObject "core" $ \obj -> do
ccg <- obj .: "genesis"
ccdsv <- obj .: "dbSerializeVersion"
ccrnm <- determineRNM <$> obj .:? "requiresNetworkMagic"
Copy link
Contributor

@mhuesch mhuesch Sep 24, 2018

Choose a reason for hiding this comment

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

I think this line can be replaced with (docs)

ccrnm <- obj .:? "requiresNetworkMagic" .!= NMMustBeJust

whether that is more or less readable is another question 🙃

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be neater to use .!= as you suggest, and then add a comment to highlight the subtlety.

-- If "requiresNetworkMagic" is not specified, default to NMMustBeJust
ccrnm <- obj .:? "requiresNetworkMagic" .!= NMMustBeJust

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mhuesch @rvl Thanks, I wasn't aware of this.

core/src/Pos/Core/Genesis/Canonical.hs Show resolved Hide resolved
lib/test/Test/Pos/Genesis/CanonicalSpec.hs Show resolved Hide resolved
lib/src/Test/Pos/Helpers.hs Show resolved Hide resolved
:: forall a. (IdTestingRequiredClassesAlmost a, ToAndFromCanonicalJson a)
=> Gen a
-> Spec
canonicalJsonTest' genA =
Copy link
Contributor

Choose a reason for hiding this comment

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

Would canonicalJsonTestWithGen or something similar be a more descriptive name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mhuesch Agree.

lib/src/Test/Pos/Helpers.hs Show resolved Hide resolved
rvl
rvl previously approved these changes Sep 25, 2018
Copy link
Contributor

@rvl rvl left a comment

Choose a reason for hiding this comment

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

Looks fine to me.

parseJSON = withObject "core" $ \obj -> do
ccg <- obj .: "genesis"
ccdsv <- obj .: "dbSerializeVersion"
ccrnm <- determineRNM <$> obj .:? "requiresNetworkMagic"
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be neater to use .!= as you suggest, and then add a comment to highlight the subtlety.

-- If "requiresNetworkMagic" is not specified, default to NMMustBeJust
ccrnm <- obj .:? "requiresNetworkMagic" .!= NMMustBeJust

@intricate intricate changed the title [WIP] [release/1.3.1] [CO-354] Override RequiresNetworkMagic from CoreConfiguration [release/1.3.1] [CO-354] Override RequiresNetworkMagic from CoreConfiguration Sep 25, 2018
@intricate intricate removed the wip label Sep 25, 2018
@mhuesch mhuesch dismissed stale reviews from rvl and themself via f4ca784 September 25, 2018 02:01
- Rename to `canonicalJsonTestWithGen`.
- Use Aeson optional-with-default combinator.
@mhuesch mhuesch force-pushed the intricate+mhuesch/CO-354/core-config-rnm branch from f4ca784 to baf55d4 Compare September 25, 2018 02:03
rvl
rvl previously approved these changes Sep 25, 2018
lib/configuration.yaml Outdated Show resolved Hide resolved
disassembler
disassembler previously approved these changes Sep 25, 2018
@intricate intricate dismissed stale reviews from disassembler and rvl via 99d6bb1 September 25, 2018 19:25
We want to be sure that mainnet/staging both have `NMMustBeNothing`
as the `requiresNetworkMagic` field of their `ProtocolMagic` value,
which is read from config.

We add a simple test which can be run on the `lib/configuration.yaml`
file and check multiple YAML keys for valid `RequiresNetworkMagic`s.
@rvl rvl merged commit 9ea4966 into release/1.3.1 Sep 26, 2018
@rvl rvl deleted the intricate+mhuesch/CO-354/core-config-rnm branch September 26, 2018 01:08
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