diff options
author | Sonic <sonic@dexon.org> | 2019-01-18 11:55:51 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:56 +0800 |
commit | 88b3ad43fb7f7d69672a9ce42992b01e17ffbb5f (patch) | |
tree | 092628d1c460a676dd234f4a3fb54185a611405f /dex/app_test.go | |
parent | 4848d54d3a497990030831cb10ea69274ddbd2f2 (diff) | |
download | dexon-88b3ad43fb7f7d69672a9ce42992b01e17ffbb5f.tar dexon-88b3ad43fb7f7d69672a9ce42992b01e17ffbb5f.tar.gz dexon-88b3ad43fb7f7d69672a9ce42992b01e17ffbb5f.tar.bz2 dexon-88b3ad43fb7f7d69672a9ce42992b01e17ffbb5f.tar.lz dexon-88b3ad43fb7f7d69672a9ce42992b01e17ffbb5f.tar.xz dexon-88b3ad43fb7f7d69672a9ce42992b01e17ffbb5f.tar.zst dexon-88b3ad43fb7f7d69672a9ce42992b01e17ffbb5f.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 'dex/app_test.go')
-rw-r--r-- | dex/app_test.go | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/dex/app_test.go b/dex/app_test.go index 7d665a0af..34b31d3d3 100644 --- a/dex/app_test.go +++ b/dex/app_test.go @@ -119,18 +119,14 @@ func TestPrepareWitness(t *testing.T) { t.Fatalf("unexpeted witness height %v", witness.Height) } - var witnessData types.WitnessData - err = rlp.DecodeBytes(witness.Data, &witnessData) + var witnessBlockHash common.Hash + err = rlp.DecodeBytes(witness.Data, &witnessBlockHash) if err != nil { t.Fatalf("rlp decode error: %v", err) } - if witnessData.Root != currentBlock.Root() { - t.Fatalf("expect root %v but %v", currentBlock.Root(), witnessData.Root) - } - - if witnessData.ReceiptHash != currentBlock.ReceiptHash() { - t.Fatalf("expect receipt hash %v but %v", currentBlock.ReceiptHash(), witnessData.ReceiptHash) + if witnessBlockHash != currentBlock.Hash() { + t.Fatalf("expect root %v but %v", currentBlock.Hash(), witnessBlockHash) } if _, err := dex.app.PrepareWitness(999); err == nil { |