diff --git a/ChangeLog.md b/ChangeLog.md index a3a3c40f..99fefa86 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,7 @@ ## Unreleased +- Support node version 8 and protocol version 8. - Add command `consensus detailed-status` for getting detailed consensus status (from protocol version 6). - Add `raw GetConsensusDetailedStatus` that presents the detailed consensus status as JSON. diff --git a/concordium-client.cabal b/concordium-client.cabal index 0a724188..dcb1dcb8 100644 --- a/concordium-client.cabal +++ b/concordium-client.cabal @@ -101,6 +101,7 @@ library , prettyprinter-ansi-terminal , proto-lens ==0.7.* , scientific + , singletons-base , split , string-interpolate , text diff --git a/deps/concordium-base b/deps/concordium-base index af5d8e93..81c5f9dc 160000 --- a/deps/concordium-base +++ b/deps/concordium-base @@ -1 +1 @@ -Subproject commit af5d8e93783541158e90cbd7fd6c496363f19415 +Subproject commit 81c5f9dc2c61c8de342057ce6c12d02e9d5223a7 diff --git a/package.yaml b/package.yaml index eab803ee..f40a51c9 100644 --- a/package.yaml +++ b/package.yaml @@ -91,6 +91,7 @@ library: - string-interpolate - scientific - cookie + - singletons-base executables: concordium-client: diff --git a/src/Concordium/Client/GRPC2.hs b/src/Concordium/Client/GRPC2.hs index 342bb5c3..68747148 100644 --- a/src/Concordium/Client/GRPC2.hs +++ b/src/Concordium/Client/GRPC2.hs @@ -537,6 +537,7 @@ instance FromProto Proto.AccountStakingInfo where Nothing -> return NoChange Just ch -> fmap timestampToUTCTime <$> fromProto ch asiPoolInfo <- fromProtoMaybe $ baker ^. ProtoFields.maybe'poolInfo + let asiIsSuspended = baker ^. ProtoFields.isSuspended return AccountStakingBaker{..} instance FromProto Proto.ArThreshold where @@ -842,6 +843,7 @@ instance FromProto Proto.ProtocolVersion where Proto.PROTOCOL_VERSION_5 -> return P5 Proto.PROTOCOL_VERSION_6 -> return P6 Proto.PROTOCOL_VERSION_7 -> return P7 + Proto.PROTOCOL_VERSION_8 -> return P8 Proto.ProtocolVersion'Unrecognized _ -> fromProtoFail "Unable to convert 'ProtocolVersion'." @@ -2270,6 +2272,12 @@ instance FromProto (Proto.AccountAddress, Proto.BakerEvent) where let edrAccount = sender edrDelegatorId <- fromProto $ delRemoved ^. ProtoFields.delegatorId return DelegationRemoved{..} + ProtoFields.BakerEvent'BakerSuspended' bkrSuspended -> do + ebsBakerId <- fromProto $ bkrSuspended ^. ProtoFields.bakerId + return BakerSuspended{..} + ProtoFields.BakerEvent'BakerResumed' bkrResumed -> do + ebrBakerId <- fromProto $ bkrResumed ^. ProtoFields.bakerId + return BakerResumed{..} instance FromProto Proto.BlockItemStatus where type Output Proto.BlockItemStatus = TransactionStatus diff --git a/src/Concordium/Client/Output.hs b/src/Concordium/Client/Output.hs index 4379f716..ff1878d6 100644 --- a/src/Concordium/Client/Output.hs +++ b/src/Concordium/Client/Output.hs @@ -1,8 +1,10 @@ {-# LANGUAGE DataKinds #-} +{-# LANGUAGE EmptyCase #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} module Concordium.Client.Output where @@ -47,6 +49,7 @@ import Control.Monad.Writer import qualified Data.Aeson as AE import qualified Data.Aeson.Types as AE import Data.Bool +import Data.Bool.Singletons import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as BSL import qualified Data.ByteString.Short as BSS @@ -880,6 +883,10 @@ showEvent verbose ciM = \case Types.Resumed cAddr invokeSucceeded -> let invokeMsg :: Text = if invokeSucceeded then "succeeded" else "failed" in verboseOrNothing [i|resumed '#{cAddr}' after an interruption that #{invokeMsg}.|] + Types.BakerSuspended bID -> + verboseOrNothing $ printf "baker %s suspended" (show bID) + Types.BakerResumed bID -> + verboseOrNothing $ printf "baker %s resumed" (show bID) where verboseOrNothing :: String -> Maybe String verboseOrNothing msg = if verbose then Just msg else Nothing @@ -1167,34 +1174,21 @@ printChainParameters cp = do SChainParametersV0 -> printChainParametersV0 cp SChainParametersV1 -> printChainParametersV1 cp SChainParametersV2 -> printChainParametersV2 cp + SChainParametersV3 -> printChainParametersV3 cp -- | Prints the chain parameters for version 0. printChainParametersV0 :: ChainParameters' 'ChainParametersV0 -> Printer -printChainParametersV0 ChainParameters{..} = +printChainParametersV0 ChainParameters{..} = do tell - [ [i|\# Validator parameters |], + [ "", + [i|\# Validator parameters |], [i| + validator extra cooldown: #{(_cpBakerExtraCooldownEpochs _cpCooldownParameters)} epochs|], - [i| + stake threshold to become a validator: #{showCcd (_ppBakerStakeThreshold _cpPoolParameters)}|], - "", - [i|\# Exchange rate parameters: |], - [i| + EUR per CCD rate (approx): #{printf "%.4f" (realToFrac (1000000 / _erMicroGTUPerEuro _cpExchangeRates) :: Double) :: String}|], - [i| + EUR per Energy rate: #{showExchangeRate (_erEuroPerEnergy _cpExchangeRates)}|], - [i| + microCCD per EUR rate: #{showExchangeRate (_erMicroGTUPerEuro _cpExchangeRates)}|], - "", - [i|\# Parameters that affect rewards distribution:|], - [i| + mint rate per slot: #{_cpRewardParameters ^. (mdMintPerSlot . unconditionally)}|], - [i| + mint distribution:|], - [i| * block reward: #{_cpRewardParameters ^. mdBakingReward}|], - [i| * finalization reward: #{_cpRewardParameters ^. mdFinalizationReward}|], - [i| + transaction fee distribution:|], - [i| * fraction for the validator: #{_cpRewardParameters ^. tfdBaker}|], - [i| * fraction for the GAS account: #{_cpRewardParameters ^. tfdGASAccount}|], - [i| + GAS account distribution:|], - [i| * producing a block: #{_cpRewardParameters ^. gasBaker}|], - [i| * adding a finalization proof: #{showConditionally (_cpRewardParameters ^. gasFinalizationProof)}|], - [i| * adding a credential deployment: #{_cpRewardParameters ^. gasAccountCreation}|], - [i| * adding a chain update: #{_cpRewardParameters ^. gasChainUpdate}|], - "", + [i| + stake threshold to become a validator: #{showCcd (_ppBakerStakeThreshold _cpPoolParameters)}|] + ] + printExchangeRateParameters _cpExchangeRates + printRewardAndTimeParameters _cpRewardParameters _cpTimeParameters + tell + [ "", [i|\# Other parameters: |], [i| + election difficulty: #{_cpConsensusParameters ^. cpElectionDifficulty}|], [i| + foundation account index: #{_cpFoundationAccount}|], @@ -1203,48 +1197,15 @@ printChainParametersV0 ChainParameters{..} = -- | Prints the chain parameters for version 1. printChainParametersV1 :: ChainParameters' 'ChainParametersV1 -> Printer -printChainParametersV1 ChainParameters{..} = +printChainParametersV1 ChainParameters{..} = do + printPoolAndCooldownParametersV1 + _cpPoolParameters + _cpCooldownParameters + printExchangeRateParameters _cpExchangeRates + printRewardAndTimeParameters _cpRewardParameters _cpTimeParameters + mapM_ printFinalizationCommitteeParameters _cpFinalizationCommitteeParameters tell [ "", - [i|\# Parameters related to staking pools:|], - [i| + minimum equity capital: #{showCcd (_cpPoolParameters ^. ppMinimumEquityCapital)}|], - [i| + maximum fraction of total stake a pool is allowed to hold: #{_cpPoolParameters ^. ppCapitalBound}|], - [i| + maximum factor a pool may stake relative to the validator's stake: #{_cpPoolParameters ^. ppLeverageBound}|], - [i| + pool owner cooldown duration: #{durationToText (durationSeconds (_cpCooldownParameters ^. cpPoolOwnerCooldown) * 1000)}|], - [i| + allowed range for finalization commission: #{showInclusiveRange show (_cpPoolParameters ^. (ppCommissionBounds . finalizationCommissionRange))}|], - [i| + allowed range for block reward commission: #{showInclusiveRange show (_cpPoolParameters ^. (ppCommissionBounds . bakingCommissionRange))}|], - [i| + allowed range for transaction commission: #{showInclusiveRange show (_cpPoolParameters ^. (ppCommissionBounds . transactionCommissionRange))}|], - "", - [i|\# Passive delegation parameters:|], - [i| + finalization commission: #{_cpPoolParameters ^. (ppPassiveCommissions . Types.finalizationCommission)}|], - [i| + block reward commission: #{_cpPoolParameters ^. (ppPassiveCommissions . Types.bakingCommission)}|], - [i| + transaction commission: #{_cpPoolParameters ^. (ppPassiveCommissions . Types.transactionCommission)}|], - "", - [i|\# Parameters related to delegators: |], - [i| + delegator cooldown duration: #{durationToText (durationSeconds (_cpCooldownParameters ^. cpDelegatorCooldown) * 1000)}|], - "", - [i|\# Exchange rate parameters: |], - [i| - EUR per CCD rate (approx): #{printf "%.4f" (realToFrac (1000000 / _erMicroGTUPerEuro _cpExchangeRates) :: Double) :: String}|], - [i| - EUR per Energy rate: #{showExchangeRate (_erEuroPerEnergy _cpExchangeRates)}|], - [i| - microCCD per EUR rate: #{showExchangeRate (_erMicroGTUPerEuro _cpExchangeRates)}|], - "", - [i|\# Parameters that affect rewards distribution:|], - [i| + mint amount per reward period: #{_cpTimeParameters ^. tpMintPerPayday}|], - [i| + mint distribution:|], - [i| * block reward: #{_cpRewardParameters ^. mdBakingReward}|], - [i| * finalization reward: #{_cpRewardParameters ^. mdFinalizationReward}|], - [i| + transaction fee distribution:|], - [i| * validator: #{_cpRewardParameters ^. tfdBaker}|], - [i| * GAS account: #{_cpRewardParameters ^. tfdGASAccount}|], - [i| + GAS rewards:|], - [i| * producing a block: #{_cpRewardParameters ^. gasBaker}|], - [i| * adding a finalization proof: #{showConditionally (_cpRewardParameters ^. gasFinalizationProof)}|], - [i| * adding a credential deployment: #{_cpRewardParameters ^. gasAccountCreation}|], - [i| * adding a chain update: #{_cpRewardParameters ^. gasChainUpdate}|], - "", - [i|\# Time parameters:|], - [i| + reward period length: #{_cpTimeParameters ^. tpRewardPeriodLength} epochs|], - "", [i|\# Other parameters: |], [i| + election difficulty: #{_cpConsensusParameters ^. cpElectionDifficulty}|], [i| + foundation account index: #{_cpFoundationAccount}|], @@ -1252,64 +1213,130 @@ printChainParametersV1 ChainParameters{..} = ] printChainParametersV2 :: ChainParameters' 'ChainParametersV2 -> Printer -printChainParametersV2 ChainParameters{..} = +printChainParametersV2 ChainParameters{..} = do + printPoolAndCooldownParametersV1 + _cpPoolParameters + _cpCooldownParameters + printExchangeRateParameters _cpExchangeRates + printRewardAndTimeParameters _cpRewardParameters _cpTimeParameters + printConsensusParametersV1 _cpConsensusParameters + mapM_ printFinalizationCommitteeParameters _cpFinalizationCommitteeParameters + tell + [ "", + [i|\# Other parameters: |], + [i| + foundation account index: #{_cpFoundationAccount}|], + [i| + maximum credential deployments per block: #{_cpAccountCreationLimit}|] + ] + +printChainParametersV3 :: ChainParameters' 'ChainParametersV3 -> Printer +printChainParametersV3 ChainParameters{..} = do + printPoolAndCooldownParametersV1 + _cpPoolParameters + _cpCooldownParameters + printExchangeRateParameters _cpExchangeRates + printRewardAndTimeParameters _cpRewardParameters _cpTimeParameters + printConsensusParametersV1 _cpConsensusParameters + mapM_ printFinalizationCommitteeParameters _cpFinalizationCommitteeParameters + tell + [ "", + [i|\# Other parameters: |], + [i| + foundation account index: #{_cpFoundationAccount}|], + [i| + maximum credential deployments per block: #{_cpAccountCreationLimit}|] + ] + +printPoolAndCooldownParametersV1 :: + PoolParameters' 'PoolParametersVersion1 -> + CooldownParameters' 'CooldownParametersVersion1 -> + Printer +printPoolAndCooldownParametersV1 poolParams cooldownParams = tell [ "", [i|\# Parameters related to staking pools:|], - [i| + minimum equity capital: #{showCcd (_cpPoolParameters ^. ppMinimumEquityCapital)}|], - [i| + maximum fraction of total stake a pool is allowed to hold: #{_cpPoolParameters ^. ppCapitalBound}|], - [i| + maximum factor a pool may stake relative to the validator's stake: #{_cpPoolParameters ^. ppLeverageBound}|], - [i| + pool owner cooldown duration: #{durationToText (durationSeconds (_cpCooldownParameters ^. cpPoolOwnerCooldown) * 1000)}|], - [i| + allowed range for finalization commission: #{showInclusiveRange show (_cpPoolParameters ^. (ppCommissionBounds . finalizationCommissionRange))}|], - [i| + allowed range for block reward commission: #{showInclusiveRange show (_cpPoolParameters ^. (ppCommissionBounds . bakingCommissionRange))}|], - [i| + allowed range for transaction commission: #{showInclusiveRange show (_cpPoolParameters ^. (ppCommissionBounds . transactionCommissionRange))}|], + [i| + minimum equity capital: #{showCcd (poolParams ^. ppMinimumEquityCapital)}|], + [i| + maximum fraction of total stake a pool is allowed to hold: #{poolParams ^. ppCapitalBound}|], + [i| + maximum factor a pool may stake relative to the validator's stake: #{poolParams ^. ppLeverageBound}|], + [i| + pool owner cooldown duration: #{durationToText (durationSeconds (cooldownParams ^. cpPoolOwnerCooldown) * 1000)}|], + [i| + allowed range for finalization commission: #{showInclusiveRange show (poolParams ^. (ppCommissionBounds . finalizationCommissionRange))}|], + [i| + allowed range for block reward commission: #{showInclusiveRange show (poolParams ^. (ppCommissionBounds . bakingCommissionRange))}|], + [i| + allowed range for transaction commission: #{showInclusiveRange show (poolParams ^. (ppCommissionBounds . transactionCommissionRange))}|], "", [i|\# Passive delegation parameters:|], - [i| + finalization commission: #{_cpPoolParameters ^. (ppPassiveCommissions . Types.finalizationCommission)}|], - [i| + block reward commission: #{_cpPoolParameters ^. (ppPassiveCommissions . Types.bakingCommission)}|], - [i| + transaction commission: #{_cpPoolParameters ^. (ppPassiveCommissions . Types.transactionCommission)}|], - "", - [i|\# Parameters related to delegators: |], - [i| + delegator cooldown duration: #{durationToText (durationSeconds (_cpCooldownParameters ^. cpDelegatorCooldown) * 1000)}|], + [i| + finalization commission: #{poolParams ^. (ppPassiveCommissions . Types.finalizationCommission)}|], + [i| + block reward commission: #{poolParams ^. (ppPassiveCommissions . Types.bakingCommission)}|], + [i| + transaction commission: #{poolParams ^. (ppPassiveCommissions . Types.transactionCommission)}|], "", + [i|\# Parameters related to delegators:|], + [i| + delegator cooldown duration: #{durationToText (durationSeconds (cooldownParams ^. cpDelegatorCooldown) * 1000)}|] + ] + +printExchangeRateParameters :: ExchangeRates -> Printer +printExchangeRateParameters ExchangeRates{..} = + tell + [ "", [i|\# Exchange rate parameters: |], - [i| - EUR per CCD rate (approx): #{printf "%.4f" (realToFrac (1000000 / _erMicroGTUPerEuro _cpExchangeRates) :: Double) :: String}|], - [i| - EUR per Energy rate: #{showExchangeRate (_erEuroPerEnergy _cpExchangeRates)}|], - [i| - microCCD per EUR rate: #{showExchangeRate (_erMicroGTUPerEuro _cpExchangeRates)}|], - "", - [i|\# Parameters that affect rewards distribution:|], - [i| + mint amount per reward period: #{_cpTimeParameters ^. tpMintPerPayday}|], - [i| + mint distribution:|], - [i| * block reward: #{_cpRewardParameters ^. mdBakingReward}|], - [i| * finalization reward: #{_cpRewardParameters ^. mdFinalizationReward}|], + [i| + EUR per CCD rate (approx): #{printf "%.4f" (realToFrac (1000000 / _erMicroGTUPerEuro) :: Double) :: String}|], + [i| + EUR per Energy rate: #{showExchangeRate (_erEuroPerEnergy)}|], + [i| + microCCD per EUR rate: #{showExchangeRate (_erMicroGTUPerEuro)}|] + ] + +printRewardAndTimeParameters :: forall cpv. (IsChainParametersVersion cpv) => RewardParameters cpv -> OParam 'PTTimeParameters cpv TimeParameters -> Printer +printRewardAndTimeParameters rewardParams timeParams = do + tell + [ "", + [i|\# Parameters that affect rewards distribution:|] + ] + printMintRate + tell + [ [i| + mint distribution:|], + [i| * block reward: #{rewardParams ^. mdBakingReward}|], + [i| * finalization reward: #{rewardParams ^. mdFinalizationReward}|], [i| + transaction fee distribution:|], - [i| * validator: #{_cpRewardParameters ^. tfdBaker}|], - [i| * GAS account: #{_cpRewardParameters ^. tfdGASAccount}|], - [i| + GAS rewards:|], - [i| * producing a block: #{_cpRewardParameters ^. gasBaker}|], - [i| * adding a finalization proof: |] <> showConditionally (_cpRewardParameters ^. gasFinalizationProof), - [i| * adding a credential deployment: #{_cpRewardParameters ^. gasAccountCreation}|], - [i| * adding a chain update: #{_cpRewardParameters ^. gasChainUpdate}|], - "", - [i|\# Time parameters:|], - [i| + reward period length: #{_cpTimeParameters ^. tpRewardPeriodLength} epochs|], - "", + [i| * validator: #{rewardParams ^. tfdBaker}|], + [i| * GAS account: #{rewardParams ^. tfdGASAccount}|], + [i| + GAS account distribution:|], + [i| * producing a block: #{rewardParams ^. gasBaker}|], + [i| * adding a finalization proof: |] <> showConditionally (rewardParams ^. gasFinalizationProof), + [i| * adding a credential deployment: #{rewardParams ^. gasAccountCreation}|], + [i| * adding a chain update: #{rewardParams ^. gasChainUpdate}|] + ] + case hasTimeParams of + STrue -> + tell + [ "", + [i|\# Time parameters:|], + [i| + reward period length: #{timeParams ^. tpRewardPeriodLength} epochs|] + ] + SFalse -> return () + where + scpv = chainParametersVersion @cpv + hasTimeParams = sIsSupported SPTTimeParameters scpv + printMintRate :: Printer + printMintRate = case (hasTimeParams, sIsSupported SPTMintPerSlot scpv) of + (SFalse, STrue) -> tell [[i| + mint amount per slot: #{rewardParams ^. (mdMintPerSlot . unconditionally)}|]] + (STrue, SFalse) -> tell [[i| + mint amount per reward period: #{timeParams ^. tpMintPerPayday}|]] + _ -> case scpv of {} + +printConsensusParametersV1 :: ConsensusParameters' 'ConsensusParametersVersion1 -> Printer +printConsensusParametersV1 consensusParams = do + tell + [ "", [i|\# Consensus parameters: |], [i| + Timeout parameters: |], - [i| * base timeout: #{_cpConsensusParameters ^. cpTimeoutParameters ^. tpTimeoutBase} ms.|], - [i| * timeout increase: #{showRatio (_cpConsensusParameters ^. cpTimeoutParameters ^. tpTimeoutIncrease)}|], - [i| * timeout decrease: #{showRatio (_cpConsensusParameters ^. cpTimeoutParameters ^. tpTimeoutDecrease)}|], - [i| + minimum time between blocks: #{_cpConsensusParameters ^. cpMinBlockTime} ms.|], - [i| + block energy limit: #{_cpConsensusParameters ^. cpBlockEnergyLimit}|], - "", + [i| * base timeout: #{consensusParams ^. cpTimeoutParameters ^. tpTimeoutBase} ms.|], + [i| * timeout increase: #{showRatio (consensusParams ^. cpTimeoutParameters ^. tpTimeoutIncrease)}|], + [i| * timeout decrease: #{showRatio (consensusParams ^. cpTimeoutParameters ^. tpTimeoutDecrease)}|], + [i| + minimum time between blocks: #{consensusParams ^. cpMinBlockTime} ms.|], + [i| + block energy limit: #{consensusParams ^. cpBlockEnergyLimit}|] + ] + +printFinalizationCommitteeParameters :: FinalizationCommitteeParameters -> Printer +printFinalizationCommitteeParameters fcp = + tell + [ "", [i|\# Finalization committee parameters:|], - [i| + minimum finalizers: #{show (_cpFinalizationCommitteeParameters ^. fcpMinFinalizers)}|], - [i| + maximum finalizers: #{show (_cpFinalizationCommitteeParameters ^. fcpMaxFinalizers)}|], - [i| + finalizer relative stake threshold: #{show (_cpFinalizationCommitteeParameters ^. fcpFinalizerRelativeStakeThreshold)}|], - "", - [i|\# Other parameters: |], - [i| + foundation account index: #{_cpFoundationAccount}|], - [i| + maximum credential deployments per block: #{_cpAccountCreationLimit}|] + [i| + minimum finalizers: #{show (fcp ^. fcpMinFinalizers)}|], + [i| + maximum finalizers: #{show (fcp ^. fcpMaxFinalizers)}|], + [i| + finalizer relative stake threshold: #{show (fcp ^. fcpFinalizerRelativeStakeThreshold)}|] ] -- | Returns a string representation of the given 'InclusiveRange'. diff --git a/src/Concordium/Client/Runner.hs b/src/Concordium/Client/Runner.hs index ef190c8c..b90fac79 100644 --- a/src/Concordium/Client/Runner.hs +++ b/src/Concordium/Client/Runner.hs @@ -1145,20 +1145,14 @@ getNextPaydayTime = do -- | Returns the UTCTime date when the baker cooldown on reducing stake/removing a baker will end, using on chain parameters getBakerCooldown :: Queries.EChainParametersAndKeys -> ClientMonad IO UTCTime getBakerCooldown (Queries.EChainParametersAndKeys (ecpParams :: ChainParameters' cpv) _) = - case Types.chainParametersVersion @cpv of - Types.SChainParametersV0 -> do + case sCooldownParametersVersionFor $ Types.chainParametersVersion @cpv of + SCooldownParametersVersion0 -> do cs <- getResponseValueOrDie =<< getConsensusInfo let epochTime = toInteger (Time.durationMillis $ Queries.csEpochDuration cs) % 1000 let cooldownTime = fromRational $ epochTime * ((cooldownEpochsV0 ecpParams + 2) % 1) currTime <- liftIO getCurrentTime return $ addUTCTime cooldownTime currTime - Types.SChainParametersV1 -> do - cooldownStart <- getNextPaydayTime - let cooldownDuration = - fromIntegral . Types.durationSeconds $ - ecpParams ^. cpCooldownParameters . cpPoolOwnerCooldown - return $ addUTCTime cooldownDuration cooldownStart - Types.SChainParametersV2 -> do + SCooldownParametersVersion1 -> do cooldownStart <- getNextPaydayTime let cooldownDuration = fromIntegral . Types.durationSeconds $ @@ -1171,14 +1165,10 @@ getBakerCooldown (Queries.EChainParametersAndKeys (ecpParams :: ChainParameters' -- | Returns the UTCTime date when the delegator cooldown on reducing stake/removing delegation will end, using on chain parameters getDelegatorCooldown :: Queries.EChainParametersAndKeys -> ClientMonad IO (Maybe UTCTime) getDelegatorCooldown (Queries.EChainParametersAndKeys (ecpParams :: ChainParameters' cpv) _) = do - case Types.chainParametersVersion @cpv of - Types.SChainParametersV0 -> do + case sCooldownParametersVersionFor $ Types.chainParametersVersion @cpv of + SCooldownParametersVersion0 -> do return Nothing - Types.SChainParametersV1 -> do - paydayTime <- getNextPaydayTime - let cooldownTime = fromIntegral . Types.durationSeconds $ ecpParams ^. cpCooldownParameters . cpDelegatorCooldown - return $ Just $ addUTCTime cooldownTime paydayTime - Types.SChainParametersV2 -> do + SCooldownParametersVersion1 -> do paydayTime <- getNextPaydayTime let cooldownTime = fromIntegral . Types.durationSeconds $ ecpParams ^. cpCooldownParameters . cpDelegatorCooldown return $ Just $ addUTCTime cooldownTime paydayTime @@ -1434,10 +1424,9 @@ getBakerStakeThresholdOrDie = do case res of Left err -> logFatal ["Could not retrieve the validator stake threshold: " <> err] Right (Queries.EChainParametersAndKeys (ecpParams :: ChainParameters' cpv) _) -> - return $ case Types.chainParametersVersion @cpv of - Types.SChainParametersV0 -> ecpParams ^. cpPoolParameters . ppBakerStakeThreshold - Types.SChainParametersV1 -> ecpParams ^. cpPoolParameters . ppMinimumEquityCapital - Types.SChainParametersV2 -> ecpParams ^. cpPoolParameters . ppMinimumEquityCapital + return $ case sPoolParametersVersionFor $ Types.chainParametersVersion @cpv of + SPoolParametersVersion0 -> ecpParams ^. cpPoolParameters . ppBakerStakeThreshold + SPoolParametersVersion1 -> ecpParams ^. cpPoolParameters . ppMinimumEquityCapital getAccountUpdateCredentialsTransactionData :: -- | A file with new credentials. @@ -3191,6 +3180,8 @@ processBakerConfigureCmd baseCfgDir verbose backend txOpts isBakerConfigure cbCa putStrLn "" let cbMetadataURL = fmap (Types.UrlText . Text.pack) metadataURL (bakerKeys, cbKeysWithProofs) <- readInputKeysFile baseCfg + -- TODO: support setting the suspend flag. Issue #326 + let cbSuspend = Nothing let payload = Types.encodePayload Types.ConfigureBaker{..} nrgCost _ = case cbKeysWithProofs of Nothing -> return . Just $ bakerConfigureEnergyCostWithoutKeys (Types.payloadSize payload) diff --git a/test/SimpleClientTests/AccountSpec.hs b/test/SimpleClientTests/AccountSpec.hs index 0cdab504..56243981 100644 --- a/test/SimpleClientTests/AccountSpec.hs +++ b/test/SimpleClientTests/AccountSpec.hs @@ -93,7 +93,8 @@ exampleBakerInfoResult pc = _bakerSignatureVerifyKey = snd $ unsafePerformIO newKeyPair }, asiPendingChange = pc, - asiPoolInfo = Just exampleBakerPoolInfo + asiPoolInfo = Just exampleBakerPoolInfo, + asiIsSuspended = False } exampleDelegatorStakingInfo :: StakePendingChange' UTCTime -> AccountStakingInfo