@@ -27,6 +27,7 @@ import (
2727 "github.com/ethereum/go-ethereum/consensus/istanbul"
2828 istanbulCore "github.com/ethereum/go-ethereum/consensus/istanbul/core"
2929 "github.com/ethereum/go-ethereum/consensus/istanbul/validator"
30+ "github.com/ethereum/go-ethereum/core"
3031 "github.com/ethereum/go-ethereum/core/types"
3132 "github.com/ethereum/go-ethereum/crypto"
3233 "github.com/ethereum/go-ethereum/ethdb"
@@ -76,6 +77,7 @@ type backend struct {
7677 db ethdb.Database
7778 chain consensus.ChainReader
7879 currentBlock func () * types.Block
80+ hasBadBlock func (hash common.Hash ) bool
7981
8082 // the channels for istanbul engine notifications
8183 commitCh chan * types.Block
@@ -208,6 +210,22 @@ func (sb *backend) Verify(proposal istanbul.Proposal) (time.Duration, error) {
208210 sb .logger .Error ("Invalid proposal, %v" , proposal )
209211 return 0 , errInvalidProposal
210212 }
213+
214+ // check bad block
215+ if sb .HasBadProposal (block .Hash ()) {
216+ return 0 , core .ErrBlacklistedHash
217+ }
218+
219+ // check block body
220+ txnHash := types .DeriveSha (block .Transactions ())
221+ uncleHash := types .CalcUncleHash (block .Uncles ())
222+ if txnHash != block .Header ().TxHash {
223+ return 0 , errMismatchTxhashes
224+ }
225+ if uncleHash != nilUncleHash {
226+ return 0 , errInvalidUncleHash
227+ }
228+
211229 // verify the header of proposed block
212230 err := sb .VerifyHeader (sb .chain , block .Header (), false )
213231 // ignore errEmptyCommittedSeals error because we don't have the committed seals yet
@@ -285,3 +303,10 @@ func (sb *backend) LastProposal() (istanbul.Proposal, common.Address) {
285303 // Return header only block here since we don't need block body
286304 return block , proposer
287305}
306+
307+ func (sb * backend ) HasBadProposal (hash common.Hash ) bool {
308+ if sb .hasBadBlock == nil {
309+ return false
310+ }
311+ return sb .hasBadBlock (hash )
312+ }
0 commit comments