osmosis icon indicating copy to clipboard operation
osmosis copied to clipboard

Define x/TokenFactory BeforeSend hook sentinel error

Open dalmirel opened this issue 3 years ago • 4 comments

The BeforeSend hook implementation returns an error gained from the smart contract execution and depends on the info provided with the SC implementation.

Artifacts:

  • osmosis/cosmos sdk fork at commit hash: 6fcd25f
  • Full Token Factory branch holding new features

Analysis summary:

https://github.com/osmosis-labs/osmosis/blob/f09305e60b5b23fec761ea14446ee33556313e69/x/tokenfactory/keeper/beforesend.go#L105-L110

Suggestion: Token factory module should ensure that the error returned from the module holds a unique error code, that will explain what happened.

  • Define a sentinel error that will hold information about the denomination triggering the hook
  • and wrap the error returned from the smart contract as well, in order to get the information about the reason - if provided in the smart contract (blocked from/to account address; the contract is frozen,...).

dalmirel avatar Sep 01 '22 22:09 dalmirel

Tagging audit collaboration team, to review issues as agreed. @ValarDragon @sunnya97

dalmirel avatar Sep 06 '22 00:09 dalmirel

Agreed, we should wrap these error types, and make more meaningful wrapping info to indicate this is the source

Nice point!

ValarDragon avatar Sep 07 '22 11:09 ValarDragon

hey @alexanderbez are you stabbing this rn? If not, I'd like to PR this change with the other audit items!

mattverse avatar Sep 26 '22 08:09 mattverse

hey @alexanderbez are you stabbing this rn? If not, I'd like to PR this change with the other audit items!

@mattverse go for it homie!

I'll be happy to review

alexanderbez avatar Sep 28 '22 16:09 alexanderbez