DA0-DA0 / dao-contracts

CosmWasm smart contracts for Interchain DAOs.
https://docs.daodao.zone
BSD 3-Clause "New" or "Revised" License
202 stars 133 forks source link

Proposal Module Message Limits #694

Open JakeHartnell opened 1 year ago

JakeHartnell commented 1 year ago

Currently, proposal modules that are enabled on a DAO can execute any message. This was a natural first step, but limitations on messages that can be executed via proposal modules can be very useful.

Polkadot's OpenGov has the notion of Origins and Tracks, the idea behind that you should have different governance processes and settings for different types of proposals (i.e. software upgrade should have a different process than treasury spend).

This can be sort of done today with proposal modules (and pre-propose modules), but what's missing is being able to scope the permissions for the type of message a proposal module is able to execute.

There are many forms these permissions might take, for example:

Obviously, this will need design. There are many in the wild examples to pull inspiration from including Authz.

Ideally as part of the create proposal flow, any messages should be validated to ensure the proposal module has permissions to execute them.

Some user stories for inspiration:

JakeHartnell commented 10 months ago

Strawman implementation idea... the first version can be very simple, the intention of this is not to recreate Authz but to build a better user experience around DAOs (i.e. I want a DAO that only does one thing).

We could make a dao-voting::msg_limits module that would handle valdiation logic and have some standardized types.

Limit the number of messages, specify an exact message, or specified allowed keys for generic CosmWasm smart contract calls.

#[cw_serde]
pub struct MsgLimit {
  /// Specify exact messages a DAO can execute
  /// If set to None only `count` will be used for validation
  allowed_msgs: Option<Vec<AllowedMsg>>,
  /// The number of messages that can be included in a prop?
  /// Must be greater than zero?
  count: u8
}

#[cw_serde]
pub enum AllowedMsg {
    /// An exact message to call, the message must match this message
    Exact(CosmosMsg),
    /// A generic smart contract message that only checks the method
    /// being called, allowing for the proposer to customize the contents /// of the message.
    GenericWasmExecuteMsg {
      /// The smart contract this message is intended for
      contract: Option<String>,
      /// Validation deserializes the binary and checks key matches
      key: String,
      /// Specify funds a DAO proposal can't exceed
      funds: Option<Vec<Coin>>,
    }
}

Validation:

Questions:

JakeHartnell commented 4 months ago

Might also be cool to add a custom validation hook, which could be a separate smart contract that does custom validation.