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

feat: Add prewitness deposit events #4745

Merged
merged 6 commits into from
Apr 12, 2024
Merged

Conversation

j4m1ef0rd
Copy link
Contributor

Pull Request

Closes: PRO-1295, PRO-1296, PRO-1294, PRO-1293

Checklist

Please conduct a thorough self-review before opening the PR.

  • I am confident that the code works.
  • I have updated documentation where appropriate.

Summary

Still not very confident on the details/types in these events, but it's hopefully a good start.

  • Added 3 new events
  • modified DepositBoosted to have the amounts of each pool used.
  • updated or added tests to cover the events.

TODO: Test on localnet.

@j4m1ef0rd j4m1ef0rd self-assigned this Apr 10, 2024
@j4m1ef0rd j4m1ef0rd requested a review from dandanlen as a code owner April 10, 2024 06:50
Copy link

codecov bot commented Apr 10, 2024

Codecov Report

Attention: Patch coverage is 78.83212% with 29 lines in your changes are missing coverage. Please review.

Project coverage is 72%. Comparing base (82285bc) to head (8a8e1e1).
Report is 9 commits behind head on main.

Files Patch % Lines
state-chain/pallets/cf-ingress-egress/src/lib.rs 70% 16 Missing and 7 partials ⚠️
...-chain/pallets/cf-ingress-egress/src/boost_pool.rs 83% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##            main   #4745    +/-   ##
======================================
- Coverage     72%     72%    -0%     
======================================
  Files        421     409    -12     
  Lines      70683   70010   -673     
  Branches   70683   70010   -673     
======================================
- Hits       51220   50654   -566     
+ Misses     17037   16925   -112     
- Partials    2426    2431     +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kylezs kylezs requested a review from msgmaxim April 10, 2024 09:50
Copy link
Contributor

@kylezs kylezs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice stuff, just a few small mostly cosmetic things

state-chain/pallets/cf-ingress-egress/src/lib.rs Outdated Show resolved Hide resolved
state-chain/pallets/cf-ingress-egress/src/lib.rs Outdated Show resolved Hide resolved
state-chain/pallets/cf-ingress-egress/src/lib.rs Outdated Show resolved Hide resolved
state-chain/pallets/cf-ingress-egress/src/lib.rs Outdated Show resolved Hide resolved
state-chain/pallets/cf-ingress-egress/src/lib.rs Outdated Show resolved Hide resolved
state-chain/pallets/cf-ingress-egress/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@dandanlen dandanlen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Just some nitty comments (not all related to this PR...)

@@ -626,14 +643,38 @@ pub mod pallet {
DepositBoosted {
deposit_address: TargetChainAccount<T, I>,
asset: TargetChainAsset<T, I>,
amount: TargetChainAmount<T, I>,
amounts: BTreeMap<BoostPoolTier, TargetChainAmount<T, I>>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: I think we should consider changing this into a Vec<(BoostPoolTier, TargetChainAmount)>, it's a bit more json-friendly (although this is SCALE so maybe it doesn't matter).

But also - doesn't the boost_id already uniquely identify the amounts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BoostPoolTier will be unique, that's why i explicitly usedBTreeMap. I'm pretty sure SCALE will make it output the same as a vec. I prefer to leave it as is. Can change it later if we find its not suitable.

Copy link
Collaborator

@dandanlen dandanlen Apr 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's fine. I was just imagining a future where we have more Tiers, or have more complex tiers (for example a tuple of (Price, MinConfirmations)). Just something to keep to in mind. We can change it later if needed.

deposit_details: <T::TargetChain as Chain>::DepositDetails,
boost_id: BoostId,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I just realised that boost_id is just the prewitnessed_deposit_id. It's a bit strange that we use these interchangeably despite them having different type aliases... Why do we distinguish these?

boost_fee: TargetChainAmount<T, I>,
action: DepositAction<T::AccountId>,
},
BoostFundsAdded {
account_id: T::AccountId,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We sometimes use booster_id and sometimes account_id. Why not use booster_id everywhere we talk about boosting?

@j4m1ef0rd j4m1ef0rd force-pushed the feat/add-prewitness-deposit-events branch from 4ea25da to 8a8e1e1 Compare April 12, 2024 04:49
@kylezs kylezs merged commit c22a7e1 into main Apr 12, 2024
46 checks passed
@kylezs kylezs deleted the feat/add-prewitness-deposit-events branch April 12, 2024 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants