Skip to content

WTF#9

Closed
ben-chain wants to merge 2 commits intoNomicFoundation:masterfrom
ben-chain:feat/eth_call_value_wtf
Closed

WTF#9
ben-chain wants to merge 2 commits intoNomicFoundation:masterfrom
ben-chain:feat/eth_call_value_wtf

Conversation

@ben-chain
Copy link

@ben-chain ben-chain commented Jun 9, 2021

So it appears that if the eth_call's value argument is greater than the from argument's current balance, it behaves as if the from's balance was origBalance + (value - origBalance) * 2. Bizarre... logs are:

initialSenderBalance
BigNumber { _hex: '0x021e19de4c7e5f18f000', _isBigNumber: true }
moreValue:
BigNumber { _hex: '0x021e19de4c7e5f18f064', _isBigNumber: true }
lessValue:
BigNumber { _hex: '0x021e19de4c7e5f18ef9c', _isBigNumber: true }
msg.value, msg.sender.balance (eth_call with EQUAL value than the account has:
[
  BigNumber { _hex: '0x021e19de4c7e5f18f000', _isBigNumber: true },
  BigNumber { _hex: '0x00', _isBigNumber: true }
]
msg.value, msg.sender.balance (eth_call with 0x64 LESS value than the account has:
[
  BigNumber { _hex: '0x021e19de4c7e5f18ef9c', _isBigNumber: true },
  BigNumber { _hex: '0x64', _isBigNumber: true }
]
msg.value, msg.sender.balance (eth_call with 0x64 MORE value than the account has:
[
  BigNumber { _hex: '0x021e19de4c7e5f18f064', _isBigNumber: true },
  BigNumber { _hex: '0x64', _isBigNumber: true }
]

@ben-chain
Copy link
Author

Whoops, this was meant to be a personal PR. My bad folks 😅

@ben-chain ben-chain closed this Jun 9, 2021
@alcuadrado
Copy link
Member

Wait, but does hardhat network behave like that?

@ben-chain
Copy link
Author

It does appear to be working in this weird way in JS tests, yes. I am not sure what the correct behavior for eth_call is supposed to be if the value param exceeds the from's balance. I am trying to get it right for the OVM geth node and I quickly went here to check what the behavior--did I just find a bug/is this the wrong behavior?

@smartcontracts
Copy link

How is eth_call supposed to behave if the value > the account's balance?

@smartcontracts
Copy link

smartcontracts commented Jun 9, 2021

A brief look at Geth makes me think an eth_call should revert if value > account balance. Would need to be confirmed with a test though.

@ben-chain
Copy link
Author

I looked into this a bit; both infura and remix throw errors.

@fvictorio
Copy link
Contributor

fvictorio commented Jun 9, 2021

I can confirm that geth throws an "insufficient funds for intrinsic transaction cost" error and that hardhat doesn't. I opened NomicFoundation/hardhat#1529 to track this.

@alcuadrado
Copy link
Member

I had no idea that was the expected behavior. Makes sense. It's simpler to implement with that restriction.

BTW, @ben-chain @smartcontracts you may find this interesting: ethereum/execution-specs#35 -- There's an ongoing effort to standardized the JSON-RPC interface, including this kind of edge cases. It's just starting, but I guess it can be useful for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants