core vm: Revert calls when balance > 128bits

This commit is contained in:
Guillaume Ballet 2018-11-24 15:35:19 +01:00
parent ccec71b3ff
commit ac0f688edd
2 changed files with 7 additions and 2 deletions

View file

@ -109,7 +109,6 @@ func (in *InterpreterEWASM) Run(contract *Contract, input []byte, ro bool) ([]by
in.contract = contract
in.contract.Input = input
initialGas := contract.Gas
module, err := wasm.ReadModule(bytes.NewReader(contract.Code), WrappedModuleResolver(in))
if err != nil {
@ -131,7 +130,6 @@ func (in *InterpreterEWASM) Run(contract *Contract, input []byte, ro bool) ([]by
return nil, err
}
// Check input and output types
sig := module.FunctionIndexSpace[mainIndex].Sig
if len(sig.ParamTypes) == 0 && len(sig.ReturnTypes) == 0 {

View file

@ -439,6 +439,13 @@ func call(p *exec.Process, in *InterpreterEWASM, gas int64, addressOffset int32,
return ErrEEICallFailure
}
// Fail if the account's balance is greater than 128bits as discussed
// in https://github.com/ewasm/hera/issues/456
if in.StateDB.GetBalance(contract.Address()).Cmp(check128bits) > 0 {
in.gasAccounting(contract.Gas)
return ErrEEICallRevert
}
if in.staticMode == true && value.Cmp(big.NewInt(0)) != 0 {
in.gasAccounting(in.contract.Gas)
return ErrEEICallFailure