Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core, internal: support various eth_call invocations post 1559 #23027

Merged
merged 1 commit into from
Jun 11, 2021

Conversation

karalabe
Copy link
Member

@karalabe karalabe commented Jun 10, 2021

This PR fixes eth_call for various combinations of pre/post 1559 and various gas parametrization.

The two major use cases we need to cover from a UX perspective are:

  • Trying to read smart contract state (we expect gas prices to be irrelevant)
  • Dry running an execution on top of a block (we expect gas prices to be meaningful)

The solution the PR employs is that if the user doesn't specify any gas price (either the old field or any of the new ones), we assume they only want to read and do not care about execution, so we disable the baseFee accounting. If on the other hand the user does specify any of the gas price fields, we keep the baseFee check live as the assumption is the user wants to dry run a transaction execution. In either case, the BASEFEE opcode is left untouched, since the goal is to allow simpler execution, but not to mess with execution results.

1. Prior to 1559, if you don't specify a gas price, 0 is used and you can call with no-balance accounts.

> eth.call({from: eth.accounts[0], to: eth.accounts[0]})
"0x"

> eth.call({from: "0xdeadbeef00000000000000000000000000000000", to: eth.accounts[0]})
"0x"

2. Prior to 1559, if you do specify a gas price, that is used and your account balance is checked against it.

> eth.call({from: eth.accounts[0], to: eth.accounts[0], gasPrice: 10})
"0x"

> eth.call({from: "0xdeadbeef00000000000000000000000000000000", to: eth.accounts[0], gasPrice: 10})
Error: err: insufficient funds for gas * price + value: address 0xdEADBEeF00000000000000000000000000000000 have 0 want 250000000 (supplied gas 25000000)
	at web3.js:6355:37(47)
	at web3.js:5089:62(37)
	at <eval>:1:9(13)

3. Prior to 1559, if you do specify a 1559 gas pricing, those get ignored and you revert to gasPrice = 0.

> eth.call({from: eth.accounts[0], to: eth.accounts[0], maxFeePerGas: 10})
"0x"

> eth.call({from: "0xdeadbeef00000000000000000000000000000000", to: eth.accounts[0], maxFeePerGas: 10})
"0x"

4. After 1559, if you don't specify a gas price, 0 is used and you can call with no-balance accounts. The basefee is forced to zero!

> eth.call({from: eth.accounts[0], to: eth.accounts[0]})
// gasPrice: 0 gasTipCap: 0 gasFeeCap: 0
"0x"

> eth.call({from: "0xdeadbeef00000000000000000000000000000000", to: eth.accounts[0]})
// gasPrice: 0 gasTipCap: 0 gasFeeCap: 0
"0x"

5. After 1559, if you do specify a gas price, that is interpreted as both the max and priority fee and your account balance is checked against them + the current base fee.

> eth.call({from: eth.accounts[0], to: eth.accounts[0], gasPrice: 10})
// gasPrice: 10 gasTipCap: 10 gasFeeCap: 10
"0x"

> eth.call({from: "0xdeadbeef00000000000000000000000000000000", to: eth.accounts[0], gasPrice: 10})
// gasPrice: 10 gasTipCap: 10 gasFeeCap: 10
Error: err: insufficient funds for gas * price + value: address 0xdEADBEeF00000000000000000000000000000000 have 0 want 250000000 (supplied gas 25000000)
	at web3.js:6355:37(47)
	at web3.js:5089:62(37)
	at <eval>:1:9(13)

> eth.call({from: eth.accounts[0], to: eth.accounts[0], gasPrice: 5})
// gasPrice: 5 gasTipCap: 5 gasFeeCap: 5
Error: err: max fee per gas less than block base fee: address 0xE80d2a018C813577f33f9E69387DC621206Fb3a4, maxFeePerGas: 5 baseFee: 7 (supplied gas 25000000)
	at web3.js:6355:37(47)
	at web3.js:5089:62(37)
	at <eval>:1:9(16)

6. After 1559, if you do specify a 1559 gas pricing, those are interpreted as specified (no auto filling of missing ones) and your account balance is checked against them + the current basefee.

> eth.call({from: eth.accounts[0], to: eth.accounts[0], maxFeePerGas: 10})
// gasPrice: 7 gasTipCap: 0 gasFeeCap: 10
"0x"

> eth.call({from: eth.accounts[0], to: eth.accounts[0], maxFeePerGas: 5})
gasPrice: 5 gasTipCap: 0 gasFeeCap: 5
Error: err: max fee per gas less than block base fee: address 0xE80d2a018C813577f33f9E69387DC621206Fb3a4, maxFeePerGas: 5 baseFee: 7 (supplied gas 25000000)
	at web3.js:6355:37(47)
	at web3.js:5089:62(37)
	at <eval>:1:9(16)

> eth.call({from: eth.accounts[0], to: eth.accounts[0], maxPriorityFeePerGas: 5})
// gasPrice: 0 gasTipCap: 5 gasFeeCap: 0
Error: err: max priority fee per gas higher than max fee per gas: address 0xE80d2a018C813577f33f9E69387DC621206Fb3a4, maxPriorityFeePerGas: 5, maxFeePerGas: 0 (supplied gas 25000000)
	at web3.js:6355:37(47)
	at web3.js:5089:62(37)
	at <eval>:1:9(16)

> eth.call({from: eth.accounts[0], to: eth.accounts[0], maxPriorityFeePerGas: 5, maxFeePerGas: 10})
gasPrice: 10 gasTipCap: 5 gasFeeCap: 10
"0x"

> eth.call({from: "0xdeadbeef00000000000000000000000000000000", to: eth.accounts[0], maxFeePerGas: 10})
// gasPrice: 7 gasTipCap: 0 gasFeeCap: 10
Error: err: insufficient funds for gas * price + value: address 0xdEADBEeF00000000000000000000000000000000 have 0 want 250000000 (supplied gas 25000000)
	at web3.js:6355:37(47)
	at web3.js:5089:62(37)
	at <eval>:1:9(13)

The PR also updates web3js (console) to support setting decimal 1559 call parameters on eth_call variants.

@karalabe karalabe added this to the 1.10.4 milestone Jun 10, 2021
@karalabe karalabe requested a review from holiman June 10, 2021 05:39
Copy link
Member

@rjl493456442 rjl493456442 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

One additional request, we have one similar things checkNonce in the core.Message. In the eth_call we disable the nonce checking. Would be nice to unify these two things. I think we can also move this check_nonce to the config object.

gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Aug 12, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Aug 12, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Aug 12, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Aug 19, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Aug 21, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Aug 22, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Aug 23, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Aug 24, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Aug 25, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Aug 25, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Aug 26, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Aug 26, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Aug 26, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 2, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 6, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 9, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 9, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 9, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 12, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 12, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 19, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 19, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 21, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 22, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 22, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 23, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 23, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 26, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 26, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants