-
Notifications
You must be signed in to change notification settings - Fork 203
Open
Description
Currently there is no check within the storage/store/events.go implementation to ensure that events passed to BatchStore are sorted by transaction index/event index and form a continuous sequence. Add this sanity check and return an error if they do not match
flow-go/storage/store/events.go
Lines 58 to 66 in 1d2ab50
| combinedEvents := make([]flow.Event, sliceSize) | |
| eventIndex := 0 | |
| for _, txEvents := range blockEvents { | |
| for _, event := range txEvents { | |
| combinedEvents[eventIndex] = event | |
| eventIndex++ | |
| } | |
| } |
the logic would be something like
combinedEvents := make([]flow.Event, sliceSize)
globalIndex := 0
eventIndex := uint32(0)
txIndex := uint32(0)
for _, txEvents := range blockEvents {
for _, event := range txEvents {
switch event.TransactionIndex {
case txIndex:
if event.EventIndex != eventIndex {
return fmt.Errorf("event index mismatch in transaction %d: expected %d, got %d", txIndex, eventIndex, event.EventIndex)
}
eventIndex++
case txIndex + 1:
txIndex = event.TransactionIndex
eventIndex = 0
default:
return fmt.Errorf("transaction index mismatch: expected %d, got %d", txIndex, event.TransactionIndex)
}
combinedEvents[globalIndex] = event
globalIndex++
}
}Along with this change, we will need to check the data from the current and past sporks to see if this issue exists to avoid causing an execution halt. We should be able to iterate execution data for each block and inspect the events since execution data is produced in the same order as execution.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels