mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 07:06:42 +00:00
Added check for circular and out-of-range dependency problem (#841)
* added check for circular and out-of-range dependency problem * addressed comment * addressed comments
This commit is contained in:
parent
adce0e8235
commit
c39c66fb9c
1 changed files with 22 additions and 0 deletions
|
|
@ -290,6 +290,11 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
|
||||||
|
|
||||||
if block.Header().TxDependency != nil {
|
if block.Header().TxDependency != nil {
|
||||||
metadata = true
|
metadata = true
|
||||||
|
|
||||||
|
if !VerifyDeps(deps) {
|
||||||
|
metadata = false
|
||||||
|
deps = GetDeps([][]uint64{})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blockContext := NewEVMBlockContext(header, p.bc, nil)
|
blockContext := NewEVMBlockContext(header, p.bc, nil)
|
||||||
|
|
@ -431,3 +436,20 @@ func GetDeps(txDependency [][]uint64) map[int][]int {
|
||||||
|
|
||||||
return deps
|
return deps
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns true if dependencies are correct
|
||||||
|
func VerifyDeps(deps map[int][]int) bool {
|
||||||
|
// number of transactions in the block
|
||||||
|
n := len(deps)
|
||||||
|
|
||||||
|
// Handle out-of-range and circular dependency problem
|
||||||
|
for tx, val := range deps {
|
||||||
|
for depTx := range val {
|
||||||
|
if depTx >= n || depTx < tx {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue