There is a strange behaviour on user wallet balances when performing a contract call (that is supposed to have no cost). Balance is right (expected value) until a free call is requested to a contract. By debugging wallet balances it is found that wallet balances always turn into maximum value at this very moment.
Ethereum code has a suspicious line where this strange behaviuor seems to come from:
eth\api_backend.go(135):
state.SetBalance(msg.From(), math.MaxBig256)
It belongs to GetEVM() function:
func (b *EthAPIBackend) GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, header *types.Header) (*vm.EVM, func() error, error) {
======> state.SetBalance(msg.From(), math.MaxBig256)
vmError := func() error { return nil }
context := core.NewEVMContext(msg, header, b.eth.BlockChain(), nil)
return vm.NewEVM(context, state, b.eth.blockchain.Config(), *b.eth.blockchain.GetVMConfig()), vmError, nil
}
Is it there any explanation for this balance setting? Is it part of the protocol? Any hint? Thx a lot!
I read at Why does function GetEVM set the balance of from address to MaxBig256?
that this is a temporary balance setting, but I still don't get the logic behind this weird behaviour. It seems to me a messy code to avoid a lack of funds problem when calling a contract, right?