Skip to content

Commit

Permalink
merged with main
Browse files Browse the repository at this point in the history
  • Loading branch information
lassemand committed Nov 25, 2024
2 parents b4fd34e + b5eb857 commit 19d674b
Show file tree
Hide file tree
Showing 17 changed files with 879 additions and 152 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ on:
workflow_dispatch: # allow manual trigger

env:
RUST: 1.73
GHC: 9.6.4
RUST: 1.82
GHC: 9.6.6

jobs:
fourmolu:
Expand Down
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## 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.
- Update GHC version to 9.6.6 (lts-22.39).

## 7.0.1

- Display the correct "at disposal" balance when used with node versions prior to 7.
Expand Down
2 changes: 2 additions & 0 deletions concordium-client.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ library
Concordium.Client.Runner.Helper
Concordium.Client.RWLock
Concordium.Client.Types.Account
Concordium.Client.Types.ConsensusStatus
Concordium.Client.Types.Contract.BuildInfo
Concordium.Client.Types.Contract.Info
Concordium.Client.Types.Contract.Parameter
Expand Down Expand Up @@ -100,6 +101,7 @@ library
, prettyprinter-ansi-terminal
, proto-lens ==0.7.*
, scientific
, singletons-base
, split
, string-interpolate
, text
Expand Down
2 changes: 1 addition & 1 deletion deps/concordium-base
Submodule concordium-base updated 101 files
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ library:
- string-interpolate
- scientific
- cookie
- singletons-base

