-
Notifications
You must be signed in to change notification settings - Fork 58
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
Allow converting between Phoenix and Moonlight Dusk #2028
Conversation
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 must say it is a bit of a hack, leveraging the contract-withdrawal system in this way. But the more I think about it, the more it makes sense to me: Moonlight is the account model for the transfer-contract so in the end conversing from phoenix into moonlight and the other way round is nothing else than depositing and withdrawing into and from the transfer-contract itself.
One thing I don't understand though: Why does there always need to be a deposit present? A deposit only makes sense if we go from moonlight into phoenix edit: phoenix to moonlight. But when we go from phoenix to moonlight edit: moonlight to phoenix, there shouldn't be a deposit.
This was exactly my line of thinking. Glad to see it resonates 😊.
I have the feeling that this question comes from a place of placing one of the models at a different footing than the other. The transactor must put forward the funds available - meaning have them available to be spent - for them to be able to securely withdraw in either model. If they don't we end up with an actual "mint", where the user would be able to generate Dusk out of thin air. Maybe I'm not understanding the question properly, so let me ask a question... Why shouldn't there be a deposit when coming from Phoenix? On a more conceptual level... Deposits and withdrawals work in exactly the same way in Moonlight and Phoenix - i.e. they're symmetric operations under a model change. Therefore, it stands to reason that the same would apply for a combination of these two operations. In other words, an atomic combination of symmetric operations is itself symmetric. |
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 would be nice to have a wallet driven test and be able to show that wallet balance is the same before and after the operation, except for the gas spent. Nevertheless, I approve, looks really good to me.
Let me try to explain what I mean: A deposit are funds that are being transferred from phoenix or moonlight dusk to a contract. Addition after some more thoughts: At the same time I also quite like the elegance of it. |
The problem I see here is that you're taking a |
16b32eb
to
2a1822b
Compare
We add the `convert` function to the contract, leveraging the deposit and withdrawal capabilities to atomically swap Dusk between the Phoenix and Moonlight models. The function is meant to be called directly - meaning as the first and only call - and takes a `Withdraw` as an argument, such that the user can prove ownership of either the account or address being deposited to. Resolves: #1994
2a1822b
to
ed860be
Compare
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.
LGTM
We add the
convert
function to the contract, leveraging the deposit and withdrawal capabilities to atomically swap Dusk between the Phoenix and Moonlight models.The function is meant to be called directly - meaning as the first and only call - and takes a
Withdraw
as an argument, such that the user can prove ownership of either the account or address being deposited to.Resolves: #1994