-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Rpc: Add getCirculatingSupply endpoint #9934
Rpc: Add getCirculatingSupply endpoint #9934
Conversation
@mvines , I wasn't able to put the non-circulating accounts list in the genesis crate and also add the computation to Also, should I change the endpoint name to |
One other note: currently this code will only populate |
Codecov Report
@@ Coverage Diff @@
## master #9934 +/- ##
========================================
- Coverage 80.4% 80.4% -0.1%
========================================
Files 283 285 +2
Lines 65951 66026 +75
========================================
+ Hits 53073 53120 +47
- Misses 12878 12906 +28 |
53b46ef
to
d582d6b
Compare
When a node boots from a snapshot, it looks like it won't have a valid bank supply until the next epoch? Call |
The current location in
Yeah I like it, which makes me want to also deprecate |
@@ -0,0 +1,30 @@ | |||
pub(crate) const NON_CIRCULATING_ACCOUNTS: [&str; 25] = [ |
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.
Some brief comments in this file that mark these accounts as mainnet-beta accounts would be nice.
"GK2zqSsXLA2rwVZk347RYhh6jJpRsCA69FjLW93ZGi3B", | ||
"HCV5dGFJXRrJ3jhDYA4DCeb9TEDTwGGYXtT3wHksu2Zr", | ||
"25odAafVXnd63L6Hq5Cx6xGmhKqkhE2y6UrLVuqUfWZj", | ||
"14FUT96s9swbmH7ZjpDvfEDywnAYy9zaNhv4xvezySGu", |
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.
Try solana_sdk::declare_id!()
to produce a Pubkey
at compile time
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.
Hmm, can you point me at an example that would work for this case?
I think I would need a different macro that can handle multiple keys to produce an non_circulating_accounts::ids()
method...?
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.
You're right, it won't work out of the box. A pubkey!("25odAafVXnd63L6Hq5Cx6xGmhKqkhE2y6UrLVuqUfWZj")
macro that produces a Pubkey struct at compile time?
True. How to handle the fact that nodes booting from snapshots at different slots will have different circulating-supply values? Perhaps it's enough to add a |
Sure, that works. |
Right now, total supply drops constantly as fees/rent are burned. If we add total supply to this response, it seems like it probably makes the most sense to calculate/cache it once at the beginning of the epoch and hold it constant like the other values. Agree? |
Oh wait. What if we just removed all the bank-level integration, and calculated everything in the |
Do you mean abandon the epoch timing altogether, and calculate everything on every request? Another option is to calculate/cache the non-circulating account addresses on the epoch boundary, but get balances to calculate supply totals on rpc request. |
Yes. We can also cache the value within RPC too for some number of slots as well. |
Sort of like #9541 ? 😆 Okay, I think I'll scrap this, and PR:
|
Problem
Users want to know the circulating supply in the cluster; even though we know this approximate value, currently we have no way to calculate it.
Summary of Changes
update_supply
module to calculate circulating and non-circulating supply on epoch boundariesgetCirculatingSupply
into rpc, which returns circulating and non-circulating supplies, and the list of non-circulating accounts. Note: these values are static, even though total supply may fall across an epoch, since supply is updated once at the beginning of the epoch.Fixes #9433
Closes #9541