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

Introduce governance_getRewardsAccumulated API #1848

Merged
merged 5 commits into from
May 31, 2023

Conversation

aidan-kwon
Copy link
Member

@aidan-kwon aidan-kwon commented May 17, 2023

Proposed changes

  • Rename PublicGovernanceAPI to GovernanceAPI because it is not for the public use
  • Introduce governance_getRewardsAccumulated API
    The API returns accumulated reward information in a given block range. Since the method requires heavy storage IO, the method is assigned to governance namespace.

The example
request payload

{
    "jsonrpc": "2.0",
    "method": "governance_getRewardsAccumulated",
    "params": [123400489,123416489],
    "id": 1
}

response payload

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "firstBlockTime": "2023-05-29 15:11:27 +0900 KST",
        "lastBlockTime": "2023-05-29 19:38:11 +0900 KST",
        "firstBlock": 123400489,
        "lastBlock": 123416489,
        "totalMinted": 102406400000000000000000,
        "totalTxFee": 1012877568458206944160,
        "totalBurntTxFee": 1012877568458206944160,
        "totalProposerRewards": 10240640000000000224014,
        "totalStakingRewards": 40962559999999999775986,
        "totalKFFRewards": 20481280000000000000000,
        "totalKCFRewards": 30721920000000000000000,
        "rewards": {
            "0x04185389ec237dba242888a5a28b5555d011a223": 341760000000000007476,
            "0x064ce4c3e8409a544ce91245f9f8cfc33bde8925": 341158409421920578070,
            "0x0bb09aab5276ae532e33caf69d00a624adbc3fdf": 4692517369325951639990,
            "0x0c41cce8ddaea235f97745a13207421dca7340fa": 341158442792400102695,
            "0x179679457f93094a4e7186abcb2089661e92fc22": 4670094563747132209866,
            "0x186de0382923086f73367bab16af09aeda4e54bf": 3344700808386003997995,
            "0x1a147924d0489fccf53471904dc271b9d20157a4": 812253494122089774069,
            "0x24e593fb29731e54905025c230727dc28d229f77": 341120033370479516086,
            "0x2b2a7a1d29a203f60e0a964fc64231265a49cd97": 405647783029499903389,
            "0x2fd3ff6e4ead7430ea25bab5e5b2b073492b7e6e": 4179365177477290146362,
            "0x4b87df856044f2580ca62f44f6e15121d7ebcc91": 943429290876805235278,
            "0x5459c9591c3c3f260eff1a538d84610015332c91": 399791330615756805978,
            "0x54e8bc489cee5ab638920cc80160d8095df846b1": 1342241347422787927227,
            "0x5ed9914689a2fafb55a0c99a1c10d2f911d37734": 1150518010638720583027,
            "0x5f1dbd747996d8d31e2ab0317be7ffffd155522a": 507972397569861326690,
            "0x75239993ac422a4e6a7441d5ab47ed6e91faf306": 9708690430353790307357,
            "0x758476368db33864b704f41cc63b8460f8e7d39a": 719558444429276229872,
            "0x85d82d811743b4b8f3c48f3e48a1664d1ffc2c10": 20481280000000000000000,
            "0x999999999939ba65abb254339eec0b2a0dac80e9": 2546664690927360639974,
            "0xac7f6f8a63733877a78917dc798ed7693095be7b": 976294207626140822860,
            "0xadb287e1f8405f085c740e791a3914f9b07acae0": 4834561973146129955927,
            "0xb89a760eb082dbae4f334a9374fa32e7b077e00d": 341120033370479516086,
            "0xbb121974208b9282e72cb0da7f48d8ae14dba954": 477271623157965876433,
            "0xc8e7053dc17bce47d2317718734ef087be40a023": 533654318603814390326,
            "0xcd7cd61f0b221a61405640b8ba10f1455cce6d51": 1153716971545888984956,
            "0xda5609a74470689a3b51cb53ee3c499b0f54f31a": 401005661421389210969,
            "0xdbd3fbdc9e1965855b773a4746f27165b787fe3c": 1153644257271028044532,
            "0xdc7dda990c08513962d5ae6dfb195b1f6879bfaf": 1954666498718499702479,
            "0xdd4c8d805fc110369d3b148a6692f283ffbdccd3": 30721920000000000000000,
            "0xdedbab7de9551a2bee78792638af67d59b8675c6": 1285976941809533886160,
            "0xe3d49ffc285c668425b2966b683776f632859efa": 714216865143954209314,
            "0xf786c3720a10cb48c8f12d0ac2086dcf227c7cde": 588428623678048468557
        }
    }
}

The output example

Types of changes

Please put an x in the boxes related to your change.

  • Bugfix
  • New feature or enhancement
  • Others

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.

  • I have read the CONTRIBUTING GUIDELINES doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes ($ make test)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Related issues

  • Please leave the issue numbers or links related to this PR here.

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...

governance/api.go Outdated Show resolved Hide resolved
governance/api_test.go Outdated Show resolved Hide resolved
governance/api.go Show resolved Hide resolved
reward/reward_distributor.go Outdated Show resolved Hide resolved
governance/api.go Show resolved Hide resolved
@kjeom
Copy link
Contributor

kjeom commented May 30, 2023

Sorry for the late.
@aidan-kwon Is it needed to be added in klaytn RPC specification?

@aidan-kwon
Copy link
Member Author

@kjeom Yes. I don't understand what exactly you mean "klaytn RPC specification" by, though

@aidan-kwon
Copy link
Member Author

@JayChoi1736 @nohkwak @toniya-klaytn @kjeom Code owners, please review this

@kjeom
Copy link
Contributor

kjeom commented May 31, 2023

@kjeom Yes. I don't understand what exactly you mean "klaytn RPC specification" by, though

I mean you want to open publicly this API in klaytn docs

@aidan-kwon
Copy link
Member Author

@kjeom Yes. The explanation of this API will be updated when the new version released

@aidan-kwon aidan-kwon merged commit 2dabae6 into klaytn:dev May 31, 2023
11 checks passed
@aidan-kwon aidan-kwon deleted the 230504-accumulatedRewardAPI branch May 31, 2023 10:56
aidan-kwon added a commit that referenced this pull request Jun 1, 2023
Introduce governance_getRewardsAccumulated API
@JayChoi1736 JayChoi1736 mentioned this pull request Jul 24, 2023
20 tasks
@kjeom kjeom mentioned this pull request Oct 27, 2023
9 tasks
@nohkwak nohkwak mentioned this pull request Oct 27, 2023
9 tasks
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.

None yet

6 participants