We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
func (k Keeper) consumeRuntimeGas(ctx sdk.Context, gas uint64) panics in function calls such as Sudo calls even though an error for this function is thrown
Sudo
For developers, this is unexpected behavior, especially when using a childCtx with a gas limit, expecting an error to be thrown.
It then required work around like the following from Juno with a recover()
recover()
// Execute contract, recover from panic func ExecuteContract(k wasmtypes.ContractOpsKeeper, childCtx sdk.Context, contractAddr sdk.AccAddress, msgBz []byte, err *error) { // Recover from panic, return error defer func() { if recoveryError := recover(); recoveryError != nil { // Determine error associated with panic if isOutofGas, msg := IsOutOfGasError(recoveryError); isOutofGas { *err = ErrOutOfGas.Wrapf("%s", msg) } else { *err = ErrContractExecutionPanic.Wrapf("%s", recoveryError) } } }() // Execute contract with sudo _, *err = k.Sudo(childCtx, contractAddr, msgBz) } // Check if error is out of gas error func IsOutOfGasError(err any) (bool, string) { switch e := err.(type) { case storetypes.ErrorOutOfGas: return true, e.Descriptor case storetypes.ErrorGasOverflow: return true, e.Descriptor default: return false, "" } }
This just seems wrong given Sudo already returns an error, so persist a Gas error up?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
func (k Keeper) consumeRuntimeGas(ctx sdk.Context, gas uint64) panics in function calls such as
Sudo
calls even though an error for this function is thrownFor developers, this is unexpected behavior, especially when using a childCtx with a gas limit, expecting an error to be thrown.
It then required work around like the following from Juno with a
recover()
This just seems wrong given Sudo already returns an error, so persist a Gas error up?
The text was updated successfully, but these errors were encountered: