aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/state_manager.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-29 17:34:40 +0800
committerobscuren <geffobscura@gmail.com>2014-10-29 17:34:40 +0800
commitfb4113dab4df8480c77bdcb707fa6b5408755b79 (patch)
treeb369bb26e7b96826120fb08ff61739326add0e92 /ethchain/state_manager.go
parent665a44646e9453e37c8a73bdd2c94ba7dc1e7c0a (diff)
downloadgo-tangerine-fb4113dab4df8480c77bdcb707fa6b5408755b79.tar
go-tangerine-fb4113dab4df8480c77bdcb707fa6b5408755b79.tar.gz
go-tangerine-fb4113dab4df8480c77bdcb707fa6b5408755b79.tar.bz2
go-tangerine-fb4113dab4df8480c77bdcb707fa6b5408755b79.tar.lz
go-tangerine-fb4113dab4df8480c77bdcb707fa6b5408755b79.tar.xz
go-tangerine-fb4113dab4df8480c77bdcb707fa6b5408755b79.tar.zst
go-tangerine-fb4113dab4df8480c77bdcb707fa6b5408755b79.zip
PoC 7 updates
* Bloom * Block restructure * Receipts
Diffstat (limited to 'ethchain/state_manager.go')
-rw-r--r--ethchain/state_manager.go26
1 files changed, 17 insertions, 9 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go
index dba3ff202..774933e48 100644
--- a/ethchain/state_manager.go
+++ b/ethchain/state_manager.go
@@ -173,8 +173,9 @@ done:
state.Update()
txGas.Sub(txGas, st.gas)
- accumelative := new(big.Int).Set(totalUsedGas.Add(totalUsedGas, txGas))
- receipt := &Receipt{tx, ethutil.CopyBytes(state.Root().([]byte)), accumelative}
+ 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(tx.logs).Bytes(), tx.logs}
if i < len(block.Receipts()) {
original := block.Receipts()[i]
@@ -183,7 +184,7 @@ done:
os.Exit(1)
}
- err := fmt.Errorf("#%d receipt failed (r) %v ~ %x <=> (c) %v ~ %x (%x...)", i+1, original.CumulativeGasUsed, original.PostState[0:4], receipt.CumulativeGasUsed, receipt.PostState[0:4], receipt.Tx.Hash()[0:4])
+ err := fmt.Errorf("#%d receipt failed (r) %v ~ %x <=> (c) %v ~ %x (%x...)", i+1, original.CumulativeGasUsed, original.PostState[0:4], receipt.CumulativeGasUsed, receipt.PostState[0:4], tx.Hash()[0:4])
return nil, nil, nil, nil, err
}
@@ -235,14 +236,19 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
fmt.Printf("## %x %x ##\n", block.Hash(), block.Number)
}
+ txSha := DeriveSha(block.transactions)
+ if bytes.Compare(txSha, block.TxSha) != 0 {
+ return fmt.Errorf("Error validating transaction sha. Received %x, got %x", block.ReceiptSha, txSha)
+ }
+
receipts, err := sm.ApplyDiff(state, parent, block)
if err != nil {
return err
}
- txSha := CreateTxSha(receipts)
- if bytes.Compare(txSha, block.TxSha) != 0 {
- return fmt.Errorf("Error validating tx sha. Received %x, got %x", block.TxSha, txSha)
+ receiptSha := DeriveSha(receipts)
+ if bytes.Compare(receiptSha, block.ReceiptSha) != 0 {
+ return fmt.Errorf("Error validating receipt sha. Received %x, got %x", block.ReceiptSha, receiptSha)
}
// Block validation
@@ -271,13 +277,15 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
// Add the block to the chain
sm.bc.Add(block)
+ // TODO at this point we should also insert LOGS in to a database
+
sm.transState = state.Copy()
// Create a bloom bin for this block
- filter := sm.createBloomFilter(state)
+ //filter := sm.createBloomFilter(state)
// Persist the data
- fk := append([]byte("bloom"), block.Hash()...)
- sm.eth.Db().Put(fk, filter.Bin())
+ //fk := append([]byte("bloom"), block.Hash()...)
+ //sm.eth.Db().Put(fk, filter.Bin())
statelogger.Infof("Imported block #%d (%x...)\n", block.Number, block.Hash()[0:4])
if dontReact == false {