-
Notifications
You must be signed in to change notification settings - Fork 204
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
Account migration #206
Account migration #206
Conversation
@asalzmann reviewing this right now. Can you give me a one sentence explanation for the switch from |
abb3576
to
c46170e
Compare
thank you for the review @sampocs ! the one-liner is that transfer acks can't be unmarshalled into TxMsgDatas, so I pushed unmarshalling acks down the stack |
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 Aidan got side tracked on this. I'll submit this first batch of nit comments now so I don't keep you waiting. Tomorrow morning I'll review the core functions at a higher level and review the upgrade stuff!
@@ -0,0 +1,43 @@ | |||
package keeper |
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.
Is this considered an ICA callback? Seems like it's just a normal IBC transfer, and if so, I think the naming of these functions are a little misleading.
If you think it makes sense to consider this an icacallback for the sake of consistency, then maybe we should rename this file to icacallbacks.go
to keep it consistent with stakeibc?
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.
agreed, the naming is confusing - everything should ideally just be called callbacks. I can rename as a final commit to this PR
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.
What do you think about calling these ibccallbacks
and then renaming stakeibc/callbacks.go
to icqcallbacks
?
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.
Good stuff! This wound up being much more complex than I would have anticipated! My main questions revolve around the ack handling between stakeibc and records (I’m most definitely missing something as I’m a little less fluent than you with the middleware).
My (likely mistaken) understanding of the flow is:
- Regardless of the ack type, we first try to handle it in the Records module’s
OnAckPacket
:- If the ack was from the IBC transfer, we handle it appropriately [here - CallRegisteredICACallback] but then still pass the ack down to stakeibc's handler here (maybe a bug?)
- If the ack was from the other ICAs, then we pass it through to stakeibc. However, it’s unclear to me how
CallRegisteredICACallback
(linked above) doesn’t fail when it’s called with any ack other than the IBC transfer - And if it’s the case that this
CallRegisteredICACallback
can handle all ack types (rather than just transfer), then why would there be any need for ack handling in stakeibc?
To phrase the question a little differently, is this - CallRegisteredICACallback expected to handle all ack/callback types (transfer, delegate, undelegate, etc. )?
- If yes, then why do we need stakeibc’s
OnAckPacket
? - If no, then wouldn’t it error on all non-transfer acks before they can propagate to stakeibc?
Additional question:
- If we handle the transfer ack in record’s
OnAckPacket
, do we need to move the unmarshalling ofTxMsgData
into each individual callback function? Since stakeibc'sOnAckPacket
should only receive the non-transfer callbacks (which will always havetxMsgData
in the ack), it seems like we could just keep the unmarshalling where it was in stakeibc'sOnAckPacket
. - Can we handle all acks in the same
OnAckPacket
? Maybe in stakeibc’s since I think it has access to the records keeper.
Apologies for the confusion / long winded response - happy to hop on a call if it makes it easier!
Good stuff! This wound up being much more complex than I would have anticipated! My main questions revolve around the ack handling between stakeibc and records (I’m most definitely missing something as I’m a little less fluent than you with the middleware). ... Great question! I think this is the key misunderstanding
We don't pass all acks through records, rather we have two middleware _stacks_, which we route IBC packets through. The stacks are defined here The first stack is the _records stack_, which consists of records -> transfer. The second stack is the _stakeibc_ stack, which consists of ICAController -> icacallbacks -> stakeibc. Actually, I think we should add icacallbacks between records and transfer! The way IBC middlewares work, received packets flow from the IBC router down the stack towards the base app; sent packets flow in the opposite direction. Packets are routed to middlewares (or modules, if no middleware is defined!) through the IBC router. The router is defined here. Notably, IBC packets sent from the transfer module are routed to the records stack, and IBC packets sent from the ICA module are routed to the icamiddleware stack (which contains stakeibc). The incoming packet flows look something like this packet{sourcePort: transfer, ...} -> ibcRouter.Route(packet) -> records.Ack(packet) -> transfer.Ack(packet) -> baseApp.Ack(packet) packet{sourcePort: icacontroller, ...} -> ibcRouter.Route(packet) -> icacontroller.Ack(packet) -> icacallbacks.Ack(packet) -> stakeibc.Ack(packet) -> baseApp.Ack(packet) |
This would be true if we didn't have an interface for ICACallbackHandler. CallICACallback requires a consistent signature across modules, which is why I generalized to acks and pushed module specific ack parsing down the stack. Let me know if you can think of a cleaner solution! I think this likely works for now though, and we can always refactor this shortly after launch.
I think this was answered in the above response, but in short: it's tricky, because the middleware stacks are different. The original reason we created separate stacks was that the Transfer module's IBCModule interface is different from ICAControllerModule's, so you can't route ICS-20 and ICS-27 packets to the same IBCModule (see the UNIMPLEMENTED methods in module_ibc.go). Also, please don't apologize! This is a great question, and explaining it uncovered a minor bug :D |
… keeper, add IBCKeeper to records module
4c9a3a1
to
974cb39
Compare
@asalzmann You're the man! I appreciate the detailed response! That clears it up a ton. I'm also aligned on having the callbacks use an |
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.
Changes look good!
@@ -16,6 +16,7 @@ const ( | |||
atom = "uatom" | |||
stAtom = "stuatom" | |||
ibcAtom = "ibc/uatom" | |||
chainId = "GAIA" |
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.
ty! been meaning to do this for awhile!
filed two follow-ons here https://stridelabs.atlassian.net/jira/software/projects/TEST/boards/2/backlog?selectedIssue=TEST-175 |
* create paths json schema * create akash network paths file * add tag description * akash paths v2 * paths schema v2 * "_v2" is the decided upon schema * change "order" to "ordering"
Co-authored-by: vish-stride <vishal@stridelabs.co>
closes: #155
What is the purpose of the change
Context
stakeibc
's module account is restricted in taking certain actions, such as IBC transferring tokens (because it is blacklisted). In upcoming versions of IBC, blacklisted accounts won't be able to transfer tokens; in the current version, tokens can be transferred, then stranded upon refund. poolparty-v3 currently has tokens stuck in this state. See #155 for more details.Structure
This diff adds a module account for each host zone. This structure was inspired by the way Osmosis creates accounts for pools (one account per pool). We could create a single account that handles all tokens (essentially a mirror of
stakeibc
's module account, but there's no natural place to create the account, and account creation inRegisterHostZone
is natural. This also sets us up to sweep token balances, if we decide to move away fromDepositRecords
.Creating accounts
[NewAccount](https://docs.cosmos.network/main/modules/auth/04_keepers.html)
creates a new account (but does not store it to state). To create new module accounts, per ADR-28, we can construct keys using the module name, the purpose of the account, and a unique key for the account. In our case, the inputs are "stakeibc", "zone" and chain id (chain ids are unique per-host zone).Brief Changelog
HostZone.Address
NewZoneAddress
function to get bech32 addresses for a host zone, based on chain idNewAccount
andSetAccount
RedeemStake
LiquidStake
SendCoins
, rather thanSendCoinsFromAccountToModule
andSendCoinsFromModuleToAccount
(SendCoins is more restrictive, so should be safer than using
SendCoinsFrom...`)Testing and Verifying
Integration tests
refunding tokens from the escrow account
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? no