-
Notifications
You must be signed in to change notification settings - Fork 562
Problem: missing json rpc of eth_feeHistory #685 #734
Conversation
will add unit test because it's heavy task, can be used maliciously |
@leejw51crypto let me know if you need support with this PR, I'd like to add it for the next release |
ok |
8f3cb1c
to
0e48645
Compare
add unit test |
dc25728
to
720fbaa
Compare
fix golangci-lint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @leejw51crypto, please add more comments and clean up the logic based on the comments. Also if you could add a changelog entry
rpc/ethereum/backend/feebackend.go
Outdated
gasUsedString := gasUsedBig.ToInt().String() | ||
gasusedfloat, _ := strconv.ParseFloat(gasUsedString, 64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you convert to float64 directly without parsing the string?
rpc/ethereum/backend/feebackend.go
Outdated
if gasLimitUint64 > 0 { | ||
gasUsedRatio = gasusedfloat / float64(gasLimitUint64) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we error if gasLimitUint64
is 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i'll return error if gaslimit is 0
rpc/ethereum/backend/feebackend.go
Outdated
type OneFeeHistory struct { | ||
BaseFee *big.Int | ||
Reward []*big.Int | ||
GasUsed float64 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to types? also add a comment to describe what it is and what it does
rpc/ethereum/backend/feebackend.go
Outdated
GasUsed float64 | ||
} | ||
|
||
func (e *EVMBackend) FeeHistory(userBlockCount rpc.DecimalOrHex, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*rpctypes.FeeHistoryResult, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add comment and split arguments
rpc/ethereum/backend/feebackend.go
Outdated
if ethBlock == nil || err != nil { | ||
return nil, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically this can return nil, nil
if both ethBlock
and err
are nil. is this expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with err==nil, ethBlock is also nil
done |
3daab0e
to
d6692e6
Compare
add oracle backend space ready structure ok refactoring return feehistory data flow ok basefee set gas used ratio computing reward add testing add gas used prepare data fill reward increase coin fixing api add mac add launch gas used ratio ok print element reward workes reward working fix panic value correct remove debugging log tidy up tidy up remove oracle tidy up fix handler crash add unit test tidy up add limit check reformat fix lint fix lint fix lint fix lint Update rpc/ethereum/backend/feebackend.go thanks Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Update rpc/ethereum/backend/feebackend.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Update rpc/ethereum/backend/feebackend.go thanks Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Update rpc/ethereum/backend/feebackend.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> fix compile error split lines remove temporary string conversion return error if gaslimit is 0 move OneFeeHistory to types add comment only err check Update rpc/ethereum/backend/feebackend.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Update rpc/ethereum/backend/feebackend.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> tidy up add feehistory-cap
f6cb2ba
to
02fcb05
Compare
Codecov Report
@@ Coverage Diff @@
## main #734 +/- ##
==========================================
- Coverage 55.86% 55.83% -0.04%
==========================================
Files 64 64
Lines 5859 5864 +5
==========================================
+ Hits 3273 3274 +1
- Misses 2386 2390 +4
Partials 200 200
|
default history cap is 100 to prevent ddos attack,
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM minor comments
tx := ethMsg.AsTransaction() | ||
reward := tx.EffectiveGasTipValue(blockBaseFee) | ||
sorter[i] = txGasAndReward{gasUsed: txGasUsed, reward: reward} | ||
break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the purpose of this break here, are we only supporting 1 MsgEthereumTx
message?
Solution: add feehistory api