Commit f4b717cb authored by obscuren's avatar obscuren

Bloom validation

parent f59a3b67
...@@ -3,6 +3,7 @@ package chain ...@@ -3,6 +3,7 @@ package chain
import ( import (
"bytes" "bytes"
"container/list" "container/list"
"errors"
"fmt" "fmt"
"math/big" "math/big"
"os" "os"
...@@ -168,7 +169,6 @@ done: ...@@ -168,7 +169,6 @@ done:
erroneous = append(erroneous, tx) erroneous = append(erroneous, tx)
err = nil err = nil
continue continue
//return nil, nil, nil, err
} }
} }
...@@ -177,7 +177,6 @@ done: ...@@ -177,7 +177,6 @@ done:
txGas.Sub(txGas, st.gas) txGas.Sub(txGas, st.gas)
cumulative := new(big.Int).Set(totalUsedGas.Add(totalUsedGas, txGas)) cumulative := new(big.Int).Set(totalUsedGas.Add(totalUsedGas, txGas))
//receipt := &Receipt{tx, ethutil.CopyBytes(state.Root().([]byte)), accumelative}
receipt := &Receipt{ethutil.CopyBytes(state.Root().([]byte)), cumulative, LogsBloom(state.Logs()).Bytes(), state.Logs()} receipt := &Receipt{ethutil.CopyBytes(state.Root().([]byte)), cumulative, LogsBloom(state.Logs()).Bytes(), state.Logs()}
if i < len(block.Receipts()) { if i < len(block.Receipts()) {
...@@ -254,8 +253,6 @@ func (sm *BlockManager) Process(block *Block) (err error) { ...@@ -254,8 +253,6 @@ func (sm *BlockManager) Process(block *Block) (err error) {
return fmt.Errorf("Error validating receipt sha. Received %x, got %x", block.ReceiptSha, receiptSha) return fmt.Errorf("Error validating receipt sha. Received %x, got %x", block.ReceiptSha, receiptSha)
} }
// TODO validate bloom
// Block validation // Block validation
if err = sm.ValidateBlock(block); err != nil { if err = sm.ValidateBlock(block); err != nil {
statelogger.Errorln("Error validating block:", err) statelogger.Errorln("Error validating block:", err)
...@@ -267,6 +264,10 @@ func (sm *BlockManager) Process(block *Block) (err error) { ...@@ -267,6 +264,10 @@ func (sm *BlockManager) Process(block *Block) (err error) {
return err return err
} }
if bytes.Compare(CreateBloom(block), block.LogsBloom) != 0 {
return errors.New("Unable to replicate block's bloom")
}
state.Update() state.Update()
if !block.State().Cmp(state) { if !block.State().Cmp(state) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment