@@ -73,24 +73,27 @@ func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block
7373 return receipts , nil
7474}
7575
76- func (self * BlockProcessor ) ApplyTransaction (coinbase * state.StateObject , state * state.StateDB , block * types.Block , tx * types.Transaction , usedGas * big.Int , transientProcess bool ) (* types.Receipt , * big.Int , error ) {
76+ func (self * BlockProcessor ) ApplyTransaction (coinbase * state.StateObject , statedb * state.StateDB , block * types.Block , tx * types.Transaction , usedGas * big.Int , transientProcess bool ) (* types.Receipt , * big.Int , error ) {
7777 // If we are mining this block and validating we want to set the logs back to 0
78- state .EmptyLogs ()
78+ statedb .EmptyLogs ()
7979
8080 txGas := new (big.Int ).Set (tx .Gas ())
8181
82- cb := state .GetStateObject (coinbase .Address ())
83- st := NewStateTransition (NewEnv (state , self .bc , tx , block ), tx , cb )
82+ cb := statedb .GetStateObject (coinbase .Address ())
83+ st := NewStateTransition (NewEnv (statedb , self .bc , tx , block ), tx , cb )
8484 _ , err := st .TransitionState ()
85+ if err != nil && (IsNonceErr (err ) || state .IsGasLimitErr (err )) {
86+ return nil , nil , err
87+ }
8588
8689 txGas .Sub (txGas , st .gas )
8790
8891 // Update the state with pending changes
89- state .Update (txGas )
92+ statedb .Update (txGas )
9093
9194 cumulative := new (big.Int ).Set (usedGas .Add (usedGas , txGas ))
92- receipt := types .NewReceipt (state .Root (), cumulative )
93- receipt .SetLogs (state .Logs ())
95+ receipt := types .NewReceipt (statedb .Root (), cumulative )
96+ receipt .SetLogs (statedb .Logs ())
9497 receipt .Bloom = types .CreateBloom (types.Receipts {receipt })
9598 chainlogger .Debugln (receipt )
9699
@@ -99,12 +102,12 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, state
99102 go self .eventMux .Post (TxPostEvent {tx })
100103 }
101104
102- go self .eventMux .Post (state .Logs ())
105+ go self .eventMux .Post (statedb .Logs ())
103106
104107 return receipt , txGas , err
105108}
106109
107- func (self * BlockProcessor ) ApplyTransactions (coinbase * state.StateObject , state * state.StateDB , block * types.Block , txs types.Transactions , transientProcess bool ) (types.Receipts , types.Transactions , types.Transactions , types.Transactions , error ) {
110+ func (self * BlockProcessor ) ApplyTransactions (coinbase * state.StateObject , statedb * state.StateDB , block * types.Block , txs types.Transactions , transientProcess bool ) (types.Receipts , types.Transactions , types.Transactions , types.Transactions , error ) {
108111 var (
109112 receipts types.Receipts
110113 handled , unhandled types.Transactions
@@ -115,12 +118,12 @@ func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, state
115118 )
116119
117120 for _ , tx := range txs {
118- receipt , txGas , err := self .ApplyTransaction (coinbase , state , block , tx , totalUsedGas , transientProcess )
121+ receipt , txGas , err := self .ApplyTransaction (coinbase , statedb , block , tx , totalUsedGas , transientProcess )
119122 if err != nil {
120123 switch {
121124 case IsNonceErr (err ):
122125 return nil , nil , nil , nil , err
123- case IsGasLimitErr (err ):
126+ case state . IsGasLimitErr (err ):
124127 return nil , nil , nil , nil , err
125128 default :
126129 statelogger .Infoln (err )
0 commit comments