Skip to content

Commit

Permalink
- fix validation of grace period for transition to new epoch in shard.
Browse files Browse the repository at this point in the history
- update probable highest nonce on bootstrap
  • Loading branch information
AdoAdoAdo committed Feb 11, 2025
1 parent dcac9c1 commit 81f985c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion process/block/shardblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,15 @@ func (sp *shardProcessor) checkEpochCorrectness(
process.ErrEpochDoesNotMatch, header.GetEpoch(), sp.epochStartTrigger.MetaEpoch())
}

epochChangeConfirmed := sp.epochStartTrigger.EpochStartRound() < sp.epochStartTrigger.EpochFinalityAttestingRound()
if sp.enableEpochsHandler.IsFlagEnabledInEpoch(common.EquivalentMessagesFlag, header.GetEpoch()) {
epochChangeConfirmed = sp.epochStartTrigger.EpochStartRound() <= sp.epochStartTrigger.EpochFinalityAttestingRound()
}

isOldEpochAndShouldBeNew := sp.epochStartTrigger.IsEpochStart() &&
header.GetRound() > sp.epochStartTrigger.EpochFinalityAttestingRound()+process.EpochChangeGracePeriod &&
header.GetEpoch() < sp.epochStartTrigger.MetaEpoch() &&
sp.epochStartTrigger.EpochStartRound() < sp.epochStartTrigger.EpochFinalityAttestingRound()
epochChangeConfirmed
if isOldEpochAndShouldBeNew {
return fmt.Errorf("%w proposed header with epoch %d should be in epoch %d",
process.ErrEpochDoesNotMatch, header.GetEpoch(), sp.epochStartTrigger.MetaEpoch())
Expand Down
1 change: 1 addition & 0 deletions process/sync/storageBootstrap/baseStorageBootstrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ func (st *storageBootstrapper) applyBlock(headerHash []byte, header data.HeaderH
st.forkDetector.AddCheckpoint(header.GetNonce(), header.GetRound(), headerHash)
if header.GetShardID() == core.MetachainShardId || !check.IfNilReflect(header.GetPreviousProof()) {
st.forkDetector.SetFinalToLastCheckpoint()
st.forkDetector.ResetProbableHighestNonce()
}
return nil
}
Expand Down

0 comments on commit 81f985c

Please sign in to comment.