@@ -183,6 +183,7 @@ func (e *epochStartData) CreateEpochStartData() (*block.EpochStart, error) {
183183func (e * epochStartData ) CreateEpochStartShardDataMetablockV3 (metablock data.MetaHeaderHandler ) ([]block.EpochStartShardData , error ) {
184184 log .Debug ("CreateEpochStartShardDataMetablockV3" ,
185185 "metablock epoch" , metablock .GetEpoch (),
186+ "for epoch" , metablock .GetEpoch ()+ 1 ,
186187 "isEpochChangeProposed" , metablock .IsEpochChangeProposed (),
187188 "trigger epoch" , e .epochStartTrigger .Epoch ())
188189
@@ -390,17 +391,34 @@ func (e *epochStartData) getShardDataFromEpochStartData(
390391 return nil , nil , process .ErrGettingShardDataFromEpochStartData
391392}
392393
394+ func (e * epochStartData ) getPrevEpoch () uint32 {
395+ prevEpoch := e .genesisEpoch
396+
397+ epochStartTriggerEpoch := e .epochStartTrigger .Epoch ()
398+
399+ if epochStartTriggerEpoch <= e .genesisEpoch {
400+ return prevEpoch
401+ }
402+
403+ prevEpoch = e .epochStartTrigger .Epoch ()
404+
405+ isAfterSupernova := epochStartTriggerEpoch > e .enableEpochsHandler .GetActivationEpoch (common .SupernovaFlag )
406+ if ! isAfterSupernova {
407+ prevEpoch --
408+ }
409+
410+ return prevEpoch
411+ }
412+
393413func (e * epochStartData ) computePendingMiniBlockList (
394414 startData * block.EpochStart ,
395415 allShardHdrList [][]data.HeaderHandler ,
396416) ([]block.MiniBlockHeader , error ) {
397-
398- prevEpoch := e .genesisEpoch
399- if e .epochStartTrigger .Epoch () > e .genesisEpoch {
400- prevEpoch = e .epochStartTrigger .Epoch () - 1
401- }
417+ prevEpoch := e .getPrevEpoch ()
402418
403419 epochStartIdentifier := core .EpochStartIdentifier (prevEpoch )
420+
421+ // TODO: analyse error handling here
404422 previousEpochStartMeta , _ := process .GetMetaHeaderFromStorage ([]byte (epochStartIdentifier ), e .marshalizer , e .store )
405423
406424 allPending := make ([]block.MiniBlockHeader , 0 )
0 commit comments