Skip to content

[Bug] x/precisebank tests fail with block-stm enabled #852

@cloudgray

Description

@cloudgray

Problem

x/precisebank tests fail with block-stm enabled

Problem Details

When Block-STM is enabled while the precisebank module is registered in the app,
the precisebank tests fail as shown below.

panic: test timed out after 30s
	running tests:
		TestPreciseBankKeeper (30s)
		TestPreciseBankKeeper/TestSendEvmTxRandomValueMultiDecimals (17s)
		TestPreciseBankKeeper/TestSendEvmTxRandomValueMultiDecimals/12_decimals (17s)

// ...

1. Bank interface implementation

Although I have not yet identified all root causes,
one of the clear causes is that the Block-STM–related bank keeper interfaces are implemented incorrectly.

As you can see in the methods below, logic for decimals conversion (e.g., 6 → 18), denom replacement (denom → extended denom), Fractional balance / Remaning change logic are missing.

// BANK KEEPER INTERFACE PASSTHROUGHS
func (k Keeper) SendCoinsFromModuleToAccountVirtual(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error {
	return k.bk.SendCoinsFromModuleToAccountVirtual(ctx, senderModule, recipientAddr, amt)
}

func (k Keeper) SendCoinsFromAccountToModuleVirtual(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error {
	return k.bk.SendCoinsFromAccountToModuleVirtual(ctx, senderAddr, recipientModule, amt)
}

func (k Keeper) IterateTotalSupply(ctx context.Context, cb func(coin sdk.Coin) bool) {
	k.bk.IterateTotalSupply(ctx, cb)
}

func (k Keeper) GetSupply(ctx context.Context, denom string) sdk.Coin {
	return k.bk.GetSupply(ctx, denom)
}

2. Fee Deduction

As-Is (DeductFees)

	if du.Denom == evmCoinInfo.DisplayDenom && du.Exponent != types.EighteenDecimals().Uint32() {

To-Be

	if du.Denom == evmCoinInfo.DisplayDenom && du.Exponent != types.GetEVMCoinDecimals().Uint32() {

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