-
Notifications
You must be signed in to change notification settings - Fork 631
[CO-410] Add RequiresNetworkMagic
and modify ProtocolMagic
#3715
Conversation
0b8c020
to
7644bd3
Compare
RequiresNetworkMagic
and modify ProtocolMagic
RequiresNetworkMagic
and modify ProtocolMagic
4b9ee6a
to
e2f59a8
Compare
e2f59a8
to
ad5438c
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.
FromJSON instances seem off to me... let me know if I'm misunderstanding though.
crypto/Pos/Crypto/Configuration.hs
Outdated
<*> pure RequiresMagic | ||
Just (A.String "NMMustBeNothing") | ||
-> ProtocolMagic <$> (ProtocolMagicId <$> o .: "pm") | ||
<*> pure RequiresNoMagic |
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.
Is there a reason that this legacy-migration logic is in the FromJSON ProtocolMagic
instance, rather than directly in the FromJSON RequiresNetworkMagic
instance?
Do we have an issue here and here with supporting the legacy names? It seems like those use the FromJSON RequiresNetworkMagic
instance, which will not be equipped to handle the legacy names.
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.
You're absolutely right, there will be issues in the FromJSON
instance of Configuration
. I'll make the necessary changes.
startTime <- Timestamp . round . (* 1000000) <$> liftIO getPOSIXTime | ||
let cfo = defaultConfigurationOptions | ||
{ cfoFilePath = "./configuration.yaml" | ||
{ cfoFilePath = configFilePath |
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 "./"
prefix might be important in some contexts, I would keep it in there.
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.
@Jimbo4350 asked about this - I'm not sure that presence/absence of a "./
is an issue here, but given that the code has been working with the prefix, I'd hesitate to casually drop it. I'm not sure that all architectures treat said prefixes similarly.
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.
My suggestion is:
{ cfoFilePath = "./" <> configFilePath
2296464
to
66e820c
Compare
66e820c
to
dcb500b
Compare
2e1b589
to
61a7eeb
Compare
1eafd3f
to
5d1317a
Compare
…rt legacy encoding
c0972b1
to
7fb6ab3
Compare
`systemTag` in `Configuration_Legacy` golden file
7fb6ab3
to
a9309aa
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 - good work!
The path issue is likely not a big deal. We can change it or leave it.
, ccExplorerExtendedApi = False | ||
} | ||
, ccWallet = WalletConfiguration { ccThrottle = Nothing } | ||
, ccReqNetMagic = RequiresNoMagic |
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.
Had to run this through in my head, but it seems that we're pulling the "requiresNetworkMagic":"RequiresNoMagic"
field from JSON into ccReqNetMagic
, and the ccGenesis.gsProtocolConstants.gpcProtocolMagic.getRequiresNetworkMagic
value is defaulting because the JSON has "protocolMagic":55550001
. This looks right 👍
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 for adding this, @intricate.
* [CO-410] Port release/1.3.1 config to develop * [CO-410] Modify ProtocolMagic * [CO-410] Continue modifying ProtocolMagic * [CO-410] Change naming * [CO-410] Add golden files for legacy `RequiresNetworkMagic` * [CO-410] Modify `RequiresNetworkMagic`'s `FromJSON` instance to support legacy encoding * [CO-410] Add golden decoding tests for legacy `ProtocolMagic` encoding * [CO-410] Add golden decode only test for `Configuration` * [CO-410] Run `pkgs/generate.sh`, remove reference files, hardcode `systemTag` in `Configuration_Legacy` golden file
…-output-hk/cardano-sl#3715) * [CO-410] Port release/1.3.1 config to develop * [CO-410] Modify ProtocolMagic * [CO-410] Continue modifying ProtocolMagic * [CO-410] Change naming * [CO-410] Add golden files for legacy `RequiresNetworkMagic` * [CO-410] Modify `RequiresNetworkMagic`'s `FromJSON` instance to support legacy encoding * [CO-410] Add golden decoding tests for legacy `ProtocolMagic` encoding * [CO-410] Add golden decode only test for `Configuration` * [CO-410] Run `pkgs/generate.sh`, remove reference files, hardcode `systemTag` in `Configuration_Legacy` golden file
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 tests which were introduced in #3712 have assisted us in ensuring that we've maintained backwards compatibility in our implementation of
ProtocolMagic
.Linked issue
https://iohk.myjetbrains.com/youtrack/issue/CO-410
Type of change
Developer checklist
Testing checklist
QA Steps
Screenshots (if available)