Describe the Bug
Currently the prototype and staking precompiles doesn't return the expected values from a smart contract perspective in case of failure.
Example in the following snippet, look at the if execErr != nil statement:
case GetAllValidatorsMethodName:
var res []byte
execErr := stateDB.ExecuteNativeAction(contract.Address(), nil, func(ctx sdk.Context) error {
res, err = c.GetAllValidators(ctx, method)
return err
})
if execErr != nil {
return nil, err
}
return res, nil
Returning nil, err looks like an unexpected revert from another smart contract calling the precompile.
Instead of this, we should do return method.Outputs.Pack(SANE_ERROR_VALUE), where a sane error value is false, 0 or any values that applies.
Describe the Bug Currently the prototype and staking precompiles doesn't return the expected values from a smart contract perspective in case of failure.
Example in the following snippet, look at the
if execErr != nil
statement:Returning
nil, err
looks like an unexpected revert from another smart contract calling the precompile.Instead of this, we should do
return method.Outputs.Pack(SANE_ERROR_VALUE)
, where a sane error value isfalse
,0
or any values that applies.Affected precompiles: prototype, staking.