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 connectors v2 extrinsics & inbound msg handlers #1364
Conversation
This reverts commit 2f22dae.
This reverts commit 9c3947d.
@NunoAlexandre @mustermeiszer I have applied all requested changes and linked the corresponding commits. I would love to get a re-review soonish so we can finally get this PR merged. |
Will do tonight or tomorrow! |
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.
Two changes we need to do IMO. Otherwise, good to go.
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.
GH tells me I left 16 comments but I think this is pretty much ready apart from Frederik's last review which are important points.
Amazing work, @wischli 💯
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.
@mustermeiszer should we emit an event in such a case so that we can more easily monitor and debug those scenarios?
) -> Result<Self::Result, Self::Error> { | ||
Pallet::<T>::do_collect_invest(who, investment_id) | ||
.map_err(|e| e.error) | ||
.map(|_| ()) |
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.
@mustermeiszer shouldn't this return how much was actually collected? 🤔
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.
Right now, do_collect_invest
would return the post dispatch weight. We might need to add the collected amount in a subsequent PR which handles the Executed*
messages.
GH not showing what this is related to. Could you list it here again @NunoAlexandre ^^ |
I also had to dig: #1364 (comment) |
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.
Ready to 🚢
Kudus for your work, perseverance, and patience, @wischli 🎖️
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.
Approve for now. Although, we got inconsistent now in naming and handling actions after hitting pallet investments...
But we will handle this in the subsequent PR so I am fine. Just noteing here for visibility.
pallets/connectors/src/inbound.rs
Outdated
/// decreased amount on the source domain. The dispatch of this message is | ||
/// delayed until the execution of the investment, e.g. at least until the | ||
/// next epoch transition. | ||
pub fn do_decrease_invest_order( |
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.
We got really inconsistent here now. Haha.
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.
Oh boy, I fully relied on search and replace without double checking 🥶 Will fix. This should not be merged.
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.
I normalized all inbound handlers with the handle
prefix as some prefix was required for the transfer functions.
pallets/connectors/src/inbound.rs
Outdated
T::ForeignInvestment::update_investment(&investor, invest_id, post_amount)?; | ||
|
||
// Burn decreased amount | ||
T::Tokens::burn_from(currency, &investor, amount)?; |
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.
Here we keep the burn, below we removed the transfer.
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.
Sorry, this slipped through. Will handle this.
fe841c0
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.
❤️
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.
Re-approve
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.
🤟🏻
* refactor: move connectors codec to traits * refactor: move TypeId for DomainAddress * Revert "fix: remove new extrinsics" This reverts commit 2f22dae. * refactor: move TypeId impl for DomainLocator * chore: add sanity checks to transfer_tranche_tokens * wip: invest & redeem handlers * feat: add foreign investment traits * feat: add u128 conv for GeneralCurrencyPrefix * refactor: normalize message codec vars * feat: add v2 extrinsics + inbound handlers * docs: minor inv improvements * tests: apply add_member changes * ci: disable on draft PRs * feat: add CurrencyInspect trait * feat: apply CurrencyInspect * tests: add transfer_non_tranche_tokens * tests: add add_currency, allow_pool_currency * chore: finish tests, fix inbound handlers * fix: order id storage in do_collect_redeem * chore: various fixes and cleanups * tests: add inbound tranche token transfer * tests: add non tranche transfers to local * chore: apply clippy * Revert "ci: disable on draft PRs" This reverts commit 9c3947d. * fix: revert creep changes * refactor: apply suggestions from review * fix: apply evm meta derivation from asset * refactor: normalize token, currency * docs: apply suggestion from code review * fix: cleanup * tests: extend allow_pool_currency fails * clippy: fix * docs: add pallets config types * refactor: apply suggestions from review * refactor: rename to ConnectorsWrappedToken * docs: improve update_asset in con tests * fix: derive tranche decimals from registry * refactor: investments trait * fix: use DomainLocator * refactor: apply suggestions from code review * refactor: extend try_get_wrapped_token * refactor: remove wrapped token conversions * docs: add subsequent pr todos * feat: add connectors queue traits * refactor: cleanup * refactor: rm local transfer checks * chore: apply clippy to connectors tests * fix: issues after rebasing * refactor: apply suggestions from code review * tests: fix after rebase * fix: remove burn, normalize inbound handlers
* feat: trait PoolMetadata * fmt * refactor: change get return type to result * tests: add PoolMetadata * fmt: taplo * feat: add connectors v2 extrinsics & inbound msg handlers (#1364) * refactor: move connectors codec to traits * refactor: move TypeId for DomainAddress * Revert "fix: remove new extrinsics" This reverts commit 2f22dae. * refactor: move TypeId impl for DomainLocator * chore: add sanity checks to transfer_tranche_tokens * wip: invest & redeem handlers * feat: add foreign investment traits * feat: add u128 conv for GeneralCurrencyPrefix * refactor: normalize message codec vars * feat: add v2 extrinsics + inbound handlers * docs: minor inv improvements * tests: apply add_member changes * ci: disable on draft PRs * feat: add CurrencyInspect trait * feat: apply CurrencyInspect * tests: add transfer_non_tranche_tokens * tests: add add_currency, allow_pool_currency * chore: finish tests, fix inbound handlers * fix: order id storage in do_collect_redeem * chore: various fixes and cleanups * tests: add inbound tranche token transfer * tests: add non tranche transfers to local * chore: apply clippy * Revert "ci: disable on draft PRs" This reverts commit 9c3947d. * fix: revert creep changes * refactor: apply suggestions from review * fix: apply evm meta derivation from asset * refactor: normalize token, currency * docs: apply suggestion from code review * fix: cleanup * tests: extend allow_pool_currency fails * clippy: fix * docs: add pallets config types * refactor: apply suggestions from review * refactor: rename to ConnectorsWrappedToken * docs: improve update_asset in con tests * fix: derive tranche decimals from registry * refactor: investments trait * fix: use DomainLocator * refactor: apply suggestions from code review * refactor: extend try_get_wrapped_token * refactor: remove wrapped token conversions * docs: add subsequent pr todos * feat: add connectors queue traits * refactor: cleanup * refactor: rm local transfer checks * chore: apply clippy to connectors tests * fix: issues after rebasing * refactor: apply suggestions from code review * tests: fix after rebase * fix: remove burn, normalize inbound handlers * refactor: simplify trait imports
Description
Please note that the spec is not finalized. I marked the corresponding sections in the code with
TODO(@review)
and added a couple of other ones which were not crystal clear to me. Of course, this does not mean, that you reviewers should solve this issue here. It should merely raise awareness as this PR is quite large such that there's a lot of noise. In order to simplify the reviewing process, I have left a couple of notes.As discussed, we want to solve issues such as handling
Executed*
messages in subsequent PRs. Thus, I have divided open tasks related to this PR into three sections: Now, either now or later and later.Changes and Descriptions
InvestmentCollector
trait required for{Collect | Redeem}For
inbound messagesInvestment
ForeignInvestment
trait required to verify a given currency...pool_currency
metadata enabledCurrencyInspect
trait to enable checking whether a currency is a tranche tokendo_collect_redeem
, see commit 6158fca and this DAO Slack message for detailsOpen tasks connected to this PR and Connectors V2
TODOs in this PR
mock-builder
)main
after Polkadot v0.9.38 #1332 is mergedTODO(@review)
TODOs in this PR or later
PoolMetadata
that allows retrieving the necessary data and the registry implements it (details) --> feat: trait PoolMetadata #1432CurrencyId
after feat: Extend CustomMetadata withtransferability
#1357InboundQueue
for inbound tranche token transfer and redemptions (blocked by Add pallet connectors gateway #1376)TODO in other PRs
PoolInspect
trait based on this proposalvalid_until
reworkpallet-foreign-investments
which should handle the storage and dispatch ofExecuted*
connectors messages andpallet-connectors
relays the storage relevant data topallet-foreign-investments
when it executes inbound messagesDecrease{Invest, Redeem}Order
andCollect{Invest, Redeem}
pallet-xcm-transactor
and remove/reworkhandle
Checklist: