-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create-testnet-data: allow to specify relays for SPOs (like create-staked) #632
Conversation
128617d
to
33d3ad8
Compare
pRelays :: Parser FilePath | ||
pRelays = | ||
Opt.strOption $ mconcat | ||
[ Opt.long "relays" |
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.
I chose a shorter flag name than create-staked
's relay-specification-file
. I feel the longer name didn't bring much value. We already chose to use different names in create-testnet-data
before, so this should not be a surprise to users.
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.
Why two different names for the same file?
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.
Not sure what you mean @carbolymer: there is a single name in create-testnet-data
and one single name in create-staked
. I simply chose a shorter, I think better, name for create-testnet-data
.
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 question is why two different parmeter names relay-specification-file
and relays
? I agree with your choice, but why not just use relays
everywhere, also in create-staked
.
mSPOsRelays <- forM relays readRelays | ||
case (relays, mSPOsRelays) of | ||
(Just fp, Just stakePoolRelays) | Map.size stakePoolRelays > fromIntegral numPools -> | ||
throwError $ GenesisCmdTooManyRelaysError fp (fromIntegral numPools) (Map.size stakePoolRelays) |
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.
This check wasn't in create-staked
, but checked with @mgmeier that it was nice to have in create-testnet-data
.
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.
Just curious, what's wrong with having more relays than SPOs?
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> it means the user is passing data that is being ignored. It's probably nice to tell the user that.
33d3ad8
to
6ee4235
Compare
handleIOExceptT (GenesisCmdStakePoolRelayFileError fp) (LBS.readFile fp) | ||
firstExceptT (GenesisCmdStakePoolRelayJsonDecodeError fp) | ||
. hoistEither $ Aeson.eitherDecode relaySpecJsonBs | ||
mayStakePoolRelays <- forM mStakePoolRelaySpecFile TN.readRelays |
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.
As in other parts of create-staked
, it's create-staked
's implementation that calls create-testnet-data
's implementation when they are shared. So nothing new here.
2820153
to
38a1669
Compare
b717fd6
to
829f70e
Compare
@@ -649,6 +657,18 @@ readAndDecodeShelleyGenesis fpath = runExceptT $ do | |||
firstExceptT (GenesisCmdGenesisFileDecodeError fpath . Text.pack) | |||
. hoistEither $ Aeson.eitherDecode' lbs | |||
|
|||
-- @readRelays fp@ reads the relays specification from a file | |||
readRelays :: () |
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.
We could have made the types here concrete.
Opt.strOption $ mconcat | ||
[ Opt.long "relay-specification-file" | ||
, Opt.metavar "FILE" | ||
, Opt.help "JSON file specified the relays of each stake pool." |
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.
"that specifies"
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.
Since this is in create-staked
, I chose not to change anything 🙂
case (relays, mSPOsRelays) of | ||
(Just fp, Just stakePoolRelays) | Map.size stakePoolRelays > fromIntegral numPools -> | ||
throwError $ GenesisCmdTooManyRelaysError fp (fromIntegral numPools) (Map.size stakePoolRelays) | ||
_ -> pure () |
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.
We can avoid the wildcard pattern (IMO this is less readable) match if you case on relays
i.e
case relays of
Nothing -> pure ()
Just relaySpecFile -> ...
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> not much shorter with your version, because I need mSPOsRelays to be a Just
to look at the size of the underlying Map. If I don't pattern match on it, I need to default Nothing
to being of size 0
, which is a bit cumbersome.
So I'll skip this one.
poolColdVKF = File $ dir </> "cold" ++ strIndex ++ ".vkey" | ||
poolVrfVKF = File $ dir </> "vrf" ++ strIndex ++ ".vkey" | ||
poolRewardVKF = File $ dir </> "staking-reward" ++ strIndex ++ ".vkey" | ||
lookupPoolRelay :: Map Word [L.StakePoolRelay] -> Seq.StrictSeq L.StakePoolRelay |
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.
👍
mSPOsRelays <- forM relays readRelays | ||
case (relays, mSPOsRelays) of | ||
(Just fp, Just stakePoolRelays) | Map.size stakePoolRelays > fromIntegral numPools -> | ||
throwError $ GenesisCmdTooManyRelaysError fp (fromIntegral numPools) (Map.size stakePoolRelays) |
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.
Just curious, what's wrong with having more relays than SPOs?
Changelog
Context
Fixes #630
How to trust this PR
Run the following:
pool-relays.json
is the following file:Then open
create_testnet_out/genesis.json
and observe that the pools have a non-empty entry in theirrelays
field.Checklist