From 4207bf1200778278d2ec2938b0ca500dfb709dce Mon Sep 17 00:00:00 2001 From: drsk Date: Thu, 14 Nov 2024 10:57:00 +0100 Subject: [PATCH 1/3] implement suspend/resume for client --- src/Concordium/Client/Commands.hs | 5 +++++ src/Concordium/Client/Runner.hs | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/Concordium/Client/Commands.hs b/src/Concordium/Client/Commands.hs index 2bae24ad..1a2c35e9 100644 --- a/src/Concordium/Client/Commands.hs +++ b/src/Concordium/Client/Commands.hs @@ -495,6 +495,7 @@ data BakerCmd bcTransactionFeeCommission :: !(Maybe AmountFraction), bcBakingRewardCommission :: !(Maybe AmountFraction), bcFinalizationRewardCommission :: !(Maybe AmountFraction), + bcSuspend :: !(Maybe Bool), bcInputKeyFile :: !(Maybe FilePath), bcOutputKeyFile :: !(Maybe FilePath) } @@ -1800,6 +1801,10 @@ bakerConfigureCmd = <*> optional (option (eitherReader amountFractionFromStringInform) (long "delegation-transaction-fee-commission" <> metavar "DECIMAL-FRACTION" <> help ("Fraction the validator takes in commission from delegators on transaction fee rewards. " ++ rangesHelpString "transaction fee commission"))) <*> optional blockCommission <*> optional (option (eitherReader amountFractionFromStringInform) (long "delegation-finalization-commission" <> metavar "DECIMAL-FRACTION" <> help ("Fraction the validator takes in commission from delegators on finalization rewards. " ++ rangesHelpString "finalization reward commission"))) + <*> optional + ( flag' True (long "suspend" <> help "Suspend the validator. The validator will not participate in the consensus anymore.") + <|> flag' False (long "resume" <> help "Resume the validator.") + ) <*> optional (strOption (long "keys-in" <> metavar "FILE" <> help "File containing validator credentials.")) <*> optional (strOption (long "keys-out" <> metavar "FILE" <> help "File to write updated validator credentials to, in case of successful transaction. These can be used to start the node.")) ) diff --git a/src/Concordium/Client/Runner.hs b/src/Concordium/Client/Runner.hs index b90fac79..73e75ded 100644 --- a/src/Concordium/Client/Runner.hs +++ b/src/Concordium/Client/Runner.hs @@ -3009,12 +3009,14 @@ processBakerConfigureCmd :: Maybe Types.AmountFraction -> -- | Finalization commission. Maybe Types.AmountFraction -> + -- | Whether to suspend/resume baker. + Maybe Bool -> -- | File to read baker keys from. Maybe FilePath -> -- | File to write baker keys to. Maybe FilePath -> IO () -processBakerConfigureCmd baseCfgDir verbose backend txOpts isBakerConfigure cbCapital cbRestakeEarnings cbOpenForDelegation metadataURL cbTransactionFeeCommission cbBakingRewardCommission cbFinalizationRewardCommission inputKeysFile outputKeysFile = do +processBakerConfigureCmd baseCfgDir verbose backend txOpts isBakerConfigure cbCapital cbRestakeEarnings cbOpenForDelegation metadataURL cbTransactionFeeCommission cbBakingRewardCommission cbFinalizationRewardCommission cbSuspend inputKeysFile outputKeysFile = do let intOpts = toInteractionOpts txOpts let outFile = toOutFile txOpts (bakerKeys, txCfg, pl) <- transactionForBakerConfigure (ioConfirm intOpts) @@ -3180,8 +3182,6 @@ 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) @@ -3744,7 +3744,7 @@ processBakerUpdateStakeCmd baseCfgDir verbose backend txOpts newStake = do askConfirmation $ Just "confirm that you want to remove validator" else return True when ok $ - processBakerConfigureCmd baseCfgDir verbose backend txOpts False (Just newStake) Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing + processBakerConfigureCmd baseCfgDir verbose backend txOpts False (Just newStake) Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing -- | Process a 'baker ...' command. processBakerCmd :: BakerCmd -> Maybe FilePath -> Verbose -> Backend -> IO () @@ -3807,23 +3807,23 @@ processBakerCmd action baseCfgDir verbose backend = transactionFeeCommission = ebadTransactionFeeCommission <$> extraData bakingRewardCommission = ebadBakingRewardCommission <$> extraData finalizationRewardCommission = ebadFinalizationRewardCommission <$> extraData - processBakerConfigureCmd baseCfgDir verbose backend txOpts False (Just initialStake) (Just autoRestake) openForDelegation metadataURL transactionFeeCommission bakingRewardCommission finalizationRewardCommission (Just bakerKeysFile) outputFile - BakerConfigure txOpts capital restake openForDelegation metadataURL transactionFeeCommission bakingRewardCommission finalizationRewardCommission inputKeysFile outputKeysFile -> - processBakerConfigureCmd baseCfgDir verbose backend txOpts True capital restake openForDelegation metadataURL transactionFeeCommission bakingRewardCommission finalizationRewardCommission inputKeysFile outputKeysFile + processBakerConfigureCmd baseCfgDir verbose backend txOpts False (Just initialStake) (Just autoRestake) openForDelegation metadataURL transactionFeeCommission bakingRewardCommission finalizationRewardCommission Nothing (Just bakerKeysFile) outputFile + BakerConfigure txOpts capital restake openForDelegation metadataURL transactionFeeCommission bakingRewardCommission finalizationRewardCommission suspend inputKeysFile outputKeysFile -> + processBakerConfigureCmd baseCfgDir verbose backend txOpts True capital restake openForDelegation metadataURL transactionFeeCommission bakingRewardCommission finalizationRewardCommission suspend inputKeysFile outputKeysFile BakerSetKeys file txOpts outfile -> do pv <- withClient backend $ do cs <- getResponseValueOrDie =<< getConsensusInfo return $ Queries.csProtocolVersion cs if pv < Types.P4 then processBakerSetKeysCmd baseCfgDir verbose backend txOpts file outfile - else processBakerConfigureCmd baseCfgDir verbose backend txOpts False Nothing Nothing Nothing Nothing Nothing Nothing Nothing (Just file) outfile + else processBakerConfigureCmd baseCfgDir verbose backend txOpts False Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing (Just file) outfile BakerRemove txOpts -> do pv <- withClient backend $ do cs <- getResponseValueOrDie =<< getConsensusInfo return $ Queries.csProtocolVersion cs if pv < Types.P4 then processBakerRemoveCmd baseCfgDir verbose backend txOpts - else processBakerConfigureCmd baseCfgDir verbose backend txOpts False (Just 0) Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing + else processBakerConfigureCmd baseCfgDir verbose backend txOpts False (Just 0) Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing BakerUpdateStake newStake txOpts -> do pv <- withClient backend $ do cs <- getResponseValueOrDie =<< getConsensusInfo @@ -3837,11 +3837,11 @@ processBakerCmd action baseCfgDir verbose backend = return $ Queries.csProtocolVersion cs if pv < Types.P4 then processBakerUpdateRestakeCmd baseCfgDir verbose backend txOpts restake - else processBakerConfigureCmd baseCfgDir verbose backend txOpts False Nothing (Just restake) Nothing Nothing Nothing Nothing Nothing Nothing Nothing + else processBakerConfigureCmd baseCfgDir verbose backend txOpts False Nothing (Just restake) Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing BakerUpdateMetadataURL url txOpts -> - processBakerConfigureCmd baseCfgDir verbose backend txOpts False Nothing Nothing Nothing (Just url) Nothing Nothing Nothing Nothing Nothing + processBakerConfigureCmd baseCfgDir verbose backend txOpts False Nothing Nothing Nothing (Just url) Nothing Nothing Nothing Nothing Nothing Nothing BakerUpdateOpenDelegationStatus status txOpts -> - processBakerConfigureCmd baseCfgDir verbose backend txOpts False Nothing Nothing (Just status) Nothing Nothing Nothing Nothing Nothing Nothing + processBakerConfigureCmd baseCfgDir verbose backend txOpts False Nothing Nothing (Just status) Nothing Nothing Nothing Nothing Nothing Nothing Nothing BakerGetEarliestWinTime bakerId useLocalTime doPoll -> do winTimestamp <- getWinTimestamp putStrLn [i|Validator #{bakerId} is expected to produce a block no sooner than:|] From e7fd3348833e6fe567a5f6c123ae6804f719c509 Mon Sep 17 00:00:00 2001 From: drsk Date: Thu, 14 Nov 2024 16:58:59 +0100 Subject: [PATCH 2/3] update concordium-base --- deps/concordium-base | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/concordium-base b/deps/concordium-base index 81c5f9dc..288a8360 160000 --- a/deps/concordium-base +++ b/deps/concordium-base @@ -1 +1 @@ -Subproject commit 81c5f9dc2c61c8de342057ce6c12d02e9d5223a7 +Subproject commit 288a83600ebb48e2dc5151cb7a752622306aa3cc From 8c2d71af7182d50513dd5a7469eebaed32612857 Mon Sep 17 00:00:00 2001 From: drsk Date: Thu, 14 Nov 2024 17:11:05 +0100 Subject: [PATCH 3/3] update changelog --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index 99fefa86..6bf72af7 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,7 @@ ## Unreleased - Support node version 8 and protocol version 8. +- Support for suspend/resume in validator update transactions. - 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.