Skip to content

Commit 22e7ffa

Browse files
Check for BSC block header mismatch
1 parent 915f94a commit 22e7ffa

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmd/btpsimple/module/bsc/receiver.go

+8
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@
1717
package bsc
1818

1919
import (
20+
"bytes"
2021
"encoding/json"
22+
"fmt"
23+
"github.com/ethereum/go-ethereum/crypto"
2124
"github.com/icon-project/btp/cmd/btpsimple/module"
2225
"github.com/icon-project/btp/cmd/btpsimple/module/bsc/binding"
2326
"github.com/icon-project/btp/common/codec"
27+
2428
"github.com/icon-project/btp/common/log"
2529
"math/big"
2630
)
@@ -55,6 +59,10 @@ func (r *receiver) newBlockUpdate(v *BlockNotification) (*module.BlockUpdate, er
5559
return nil, err
5660
}
5761

62+
if !bytes.Equal(v.Header.Hash().Bytes(), crypto.Keccak256(bu.Header)) {
63+
return nil, fmt.Errorf("mismatch block hash with BlockNotification")
64+
}
65+
5866
/*proof, err := r.c.GetProof(v.Height, HexToAddress(r.src.ContractAddress()))
5967
if err != nil {
6068
return nil, err

0 commit comments

Comments
 (0)