@@ -73,24 +73,27 @@ func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block
73
73
return receipts , nil
74
74
}
75
75
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 ) {
77
77
// If we are mining this block and validating we want to set the logs back to 0
78
- state .EmptyLogs ()
78
+ statedb .EmptyLogs ()
79
79
80
80
txGas := new (big.Int ).Set (tx .Gas ())
81
81
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 )
84
84
_ , err := st .TransitionState ()
85
+ if err != nil && (IsNonceErr (err ) || state .IsGasLimitErr (err )) {
86
+ return nil , nil , err
87
+ }
85
88
86
89
txGas .Sub (txGas , st .gas )
87
90
88
91
// Update the state with pending changes
89
- state .Update (txGas )
92
+ statedb .Update (txGas )
90
93
91
94
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 ())
94
97
receipt .Bloom = types .CreateBloom (types.Receipts {receipt })
95
98
chainlogger .Debugln (receipt )
96
99
@@ -99,12 +102,12 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, state
99
102
go self .eventMux .Post (TxPostEvent {tx })
100
103
}
101
104
102
- go self .eventMux .Post (state .Logs ())
105
+ go self .eventMux .Post (statedb .Logs ())
103
106
104
107
return receipt , txGas , err
105
108
}
106
109
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 ) {
108
111
var (
109
112
receipts types.Receipts
110
113
handled , unhandled types.Transactions
@@ -115,12 +118,12 @@ func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, state
115
118
)
116
119
117
120
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 )
119
122
if err != nil {
120
123
switch {
121
124
case IsNonceErr (err ):
122
125
return nil , nil , nil , nil , err
123
- case IsGasLimitErr (err ):
126
+ case state . IsGasLimitErr (err ):
124
127
return nil , nil , nil , nil , err
125
128
default :
126
129
statelogger .Infoln (err )
0 commit comments