Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
the token module state. They are still required by the current token module implementation, and initialization
without the parameters set will be rejected, so there are no observable changes to PLT behaviour.
- Fixed the `build_catchup_url` in the Ubuntu build release pipeline.
- Added boilerplate code for the upcoming P10.

## 9.0.7

Expand Down
2 changes: 1 addition & 1 deletion concordium-base
Submodule concordium-base updated 49 files
+53 −0 .github/workflows/release-concordium-base-derive.yaml
+51 −0 .github/workflows/release-concordium-base.yaml
+2 −0 .gitignore
+1 −0 concordium-base.cabal
+1 −1 concordium-grpc-api
+3 −0 haskell-bins/genesis/Genesis.hs
+3 −0 haskell-src/Concordium/Constants.hs
+1 −0 haskell-src/Concordium/Cost.hs
+1 −0 haskell-src/Concordium/GRPC2.hs
+19 −0 haskell-src/Concordium/Genesis/Data.hs
+151 −0 haskell-src/Concordium/Genesis/Data/P10.hs
+1 −1 haskell-src/Concordium/Types/Accounts.hs
+7 −0 haskell-src/Concordium/Types/Migration.hs
+2 −0 haskell-src/Concordium/Types/Parameters.hs
+1 −0 haskell-src/Concordium/Types/ProtocolLevelTokens/CBOR.hs
+21 −0 haskell-src/Concordium/Types/ProtocolVersion.hs
+1 −0 haskell-src/Concordium/Types/SeedState.hs
+1 −0 haskell-src/Concordium/Wasm.hs
+110 −0 haskell-tests/Types/CBOR.hs
+2 −2 identity-provider-service/Cargo.lock
+2 −2 idiss/Cargo.lock
+2 −2 mobile_wallet/Cargo.lock
+2 −2 rust-bins/Cargo.lock
+2 −2 rust-src/Cargo.lock
+9 −1 rust-src/concordium_base/CHANGELOG.md
+2 −2 rust-src/concordium_base/Cargo.toml
+9 −1 rust-src/concordium_base/src/aggregate_sig/mod.rs
+0 −14 rust-src/concordium_base/src/base.rs
+213 −3 rust-src/concordium_base/src/common/cbor.rs
+2 −2 rust-src/concordium_base/src/common/cbor/decoder.rs
+87 −0 rust-src/concordium_base/src/common/encoded.rs
+4 −0 rust-src/concordium_base/src/common/mod.rs
+334 −0 rust-src/concordium_base/src/common/upward.rs
+8 −1 rust-src/concordium_base/src/curve_arithmetic/secret_value.rs
+1 −1 rust-src/concordium_base/src/ecvrf/secret.rs
+9 −1 rust-src/concordium_base/src/elgamal/message.rs
+10 −1 rust-src/concordium_base/src/elgamal/secret.rs
+1 −0 rust-src/concordium_base/src/lib.rs
+1 −0 rust-src/concordium_base/src/pedersen_commitment/randomness.rs
+30 −19 rust-src/concordium_base/src/protocol_level_tokens/token_event.rs
+16 −15 rust-src/concordium_base/src/protocol_level_tokens/token_operations.rs
+26 −22 rust-src/concordium_base/src/protocol_level_tokens/token_reject_reason.rs
+9 −1 rust-src/concordium_base/src/ps_sig/known_message.rs
+9 −1 rust-src/concordium_base/src/ps_sig/secret.rs
+48 −3 rust-src/concordium_base/src/smart_contracts.rs
+11 −9 rust-src/concordium_base/src/transactions.rs
+89 −10 rust-src/concordium_base/src/updates.rs
+1 −1 rust-src/concordium_base_derive/Cargo.toml
+129 −45 rust-src/concordium_base_derive/src/cbor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ genesisBakerInfoEx spv cp GenesisBaker{..} = case spv of
SP7 -> binfoV1
SP8 -> binfoV1
SP9 -> binfoV1
SP10 -> binfoV1
where
bkrInfo =
BakerInfo
Expand Down
1 change: 1 addition & 0 deletions concordium-consensus/src/Concordium/GlobalState/Block.hs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ blockVersion SP6 = 3
blockVersion SP7 = 3
blockVersion SP8 = 3
blockVersion SP9 = 3
blockVersion SP10 = 3
{-# INLINE blockVersion #-}

-- | Type class that supports serialization of a block.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ migratePersistentAccount m@StateMigrationParametersP5ToP6{} (PAV2 acc) = PAV2 <$
migratePersistentAccount m@StateMigrationParametersP6ToP7{} (PAV2 acc) = PAV3 <$> V1.migratePersistentAccount m acc
migratePersistentAccount m@StateMigrationParametersP7ToP8{} (PAV3 acc) = PAV4 <$> V1.migratePersistentAccount m acc
migratePersistentAccount m@StateMigrationParametersP8ToP9{} (PAV4 acc) = PAV5 <$> V1.migratePersistentAccount m acc
migratePersistentAccount m@StateMigrationParametersP9ToP10{} (PAV5 acc) = PAV5 <$> V1.migratePersistentAccount m acc

-- | Migrate a 'PersistentBakerInfoRef' between protocol versions according to a state migration.
migratePersistentBakerInfoRef ::
Expand All @@ -887,6 +888,7 @@ migratePersistentBakerInfoRef m@StateMigrationParametersP5ToP6{} (PBIRV2 bir) =
migratePersistentBakerInfoRef m@StateMigrationParametersP6ToP7{} (PBIRV2 bir) = PBIRV3 <$> V1.migratePersistentBakerInfoEx m bir
migratePersistentBakerInfoRef m@StateMigrationParametersP7ToP8{} (PBIRV3 bir) = PBIRV4 <$> V1.migratePersistentBakerInfoEx m bir
migratePersistentBakerInfoRef m@StateMigrationParametersP8ToP9{} (PBIRV4 bir) = PBIRV5 <$> V1.migratePersistentBakerInfoEx m bir
migratePersistentBakerInfoRef m@StateMigrationParametersP9ToP10{} (PBIRV5 bir) = PBIRV5 <$> V1.migratePersistentBakerInfoEx m bir

-- * Conversion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ migratePersistentBakerInfoEx StateMigrationParametersP7ToP8{} = migrateReference
m' (BakerInfoEx av2)
migrateBakerInfoExV1 BakerInfoExV1{..} = return BakerInfoExV1{_bieIsSuspended = CTrue False, ..}
migratePersistentBakerInfoEx StateMigrationParametersP8ToP9{} = migrateReference (return . coerceBakerInfoExV1)
migratePersistentBakerInfoEx StateMigrationParametersP9ToP10{} = migrateReference (return . coerceBakerInfoExV1)

-- | Migrate a 'V0.PersistentBakerInfoEx' to a 'PersistentBakerInfoEx'.
-- See documentation of @migratePersistentBlockState@.
Expand Down Expand Up @@ -2472,6 +2473,7 @@ migratePersistentAccount StateMigrationParametersP5ToP6{} acc = migrateV2ToV2 ac
migratePersistentAccount StateMigrationParametersP6ToP7{} acc = migrateV2ToV3 acc
migratePersistentAccount StateMigrationParametersP7ToP8{} acc = migrateV3ToV4 acc
migratePersistentAccount StateMigrationParametersP8ToP9{} acc = migrateV4ToV5 acc
migratePersistentAccount StateMigrationParametersP9ToP10{} acc = migrateV5ToV5 acc

-- | Migration for 'PersistentAccount' from 'V0.PersistentAccount'. This supports migration from
-- 'P4' to 'P5'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ migratePersistentEpochBakers migration PersistentEpochBakers{..} = do
SomeParam $ unOParam _bakerFinalizationCommitteeParameters
StateMigrationParametersP8ToP9{} ->
SomeParam $ unOParam _bakerFinalizationCommitteeParameters
StateMigrationParametersP9ToP10{} ->
SomeParam $ unOParam _bakerFinalizationCommitteeParameters
return
PersistentEpochBakers
{ _bakerInfos = newBakerInfos,
Expand Down Expand Up @@ -336,6 +338,10 @@ migratePersistentActiveDelegators StateMigrationParametersP8ToP9{} = \case
PersistentActiveDelegatorsV1{..} -> do
newDelegators <- Trie.migrateTrieN True return adDelegators
return PersistentActiveDelegatorsV1{adDelegators = newDelegators, ..}
migratePersistentActiveDelegators StateMigrationParametersP9ToP10{} = \case
PersistentActiveDelegatorsV1{..} -> do
newDelegators <- Trie.migrateTrieN True return adDelegators
return PersistentActiveDelegatorsV1{adDelegators = newDelegators, ..}

emptyPersistentActiveDelegators :: forall av. (IsAccountVersion av) => PersistentActiveDelegators av
emptyPersistentActiveDelegators =
Expand Down Expand Up @@ -387,6 +393,7 @@ migrateTotalActiveCapital StateMigrationParametersP5ToP6{} _ (TotalActiveCapital
migrateTotalActiveCapital StateMigrationParametersP6ToP7{} _ (TotalActiveCapitalV1 bts) = TotalActiveCapitalV1 bts
migrateTotalActiveCapital StateMigrationParametersP7ToP8{} _ (TotalActiveCapitalV1 bts) = TotalActiveCapitalV1 bts
migrateTotalActiveCapital StateMigrationParametersP8ToP9{} _ (TotalActiveCapitalV1 bts) = TotalActiveCapitalV1 bts
migrateTotalActiveCapital StateMigrationParametersP9ToP10{} _ (TotalActiveCapitalV1 bts) = TotalActiveCapitalV1 bts

instance (IsAccountVersion av) => Serialize (TotalActiveCapital av) where
put TotalActiveCapitalV0 = return ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ migrateSeedState (StateMigrationParametersP5ToP6 (P6.StateMigrationData _ time))
migrateSeedState StateMigrationParametersP6ToP7{} ss = migrateSeedStateV1Trivial ss
migrateSeedState StateMigrationParametersP7ToP8{} ss = migrateSeedStateV1Trivial ss
migrateSeedState StateMigrationParametersP8ToP9{} ss = migrateSeedStateV1Trivial ss
migrateSeedState StateMigrationParametersP9ToP10{} ss = migrateSeedStateV1Trivial ss

-- | Trivial migration of a 'SeedStateV1' between protocol versions.
migrateSeedStateV1Trivial :: SeedState 'SeedStateVersion1 -> SeedState 'SeedStateVersion1
Expand Down Expand Up @@ -642,6 +643,10 @@ migrateBlockRewardDetails StateMigrationParametersP8ToP9{} _ _ (SomeParam TimePa
(BlockRewardDetailsV1 hbr) ->
BlockRewardDetailsV1
<$> migrateHashedBufferedRef (migratePoolRewardsP6 oldEpoch _tpRewardPeriodLength) hbr
migrateBlockRewardDetails StateMigrationParametersP9ToP10{} _ _ (SomeParam TimeParametersV1{..}) oldEpoch = \case
(BlockRewardDetailsV1 hbr) ->
BlockRewardDetailsV1
<$> migrateHashedBufferedRef (migratePoolRewardsP6 oldEpoch _tpRewardPeriodLength) hbr

instance
(MonadBlobStore m, IsBlockHashVersion bhv, IsAccountVersion av) =>
Expand Down Expand Up @@ -2848,6 +2853,7 @@ doGetRewardStatus pbs = do
SP7 -> rewardsV1
SP8 -> rewardsV1
SP9 -> rewardsV1
SP10 -> rewardsV1

doRewardFoundationAccount :: (SupportsPersistentState pv m) => PersistentBlockState pv -> Amount -> m (PersistentBlockState pv)
doRewardFoundationAccount pbs reward = do
Expand Down Expand Up @@ -2976,6 +2982,7 @@ doModifyAccount pbs aUpd@AccountUpdate{..} = do
SP7 -> return _auIndex
SP8 -> return _auIndex
SP9 -> return _auIndex
SP10 -> return _auIndex
!oldRel <- accountNextReleaseTimestamp acc
!newRel <- accountNextReleaseTimestamp acc'
return (acctRef :: RSAccountRef pv, oldRel, newRel)
Expand Down Expand Up @@ -3679,6 +3686,7 @@ doProcessReleaseSchedule pbs ts = do
SP7 -> processAccountP5
SP8 -> processAccountP5
SP9 -> processAccountP5
SP10 -> processAccountP5
(newAccs, newRS) <- foldM processAccount (bspAccounts bsp, remRS) affectedAccounts
storePBS pbs (bsp{bspAccounts = newAccs, bspReleaseSchedule = newRS})

Expand Down Expand Up @@ -4874,6 +4882,7 @@ migrateBlockPointers migration BlockStatePointers{..} = do
StateMigrationParametersP6ToP7{} -> RSMNewToNew
StateMigrationParametersP7ToP8{} -> RSMNewToNew
StateMigrationParametersP8ToP9{} -> RSMNewToNew
StateMigrationParametersP9ToP10{} -> RSMNewToNew
logEvent GlobalState LLTrace "Migrating release schedule"
newReleaseSchedule <- migrateReleaseSchedule rsMigration bspReleaseSchedule
pab <- lift . refLoad $ bspBirkParameters ^. birkActiveBakers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ migrateModules migration mods = do
StateMigrationParametersP6ToP7{} -> migrateToP7 @v wasmMod -- always recompile to lower transaction costs.
StateMigrationParametersP7ToP8{} -> return $! moduleVInterface{GSWasm.miModule = PIMVMem artifact}
StateMigrationParametersP8ToP9{} -> return $! moduleVInterface{GSWasm.miModule = PIMVMem artifact}
StateMigrationParametersP9ToP10{} -> return $! moduleVInterface{GSWasm.miModule = PIMVMem artifact}

-- store the module into the new state, and remove it from memory
makeFlushedHashedCachedRef $!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ migratePendingUpdates migration PendingUpdates{..} = withCPVConstraints (chainPa
NoParam -> return NoParam
StateMigrationParametersP8ToP9{} -> case pElectionDifficultyQueue of
NoParam -> return NoParam
StateMigrationParametersP9ToP10{} -> case pElectionDifficultyQueue of
NoParam -> return NoParam
newTimeParameters <- case migration of
StateMigrationParametersTrivial -> case pTimeParametersQueue of
NoParam -> return NoParam
Expand All @@ -338,6 +340,8 @@ migratePendingUpdates migration PendingUpdates{..} = withCPVConstraints (chainPa
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
StateMigrationParametersP8ToP9{} -> case pTimeParametersQueue of
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
StateMigrationParametersP9ToP10{} -> case pTimeParametersQueue of
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
newCooldownParameters <- case migration of
StateMigrationParametersTrivial -> case pCooldownParametersQueue of
NoParam -> return NoParam
Expand All @@ -360,6 +364,8 @@ migratePendingUpdates migration PendingUpdates{..} = withCPVConstraints (chainPa
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
StateMigrationParametersP8ToP9{} -> case pCooldownParametersQueue of
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
StateMigrationParametersP9ToP10{} -> case pCooldownParametersQueue of
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
newTimeoutParameters <- case migration of
StateMigrationParametersTrivial -> case pTimeoutParametersQueue of
NoParam -> return NoParam
Expand All @@ -381,6 +387,8 @@ migratePendingUpdates migration PendingUpdates{..} = withCPVConstraints (chainPa
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
StateMigrationParametersP8ToP9{} -> case pTimeoutParametersQueue of
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
StateMigrationParametersP9ToP10{} -> case pTimeoutParametersQueue of
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
newMinBlockTimeQueue <- case migration of
StateMigrationParametersTrivial -> case pMinBlockTimeQueue of
NoParam -> return NoParam
Expand All @@ -402,6 +410,8 @@ migratePendingUpdates migration PendingUpdates{..} = withCPVConstraints (chainPa
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
StateMigrationParametersP8ToP9{} -> case pMinBlockTimeQueue of
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
StateMigrationParametersP9ToP10{} -> case pMinBlockTimeQueue of
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
newBlockEnergyLimitQueue <- case migration of
StateMigrationParametersTrivial -> case pBlockEnergyLimitQueue of
NoParam -> return NoParam
Expand All @@ -423,6 +433,8 @@ migratePendingUpdates migration PendingUpdates{..} = withCPVConstraints (chainPa
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
StateMigrationParametersP8ToP9{} -> case pBlockEnergyLimitQueue of
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
StateMigrationParametersP9ToP10{} -> case pBlockEnergyLimitQueue of
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
newFinalizationCommitteeParametersQueue <- case migration of
StateMigrationParametersTrivial -> case pFinalizationCommitteeParametersQueue of
NoParam -> return NoParam
Expand All @@ -444,6 +456,8 @@ migratePendingUpdates migration PendingUpdates{..} = withCPVConstraints (chainPa
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
StateMigrationParametersP8ToP9{} -> case pFinalizationCommitteeParametersQueue of
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
StateMigrationParametersP9ToP10{} -> case pFinalizationCommitteeParametersQueue of
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
newValidatorScoreParametersQueue <- case migration of
StateMigrationParametersTrivial -> case pValidatorScoreParametersQueue of
NoParam -> return NoParam
Expand All @@ -465,6 +479,8 @@ migratePendingUpdates migration PendingUpdates{..} = withCPVConstraints (chainPa
return (SomeParam hbr)
StateMigrationParametersP8ToP9{} -> case pValidatorScoreParametersQueue of
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
StateMigrationParametersP9ToP10{} -> case pValidatorScoreParametersQueue of
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
return $!
PendingUpdates
{ pRootKeysUpdateQueue = newRootKeys,
Expand Down Expand Up @@ -812,6 +828,7 @@ migrateUpdates migration Updates{..} = do
StateMigrationParametersP6ToP7 -> CFalse
StateMigrationParametersP7ToP8 _ -> CFalse
StateMigrationParametersP8ToP9 _ -> CTrue minUpdateSequenceNumber
StateMigrationParametersP9ToP10 _ -> CTrue minUpdateSequenceNumber
return
Updates
{ currentKeyCollection = newKeyCollection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module Concordium.GlobalState.Persistent.Genesis (genesisState) where
import qualified Concordium.Genesis.Data as GenesisData
import qualified Concordium.Genesis.Data.BaseV1 as GDBaseV1
import qualified Concordium.Genesis.Data.P1 as P1
import qualified Concordium.Genesis.Data.P10 as P10
import qualified Concordium.Genesis.Data.P2 as P2
import qualified Concordium.Genesis.Data.P3 as P3
import qualified Concordium.Genesis.Data.P4 as P4
Expand Down Expand Up @@ -90,6 +91,9 @@ genesisState gd = MTL.runExceptT $ case Types.protocolVersion @pv of
Types.SP9 -> case gd of
GenesisData.GDP9 P9.GDP9Initial{..} ->
buildGenesisBlockState (CGPV1 genesisCore) genesisInitialState
Types.SP10 -> case gd of
GenesisData.GDP10 P10.GDP10Initial{..} ->
buildGenesisBlockState (CGPV1 genesisCore) genesisInitialState

-------- Types -----------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ instance (MonadBlobStore m, IsProtocolVersion pv) => BlobStorable m (ReleaseSche
SP7 -> fmap ReleaseScheduleP5 <$> load
SP8 -> fmap ReleaseScheduleP5 <$> load
SP9 -> fmap ReleaseScheduleP5 <$> load
SP10 -> fmap ReleaseScheduleP5 <$> load

instance (MonadBlobStore m) => Cacheable m (ReleaseSchedule pv) where
cache (ReleaseScheduleP0 rs) = ReleaseScheduleP0 <$> cache rs
Expand Down Expand Up @@ -342,6 +343,7 @@ emptyReleaseSchedule = case protocolVersion @pv of
SP7 -> rsP1
SP8 -> rsP1
SP9 -> rsP1
SP10 -> rsP1
where
rsP0 :: (RSAccountRef pv ~ AccountAddress) => m (ReleaseSchedule pv)
rsP0 = do
Expand Down Expand Up @@ -391,6 +393,7 @@ trivialReleaseScheduleMigration = case protocolVersion @pv of
SP7 -> RSMNewToNew
SP8 -> RSMNewToNew
SP9 -> RSMNewToNew
SP10 -> RSMNewToNew

-- | Migrate a release schedule from one protocol version to another, given by a
-- 'ReleaseScheduleMigration'.
Expand Down
4 changes: 3 additions & 1 deletion concordium-consensus/src/Concordium/KonsensusV1/TestMonad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Concordium.TimeMonad
import Concordium.Types

import qualified Concordium.Genesis.Data.BaseV1 as BaseV1
import qualified Concordium.Genesis.Data.P10 as P10
import qualified Concordium.Genesis.Data.P6 as P6
import qualified Concordium.Genesis.Data.P7 as P7
import qualified Concordium.Genesis.Data.P8 as P8
Expand All @@ -33,7 +34,7 @@ import qualified Concordium.GlobalState.AccountMap.LMDB as LMDBAccountMap
import Concordium.GlobalState.BlockState
import qualified Concordium.GlobalState.ContractStateV1 as StateV1
import Concordium.GlobalState.Parameters (
GenesisData (GDP6, GDP7, GDP8, GDP9),
GenesisData (GDP10, GDP6, GDP7, GDP8, GDP9),
defaultRuntimeParameters,
genesisBlockHash,
)
Expand Down Expand Up @@ -153,6 +154,7 @@ genesisCore = case protocolVersion @pv of
SP7 -> \(GDP7 P7.GDP7Initial{genesisCore = core}) -> core
SP8 -> \(GDP8 P8.GDP8Initial{genesisCore = core}) -> core
SP9 -> \(GDP9 P9.GDP9Initial{genesisCore = core}) -> core
SP10 -> \(GDP10 P10.GDP10Initial{genesisCore = core}) -> core

-- | Run an operation in the 'TestMonad' with the given baker, time and genesis data.
-- This sets up a temporary blob store for the block state that is deleted after use.
Expand Down
61 changes: 61 additions & 0 deletions concordium-consensus/src/Concordium/ProtocolUpdate/P10.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}

module Concordium.ProtocolUpdate.P10 (
Update (..),
checkUpdate,
updateRegenesis,
updateNextProtocolVersion,
) where

import Control.Monad.State
import qualified Data.HashMap.Strict as HM
import Data.Serialize

import qualified Concordium.Crypto.SHA256 as SHA256
import Concordium.Types
import Concordium.Types.Updates

import Concordium.GlobalState.BlockState
import qualified Concordium.GlobalState.Persistent.BlockState as PBS
import Concordium.GlobalState.Types
import qualified Concordium.GlobalState.Types as GSTypes
import Concordium.KonsensusV1.TreeState.Implementation
import Concordium.KonsensusV1.TreeState.Types
import qualified Concordium.ProtocolUpdate.P10.Reboot as Reboot

-- | Updates that are supported from protocol version P10.
data Update = Reboot
deriving (Show)

-- | Hash map for resolving updates from their specification hash.
updates :: HM.HashMap SHA256.Hash (Get Update)
updates = HM.fromList [(Reboot.updateHash, return Reboot)]

-- | Determine if a 'ProtocolUpdate' corresponds to a supported update type.
checkUpdate :: ProtocolUpdate -> Either String Update
checkUpdate ProtocolUpdate{..} = case HM.lookup puSpecificationHash updates of
Nothing -> Left "Specification hash does not correspond to a known protocol update."
Just updateGet -> case runGet updateGet puSpecificationAuxiliaryData of
Left err -> Left $! "Could not deserialize auxiliary data: " ++ err
Right update -> return update

-- | Construct the genesis data for a P10 update.
updateRegenesis ::
( MPV m ~ 'P10,
BlockStateStorage m,
MonadState (SkovData (MPV m)) m,
GSTypes.BlockState m ~ PBS.HashedPersistentBlockState (MPV m)
) =>
-- | The update taking effect.
Update ->
-- | The terminal block of the old chain.
BlockPointer (MPV m) ->
m (PVInit m)
updateRegenesis Reboot = Reboot.updateRegenesis

-- | Determine the protocol version the update will update to.
updateNextProtocolVersion ::
Update ->
SomeProtocolVersion
updateNextProtocolVersion Reboot{} = SomeProtocolVersion SP10
Loading
Loading