This repository was archived by the owner on Aug 19, 2024. It is now read-only.
Implemented FeeHistory API#1130
Merged
aeharvlee merged 9 commits intoklaytn:devfrom Feb 11, 2022
Merged
Conversation
Most of the code is based on Ethereum's code. So please take a look. Differences * Klaytn uses baseFeePerGas as 0. * Klaytn uses maxPriorityPerGas as 25 ston which is configured by governance. * Didn't applied cache because Gas-related values in Klaytn are all fixed, so it was determined that this API is unlikely to be used significantly. * Added OracleBackend but there are some differences from Etheruem's backend * Remove SubscribeChainHeadEvent because Klaytn uses fixed gasPrice policy, so we don't have to fetch and cache latest head. * Remove PendingBlockAndReceipts because there is no related apis about pending block in Klaytn backend. * Change GetReceipts to GetBlockReceipts because this fits to Klaytn backend operation.
5 tasks
7 tasks
jimni1222
reviewed
Feb 9, 2022
5 tasks
jimni1222
previously approved these changes
Feb 10, 2022
jimni1222
reviewed
Feb 10, 2022
9 tasks
aidan-kwon
reviewed
Feb 10, 2022
aidan-kwon
previously approved these changes
Feb 10, 2022
Member
|
@jeongkyun-oh @yoomee1313 PTAL |
sirano11
previously approved these changes
Feb 11, 2022
IntrinsicGas now consider AccessList. This is feature is from upstream/dev branch.
aidan-kwon
previously approved these changes
Feb 11, 2022
jimni1222
previously approved these changes
Feb 11, 2022
IntrinsicGas now consider AccessList. This is feature is from upstream/dev branch.
jimni1222
approved these changes
Feb 11, 2022
sirano11
approved these changes
Feb 11, 2022
aidan-kwon
approved these changes
Feb 11, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Most of the code is based on Ethereum's code, So please take a look Ethereum's FeeHistory API
Related docs
Differences with Geth's implementation.
0so there is no need to calculate this value.25 stonwhich is configured by governance so there is no need to calculate this value.OracleBackendbut there are some differences from Etheruem's OracleBackendSubscribeChainHeadEventbecause Klaytn uses fixed gasPrice policy, so we don't have to fetch and cache latest head.PendingBlockAndReceiptsbecause there is no related apis about pending block in Klaytn backend.GetReceiptstoGetBlockReceiptsbecause this fits to Klaytn backend operation.How to test this PR
First, please clone my origin repo.
1. Run added tests in this PR.
go test -run "TestEthereumAPI_*" -v ./... -count=12. Build ken and test with it.
1. Build ken with source codes related with this PR.
make ken2. Run ken
ethnamepsace to RPC_API and WS_API in kend.conf3. Setup environment to send txs
Test logs
KEN
Beautified Result
{ "jsonrpc": "2.0", "id": 1, "result": { "oldestBlock": "0xa5b", "reward": [ [ "0x0", "0x0", "0x0" ], [ "0x0", "0x0", "0x0" ], [ "0x0", "0x0", "0x0" ], [ "0x0", "0x0", "0x0" ], [ "0x0", "0x0", "0x0" ], [ "0x5d21dba00", "0x5d21dba00", "0x5d21dba00" ], [ "0x0", "0x0", "0x0" ], [ "0x0", "0x0", "0x0" ], [ "0x5d21dba00", "0x5d21dba00", "0x5d21dba00" ], [ "0x0", "0x0", "0x0" ], [ "0x0", "0x0", "0x0" ], [ "0x5d21dba00", "0x5d21dba00", "0x5d21dba00" ], [ "0x0", "0x0", "0x0" ], [ "0x0", "0x0", "0x0" ], [ "0x0", "0x0", "0x0" ], [ "0x0", "0x0", "0x0" ] ], "baseFeePerGas": [ "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0" ], "gasUsedRatio": [ 0, 0, 0, 0, 0, 0.0002952004000002952, 0, 0, 0.00029504250000029504, 0, 0, 0.0002963777000002964, 0, 0, 0, 0 ] } }Should note that
17(=0x10 + 0x1)because it should always return nextBaseFee based on the spec. Other fields lengths are all16(=0x10).2656(=0xa60), 2659(=0xa63), (2662 =0xa66).Block#2656(=0xa60)used total gas295200400=> 295200400 / UpperGasLimit ==0.0002952004000002952which is the same with API return.Related KEN logs
Geth
Specify reward percentiles
Beautified Result
{ "jsonrpc": "2.0", "id": 1, "result": { "oldestBlock": "0xd228dd", "reward": [ [ "0x3b9aca00", "0x3b9aca00", "0x3b9aca00" ], [ "0x3b9aca00", "0x3b9aca00", "0x3b9aca00" ], [ "0x3b9aca00", "0x3b9aca00", "0x3b9aca00" ], [ "0x3b9aca00", "0x3b9aca00", "0x3b9aca00" ], [ "0x3b9aca00", "0x3b9aca00", "0x3b9aca00" ], [ "0x3fd92b98", "0x3fd92b98", "0x3fd92b98" ], [ "0x3b9aca00", "0x3b9aca00", "0x3b9aca00" ], [ "0x3b9aca00", "0x3b9aca00", "0x3b9aca00" ], [ "0x3b9aca00", "0x3b9aca00", "0x3b9aca00" ], [ "0x40d1c0f0", "0x40d1c0f0", "0x40d1c0f0" ], [ "0x3b9aca00", "0x3b9aca00", "0x3b9aca00" ], [ "0x3b9aca00", "0x3b9aca00", "0x3b9aca00" ], [ "0x9502f900", "0x9502f900", "0x9502f900" ], [ "0x3b9aca00", "0x3b9aca00", "0x3b9aca00" ], [ "0x3b9aca00", "0x3b9aca00", "0x3b9aca00" ], [ "0x3b9aca00", "0x3b9aca00", "0x3b9aca00" ] ], "baseFeePerGas": [ "0x31bc8b70b6", "0x302315d904", "0x2f06e93aaa", "0x32e0c409bb", "0x35f6c31f2c", "0x31e4232d6c", "0x2f230a3b20", "0x350520a56f", "0x37ec9b6c52", "0x38814bf9ab", "0x32f9d702a4", "0x2f273fd988", "0x29d67aa866", "0x2f0fc76273", "0x34f1595f15", "0x3b782e8404", "0x37fe584321" ], "gasUsedRatio": [ 0.3713660480529107, 0.40775872004001795, 0.8275560837363439, 0.7426136284391863, 0.1981128474818883, 0.2791763666666667, 0.9992401, 0.7191034, 0.5415432666666666, 0.10859236666666666, 0.20004521081502755, 0.04908717914803387, 0.999436, 0.9998665, 0.9931128333333333, 0.2662043333333333 ] } }Didn't specify reward percentiles
Beautified Result
{ "jsonrpc": "2.0", "id": 1, "result": { "oldestBlock": "0xd228dd", "baseFeePerGas": [ "0x31bc8b70b6", "0x302315d904", "0x2f06e93aaa", "0x32e0c409bb", "0x35f6c31f2c", "0x31e4232d6c", "0x2f230a3b20", "0x350520a56f", "0x37ec9b6c52", "0x38814bf9ab", "0x32f9d702a4", "0x2f273fd988", "0x29d67aa866", "0x2f0fc76273", "0x34f1595f15", "0x3b782e8404", "0x37fe584321" ], "gasUsedRatio": [ 0.3713660480529107, 0.40775872004001795, 0.8275560837363439, 0.7426136284391863, 0.1981128474818883, 0.2791763666666667, 0.9992401, 0.7191034, 0.5415432666666666, 0.10859236666666666, 0.20004521081502755, 0.04908717914803387, 0.999436, 0.9998665, 0.9931128333333333, 0.2662043333333333 ] } }** Fetch empty blocks **
Beautified Result
{ "jsonrpc": "2.0", "id": 1, "result": { "oldestBlock": "0xc", "reward": [ [ "0x0", "0x0", "0x0" ], [ "0x0", "0x0", "0x0" ], [ "0x0", "0x0", "0x0" ], [ "0x0", "0x0", "0x0" ], [ "0x0", "0x0", "0x0" ] ], "baseFeePerGas": [ "0x0", "0x0", "0x0", "0x0", "0x0", "0x0" ], "gasUsedRatio": [ 0, 0, 0, 0, 0 ] } }Types of changes
Please put an x in the boxes related to your change.
Checklist
Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.
$ make test)Related issues
Further comments
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...