Skip to content

Commit

Permalink
fix V-DOGE-VUL-013 (#51)
Browse files Browse the repository at this point in the history
* Add Extract unit test case

* ibft verify header with validator list
  • Loading branch information
DarianShawn authored May 18, 2022
1 parent 75b31a2 commit 0b6e7bf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions consensus/ibft/extra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ func TestExtraEncoding(t *testing.T) {
},
},
},
{
data: &IstanbulExtra{
Validators: []types.Address{},
Seal: nil,
CommittedSeal: [][]byte{},
},
},
}

for _, c := range cases {
Expand Down
7 changes: 6 additions & 1 deletion consensus/ibft/ibft.go
Original file line number Diff line number Diff line change
Expand Up @@ -1248,9 +1248,14 @@ func (i *Ibft) isSealing() bool {
// verifyHeaderImpl implements the actual header verification logic
func (i *Ibft) verifyHeaderImpl(snap *Snapshot, parent, header *types.Header) error {
// ensure the extra data is correctly formatted
if _, err := getIbftExtra(header); err != nil {
extract, err := getIbftExtra(header)
if err != nil {
return err
}
// ensure validatorset exists in extra data
if len(extract.Validators) == 0 {
return fmt.Errorf("empty extract validatorset")
}

if hookErr := i.runHook(VerifyHeadersHook, header.Number, header.Nonce); hookErr != nil {
return hookErr
Expand Down

0 comments on commit 0b6e7bf

Please sign in to comment.