hackbg / fadroma

Magical flying bulldozer for the Cosmosverse. Contains clients for Tendermint-based chains in various degrees of completeness, and a mini build system for deploying systems of multiple interdependent smart contracts from source.
https://fadroma.tech
GNU Affero General Public License v3.0
51 stars 15 forks source link

Ensemble: Replies do not correctly overwrite the caller data if they return Some. #182

Open luca992 opened 1 year ago

luca992 commented 1 year ago

I have a fairly complex operation which when I execute it in Contract A, will instantiate two Contracts B & C. Contract C relies on B. So Contract A will wait for the reply of the Contract B instantiation. Then from the reply it will launch another submessage to instantiate Contract C. Contract A then waits for the reply of Contract C. Finally Contract A will return a response after Contract C replies with the addresses of both Contract B & C.

The data set by Contract A from the final reply from Contract C is not being returned in the response in Ensemble:

Screenshot 2023-06-26 at 8 39 23 PM

It is picking the wrong index and setting the data of state[1] when I think it should be overwriting the data in state[0]

egasimus commented 1 year ago

Acknowledged, thank you for your report. Will investigate

egasimus commented 1 year ago

Hi @luca992, so I think I've reproduced the issue on the fix/182 branch (test case), and I've been trying to track down where exactly it's caused.

My expectation is that the addresses of contracts B and C automatically appear as attributes on the final response (from contract A to caller), and indeed neither attributes nor events from the inter-contract responses are being propagated to the final response.

Can you confirm that this is also what you expect to see? Why would they appear in data?

(In the meantime, I've also updated the Fadroma repo so that it isn't a Cargo workspace anymore. Since Cargo doesn't support nested workspaces, this change should make it easier to include the Fadroma crates as path dependencies, should you at any point decide to debug something with a local checkout of the Fadroma source.)

egasimus commented 1 year ago

Can you confirm that this is also what you expect to see? Why would they appear in data?

@luca992 can you confirm that the above is still an issue?

luca992 commented 1 year ago

Can you confirm that this is also what you expect to see? Why would they appear in data?

@luca992 can you confirm that the above is still an issue?

Yeah sorry forgot to check. I'll try it out this weekend

egasimus commented 1 year ago

@luca992 Any news? Your message on TG from a couple weeks ago suggested that this is not a bug, but expected behavior of Secret Network that has been correctly replicated in Fadroma Ensemble.

luca992 commented 1 year ago

@egasimus sorry, I forgot to try it out again the other week. Just pulled that branch, unfortunately it seems to be the same. The data is still not being returned.

And that behavior is not what I'm referring to here. After the chain of submessages I send as described above, the data I am setting that is returned in the result of last time reply is called is not being returned. This doesn't happen on chain, which returns the data as expected.

Eventually if you need I could make a test case for you. But I have a lot going on right now.