mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
core/vm: set revert flag in contract when state revert happen.
This commit is contained in:
parent
19c8193876
commit
3b20bbfbbd
1 changed files with 11 additions and 4 deletions
|
|
@ -163,7 +163,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
|
||||||
// when we're in homestead this also counts for code storage gas errors.
|
// when we're in homestead this also counts for code storage gas errors.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
contract.UseGas(contract.Gas)
|
contract.UseGas(contract.Gas)
|
||||||
evm.StateDB.RevertToSnapshot(snapshot)
|
evm.Revert(snapshot, contract)
|
||||||
}
|
}
|
||||||
return ret, contract.Gas, err
|
return ret, contract.Gas, err
|
||||||
}
|
}
|
||||||
|
|
@ -200,7 +200,7 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
|
||||||
ret, err = run(evm, snapshot, contract, input)
|
ret, err = run(evm, snapshot, contract, input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
contract.UseGas(contract.Gas)
|
contract.UseGas(contract.Gas)
|
||||||
evm.StateDB.RevertToSnapshot(snapshot)
|
evm.Revert(snapshot, contract)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret, contract.Gas, err
|
return ret, contract.Gas, err
|
||||||
|
|
@ -234,7 +234,7 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
|
||||||
ret, err = run(evm, snapshot, contract, input)
|
ret, err = run(evm, snapshot, contract, input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
contract.UseGas(contract.Gas)
|
contract.UseGas(contract.Gas)
|
||||||
evm.StateDB.RevertToSnapshot(snapshot)
|
evm.Revert(snapshot, contract)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret, contract.Gas, err
|
return ret, contract.Gas, err
|
||||||
|
|
@ -295,7 +295,7 @@ func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.I
|
||||||
if maxCodeSizeExceeded ||
|
if maxCodeSizeExceeded ||
|
||||||
(err != nil && (evm.ChainConfig().IsHomestead(evm.BlockNumber) || err != ErrCodeStoreOutOfGas)) {
|
(err != nil && (evm.ChainConfig().IsHomestead(evm.BlockNumber) || err != ErrCodeStoreOutOfGas)) {
|
||||||
contract.UseGas(contract.Gas)
|
contract.UseGas(contract.Gas)
|
||||||
evm.StateDB.RevertToSnapshot(snapshot)
|
evm.Revert(snapshot, contract)
|
||||||
}
|
}
|
||||||
// If the vm returned with an error the return value should be set to nil.
|
// If the vm returned with an error the return value should be set to nil.
|
||||||
// This isn't consensus critical but merely to for behaviour reasons such as
|
// This isn't consensus critical but merely to for behaviour reasons such as
|
||||||
|
|
@ -312,3 +312,10 @@ func (evm *EVM) ChainConfig() *params.ChainConfig { return evm.chainConfig }
|
||||||
|
|
||||||
// Interpreter returns the EVM interpreter
|
// Interpreter returns the EVM interpreter
|
||||||
func (evm *EVM) Interpreter() *Interpreter { return evm.interpreter }
|
func (evm *EVM) Interpreter() *Interpreter { return evm.interpreter }
|
||||||
|
|
||||||
|
// Revert revert all state changes made since the given revision.
|
||||||
|
// set `reverted` flag recursively.
|
||||||
|
func (evm *EVM) Revert(snapshot int, contract *Contract) {
|
||||||
|
evm.StateDB.RevertToSnapshot(snapshot)
|
||||||
|
contract.MarkReverted()
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue