-
Notifications
You must be signed in to change notification settings - Fork 411
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
Save contract info before calling instantiate entrypoint #2044
Comments
There is one scenario I'd consider before implementing this. What would happen if the contract query itself from the |
Contract address is already here: {
"data": {
"value": "Generic error: Querier system error: No such contract: wasm1nc5tatafv6eyq7llkr2gv50ff9e22mnf70qgjlv737ktmt4eswrqr5j2ht"
}
} I guess it works totally fine, and in my opinion this functionality should stay as it is. Instantiate entry-point may always return an error, so there is no reason to use its address to interact in any ways with the blockchain, also querying the contract_code_info should fail as it is now. We should just align the MT behaviour. As I understand the original request, the problem is, that MT behaviour differs from wasmd, and not that wasmd should provide contract code info inside the instantiate function (for some strange reason). So I suggest to do changes in MT not in wasmd. |
Additionally, in my opinion, during the instantiation, the code_id is useless for the contract. One can store the same code multiple times and instantiate logically the same smart contract based on different code_id. I can not imagine a use case where checking the value of code_id inside instantiate may be useful in any ways. But I may be wrong... |
Thank you for contacting me off-github to talk about that issue. We indeed have a use-case, where we need this feature.
We are fine with which-ever, but we would prefer a non-breaking wasmd patch to be able to have that quickly out there. Use CaseAs discussed, here is my use-case (actual Abstract use-case ). Inside the instantiation of our This was introduced because we have storage constraints on the chain we target that don't allow us to store too much address per abstract account Thank you ! |
Did some tests on the node using newest let contract_addr = env.contract.address;
deps.querier.query_wasm_contract_info(contract_addr); inside let code_id = 1u64;
deps.querier.query_wasm_code_info(code_id); inside |
Thanks for looking into that, Darek. |
Thanks for those experimentations. TL;DR: I think querying the contract inside instantiate doesn't have to fail |
Yes, that's true, but I think it feels a bit weird that you would be able to query the contract before it is instantiated. Technically there cannot come much "harm" from that, but seems a bit inconsistent. |
Current behaviour
The instantiate entrypoint is called before the contract info is stored.
This results in an error occuring if the contract tries to query that info inside the instantiate entrypoint.
Expected behaviour
We should probably call the entrypoint after saving the info. That should make the data available to query inside the instantiate entrypoint. To me, it doesn't look like there is any specific reason for the current order and it is confusing and a somewhat inconsistent1.
We should just make sure that it gets reverted if the instantiate entrypoint errors. I think that should be the case automatically when returning an error, but a test for that would be good.
Footnotes
See https://github.com/CosmWasm/cw-multi-test/issues/226 and https://discord.com/channels/737637324434833438/737643344712171600/1303704162298630186 ↩
The text was updated successfully, but these errors were encountered: