Skip to content
This repository was archived by the owner on Apr 4, 2024. It is now read-only.

Conversation

@loredanacirstea
Copy link
Contributor

Problem:

  • rewards calculation based on percentiles took into consideration the tendermint tx count instead of MsgEthereumTx count.
  • sorter := make(sortGasAndReward, tendermintTxCount) creates an array of {0 <nil>} values.
    The nil value from the reward attribute was never rewritten for tendermint Tx without any MsgEthereumTx

Fixes:

Fixes #974

Closes: #XXX

Description


For contributor use:

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

For admin use:

  • Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • Reviewers assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

Problem:
- rewards calculation based on percentiles took into consideration the tendermint tx count instead of `MsgEthereumTx` count.
- `sorter := make(sortGasAndReward, tendermintTxCount)` creates an array of `{0 <nil>}` values.
The `nil` value from the `reward` attribute was never rewritten for tendermint Tx without any `MsgEthereumTx`

Fixes:
- return early if there are 0 `MsgEthereumTx`
- use the `MsgEthereumTx` count to calculate rewards
rewardCount := len(rewardPercentiles)
targetOneFeeHistory.Reward = make([]*big.Int, rewardCount)
for i := 0; i < rewardCount; i++ {
targetOneFeeHistory.Reward[i] = big.NewInt(2000)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

2000 was chosen as default in https://github.com/tharsis/ethermint/pull/734/files#diff-4d996264fd51e2936260254650a034814a870ddfa9f7df7398d53feba7c39ef6R64.
Standard default value is 0 and it was usually rewritten anyway by the code below this line.

reward = big.NewInt(0)
}
sorter[i] = txGasAndReward{gasUsed: txGasUsed, reward: reward}
break
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why the break? I see this same question was asked by @fedekunze :

I don't understand the purpose of this break here, are we only supporting 1 MsgEthereumTx message?
#734 (comment)

But I did not find the answer to it.

From what I understand, we should calculate the reward only from MsgEthereumTx and not from tendermintTx. But I have some questions:

  • can we find multiple MsgEthereumTx in a tendermint Tx? (tx.GetMsgs())
  • if yes, on what rules are the MsgEthereumTx batched in a Tx?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, we can find MsgEthereumTx in a Tendermint Tx. There are no filters, we can only iterate over the msgs

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

ACK, can you add a CHANGELOG entry? 👍

@fedekunze fedekunze merged commit d04787e into evmos:main Mar 15, 2022
yihuang pushed a commit to yihuang/ethermint that referenced this pull request Mar 24, 2022
* eth_feeHistory - fix reward calculation from MsgEthereumTx

Problem:
- rewards calculation based on percentiles took into consideration the tendermint tx count instead of `MsgEthereumTx` count.
- `sorter := make(sortGasAndReward, tendermintTxCount)` creates an array of `{0 <nil>}` values.
The `nil` value from the `reward` attribute was never rewritten for tendermint Tx without any `MsgEthereumTx`

Fixes:
- return early if there are 0 `MsgEthereumTx`
- use the `MsgEthereumTx` count to calculate rewards

* Add change log
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RPC method eth_feeHistory crashed: runtime error: invalid memory address or nil pointer dereference

2 participants