-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat: cf_boost_pool_details rpc #4780
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4780 +/- ##
======================================
- Coverage 72% 72% -0%
======================================
Files 412 412
Lines 70494 70526 +32
Branches 70494 70526 +32
======================================
- Hits 51012 50902 -110
- Misses 17022 17128 +106
- Partials 2460 2496 +36 ☔ View full report in Codecov by Sentry. |
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.
Looks good to me, would await @GabrielBuragev 's approval before merging
Are the parameters (asset, tier) optional? Also, check the preferred spec for the response schema here: https://www.notion.so/chainflip/BOOST-aa8375e7bfa14c0895bf234047a0a972?pvs=4#5ed657173cdc4d8a81840ca8734bd316 |
pub struct BoostPoolDetails { | ||
pub available_amount: AssetAmount, | ||
pub amounts: BTreeMap<AccountId32, AssetAmount>, | ||
pub pending_boosts: BTreeMap<PrewitnessedDepositId, BTreeMap<AccountId32, AssetAmount>>, |
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.
pending_boosts
might be a bit confusing here. Maybe deposits_pending_finalization
or pending_amounts
?
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.
Also, can we adjust it so it follows the specs defined?
deposits_pending_finalization: [{
channel_id,
source_chain,
asset,
booster_shares:[{
account_id,
amount
}]
}] // We can derive the total in_use amount from this
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.
Not sure how I missed this part of the spec on Notion (I find Notion updates hard to track sometimes...). I thought I'd just start by doing the easiest thing, which is exposing all information (which is more or less how it is described in the linear issue), and make any adjustments if requested.
Now that I see the spec, I have questions:
- Why is it necessary to include
source_chain
/asset
? This RPC for a specific asset already, so it is already known by the caller of this RPC. - Do we actually want
channel_id
rather than the deposit id (as I'm providing currently)? Channels can have more than one deposit, so I think the deposit id might be necessary to uniquely identify the deposit, and it is more the question whether we want to additionally provide channel_id.
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.
Another question is regarding pending_withdrawal_amount
from the schema:
pending_withdrawal_amount: [{
account_id,
amount
}],
Does this mean that we are only interested in the amounts (the sum of them?) rather than which deposits we are waiting for? Seems like both are important and if you have the deposit id (as I provide currently), you'd be able to derive the amount, but not the other way around.
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.
Why is it necessary to include source_chain/asset? This RPC for a specific asset already, so it is already known by the caller of this RPC.
Initially, i thought this RPC would have the ability to return the details for all the existing boost pools and the asset/tier params would be optional. The preferred way would be to allow the following:
- No params provided - return the details for all boost pools
asset
param provided - return the details for all boost pools for the provided asset
In the first case we will need the asset/source_chain included in the specific object. So lets include it and enable these 2 use cases above.
Do we actually want channel_id rather than the deposit id (as I'm providing currently)? Channels can have more than one deposit, so I think the deposit id might be necessary to uniquely identify the deposit, and it is more the question whether we want to additionally provide channel_id.
Thats a good point. Lets include the prewitnessed_deposit_id
here. But lets also keep the other fields for convenience please (channel_id
, source_chain
, asset
). We can do a clean up in the end based on what ended up being used or not. I really can not recall the exact reason why we included channel_id
here and not prewitnessed_deposit_id
.
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.
Does this mean that we are only interested in the amounts (the sum of them?) rather than which deposits we are waiting for? Seems like both are important and if you have the deposit id (as I provide currently), you'd be able to derive the amount, but not the other way around.
Its a good point, we might further improve this rpc by including the deposit ids besides the other fields too (account_id
, amount
).
I would rather we expose as much details as possible on this RPC. Exposing only the ids means that we have to look elsewhere to get the details related to that deposit.
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.
Exposing only the ids means that we have to look elsewhere to get the details related to that deposit.
But the amounts are already exposed this very response under pending_boosts
. I don't think we should return the amounts twice in the same response (similar to how you suggested that total_available_amount wasn't necessary).
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.
But lets also keep the other fields for convenience please (channel_id, source_chain, asset). We can do a clean up in the end based on what ended up being used or not. I really can not recall the exact reason why we included channel_id here and not prewitnessed_deposit_id.
There is no problem adding source_chain
and asset
, but the reason I asked about channel_id
specifically is that we don't currently store that information in the boost pool. Let's think whether it is actually required (or might be required in the future), and if so, think of the best way to provide it.
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.
Exposing only the ids means that we have to look elsewhere to get the details related to that deposit.
But the amounts are already exposed this very response under
pending_boosts
. I don't think we should return the amounts twice in the same response (similar to how you suggested that total_available_amount wasn't necessary).
You are right. After seeing the snap i have a better understanding of your comment. The current schema looks good!
One more thing, how hard would it be to allow filtering the results by account_id ? |
Can we return an array instead of an object with |
Can I ask how this will be used? I imagined that if we provide all the details from all pools, the web app could periodically request it, cache it somewhere, and then derive any information it needs to display, and most of the time it will want everything anyway. Or are you planning to make an RPC call every time a user requests it (i.e. without caching)? It wouldn't be difficult to allow filtering by account_id, but it feels like if something can (as easily) be done in in the app, it should be done there? |
It will be used differently in different places.
Lets ignore the filtering by |
OK. Though I still want to understand the motivation behind this. If there is a good reason, we should provide this.
Makes sense if it will be used by clients' browsers. Though my understanding was that node's RPC server was to be used by the app's backend, and the users' browsers aren't making direct rpc requrests to a node. If the calls go through the backend, then you'd already have all the data for each LP on the backend, and you could filter internally. Is there a reason for clients to call node RPCs directly (other than this being potentially more work for the backend to expose this)?
It seems like for these two the filtering by LP isn't needed? I was mainly asking for when we'd need to filter by account_id (though I appreciate your comprehensive response). |
Updates:
|
To give you a bit more context on how the LP app was structured. We ended up doing some of the RPC calls directly on the client side (LP app) back in the days so we could ship it out faster and in time (without having to setup a whole backend for it). Having that in mind, i thought it might be useful to have that filtering baked in so we could utilize it there without any extra effort. But when i think about it deeper now, we anyways want to start moving most of the stuff on the LP app to its own backend, so this might be a good time to start that. We will still be able to utilize the cache and filter by account ids there. We can move forward without that. Thanks for pointing out these things, made me re-think :D |
d1450fd
to
b41969d
Compare
* origin/main: Arbitrum gas limit multiplier (#4781) fix: don't set code red on "agg-key set by gov-key" (#4813) fix: sign tx with correct key during rotation (#4794) chore: arbitrum witnesser permission (#4798) Solana (#4414) feat: try-runtime build step on dev ci (#4807) feat: optimistic build, streamlined ci-main (#4806) chore: log raw dispatch error (#4809) feat: allow for single binary CFE upgrades (#4634) fix: take fee on to usdc (#4801) (#4804) refactor: minor cleanup of retrier code and vault pallet (#4803) feat: cf_boost_pool_details rpc (#4780) # Conflicts: # Cargo.lock # state-chain/chains/src/sol.rs # state-chain/chains/src/sol/program_instructions.rs # state-chain/chains/src/sol/sol_tx_building_blocks.rs # state-chain/chains/src/sol/token_instructions.rs # state-chain/runtime/src/safe_mode.rs
Pull Request
Closes: PRO-1324
Closes: PRO-1336
Checklist
Please conduct a thorough self-review before opening the PR.
Summary
Added
cf_boost_pool_details
rpc call which takes asset as the sole parameter and returns details (amounts, pendings boosts and pending withdrawals) of all existing pools for that asset. I wasn't sure if we wanted pool tier as a parameter as well (see my question in PRO-1324), but the approach I took here made the most sense to me (changing this wouldn't be difficult, so happy to do so if necessary).I considered simply making the fields of
BoostPool
public and read them directly when constructingBoostPoolDetails
in the rpc handler, but in the end I thought it was important to keepScaledAmount
an implementation detail of BoostPool, so I added getters which convert all usages ofScaledAmount
to ChainAsset first (which is consitent with the rest of BoostPool's interface.)Usage:
See sample response here: https://github.com/chainflip-io/chainflip-backend/blob/716a4c9e0bcfb85ea3f3bfac6d8304a87457eed7/state-chain/custom-rpc/src/snapshots/custom_rpc__test__boost_details_serialization.snap