Skip to content

app/ante/evm: checkValidFrom looks suspiciously wrong; could use better naming with purpose of helper function, use AccAddress.Empty() method #2416

@odeke-em

Description

@odeke-em

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

Auditing this code I saw

func checkValidFrom(
from sdktypes.AccAddress,
) error {
// Validate `From` field
if from != nil {
return errorsmod.Wrapf(errortypes.ErrInvalidRequest, "invalid from address %s, expect empty string", from)
}
return nil

which looks like it just ensures that it returns an error if the from address is non-empty, but:

  • checkValidFrom is misleading because it is the opposite of an expectation of a from address (you'd expect that it would valid that the address was set) but it inverts the purpose hence it could be named "ensureFromIsEmpty"
  • that code just checks that from is non-nil then returns an error but what happens if one just passed in an empty sdktypes.AccAddress{}? I believe the actual check should be: if !from.Empty()

/cc @fedekunze

Evmos Version

main

How to reproduce?

Please read the bug report above

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions