Skip to content

Commit d6e03e1

Browse files
author
colinlyguo
committed
address comments
1 parent 819f4ce commit d6e03e1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

rollup/internal/controller/relayer/l2_relayer_sanity.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,17 @@ func (r *Layer2Relayer) getBatchesFromCalldata(info *CalldataInfo) ([]*dbBatchWi
131131
return nil, nil, fmt.Errorf("failed to get L2 blocks for chunk %d: %w", chunk.Index, err)
132132
}
133133
for _, block := range blockWithL1Messages {
134+
bn := block.Header.Number.Uint64()
135+
seenL2 := false
134136
for _, tx := range block.Transactions {
135137
if tx.Type == types.L1MessageTxType {
136-
l1MessagesWithBlockNumbers[block.Header.Number.Uint64()] = append(l1MessagesWithBlockNumbers[block.Header.Number.Uint64()], tx)
138+
if seenL2 {
139+
// Invariant violated: found an L1 after an L2 in the same block.
140+
return nil, nil, fmt.Errorf("L1 message after L2 tx in block %d", bn)
141+
}
142+
l1MessagesWithBlockNumbers[bn] = append(l1MessagesWithBlockNumbers[bn], tx)
143+
} else {
144+
seenL2 = true
137145
}
138146
}
139147
}

0 commit comments

Comments
 (0)