-
Notifications
You must be signed in to change notification settings - Fork 44
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
Stellar Asset Contract missing admin() and issuer() functions #635
Comments
Could you please describe the use case in short? (the example PR is quite large and it's not immediately obvious where the admin would help). The key distinction between As for the |
There is a soroban smart contract which represents a bridge between Stellar and Ethereum. A user can deposit assets on the bridge and then on ethereum there is a contract where the recipient of the bridge transfer can withdraw the asset which was deposited on the soroban smart contract. The same applies to the other direction (e.g. a user deposits on the ethereum bridge contract and withdraws the corresponding amount from the soroban contract). Here are some example workflows:
Note how in (2) the soroban smart contract needs to mint the asset where as in (3) the smart contract does a normal asset transfer. An easy way to support both scenarios is if the soroban smart contract can call a function on the asset contract to determine if it is an admin. If the function returns true it will mint the asset otherwise it will call
Does it make sense for there to be a |
A safer/more robust way to do either mint or xfer would be to call
That's a good question. I'm not sure if |
Can you explain how this is safer / more robust? I think calling try_mint could work but I don't see how it is safer or more robust. Keep in mind we only want to mint if and only if we are an admin of the asset contract.
No, there is no way to prevent someone from calling |
This doesn't make any assumptions about the token administrative functions, implementation of
That's one of the options. With auth next it's possible to e.g. have multiple bridge validators as token admins. It should be easy enough to pass the required signatures to mint on their behalf (so your contract doesn't necessarily have to be an admin). The approach of just calling what you need would work with this as well.
I don't see how this is an issue, given that invariants won't be broken. But if you don't like it, the above approach still works. |
Actually it does because you are assuming that mint will fail when called by a non-admin account. In my opinion, using an is_admin function is a more explicit check where as attempting to call mint is an indirect way of determining whether I am an admin.
That is already the case. The bridge admin is a stellar account with multiple signers. Each signer of the account represents a different validator. The threshold on the account represents how many validators need to approve a withdrawal for it to succeed. |
This invariant "you could also e.g. check for the contract's token balance and xfer if there is any (IIUC the token is either minted or stored, but never both)." is broken by the |
It doesn't make any assumptions like that. It doesn't really matter what is the auth on mint; the end result should be the same as long as the token follows the interface.
What I mean is that it's possible to forward the auth for the mint/xfer operation on behalf of arbitrary admin account and there is no need for the bridge contract to be the token admin. I don't know if that's necessarily a better option, just bringing it up.
I'm talking about your contract invariant, which IIUC is 'the user X has to receive a given amount of token Y'. It doesn't really matter if token Y has been minted or transferred from the contract's balance (the latter would be highly unlikely though). Again, that's just a possible option, but it doesn't seem like it breaks anything. |
I think the issue here is that we have two different interpretations of the interface. Here is the token trait interface: Note how there exists a It seems that you are suggesting I think it makes sense to include both |
I think we are on the same page here. Similar to initialization, I'm not sure if admin changes are abstract enough and are universally usable/useful. OTOH I also see the value of having both functions at the cost of restricting the implementers to a single admin. Maybe we should discuss this on Discord for the sake of getting more attention. That said, I still think that in a lot of cases (including your particular case) there is nothing wrong about handling the contract call failures gracefully; that's the whole reason we have the |
it is not necessary that we need to restrict implementers to a single admin. Consider the following two functions:
|
|
So first, I should mention there's an issue open about adding a function to return the admin - #541. I have been thinking about if there are any admin methods in the interface that should be pulled out because they're specific to Stellar assets and can be implemented as an extension to the interface ( |
What problem does your feature solve?
There is no way to determine the admin of a stellar asset contract. Similarly, there is no way to determine the issuer of a stellar asset from except by calling the
name()
function and splitting on the':
.What would you like to see?
Introduce an
admin()
function which returns the current admin of the Stellar Asset Contract.Introduce an
issuer()
which returns the issuer of the stellar asset.We should also consider renaming
symbol()
tocode()
so that it is consistent with the classic Stellar Asset semantics.What alternatives are there?
As mentioned previously, the issuer can be determined by calling the
name()
function and splitting on the':
. I think it would be better to remove thename()
function in favor of anissuer()
function.As for obtaining the admin, you can do it off chain by looking up the ledger entry containing the admin state. However, there isn't any way to recover this info from another soroban smart contract as far as I can tell.
The soroban implementation of starbridge is an example of a contract which would benefit by having an
admin()
orissuer()
functionThe text was updated successfully, but these errors were encountered: