Skip to content

Commit b9fb596

Browse files
author
drsk
committed
COR-2001: P10 boilerplate code
1 parent 024f9e4 commit b9fb596

File tree

19 files changed

+240
-3
lines changed

19 files changed

+240
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
the token module state. They are still required by the current token module implementation, and initialization
99
without the parameters set will be rejected, so there are no observable changes to PLT behaviour.
1010
- Fixed the `build_catchup_url` in the Ubuntu build release pipeline.
11+
- Added boilerplate code for the upcoming P10.
1112

1213
## 9.0.7
1314

concordium-consensus/src/Concordium/GlobalState/BakerInfo.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ genesisBakerInfoEx spv cp GenesisBaker{..} = case spv of
377377
SP7 -> binfoV1
378378
SP8 -> binfoV1
379379
SP9 -> binfoV1
380+
SP10 -> binfoV1
380381
where
381382
bkrInfo =
382383
BakerInfo

concordium-consensus/src/Concordium/GlobalState/Block.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ blockVersion SP6 = 3
144144
blockVersion SP7 = 3
145145
blockVersion SP8 = 3
146146
blockVersion SP9 = 3
147+
blockVersion SP10 = 3
147148
{-# INLINE blockVersion #-}
148149

149150
-- | Type class that supports serialization of a block.

concordium-consensus/src/Concordium/GlobalState/Persistent/Account.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,7 @@ migratePersistentAccount m@StateMigrationParametersP5ToP6{} (PAV2 acc) = PAV2 <$
865865
migratePersistentAccount m@StateMigrationParametersP6ToP7{} (PAV2 acc) = PAV3 <$> V1.migratePersistentAccount m acc
866866
migratePersistentAccount m@StateMigrationParametersP7ToP8{} (PAV3 acc) = PAV4 <$> V1.migratePersistentAccount m acc
867867
migratePersistentAccount m@StateMigrationParametersP8ToP9{} (PAV4 acc) = PAV5 <$> V1.migratePersistentAccount m acc
868+
migratePersistentAccount m@StateMigrationParametersP9ToP10{} (PAV5 acc) = PAV5 <$> V1.migratePersistentAccount m acc
868869

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

891893
-- * Conversion
892894

concordium-consensus/src/Concordium/GlobalState/Persistent/Account/StructureV1.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ migratePersistentBakerInfoEx StateMigrationParametersP7ToP8{} = migrateReference
134134
m' (BakerInfoEx av2)
135135
migrateBakerInfoExV1 BakerInfoExV1{..} = return BakerInfoExV1{_bieIsSuspended = CTrue False, ..}
136136
migratePersistentBakerInfoEx StateMigrationParametersP8ToP9{} = migrateReference (return . coerceBakerInfoExV1)
137+
migratePersistentBakerInfoEx StateMigrationParametersP9ToP10{} = migrateReference (return . coerceBakerInfoExV1)
137138

138139
-- | Migrate a 'V0.PersistentBakerInfoEx' to a 'PersistentBakerInfoEx'.
139140
-- See documentation of @migratePersistentBlockState@.
@@ -2472,6 +2473,7 @@ migratePersistentAccount StateMigrationParametersP5ToP6{} acc = migrateV2ToV2 ac
24722473
migratePersistentAccount StateMigrationParametersP6ToP7{} acc = migrateV2ToV3 acc
24732474
migratePersistentAccount StateMigrationParametersP7ToP8{} acc = migrateV3ToV4 acc
24742475
migratePersistentAccount StateMigrationParametersP8ToP9{} acc = migrateV4ToV5 acc
2476+
migratePersistentAccount StateMigrationParametersP9ToP10{} acc = migrateV5ToV5 acc
24752477

24762478
-- | Migration for 'PersistentAccount' from 'V0.PersistentAccount'. This supports migration from
24772479
-- 'P4' to 'P5'.

concordium-consensus/src/Concordium/GlobalState/Persistent/Bakers.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ migratePersistentEpochBakers migration PersistentEpochBakers{..} = do
159159
SomeParam $ unOParam _bakerFinalizationCommitteeParameters
160160
StateMigrationParametersP8ToP9{} ->
161161
SomeParam $ unOParam _bakerFinalizationCommitteeParameters
162+
StateMigrationParametersP9ToP10{} ->
163+
SomeParam $ unOParam _bakerFinalizationCommitteeParameters
162164
return
163165
PersistentEpochBakers
164166
{ _bakerInfos = newBakerInfos,
@@ -336,6 +338,10 @@ migratePersistentActiveDelegators StateMigrationParametersP8ToP9{} = \case
336338
PersistentActiveDelegatorsV1{..} -> do
337339
newDelegators <- Trie.migrateTrieN True return adDelegators
338340
return PersistentActiveDelegatorsV1{adDelegators = newDelegators, ..}
341+
migratePersistentActiveDelegators StateMigrationParametersP9ToP10{} = \case
342+
PersistentActiveDelegatorsV1{..} -> do
343+
newDelegators <- Trie.migrateTrieN True return adDelegators
344+
return PersistentActiveDelegatorsV1{adDelegators = newDelegators, ..}
339345

340346
emptyPersistentActiveDelegators :: forall av. (IsAccountVersion av) => PersistentActiveDelegators av
341347
emptyPersistentActiveDelegators =
@@ -387,6 +393,7 @@ migrateTotalActiveCapital StateMigrationParametersP5ToP6{} _ (TotalActiveCapital
387393
migrateTotalActiveCapital StateMigrationParametersP6ToP7{} _ (TotalActiveCapitalV1 bts) = TotalActiveCapitalV1 bts
388394
migrateTotalActiveCapital StateMigrationParametersP7ToP8{} _ (TotalActiveCapitalV1 bts) = TotalActiveCapitalV1 bts
389395
migrateTotalActiveCapital StateMigrationParametersP8ToP9{} _ (TotalActiveCapitalV1 bts) = TotalActiveCapitalV1 bts
396+
migrateTotalActiveCapital StateMigrationParametersP9ToP10{} _ (TotalActiveCapitalV1 bts) = TotalActiveCapitalV1 bts
390397

391398
instance (IsAccountVersion av) => Serialize (TotalActiveCapital av) where
392399
put TotalActiveCapitalV0 = return ()

concordium-consensus/src/Concordium/GlobalState/Persistent/BlockState.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ migrateSeedState (StateMigrationParametersP5ToP6 (P6.StateMigrationData _ time))
187187
migrateSeedState StateMigrationParametersP6ToP7{} ss = migrateSeedStateV1Trivial ss
188188
migrateSeedState StateMigrationParametersP7ToP8{} ss = migrateSeedStateV1Trivial ss
189189
migrateSeedState StateMigrationParametersP8ToP9{} ss = migrateSeedStateV1Trivial ss
190+
migrateSeedState StateMigrationParametersP9ToP10{} ss = migrateSeedStateV1Trivial ss
190191

191192
-- | Trivial migration of a 'SeedStateV1' between protocol versions.
192193
migrateSeedStateV1Trivial :: SeedState 'SeedStateVersion1 -> SeedState 'SeedStateVersion1
@@ -642,6 +643,10 @@ migrateBlockRewardDetails StateMigrationParametersP8ToP9{} _ _ (SomeParam TimePa
642643
(BlockRewardDetailsV1 hbr) ->
643644
BlockRewardDetailsV1
644645
<$> migrateHashedBufferedRef (migratePoolRewardsP6 oldEpoch _tpRewardPeriodLength) hbr
646+
migrateBlockRewardDetails StateMigrationParametersP9ToP10{} _ _ (SomeParam TimeParametersV1{..}) oldEpoch = \case
647+
(BlockRewardDetailsV1 hbr) ->
648+
BlockRewardDetailsV1
649+
<$> migrateHashedBufferedRef (migratePoolRewardsP6 oldEpoch _tpRewardPeriodLength) hbr
645650

646651
instance
647652
(MonadBlobStore m, IsBlockHashVersion bhv, IsAccountVersion av) =>
@@ -2848,6 +2853,7 @@ doGetRewardStatus pbs = do
28482853
SP7 -> rewardsV1
28492854
SP8 -> rewardsV1
28502855
SP9 -> rewardsV1
2856+
SP10 -> rewardsV1
28512857

28522858
doRewardFoundationAccount :: (SupportsPersistentState pv m) => PersistentBlockState pv -> Amount -> m (PersistentBlockState pv)
28532859
doRewardFoundationAccount pbs reward = do
@@ -2976,6 +2982,7 @@ doModifyAccount pbs aUpd@AccountUpdate{..} = do
29762982
SP7 -> return _auIndex
29772983
SP8 -> return _auIndex
29782984
SP9 -> return _auIndex
2985+
SP10 -> return _auIndex
29792986
!oldRel <- accountNextReleaseTimestamp acc
29802987
!newRel <- accountNextReleaseTimestamp acc'
29812988
return (acctRef :: RSAccountRef pv, oldRel, newRel)
@@ -3679,6 +3686,7 @@ doProcessReleaseSchedule pbs ts = do
36793686
SP7 -> processAccountP5
36803687
SP8 -> processAccountP5
36813688
SP9 -> processAccountP5
3689+
SP10 -> processAccountP5
36823690
(newAccs, newRS) <- foldM processAccount (bspAccounts bsp, remRS) affectedAccounts
36833691
storePBS pbs (bsp{bspAccounts = newAccs, bspReleaseSchedule = newRS})
36843692

@@ -4874,6 +4882,7 @@ migrateBlockPointers migration BlockStatePointers{..} = do
48744882
StateMigrationParametersP6ToP7{} -> RSMNewToNew
48754883
StateMigrationParametersP7ToP8{} -> RSMNewToNew
48764884
StateMigrationParametersP8ToP9{} -> RSMNewToNew
4885+
StateMigrationParametersP9ToP10{} -> RSMNewToNew
48774886
logEvent GlobalState LLTrace "Migrating release schedule"
48784887
newReleaseSchedule <- migrateReleaseSchedule rsMigration bspReleaseSchedule
48794888
pab <- lift . refLoad $ bspBirkParameters ^. birkActiveBakers

concordium-consensus/src/Concordium/GlobalState/Persistent/BlockState/Modules.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ migrateModules migration mods = do
577577
StateMigrationParametersP6ToP7{} -> migrateToP7 @v wasmMod -- always recompile to lower transaction costs.
578578
StateMigrationParametersP7ToP8{} -> return $! moduleVInterface{GSWasm.miModule = PIMVMem artifact}
579579
StateMigrationParametersP8ToP9{} -> return $! moduleVInterface{GSWasm.miModule = PIMVMem artifact}
580+
StateMigrationParametersP9ToP10{} -> return $! moduleVInterface{GSWasm.miModule = PIMVMem artifact}
580581

581582
-- store the module into the new state, and remove it from memory
582583
makeFlushedHashedCachedRef $!

concordium-consensus/src/Concordium/GlobalState/Persistent/BlockState/Updates.hs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ migratePendingUpdates migration PendingUpdates{..} = withCPVConstraints (chainPa
317317
NoParam -> return NoParam
318318
StateMigrationParametersP8ToP9{} -> case pElectionDifficultyQueue of
319319
NoParam -> return NoParam
320+
StateMigrationParametersP9ToP10{} -> case pElectionDifficultyQueue of
321+
NoParam -> return NoParam
320322
newTimeParameters <- case migration of
321323
StateMigrationParametersTrivial -> case pTimeParametersQueue of
322324
NoParam -> return NoParam
@@ -338,6 +340,8 @@ migratePendingUpdates migration PendingUpdates{..} = withCPVConstraints (chainPa
338340
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
339341
StateMigrationParametersP8ToP9{} -> case pTimeParametersQueue of
340342
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
343+
StateMigrationParametersP9ToP10{} -> case pTimeParametersQueue of
344+
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
341345
newCooldownParameters <- case migration of
342346
StateMigrationParametersTrivial -> case pCooldownParametersQueue of
343347
NoParam -> return NoParam
@@ -360,6 +364,8 @@ migratePendingUpdates migration PendingUpdates{..} = withCPVConstraints (chainPa
360364
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
361365
StateMigrationParametersP8ToP9{} -> case pCooldownParametersQueue of
362366
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
367+
StateMigrationParametersP9ToP10{} -> case pCooldownParametersQueue of
368+
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
363369
newTimeoutParameters <- case migration of
364370
StateMigrationParametersTrivial -> case pTimeoutParametersQueue of
365371
NoParam -> return NoParam
@@ -381,6 +387,8 @@ migratePendingUpdates migration PendingUpdates{..} = withCPVConstraints (chainPa
381387
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
382388
StateMigrationParametersP8ToP9{} -> case pTimeoutParametersQueue of
383389
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
390+
StateMigrationParametersP9ToP10{} -> case pTimeoutParametersQueue of
391+
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
384392
newMinBlockTimeQueue <- case migration of
385393
StateMigrationParametersTrivial -> case pMinBlockTimeQueue of
386394
NoParam -> return NoParam
@@ -402,6 +410,8 @@ migratePendingUpdates migration PendingUpdates{..} = withCPVConstraints (chainPa
402410
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
403411
StateMigrationParametersP8ToP9{} -> case pMinBlockTimeQueue of
404412
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
413+
StateMigrationParametersP9ToP10{} -> case pMinBlockTimeQueue of
414+
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
405415
newBlockEnergyLimitQueue <- case migration of
406416
StateMigrationParametersTrivial -> case pBlockEnergyLimitQueue of
407417
NoParam -> return NoParam
@@ -423,6 +433,8 @@ migratePendingUpdates migration PendingUpdates{..} = withCPVConstraints (chainPa
423433
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
424434
StateMigrationParametersP8ToP9{} -> case pBlockEnergyLimitQueue of
425435
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
436+
StateMigrationParametersP9ToP10{} -> case pBlockEnergyLimitQueue of
437+
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
426438
newFinalizationCommitteeParametersQueue <- case migration of
427439
StateMigrationParametersTrivial -> case pFinalizationCommitteeParametersQueue of
428440
NoParam -> return NoParam
@@ -444,6 +456,8 @@ migratePendingUpdates migration PendingUpdates{..} = withCPVConstraints (chainPa
444456
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
445457
StateMigrationParametersP8ToP9{} -> case pFinalizationCommitteeParametersQueue of
446458
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
459+
StateMigrationParametersP9ToP10{} -> case pFinalizationCommitteeParametersQueue of
460+
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
447461
newValidatorScoreParametersQueue <- case migration of
448462
StateMigrationParametersTrivial -> case pValidatorScoreParametersQueue of
449463
NoParam -> return NoParam
@@ -465,6 +479,8 @@ migratePendingUpdates migration PendingUpdates{..} = withCPVConstraints (chainPa
465479
return (SomeParam hbr)
466480
StateMigrationParametersP8ToP9{} -> case pValidatorScoreParametersQueue of
467481
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
482+
StateMigrationParametersP9ToP10{} -> case pValidatorScoreParametersQueue of
483+
SomeParam hbr -> SomeParam <$> migrateHashedBufferedRef (migrateUpdateQueue id) hbr
468484
return $!
469485
PendingUpdates
470486
{ pRootKeysUpdateQueue = newRootKeys,
@@ -812,6 +828,7 @@ migrateUpdates migration Updates{..} = do
812828
StateMigrationParametersP6ToP7 -> CFalse
813829
StateMigrationParametersP7ToP8 _ -> CFalse
814830
StateMigrationParametersP8ToP9 _ -> CTrue minUpdateSequenceNumber
831+
StateMigrationParametersP9ToP10 _ -> CTrue minUpdateSequenceNumber
815832
return
816833
Updates
817834
{ currentKeyCollection = newKeyCollection,

concordium-consensus/src/Concordium/GlobalState/Persistent/Genesis.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module Concordium.GlobalState.Persistent.Genesis (genesisState) where
1212
import qualified Concordium.Genesis.Data as GenesisData
1313
import qualified Concordium.Genesis.Data.BaseV1 as GDBaseV1
1414
import qualified Concordium.Genesis.Data.P1 as P1
15+
import qualified Concordium.Genesis.Data.P10 as P10
1516
import qualified Concordium.Genesis.Data.P2 as P2
1617
import qualified Concordium.Genesis.Data.P3 as P3
1718
import qualified Concordium.Genesis.Data.P4 as P4
@@ -90,6 +91,9 @@ genesisState gd = MTL.runExceptT $ case Types.protocolVersion @pv of
9091
Types.SP9 -> case gd of
9192
GenesisData.GDP9 P9.GDP9Initial{..} ->
9293
buildGenesisBlockState (CGPV1 genesisCore) genesisInitialState
94+
Types.SP10 -> case gd of
95+
GenesisData.GDP10 P10.GDP10Initial{..} ->
96+
buildGenesisBlockState (CGPV1 genesisCore) genesisInitialState
9397

9498
-------- Types -----------
9599

0 commit comments

Comments
 (0)