Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEVM-fix: check in ValidatePlainTxDAG #195

Merged
Merged
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
16 changes: 9 additions & 7 deletions core/types/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,23 @@ func ValidatePlainTxDAG(d TxDAG, txCnt int) error {
return fmt.Errorf("PlainTxDAG contains wrong txs count, expect: %v, actual: %v", txCnt, d.TxCount())
}
for i := 0; i < txCnt; i++ {
dep := d.TxDep(i)
if dep == nil {
dp := d.TxDep(i)
if dp == nil {
return fmt.Errorf("PlainTxDAG contains nil txdep, tx: %v", i)
}
for j, tx := range dep.TxIndexes {
if dp.Flags != nil && *dp.Flags & ^TxDepFlagMask > 0 {
return fmt.Errorf("PlainTxDAG contains unknown flags, flags: %v", *dp.Flags)
}
dep := TxDependency(d, i)
for j, tx := range dep {
if tx >= uint64(i) || tx >= uint64(txCnt) {
return fmt.Errorf("PlainTxDAG contains the exceed range dependency, tx: %v", i)
}
if j > 0 && dep.TxIndexes[j] <= dep.TxIndexes[j-1] {
if j > 0 && dep[j] <= dep[j-1] {
return fmt.Errorf("PlainTxDAG contains unordered dependency, tx: %v", i)
}
}
if dep.Flags != nil && *dep.Flags & ^TxDepFlagMask > 0 {
return fmt.Errorf("PlainTxDAG contains unknown flags, flags: %v", *dep.Flags)
}

}
return nil
}
Expand Down
Loading