@@ -168,8 +168,10 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
168168 // above we revert to the snapshot and consume any gas remaining. Additionally
169169 // when we're in homestead this also counts for code storage gas errors.
170170 if err != nil {
171- contract .UseGas (contract .Gas )
172171 evm .StateDB .RevertToSnapshot (snapshot )
172+ if err != errExecutionReverted {
173+ contract .UseGas (contract .Gas )
174+ }
173175 }
174176 return ret , contract .Gas , err
175177}
@@ -207,10 +209,11 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
207209
208210 ret , err = run (evm , snapshot , contract , input )
209211 if err != nil {
210- contract .UseGas (contract .Gas )
211212 evm .StateDB .RevertToSnapshot (snapshot )
213+ if err != errExecutionReverted {
214+ contract .UseGas (contract .Gas )
215+ }
212216 }
213-
214217 return ret , contract .Gas , err
215218}
216219
@@ -239,10 +242,11 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
239242
240243 ret , err = run (evm , snapshot , contract , input )
241244 if err != nil {
242- contract .UseGas (contract .Gas )
243245 evm .StateDB .RevertToSnapshot (snapshot )
246+ if err != errExecutionReverted {
247+ contract .UseGas (contract .Gas )
248+ }
244249 }
245-
246250 return ret , contract .Gas , err
247251}
248252
@@ -281,8 +285,10 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
281285 // when we're in Homestead this also counts for code storage gas errors.
282286 ret , err = run (evm , snapshot , contract , input )
283287 if err != nil {
284- contract .UseGas (contract .Gas )
285288 evm .StateDB .RevertToSnapshot (snapshot )
289+ if err != errExecutionReverted {
290+ contract .UseGas (contract .Gas )
291+ }
286292 }
287293 return ret , contract .Gas , err
288294}
@@ -339,18 +345,12 @@ func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.I
339345 // When an error was returned by the EVM or when setting the creation code
340346 // above we revert to the snapshot and consume any gas remaining. Additionally
341347 // when we're in homestead this also counts for code storage gas errors.
342- if maxCodeSizeExceeded ||
343- (err != nil && (evm .ChainConfig ().IsHomestead (evm .BlockNumber ) || err != ErrCodeStoreOutOfGas )) {
344- contract .UseGas (contract .Gas )
348+ if maxCodeSizeExceeded || (err != nil && (evm .ChainConfig ().IsHomestead (evm .BlockNumber ) || err != ErrCodeStoreOutOfGas )) {
345349 evm .StateDB .RevertToSnapshot (snapshot )
350+ if err != errExecutionReverted {
351+ contract .UseGas (contract .Gas )
352+ }
346353 }
347- // If the vm returned with an error the return value should be set to nil.
348- // This isn't consensus critical but merely to for behaviour reasons such as
349- // tests, RPC calls, etc.
350- if err != nil {
351- ret = nil
352- }
353-
354354 return ret , contractAddr , contract .Gas , err
355355}
356356
0 commit comments