CosmosContracts / juno

Open Source Platform for Interoperable Smart Contracts
Apache License 2.0
311 stars 172 forks source link

On the necessity of `AcceptedStargateQueries` in Juno #714

Open mikedotexe opened 1 year ago

mikedotexe commented 1 year ago

Background

I've been talking with some CosmWasm devs about what we want to build for upcoming hackathons. Some of the cutting-edge areas to explore involve having a smart contract be "self-aware" as well as aware of other contracts' details. I could see great value in having contracts have access to Stargate queries that return info about itself or other contracts.

For instance, ContractHistory could be a valuable query in the future. https://github.com/CosmWasm/wasmd/blob/a4548ba17526027ced9cfd3fe783c4d66831f9e4/proto/cosmwasm/wasm/v1/query.proto#L97-L104

Currently, to allow this query message, we'd need to add it to keepers.go in Juno to the whitelist, similar to what I did here: https://github.com/CosmosContracts/juno/pull/658/files

For context, I want to note that there's a history of caution around Stargate queries because of real non-determinism experienced by Juno from some jokester who halted the chain.

Here's a screenshot from this Discord message in the CosmWasm Discord.

Screen Shot 2023-06-15 at 10 16 13 AM

Seeing as it's been a comfortable period of time since we've seen a chain halt due to non-determinism from a CosmWasm query, and Confio has addressed the shortcoming by not allowing the specific error message to be returned (which was deemed to be the root cause if I'm reading this correctly) perhaps it's time we reconsider whether we need a shortlist of allowed Stargate queries anymore. It's possible this was a smart, cautionary move, but this guard may become vestigial at some point in maturity. The question is whether that time is now.

Before ending this section, I want to mention that at the time of this writing, the Cosmos ecosystem at large has not figured out the implementation details for account abstraction, though we're all excited for it. I believe besides the ContractHistory example earlier, some of the most important Stargate queries we'll need are around authz and feegrant queries. This is where the sauce is gon' happen.

Do we want to individually add Stargate queries for authz? Or can we do a blanket allowance for certain modules?

Suggested Design

I'd suggest we hold a conversation around if we need this AcceptedStargateQueries approach anymore.

Acceptance Criteria

A good, solid conversation where people feel empowered and understand one another. Purvis chapter 6 verse 66.

Timeliness

Let's build some dope shit at the hackathons coming up in a month. Would be really cool to join heads on a long-term and temporary solution so hackers can change the world in real-time in a few weeks.

Reecepbcups commented 1 year ago

I would like to enable all Stargate queries for contracts

I can work to get this into v16, though I need to write test for each query to ensure it does not halt.

I'm not sure if I can just do * somewhere or if I have to specify every message. May require some reflection hmm. will look into more

mikedotexe commented 1 year ago

Thank you @Reecepbcups! You're on it as usual. I've had multiple conversations with the good folks at Yieldmos, and we're realizing that querying for authz grants might be more important than other messages, in the event that it gets complicated to do the blanket approach 🙏🏼