executables:
concordium-client:
Expand Down
2 changes: 1 addition & 1 deletion scripts/distributables/linux-concordium-client.Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pipeline {
agent any
environment {
GHC_VERSION = '9.6.4'
GHC_VERSION = '9.6.6'
VERSION = sh(
returnStdout: true,
script: '''\
Expand Down
4 changes: 2 additions & 2 deletions scripts/distributables/macos-concordium-client.Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pipeline {
agent { label 'jenkins-worker' }
environment {
GHC_VERSION = '9.6.4'
RUST_VERSION = '1.73'
GHC_VERSION = '9.6.6'
RUST_VERSION = '1.82'
VERSION = sh(
returnStdout: true,
script: '''\
Expand Down
4 changes: 2 additions & 2 deletions scripts/distributables/windows-concordium-client.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pipeline {
stages {
stage('build') {
environment {
GHC_VERSION = '9.6.4'
GHC_VERSION = '9.6.6'
BASE_OUTFILE = 's3://distribution.concordium.software/tools/windows/concordium-client'
}
steps {
Expand All @@ -22,7 +22,7 @@ pipeline {
fi

# Ensure correct rust env
rustup default 1.73-x86_64-pc-windows-gnu
rustup default 1.82-x86_64-pc-windows-gnu

# Build project
stack build --force-dirty
Expand Down
20 changes: 20 additions & 0 deletions src/Concordium/Client/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ data ConsensusCmd
ccuKeys :: ![FilePath],
ccuInteractionOpts :: !InteractionOpts
}
| ConsensusDetailedStatus
{ cdsGenesisIndex :: !(Maybe GenesisIndex)
}
deriving (Show)

data BlockCmd = BlockShow
Expand Down Expand Up @@ -492,6 +495,7 @@ data BakerCmd
bcTransactionFeeCommission :: !(Maybe AmountFraction),
bcBakingRewardCommission :: !(Maybe AmountFraction),
bcFinalizationRewardCommission :: !(Maybe AmountFraction),
bcSuspend :: !(Maybe Bool),
bcInputKeyFile :: !(Maybe FilePath),
bcOutputKeyFile :: !(Maybe FilePath)
}
Expand Down Expand Up @@ -1560,6 +1564,7 @@ consensusCmds =
( ConsensusCmd
<$> ( hsubparser
( consensusStatusCmd
<> consensusDetailedStatusCmd
<> consensusShowChainParametersCmd
<> consensusShowParametersCmd
)
Expand All @@ -1579,6 +1584,17 @@ consensusStatusCmd =
(progDesc "List various parameters related to the current state of the consensus protocol.")
)

consensusDetailedStatusCmd :: Mod CommandFields ConsensusCmd
consensusDetailedStatusCmd =
command
"detailed-status"
( info
( ConsensusDetailedStatus
<$> optional (option auto (long "genesis-index" <> metavar "GENINDEX" <> help "Genesis index (defaults to latest)"))
)
(progDesc "Show detailed consensus status information.")
)

consensusShowParametersCmd :: Mod CommandFields ConsensusCmd
consensusShowParametersCmd =
command
Expand Down Expand Up @@ -1785,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."))
)
Expand Down
196 changes: 196 additions & 0 deletions src/Concordium/Client/GRPC2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ import qualified Concordium.Types.Transactions as Transactions
import qualified Concordium.Types.Updates as Updates
import qualified Concordium.Wasm as Wasm

import Concordium.Client.Types.ConsensusStatus
import qualified Concordium.Crypto.BlockSignature as BlockSignature
import qualified Proto.V2.Concordium.Service as CS
import qualified Proto.V2.Concordium.Types as Proto
import qualified Proto.V2.Concordium.Types as ProtoFields
Expand Down Expand Up @@ -535,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
Expand Down Expand Up @@ -840,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'."

Expand Down Expand Up @@ -2268,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
Expand Down Expand Up @@ -2874,6 +2884,186 @@ instance FromProto Proto.WinningBaker where
let wbPresent = winningBaker ^. ProtoFields.present
return WinningBaker{..}

instance FromProto Proto.FinalizerIndex where
type Output Proto.FinalizerIndex = FinalizerIndex
fromProto fi = return . FinalizerIndex $ fi ^. ProtoFields.value

instance FromProto Proto.QuorumMessage where
type Output Proto.QuorumMessage = QuorumMessage
fromProto qm = do
qmSignature <- fromProto (qm ^. ProtoFields.signature)
qmBlock <- fromProto (qm ^. ProtoFields.block)
qmFinalizer <- fromProto (qm ^. ProtoFields.finalizer)
qmRound <- fromProto (qm ^. ProtoFields.round)
qmEpoch <- fromProto (qm ^. ProtoFields.epoch)
return QuorumMessage{..}

instance FromProto Proto.RawQuorumCertificate where
type Output Proto.RawQuorumCertificate = QuorumCertificate
fromProto qc = do
qcBlockHash <- fromProto (qc ^. ProtoFields.blockHash)
qcRound <- fromProto (qc ^. ProtoFields.round)
qcEpoch <- fromProto (qc ^. ProtoFields.epoch)
qcAggregateSignature <- fromProto (qc ^. ProtoFields.aggregateSignature)
qcSignatories <- mapM fromProto (qc ^. ProtoFields.signatories)
return QuorumCertificate{..}

instance FromProto Proto.BlockSignature where
type Output Proto.BlockSignature = BlockSignature.Signature
fromProto = deMkSerialize

instance FromProto Proto.TimeoutMessage where
type Output Proto.TimeoutMessage = TimeoutMessage
fromProto tm = do
tmFinalizer <- fromProto (tm ^. ProtoFields.finalizer)
tmRound <- fromProto (tm ^. ProtoFields.round)
tmEpoch <- fromProto (tm ^. ProtoFields.epoch)
tmQuorumCertificate <- fromProto (tm ^. ProtoFields.quorumCertificate)
tmSignature <- fromProto (tm ^. ProtoFields.signature)
tmMessageSignature <- fromProto (tm ^. ProtoFields.messageSignature)
return TimeoutMessage{..}

instance FromProto Proto.RawFinalizerRound where
type Output Proto.RawFinalizerRound = FinalizerRound
fromProto fr = do
frRound <- fromProto (fr ^. ProtoFields.round)
frFinalizers <- mapM fromProto (fr ^. ProtoFields.finalizers)
return FinalizerRound{..}

instance FromProto Proto.RawTimeoutCertificate where
type Output Proto.RawTimeoutCertificate = TimeoutCertificate
fromProto tc = do
tcRound <- fromProto (tc ^. ProtoFields.round)
tcMinEpoch <- fromProto (tc ^. ProtoFields.minEpoch)
tcQcRoundsFirstEpoch <- mapM fromProto (tc ^. ProtoFields.qcRoundsFirstEpoch)
tcQcRoundsSecondEpoch <- mapM fromProto (tc ^. ProtoFields.qcRoundsSecondEpoch)
tcAggregateSignature <- fromProto (tc ^. ProtoFields.aggregateSignature)
return TimeoutCertificate{..}

instance FromProto Proto.PersistentRoundStatus where
type Output Proto.PersistentRoundStatus = PersistentRoundStatus
fromProto prs = do
prsLastSignedQuorumMessage <- mapM fromProto (prs ^. ProtoFields.maybe'lastSignedQuorumMessage)
prsLastSignedTimeoutMessage <- mapM fromProto (prs ^. ProtoFields.maybe'lastSignedTimeoutMessage)
prsLastBakedRound <- fromProto (prs ^. ProtoFields.lastBakedRound)
prsLatestTimeout <- mapM fromProto (prs ^. ProtoFields.maybe'latestTimeout)
return PersistentRoundStatus{..}

instance FromProto Proto.RoundTimeout where
type Output Proto.RoundTimeout = RoundTimeout
fromProto rt = do
rtTimeoutCertificate <- fromProto (rt ^. ProtoFields.timeoutCertificate)
rtQuorumCertificate <- fromProto (rt ^. ProtoFields.quorumCertificate)
return RoundTimeout{..}

instance FromProto Proto.RawFinalizationEntry where
type Output Proto.RawFinalizationEntry = FinalizationEntry
fromProto fe = do
feFinalizedQC <- fromProto (fe ^. ProtoFields.finalizedQc)
feSuccessorQC <- fromProto (fe ^. ProtoFields.successorQc)
feSuccessorProof <- fromProto (fe ^. ProtoFields.successorProof)
return FinalizationEntry{..}

instance FromProto Proto.RoundStatus where
type Output Proto.RoundStatus = RoundStatus
fromProto rs = do
rsCurrentRound <- fromProto (rs ^. ProtoFields.currentRound)
rsHighestCertifiedBlock <- fromProto (rs ^. ProtoFields.highestCertifiedBlock)
rsPreviousRoundTimeout <- mapM fromProto (rs ^. ProtoFields.maybe'previousRoundTimeout)
let rsRoundEligibleToBake = rs ^. ProtoFields.roundEligibleToBake
rsCurrentEpoch <- fromProto (rs ^. ProtoFields.currentEpoch)
rsLastEpochFinalizationEntry <- mapM fromProto (rs ^. ProtoFields.maybe'lastEpochFinalizationEntry)
rsCurrentTimeout <- fromProto (rs ^. ProtoFields.currentTimeout)
return RoundStatus{..}

instance FromProto Proto.BlockTableSummary where
type Output Proto.BlockTableSummary = BlockTableSummary
fromProto bts = do
let btsDeadBlockCacheSize = bts ^. ProtoFields.deadBlockCacheSize
btsLiveBlocks <- mapM fromProto (bts ^. ProtoFields.liveBlocks)
return BlockTableSummary{..}

instance FromProto Proto.RoundExistingBlock where
type Output Proto.RoundExistingBlock = RoundExistingBlock
fromProto reb = do
rebRound <- fromProto (reb ^. ProtoFields.round)
rebBaker <- fromProto (reb ^. ProtoFields.baker)
rebBlock <- fromProto (reb ^. ProtoFields.block)
return RoundExistingBlock{..}

instance FromProto Proto.RoundExistingQC where
type Output Proto.RoundExistingQC = RoundExistingQC
fromProto req = do
reqRound <- fromProto (req ^. ProtoFields.round)
reqEpoch <- fromProto (req ^. ProtoFields.epoch)
return RoundExistingQC{..}

instance FromProto Proto.FullBakerInfo where
type Output Proto.FullBakerInfo = FullBakerInfo
fromProto fbi = do
fbiBakerIdentity <- fromProto (fbi ^. ProtoFields.bakerIdentity)
fbiElectionVerifyKey <- fromProto (fbi ^. ProtoFields.electionVerifyKey)
fbiSignatureVerifyKey <- fromProto (fbi ^. ProtoFields.signatureVerifyKey)
fbiAggregationVerifyKey <- fromProto (fbi ^. ProtoFields.aggregationVerifyKey)
fbiStake <- fromProto (fbi ^. ProtoFields.stake)
return FullBakerInfo{..}

instance FromProto Proto.FinalizationCommitteeHash where
type Output Proto.FinalizationCommitteeHash = Hash
fromProto = deMkSerialize

instance FromProto Proto.BakersAndFinalizers where
type Output Proto.BakersAndFinalizers = BakersAndFinalizers
fromProto baf = do
bafBakers <- mapM fromProto (baf ^. ProtoFields.bakers)
bafFinalizers <- mapM fromProto (baf ^. ProtoFields.finalizers)
bafBakerTotalStake <- fromProto (baf ^. ProtoFields.bakerTotalStake)
bafFinalizerTotalStake <- fromProto (baf ^. ProtoFields.finalizerTotalStake)
bafFinalizationCommitteeHash <- fromProto (baf ^. ProtoFields.finalizationCommitteeHash)
return BakersAndFinalizers{..}

instance FromProto Proto.EpochBakers where
type Output Proto.EpochBakers = EpochBakers
fromProto epochBakers = do
ebPreviousEpochBakers <- fromProto (epochBakers ^. ProtoFields.previousEpochBakers)
ebCurrentEpochBakers <- mapM fromProto (epochBakers ^. ProtoFields.maybe'currentEpochBakers)
ebNextEpochBakers <- mapM fromProto (epochBakers ^. ProtoFields.maybe'nextEpochBakers)
ebNextPayday <- fromProto (epochBakers ^. ProtoFields.nextPayday)
return EpochBakers{..}

instance FromProto Proto.TimeoutMessages where
type Output Proto.TimeoutMessages = TimeoutMessages
fromProto timeoutMessages = do
tmFirstEpoch <- fromProto (timeoutMessages ^. ProtoFields.firstEpoch)
tmFirstEpochTimeouts <- mapM fromProto (timeoutMessages ^. ProtoFields.firstEpochTimeouts)
tmSecondEpochTimeouts <- mapM fromProto (timeoutMessages ^. ProtoFields.secondEpochTimeouts)
return TimeoutMessages{..}

instance FromProto Proto.BranchBlocks where
type Output Proto.BranchBlocks = [BlockHash]
fromProto branchBlocks = mapM fromProto (branchBlocks ^. ProtoFields.blocksAtBranchHeight)

instance FromProto Proto.ConsensusDetailedStatus where
type Output Proto.ConsensusDetailedStatus = ConsensusDetailedStatus
fromProto consensusDetailedStatus = do
cdsGenesisBlock <- fromProto (consensusDetailedStatus ^. ProtoFields.genesisBlock)
cdsPersistentRoundStatus <- fromProto (consensusDetailedStatus ^. ProtoFields.persistentRoundStatus)
cdsRoundStatus <- fromProto (consensusDetailedStatus ^. ProtoFields.roundStatus)
let cdsNonFinalizedTransactionCount = consensusDetailedStatus ^. ProtoFields.nonFinalizedTransactionCount
let cdsTransactionTablePurgeCounter = consensusDetailedStatus ^. ProtoFields.transactionTablePurgeCounter
cdsBlockTable <- fromProto (consensusDetailedStatus ^. ProtoFields.blockTable)
cdsBranches <- mapM fromProto (consensusDetailedStatus ^. ProtoFields.branches)
cdsRoundExistingBlocks <- mapM fromProto (consensusDetailedStatus ^. ProtoFields.roundExistingBlocks)
cdsRoundExistingQCs <- mapM fromProto (consensusDetailedStatus ^. ProtoFields.roundExistingQcs)
cdsGenesisBlockHeight <- fromProto (consensusDetailedStatus ^. ProtoFields.genesisBlockHeight)
cdsLastFinalizedBlock <- fromProto (consensusDetailedStatus ^. ProtoFields.lastFinalizedBlock)
cdsLastFinalizedBlockHeight <- fromProto (consensusDetailedStatus ^. ProtoFields.lastFinalizedBlockHeight)
cdsLatestFinalizationEntry <- mapM fromProto (consensusDetailedStatus ^. ProtoFields.maybe'latestFinalizationEntry)
cdsEpochBakers <- fromProto (consensusDetailedStatus ^. ProtoFields.epochBakers)
cdsTimeoutMessages <- mapM fromProto (consensusDetailedStatus ^. ProtoFields.maybe'timeoutMessages)
cdsTerminalBlock <- mapM fromProto (consensusDetailedStatus ^. ProtoFields.maybe'terminalBlock)
return ConsensusDetailedStatus{..}

type LoggerMethod = Text -> IO ()

data GrpcConfig = GrpcConfig
Expand Down Expand Up @@ -3319,6 +3509,12 @@ getBlockInfo bhInput = withUnary (call @"getBlockInfo") msg (fmap fromProto)
getConsensusInfo :: (MonadIO m) => ClientMonad m (GRPCResult (FromProtoResult ConsensusStatus))
getConsensusInfo = withUnary (call @"getConsensusInfo") defMessage (fmap fromProto)

-- | Get detailed consensus state information (for consensus version 1).
getConsensusDetailedStatus :: (MonadIO m) => Maybe GenesisIndex -> ClientMonad m (GRPCResult (FromProtoResult ConsensusDetailedStatus))
getConsensusDetailedStatus mGenesisIndex = withUnary (call @"getConsensusDetailedStatus") msg (fmap fromProto)
where
msg = defMessage & ProtoFields.maybe'genesisIndex .~ fmap toProto mGenesisIndex

-- | Get the source of a smart contract module.
getModuleSource :: (MonadIO m) => ModuleRef -> BlockHashInput -> ClientMonad m (GRPCResult (FromProtoResult Wasm.WasmModule))
getModuleSource modRef bhInput = withUnary (call @"getModuleSource") msg (fmap fromProto)
Expand Down
Loading

0 comments on commit 19d674b

Please sign in to comment.