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

RPCDaemon gives different eth_gasPrice results compared to Infura/Silkrpc #2483

Closed
canepat opened this issue Aug 2, 2021 · 0 comments · Fixed by #2484
Closed

RPCDaemon gives different eth_gasPrice results compared to Infura/Silkrpc #2483

canepat opened this issue Aug 2, 2021 · 0 comments · Fixed by #2484

Comments

@canepat
Copy link
Member

canepat commented Aug 2, 2021

System information

Erigon version: 2021.08.1-alpha

OS & Version: Linux Ubuntu 20.04.2 LTS

Commit hash : 12982b2

Expected behaviour

Response to eth_gasPrice API in Goerli testnet is the same using:

  • Infura (used as reference, its client version is Geth v1.10.6)
  • RPCDaemon connected to Erigon Core
  • Silkrpc connected to Erigon Core

Actual behaviour

RPCDaemon+Erigon gives a different result from Infura and Sillkrpc-Erigon (which give the same result). E.g. at block number 0x502087

Infura: {"jsonrpc":"2.0","id":1,"result":"0x12a05f200"}
Silkrpc: {"id":1,"jsonrpc":"2.0","result":"0x12a05f200"}
RPCDaemon: {"jsonrpc":"2.0","id":1,"result":"0x12a05f1dd"}

Steps to reproduce the behaviour

  • Check that all three API endpoints (Infura/RPCDaemon/Silkrpc) return the same response to eth_blockNumber (sanity check)
  • Compare how the three API endpoints (Infura/RPCDaemon/Silkrpc) answer to eth_gasPrice

Analysis

The difference in RPCDaemon response is always some multiplier of the block baseFee (currently 7 wei on Goerli) and seems to depend on two factors:

  • the sorting performed in the transaction gas price heap, which triggers calls to function Less. Such function in turn calls function GetEffectiveGasTip for DynamicFeeTransaction and for LegacyTx where gasFeeCap and consequently GasPrice attribute is decremented by baseFee at every call: effectiveFee := gasFeeCap.Sub(gasFeeCap, baseFee), hence the first missing pieces depending on the number of Less calls.
  • the SuggestPrice function used to implement the eth_gasPrice API requires adding baseFee to the returned value to obtain the legacy gas price, which is the expected result according to Geth, given that AFAIK a formal behavior is not spec'd. However, the calling GasPrice function does not add such contribute to the returned price, hence the second missing piece.
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 a pull request may close this issue.

1 participant