From d7eb356c02d590318d5d244b9510935a8d34a89e Mon Sep 17 00:00:00 2001 From: drsk <827698+drsk0@users.noreply.github.com> Date: Tue, 22 Oct 2024 12:18:22 +0200 Subject: [PATCH] p8: Move the suspended flag (#564) This moves the suspended flag from AccountInfo to AccountStakingInfo.Baker --- concordium-grpc-api | 2 +- haskell-src/Concordium/GRPC2.hs | 2 +- haskell-src/Concordium/Types/Accounts.hs | 24 +++++++++++++----------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/concordium-grpc-api b/concordium-grpc-api index f2b40818a..cf3ba6817 160000 --- a/concordium-grpc-api +++ b/concordium-grpc-api @@ -1 +1 @@ -Subproject commit f2b40818ae5420dec2a079d013a33b5420e5cbad +Subproject commit cf3ba6817f36b1f49873cef580fadb5e79d67032 diff --git a/haskell-src/Concordium/GRPC2.hs b/haskell-src/Concordium/GRPC2.hs index c87748c81..3d3795a3c 100644 --- a/haskell-src/Concordium/GRPC2.hs +++ b/haskell-src/Concordium/GRPC2.hs @@ -475,6 +475,7 @@ instance ToProto AccountStakingInfo where case asiPoolInfo of Nothing -> return () Just asipi -> ProtoFields.poolInfo .= toProto asipi + ProtoFields.isSuspended .= asiIsSuspended ) ) toProto AccountStakingDelegated{..} = @@ -619,7 +620,6 @@ instance ToProto AccountInfo where ProtoFields.maybe'stake .= toProto aiStakingInfo ProtoFields.cooldowns .= fmap toProto aiAccountCooldowns ProtoFields.availableBalance .= toProto aiAccountAvailableAmount - ProtoFields.isSuspended .= aiAccountIsSuspended instance ToProto Wasm.Parameter where type Output Wasm.Parameter = Proto.Parameter diff --git a/haskell-src/Concordium/Types/Accounts.hs b/haskell-src/Concordium/Types/Accounts.hs index 542e18419..b466dddac 100644 --- a/haskell-src/Concordium/Types/Accounts.hs +++ b/haskell-src/Concordium/Types/Accounts.hs @@ -589,7 +589,11 @@ data AccountStakingInfo asiStakeEarnings :: !Bool, asiBakerInfo :: !BakerInfo, asiPendingChange :: !(StakePendingChange' UTCTime), - asiPoolInfo :: !(Maybe BakerPoolInfo) + asiPoolInfo :: !(Maybe BakerPoolInfo), + -- | Flag indicating whether the account is currently suspended. A suspended account + -- is not participating in the consensus protocol. The `asiIsSuspended` flag does not + -- have any effect on stake or delegators of a validator. + asiIsSuspended :: !Bool } | -- | The account is delegating stake to a baker. AccountStakingDelegated @@ -613,7 +617,10 @@ toAccountStakingInfo epochConv (AccountStakeBaker AccountBaker{..}) = asiPendingChange = pcTime <$> _bakerPendingChange, asiPoolInfo = case _accountBakerInfo of BakerInfoExV0{} -> Nothing - BakerInfoExV1{..} -> Just _bieBakerPoolInfo + BakerInfoExV1{..} -> Just _bieBakerPoolInfo, + asiIsSuspended = case _accountBakerInfo of + BakerInfoExV0{} -> False + BakerInfoExV1{..} -> fromCondDef _bieAccountIsSuspended False } where pcTime (PendingChangeEffectiveV0 e) = epochConv e @@ -663,7 +670,8 @@ accountStakingInfoToJSON AccountStakingBaker{..} = ["accountBaker" .= bi] "bakerId" .= (asiBakerInfo ^. bakerIdentity), "bakerElectionVerifyKey" .= (asiBakerInfo ^. bakerElectionVerifyKey), "bakerSignatureVerifyKey" .= (asiBakerInfo ^. bakerSignatureVerifyKey), - "bakerAggregationVerifyKey" .= (asiBakerInfo ^. bakerAggregationVerifyKey) + "bakerAggregationVerifyKey" .= (asiBakerInfo ^. bakerAggregationVerifyKey), + "bakerIsSuspended" .= asiIsSuspended ] <> pendingChangeToJSON asiPendingChange <> maybe [] (\bpi -> ["bakerPoolInfo" .= bpi]) asiPoolInfo @@ -751,12 +759,7 @@ data AccountInfo = AccountInfo -- pre-cooldown or pre-pre-cooldown (e.g. if the cooldown interval has been decreased). aiAccountCooldowns :: ![Cooldown], -- | The balance of the account that is available for transactions. - aiAccountAvailableAmount :: !Amount, - -- | Flag indicating whether the account is currently suspended. A - -- suspended account is in effect not participating in the consensus - -- protocol. The aiAccountIsSuspended flag does not have any effect on - -- stake or delegators of a validator. - aiAccountIsSuspended :: !Bool + aiAccountAvailableAmount :: !Amount } deriving (Eq, Show) @@ -774,8 +777,7 @@ accountInfoPairs AccountInfo{..} = "accountIndex" .= aiAccountIndex, "accountAddress" .= aiAccountAddress, "accountCooldowns" .= aiAccountCooldowns, - "accountAvailableAmount" .= aiAccountAvailableAmount, - "accountIsSuspended" .= aiAccountIsSuspended + "accountAvailableAmount" .= aiAccountAvailableAmount ] <> accountStakingInfoToJSON aiStakingInfo