-
Notifications
You must be signed in to change notification settings - Fork 631
[release/1.3.1] [CO-354] Add RequiresNetworkMagic
and modify ProtocolMagic
#3556
[release/1.3.1] [CO-354] Add RequiresNetworkMagic
and modify ProtocolMagic
#3556
Conversation
Add `RequiresNetworkMagic` datatype and `requiresNetworkMagic` field to `ProtocolMagic`. Pull `Int32` of ProtocolMagic into a newtype wrapper `ProtocolMagicId`. Push modified `ProtocolMagic` through the codebase. Modify `GenericBlockHeader` to use `ProtocolMagicId` instead of `ProtocolMagic`, to avoid issues of undefined `requiresNetworkMagic` when reading a block.
|
||
import Test.Pos.Block.Arbitrary.Generate (generateMainBlock) | ||
|
||
-- We need 'ProtocolMagic' and 'ProtocolConstants' in order to generate a | ||
-- 'MainBlock'. | ||
|
||
pm :: ProtocolMagic | ||
pm = ProtocolMagic 0 | ||
pm = ProtocolMagic (ProtocolMagicId 0) NMMustBeNothing |
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.
\o/
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 really good!
toJSON NMMustBeNothing = pure (JSString "NMMustBeNothing") | ||
toJSON NMMustBeJust = pure (JSString "NMMustBeJust") | ||
|
||
instance ReportSchemaErrors m => FromJSON m RequiresNetworkMagic 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.
If you replace ReportSchemaErrors m
with (Monad m, MonadError SchemaError m)
then you can drop -fno-simplifiable-class-constraints
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.
Thanks! Will apply this on develop
.
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.
@ruhatch Interesting. Will look to make this change.
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 good, but this is going to be horrible to merge back to develop!
@ruhatch Oh, for sure!! |
@ruhatch @intricate For better or worse, we began most of this work on |
Description
This PR modifies the
ProtocolMagic
data structure and introduces new data types:RequiresNetworkMagic
andProtocolMagicId
(a new type wrapper around anInt32
).ProtocolMagic
has been modified such that it consists of two fields:getProtocolMagicId :: ProtocolMagicId
andgetRequiresNetworkMagic :: RequiresNetworkMagic
.The
goldenTestJSONDec
andgoldenTestCanonicalJSONDec
tests which were introduced in #3540 have assisted us in ensuring that we've maintained backwards compatibility in our implementation ofProtocolMagic
.Linked issue
https://iohk.myjetbrains.com/youtrack/issue/CO-354
Type of change
Developer checklist
Testing checklist
QA Steps
Screenshots (if available)