aboutsummaryrefslogtreecommitdiffstats
path: root/core/blockchain.go
diff options
context:
space:
mode:
authorSonic <sonic@dexon.org>2019-01-18 11:55:51 +0800
committerWei-Ning Huang <w@dexon.org>2019-03-12 12:19:09 +0800
commit0826bd64ff765250ff5a4b2448eadc98d3285c03 (patch)
treef818191c9e8e6441c43bf47fdb6b224988d60ad6 /core/blockchain.go
parentcd0d64a6deba5e1fef2b71e341afa67e09c1b639 (diff)
downloaddexon-0826bd64ff765250ff5a4b2448eadc98d3285c03.tar
dexon-0826bd64ff765250ff5a4b2448eadc98d3285c03.tar.gz
dexon-0826bd64ff765250ff5a4b2448eadc98d3285c03.tar.bz2
dexon-0826bd64ff765250ff5a4b2448eadc98d3285c03.tar.lz
dexon-0826bd64ff765250ff5a4b2448eadc98d3285c03.tar.xz
dexon-0826bd64ff765250ff5a4b2448eadc98d3285c03.tar.zst
dexon-0826bd64ff765250ff5a4b2448eadc98d3285c03.zip
core, dex: use block hash as witness data (#160)
Using only state root and receipt root as witness data can not protect other fields in block header, ex: bloom, difficulty, gas limit, gas used... So that everyone can manipulate these fields to create as many valid blocks at the same height as he want. Although this will not effect the state, one can spam us when syncing. Using block hash as witness data can solve this.
Diffstat (limited to 'core/blockchain.go')
-rw-r--r--core/blockchain.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index 80d11becd..2567505b8 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -1834,13 +1834,13 @@ func (bc *BlockChain) processBlock(
)
bstart := time.Now()
- var witnessData types.WitnessData
- if err := rlp.Decode(bytes.NewReader(witness.Data), &witnessData); err != nil {
+ var witnessBlockHash common.Hash
+ if err := rlp.Decode(bytes.NewReader(witness.Data), &witnessBlockHash); err != nil {
log.Error("Witness rlp decode failed", "error", err)
return nil, nil, nil, fmt.Errorf("rlp decode fail: %v", err)
}
- if err := bc.Validator().ValidateWitnessData(witness.Height, witnessData); err != nil {
+ if err := bc.Validator().ValidateWitnessData(witness.Height, witnessBlockHash); err != nil {
return nil, nil, nil, fmt.Errorf("validate witness data error: %v", err)
}