-
Notifications
You must be signed in to change notification settings - Fork 389
Description
When we make a submessage, we can handle both success and errors from the released message. However, this comes at a cost of paying the instantiation gas cost of the original module for each submessage.
For some use cases, eg. mapping errors in #762, we only want to handle if an error arises, and don't care about the return values. Since we assume errors are not the normal case, we add a lot of gas overhead to all the callbacks we ignore. It would be more efficient to be able to filter these out in Go, and just get callbacks on error if that is what we want.
In particular, I want to extend SubMsg with one more field:
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct SubMsg<T = Empty>
where
T: Clone + fmt::Debug + PartialEq + JsonSchema,
{
pub id: u64,
pub msg: CosmosMsg<T>,
pub gas_limit: Option<u64>,
pub only_error: Option<bool>,
}If only_error is set to true, then we only make the response callback if there was an error (incl running out of gas), otherwise, just handle it like a message.
I made only_error as an Option because I feel it is usually unset and we can make the normal JSON smaller (and use less gas) by simply omitting the field. Some(true) may be a bit wordy, but None and false are the same, which is the typical case. (I can change it to just bool if there is disagreement)