Skip to content
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

the compiler allows you to create getters with arguments (tuple in my issue) that cannot be used on the stack #778

Open
1 task done
tamerland05 opened this issue Sep 2, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@tamerland05
Copy link

Are you using the latest released (or pre-released, a.k.a. "next") version?

  • I'm using the latest Tact version

Tact source code

No response

Relevant Tact/build system log output

No response

What happened?

the compiler allows you to create getters that take the message type as arguments (https://github.com/Architec-Ton/Architecton-p2p/blob/bf547222/contracts/order/router.tact ) compiled in func as a tuple type, which in turn is not supported in the stack structure: "Unsupported stack item type: tuple" (https://github.com/ton-org/ton/blob/09cef89fe7eca49c7e9d1dd4347dcde1a29d09e2/src/client/api/HttpApi.ts#L132)

What did you expect?

it seems that when trying to build a contract with a getter accepting a message, a compilation error should occur, however, it did not happen.

Steps to reproduce

https://github.com/Architec-Ton/Architecton-p2p/blob/bf547222 - try to
npx blueprint build Router and call await Router.from...(...).getCalculateOrder(provider.provider(provider.sender().address!), {
$$type: 'InitData',
seller: provider.sender().address!,
nonce: BigInt(Date.now())
})
you get:
image

How do you run Tact?

Blueprint

Anything else?

No response

@tamerland05 tamerland05 added the bug Something isn't working label Sep 2, 2024
@anton-trunov
Copy link
Member

@tamerland05 Thank you for raising the issue. I checked the compiler code and it looks fine. I also added two more tests for the cases when a message is passed as a parameter to a getter and to an init() and it also works fine. You can check the testing PR here: #792.

when trying to build a contract with a getter accepting a message, a compilation error should occur, however, it did not happen.

so this does not look as a valid assumption to me

Could you perhaps try reproducing it locally using Sandbox tests as I tried with #792?

@tamerland05
Copy link
Author

well, in the case that you have emulated, the methods from the tact code when compiled into func had the argumet type (cell, int), however, in my case https://github.com/tamerland05/CheckMessageInGetter/blob/main/build/Getters/tact_Test.code.fc#L140 the SetIdAndData type, the same as yours, is compiled into tuple, which is no longer supported by the tvm stack, I don't know why this happens, but perhaps this is due to the fact that I put SetIdAndData in the init of the contract. The tests work, but as far as I looked at the sanbox code, it does not fully emulate the behavior of tvm, at least in get methods. However, the error is clearly visible when I deploy the contract to the testnet and try to call this get method:
image

It would be great if you would clone the repository and try to run the getters yourself, even on my contract EQA064UrLu0seP_n6TgA7nIoPIMy8K0_8rnYaAREJ4JMFpgy, even on your own pre-installed (just take other init values) and see this error yourself, however, the bug investigation should probably be stopped even when tuple appears in the func code

@anton-trunov
Copy link
Member

tuple, which is no longer supported by the tvm stack

Tuples are supported by TVM, it's one of the native types of TVM

@tamerland05
Copy link
Author

hmm, then maybe this bug is related to the fact that @ton does not support tuple for sending, because the error clearly says so

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants