Skip to content
Draft
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
26 changes: 23 additions & 3 deletions process/block/metablock.go
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,25 @@ func (mp *metaProcessor) requestShardHeadersIfNeeded(
}
}

func (mp *metaProcessor) revertEpochStartTrigger(
header data.HeaderHandler,
) {
metaHeader, ok := header.(data.MetaHeaderHandler)
if !ok {
log.Warn("revertEpochStartTrigger: failed to revert", "error", process.ErrWrongTypeAssertion)
return
}

if metaHeader.IsStartOfEpochBlock() {
log.LogIfError(mp.epochStartTrigger.RevertStateToBlock(metaHeader))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calling RevertStateToBlock might not fully revert SetProcessed, tbd

mp.epochStartTrigger.SetEpochChangeProposed(true)
}

if metaHeader.IsEpochChangeProposed() {
mp.epochStartTrigger.SetEpochChangeProposed(false)
}
}

// CommitBlock commits the block in the blockchain if everything was checked successfully
func (mp *metaProcessor) CommitBlock(
headerHandler data.HeaderHandler,
Expand Down Expand Up @@ -1286,6 +1305,8 @@ func (mp *metaProcessor) CommitBlock(
mp.RevertHeaderV3OnCommit(headerHandler)
_ = mp.blockChain.SetCurrentBlockHeader(prevBlockHeader)
mp.blockChain.SetCurrentBlockHeaderHash(prevBlockHeaderHash)

mp.revertEpochStartTrigger(headerHandler)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the RevertStateToBlock which is called inside revertEpochStartTrigger was supposed to be called with the previous header not the header being reverted.
Now we do need the current header as well (for the new flag) but I don't think the new method was fully adapted.

}
}()
}
Expand Down Expand Up @@ -1480,9 +1501,6 @@ func (mp *metaProcessor) CommitBlock(
highestFinalBlockNonce: highestFinalBlockNonce,
}

// TODO adjust this method if needed for Supernova
mp.prepareDataForBootStorer(args)

mp.blockSizeThrottler.Succeed(header.GetRound())

mp.displayPoolsInfo()
Expand All @@ -1492,6 +1510,8 @@ func (mp *metaProcessor) CommitBlock(
return err
}

mp.prepareDataForBootStorer(args)

errNotCritical = mp.removeTxsFromPools(headerHash, header, body)
if errNotCritical != nil {
log.Debug("removeTxsFromPools", "error", errNotCritical.Error())
Expand Down
9 changes: 6 additions & 3 deletions process/block/shardblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,10 @@ func (sp *shardProcessor) CommitBlock(
sp.RevertHeaderV3OnCommit(headerHandler)
_ = sp.blockChain.SetCurrentBlockHeader(prevBlockHeader)
sp.blockChain.SetCurrentBlockHeaderHash(prevBlockHeaderHash)

if headerHandler.IsStartOfEpochBlock() {
log.LogIfError(sp.epochStartTrigger.RevertStateToBlock(headerHandler))
}
}
}()
}
Expand Down Expand Up @@ -1162,9 +1166,6 @@ func (sp *shardProcessor) CommitBlock(
epochStartTriggerConfigKey: epochStartKey,
}

// TODO adjust this method if needed for Supernova
sp.prepareDataForBootStorer(args)

// write data to log
go func() {
sp.txCounter.headerExecuted(header)
Expand All @@ -1188,6 +1189,8 @@ func (sp *shardProcessor) CommitBlock(
return err
}

sp.prepareDataForBootStorer(args)

errNotCritical = sp.removeTxsFromPools(headerHash, header, body)
if errNotCritical != nil {
log.Debug("removeTxsFromPools", "error", errNotCritical.Error())
Expand Down
Loading