Skip to content

Commit 8ab2428

Browse files
authored
Transition should only move away from qbft if explicitly set to ibft (#1463)
1 parent 72cd58f commit 8ab2428

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

consensus/istanbul/config.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,17 @@ func (c *Config) IsQBFTConsensusAt(blockNumber *big.Int) bool {
165165
return true
166166
}
167167
}
168-
169168
result := false
170-
c.getTransitionValue(blockNumber, func(transition params.Transition) {
171-
result = strings.EqualFold(transition.Algorithm, params.QBFT)
172-
})
169+
if c != nil && blockNumber != nil && c.Transitions != nil {
170+
for i := 0; i < len(c.Transitions) && c.Transitions[i].Block.Cmp(blockNumber) <= 0; i++ {
171+
if strings.EqualFold(c.Transitions[i].Algorithm, params.QBFT) && len(c.Transitions[i].Algorithm) > 0 {
172+
result = true
173+
}
174+
if strings.EqualFold(c.Transitions[i].Algorithm, params.IBFT) {
175+
result = false
176+
}
177+
}
178+
}
173179

174180
return result
175181
}

params/config_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ func TestCheckTransitionsData(t *testing.T) {
336336
tranI10 := Transition{big.NewInt(10), IBFT, 30000, 5, 5, 10, 50, common.Address{}, "", nil, nil, nil, nil, 0, nil, 0}
337337
tranQ8 := Transition{big.NewInt(8), QBFT, 30000, 5, 10, 10, 50, common.Address{}, "", nil, nil, nil, nil, 0, nil, 0}
338338

339-
340339
ibftTransitionsConfig = append(ibftTransitionsConfig, tranI0, tranI10)
341340
qbftTransitionsConfig = append(qbftTransitionsConfig, tranQ5, tranQ8)
342341

0 commit comments

Comments
 (0)