Skip to content
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

Support validatorId. #286

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

## 6.2.0

- Revise client's reconnect handling so that the client will no longer attempt
to automatically reconnect on timeouts and node resource exhaustion.
- Rename bakers to validators in output.
Expand Down
2 changes: 1 addition & 1 deletion concordium-client.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.24
-- see: https://github.com/sol/hpack

name: concordium-client
version: 6.1.1
version: 6.2.0
description: Please see the README on GitHub at <https://github.com/Concordium/concordium-client#readme>
homepage: https://github.com/Concordium/concordium-client#readme
bug-reports: https://github.com/Concordium/concordium-client/issues
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: concordium-client
version: 6.1.1
version: 6.2.0
github: "Concordium/concordium-client"
author: "Concordium"
maintainer: "[email protected]"
Expand Down
16 changes: 12 additions & 4 deletions src/Concordium/Client/Cli.hs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ data BakerCredentials = BakerCredentials
}

instance AE.ToJSON BakerCredentials where
toJSON BakerCredentials{..} = object (("bakerId" .= bcIdentity) : bakerKeysToPairs bcKeys)
toJSON BakerCredentials{..} = object (("bakerId" .= bcIdentity) : ("validatorId" .= bcIdentity) : bakerKeysToPairs bcKeys)

instance AE.FromJSON BakerKeys where
parseJSON = withObject "Baker keys" $ \v -> do
Expand All @@ -279,7 +279,15 @@ instance AE.FromJSON BakerKeys where
bkElectionVerifyKey <- v .: "electionVerifyKey"
bkSigSignKey <- v .: "signatureSignKey"
bkSigVerifyKey <- v .: "signatureVerifyKey"
bkBakerId <- v .:? "bakerId"
mbkBakerId <- v .:? "bakerId"
mvalidatorId <- v .:? "validatorId"
bkBakerId <- case (mbkBakerId, mvalidatorId) of
(Just bid, Just vid)
| bid == vid -> return (Just bid)
| otherwise -> fail "Both 'bakerId' and 'validatorId' are present, and different."
(Just bid, Nothing) -> return (Just bid)
(Nothing, Just vid) -> return (Just vid)
(Nothing, Nothing) -> return Nothing
return BakerKeys{..}

bakerKeysToPairs :: BakerKeys -> [Pair]
Expand All @@ -291,7 +299,7 @@ bakerKeysToPairs v =
"signatureSignKey" .= bkSigSignKey v,
"signatureVerifyKey" .= bkSigVerifyKey v
]
++ ["bakerId" .= bid | bid <- maybeToList (bkBakerId v)]
++ concat [["bakerId" .= bid, "validatorId" .= bid] | bid <- maybeToList (bkBakerId v)]

instance AE.ToJSON BakerKeys where
toJSON = object . bakerKeysToPairs
Expand All @@ -303,7 +311,7 @@ bakerPublicKeysToPairs v =
"electionVerifyKey" .= bkElectionVerifyKey v,
"signatureVerifyKey" .= bkSigVerifyKey v
]
++ ["bakerId" .= bid | bid <- maybeToList (bkBakerId v)]
++ concat [["bakerId" .= bid, "validatorId" .= bid] | bid <- maybeToList (bkBakerId v)]

-- | Hardcoded network ID.
defaultNetId :: Int
Expand Down
8 changes: 4 additions & 4 deletions src/Concordium/Client/Runner.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2981,9 +2981,9 @@ processBakerConfigureCmd baseCfgDir verbose backend txOpts isBakerConfigure cbCa
in unless encrypted $
case inputKeysFile of
Nothing ->
logInfo [printf "To use it add \"bakerId\": %s to the keys file." (show bakerId)]
logInfo [printf "To use it add \"validatorId\": %s to the keys file." (show bakerId)]
Just inf ->
logInfo [printf "To use it add \"bakerId\": %s to the keys file %s." (show bakerId) inf]
logInfo [printf "To use it add \"validatorId\": %s to the keys file %s." (show bakerId) inf]

eventsFromTransactionResult Nothing = return []
eventsFromTransactionResult (Just result) = do
Expand Down Expand Up @@ -3201,7 +3201,7 @@ processBakerAddCmd baseCfgDir verbose backend txOpts abBakingStake abRestakeEarn
_ ->
let encrypted = snd bakerKeys
in unless encrypted $
logInfo [printf "To use it add \"bakerId\": %s to the keys file %s." (show bakerId) inputKeysFile]
logInfo [printf "To use it add \"validatorId\": %s to the keys file %s." (show bakerId) inputKeysFile]

eventsFromTransactionResult Nothing = return []
eventsFromTransactionResult (Just result) = do
Expand Down Expand Up @@ -3361,7 +3361,7 @@ processBakerSetKeysCmd baseCfgDir verbose backend txOpts inputKeysFile outputKey
_ ->
let encrypted = snd bakerKeys
in unless encrypted $
logInfo [printf "To use it add \"bakerId\": %s to the keys file %s." (show bakerId) inputKeysFile]
logInfo [printf "To use it add \"validatorId\": %s to the keys file %s." (show bakerId) inputKeysFile]

eventsFromTransactionResult Nothing = return []
eventsFromTransactionResult (Just result) = do
Expand Down
Loading