Skip to content

[Bug]: precompile/common.AfterBalanceChange panics on addresses that are not 20-bytes long #272

@Pitasi

Description

@Pitasi

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

I have a precompile that moves funds from users to "system" accounts used as escrow.

The addresses generated for these escrow accounts are made like this:

func (k *Keychain) AccAddress() sdk.AccAddress {
	bz := make([]byte, 8)
	binary.BigEndian.PutUint64(bz, k.Id)
	addr := append([]byte("keychain-"), bz...)

	return addr
}

For example, they look like this: warden1ddjhjcmgv95kutgqqqqqqqqqqqqs5sgg2s

The newly introduced call to AfterBalanceChange(...) for the precompile revert logic, tries to parse all addresses that sent or received tokens as 20-bytes long byte arrays here:

return common.Address(accAddr.Bytes()), nil

This lead to a panic in my particular use case:

runtime error: cannot convert slice with length 17 to array or pointer to array with length 20

My question is:

  • should I change my logic? Is it a bad practice to have these custom addresses and working with the EVM?
  • or, is there a way to fix AfterBalanceChange?

Cosmos EVM Version

main

How to reproduce?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions