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

Eth JSON-RPC: populate reward in eth_feeHistory #10245

Merged
merged 3 commits into from
Feb 14, 2023
Merged

Conversation

ychiaoli18
Copy link
Contributor

Related Issues

#10236

Proposed Changes

Additional Info

Checklist

Before you mark the PR ready for review, please make sure that:

  • Commits have a clear commit message.
  • PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, test
    • area, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps
  • New features have usage guidelines and / or documentation updates in
  • Tests exist for new functionality or change in behavior
  • CI is green

@ychiaoli18 ychiaoli18 requested a review from a team as a code owner February 13, 2023 02:29
Copy link
Contributor

@magik6k magik6k left a comment

Choose a reason for hiding this comment

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

Itests fail

    eth_fee_history_test.go:55: 
        	Error Trace:	/home/circleci/project/itests/eth_fee_history_test.go:55
        	Error:      	Not equal: 
        	            	expected: 17
        	            	actual  : 16
        	Test:       	TestEthFeeHistory
    blockminer.go:362: shutting down mining
    blockminer.go:362: shutting down mining
--- FAIL: TestEthFeeHistory (9.00s)

@ychiaoli18 ychiaoli18 marked this pull request as ready for review February 13, 2023 19:27
Comment on lines +48 to +53
availablePriorityFee := big.Sub(big.Int(tx.MaxFeePerGas), blkBaseFee)
if big.Cmp(big.Int(tx.MaxPriorityFeePerGas), availablePriorityFee) <= 0 {
return tx.MaxPriorityFeePerGas
}
return EthBigInt(availablePriorityFee)
}
Copy link
Member

Choose a reason for hiding this comment

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

I rewrote this a little to make it nicer to read.

Comment on lines 2165 to 2181
var totalGasUsed uint64
for _, tx := range txGasRewards {
totalGasUsed += tx.gas
}

rewards := make([]ethtypes.EthBigInt, len(rewardPercentiles))
for i := range rewards {
rewards[i] = ethtypes.EthBigIntZero
}

if len(txGasRewards) == 0 {
return rewards, totalGasUsed
}

sort.Sort(txGasRewards)

var idx int
Copy link
Member

Choose a reason for hiding this comment

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

Also adjusted the logic here so that it's easier to follow.

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.

3 participants