diff options
author | zelig <viktor.tron@gmail.com> | 2014-07-21 20:26:29 +0800 |
---|---|---|
committer | zelig <viktor.tron@gmail.com> | 2014-07-21 20:26:29 +0800 |
commit | 1e4af85a380977233a3bceaf5e2a020a281aa19a (patch) | |
tree | acf6f1506952e9edc400d3b450d153db90ce536e /ethchain/state_manager.go | |
parent | 017d36e6b2e127084448dfb38bd1b8de7424e1c9 (diff) | |
parent | 2762ec22d0693b406ead2f0c07b62e9b66d395e4 (diff) | |
download | dexon-1e4af85a380977233a3bceaf5e2a020a281aa19a.tar dexon-1e4af85a380977233a3bceaf5e2a020a281aa19a.tar.gz dexon-1e4af85a380977233a3bceaf5e2a020a281aa19a.tar.bz2 dexon-1e4af85a380977233a3bceaf5e2a020a281aa19a.tar.lz dexon-1e4af85a380977233a3bceaf5e2a020a281aa19a.tar.xz dexon-1e4af85a380977233a3bceaf5e2a020a281aa19a.tar.zst dexon-1e4af85a380977233a3bceaf5e2a020a281aa19a.zip |
merge upstream
Diffstat (limited to 'ethchain/state_manager.go')
-rw-r--r-- | ethchain/state_manager.go | 58 |
1 files changed, 22 insertions, 36 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go index 3eafd2d6e..6bd3edd0d 100644 --- a/ethchain/state_manager.go +++ b/ethchain/state_manager.go @@ -7,7 +7,6 @@ import ( "github.com/ethereum/eth-go/ethcrypto" "github.com/ethereum/eth-go/ethlog" "github.com/ethereum/eth-go/ethreact" - "github.com/ethereum/eth-go/ethtrie" "github.com/ethereum/eth-go/ethutil" "github.com/ethereum/eth-go/ethwire" "math/big" @@ -121,7 +120,10 @@ func (self *StateManager) ProcessTransactions(coinbase *StateObject, state *Stat done: for i, tx := range txs { txGas := new(big.Int).Set(tx.Gas) - st := NewStateTransition(coinbase, tx, state, block) + + cb := state.GetStateObject(coinbase.Address()) + st := NewStateTransition(cb, tx, state, block) + //fmt.Printf("#%d\n", i+1) err = st.TransitionState() if err != nil { switch { @@ -149,10 +151,17 @@ done: accumelative := new(big.Int).Set(totalUsedGas.Add(totalUsedGas, txGas)) receipt := &Receipt{tx, ethutil.CopyBytes(state.Root().([]byte)), accumelative} + if i < len(block.Receipts()) { + original := block.Receipts()[i] + if !original.Cmp(receipt) { + return nil, nil, nil, fmt.Errorf("err diff #%d (r) %v ~ %x <=> (c) %v ~ %x (%x)\n", i+1, original.CumulativeGasUsed, original.PostState[0:4], receipt.CumulativeGasUsed, receipt.PostState[0:4], receipt.Tx.Hash()) + } + } + receipts = append(receipts, receipt) handled = append(handled, tx) - if ethutil.Config.Diff { + if ethutil.Config.Diff && ethutil.Config.DiffType == "all" { state.CreateOutputForDiff() } } @@ -188,36 +197,11 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) { // before that. defer state.Reset() - if ethutil.Config.Diff { - fmt.Printf("## 0x%x 0x%x ##\n", block.Hash(), block.Number) + if ethutil.Config.Diff && ethutil.Config.DiffType == "all" { + fmt.Printf("## %x %x ##\n", block.Hash(), block.Number) } - receipts, err := sm.ApplyDiff(state, parent, block) - defer func() { - if err != nil { - if len(receipts) == len(block.Receipts()) { - for i, receipt := range block.Receipts() { - statelogger.Infof("diff (r) %v ~ %x <=> (c) %v ~ %x (%x)\n", receipt.CumulativeGasUsed, receipt.PostState[0:4], receipts[i].CumulativeGasUsed, receipts[i].PostState[0:4], receipt.Tx.Hash()) - } - } else { - statelogger.Warnln("Unable to print receipt diff. Length didn't match", len(receipts), "for", len(block.Receipts())) - } - } else { - /* - for i, receipt := range receipts { - gu := new(big.Int) - if i != 0 { - gu.Sub(receipt.CumulativeGasUsed, receipts[i-1].CumulativeGasUsed) - } else { - gu.Set(receipt.CumulativeGasUsed) - } - - statelogger.Infof("[r] %v ~ %x (%x)\n", gu, receipt.PostState[0:4], receipt.Tx.Hash()) - } - */ - } - }() - + _, err = sm.ApplyDiff(state, parent, block) if err != nil { return err } @@ -235,12 +219,14 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) { return err } - if ethutil.Config.Paranoia { - valid, _ := ethtrie.ParanoiaCheck(state.trie) - if !valid { - err = fmt.Errorf("PARANOIA: World state trie corruption") + /* + if ethutil.Config.Paranoia { + valid, _ := ethtrie.ParanoiaCheck(state.trie) + if !valid { + err = fmt.Errorf("PARANOIA: World state trie corruption") + } } - } + */ if !block.State().Cmp(state) { |