-
Notifications
You must be signed in to change notification settings - Fork 60
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
Fix the stack management for account procedures #783
Comments
To provide the above interface, one thing that could be done, is to use the same strategy as #701, and have the accounts procedures available to The user would initialize the memory with the callback addresses in the beginning of the transaction script, and then would |
I think a couple of things may be conflated here. A few comments:
We need to use
I'm not sure I follow this part. The referenced code should not leave any extra items on the stack (if it does, there is a bug somewhere). The call sequence looks something like this:
Flow between items 2 and 3 has been the source of quite a bit of confusion, and we should probably refactor it (as is described in #685) - but all of this is hidden from the user because |
This only works from inside the account context, as in |
hmmm - |
Or I guess you mean we have a procedure on the account which internally invokes |
Yes. We seem to agree on how it works. We don't seem to agree on how useful it is. Basically what I'm trying to say is this only works as a nice to use function if you're writing the account code. And there is very little use for that. The vast majority of the code will be note scripts or tx scripts. At least in my eyes, the most common case should be the easiest. So that would be making the so-called nice to use functions usable from the tx script. Account code is more complicated, we can't really hide the padding of the stack, because the function exposed by the account are |
I am not sure about the last point. Writing account procedures which internally call kernel procedures would be fairly common too. I can't say whether it will be more or less common then writing note/tx scripts - but in my mind they are roughly comparable in importance. I agree that there isn't much we can do with the procedures exposed by the account interface itself because they must be So, basically, my thinking is:
|
@bobbinth I think that everything you described was done by ABI PR. The procedures from the I think that this issue is not relevant anymore. |
AFAIU, the current code is organized as follows:
miden
lib is used to expose easy to use functions to users, e.g.:miden-base/miden-lib/asm/miden/account.masm
Lines 87 to 96 in dbe83c9
And internally this function manages the stack, such that the user won't lose its state:
miden-base/miden-lib/asm/miden/account.masm
Lines 96 to 101 in dbe83c9
kernel
library expects padded stack, since it can't return more than 16 elements, and it must overwrite some of the elements in the stack:miden-base/miden-lib/asm/kernels/transaction/api.masm
Lines 163 to 170 in dbe83c9
The above means the user would
exec.set_item
and have a nice to use API.However, for security,
set_account_item
must authenticate the origin of the call, e.g. to prevent a rogue note from changing the account's code. This means the function can not beexec
ed, and it must becall
ed instead.Now, because the
call
can return at most 16 elements in the stack, the code above that was suppose to provide a nice API is unusable, because it is pushing 3 elements to the stack which are never cleaned up:miden-base/miden-lib/asm/miden/account.masm
Lines 97 to 102 in dbe83c9
The text was updated successfully, but these errors were encountered: