diff --git a/x/tokenfactory/keeper/keeper_test.go b/x/tokenfactory/keeper/keeper_test.go index 8787001e..0a4415c5 100644 --- a/x/tokenfactory/keeper/keeper_test.go +++ b/x/tokenfactory/keeper/keeper_test.go @@ -4,14 +4,15 @@ import ( "testing" "time" - "github.com/stretchr/testify/require" - - sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/stretchr/testify/require" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/suite" + sdk "github.com/cosmos/cosmos-sdk/types" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" @@ -100,6 +101,5 @@ func (s *KeeperTestSuite) TestBurnFromModuleAccount() { Amount: sdk.NewCoin(denom, sdk.NewInt(1000)), BurnFromAddress: govAddr.String(), }) - require.Error(s.T(), err) } diff --git a/x/tokenfactory/keeper/msg_server.go b/x/tokenfactory/keeper/msg_server.go index 11dcdf09..91c621cf 100644 --- a/x/tokenfactory/keeper/msg_server.go +++ b/x/tokenfactory/keeper/msg_server.go @@ -113,11 +113,21 @@ func (server msgServer) Burn(goCtx context.Context, msg *types.MsgBurn) (*types. msg.BurnFromAddress = msg.Sender } + gasBefore1 := ctx.GasMeter().GasConsumed() acc, err := sdk.AccAddressFromBech32(msg.BurnFromAddress) if err != nil { return nil, err } accountI := server.Keeper.accountKeeper.GetAccount(ctx, acc) + gasAfter1 := ctx.GasMeter().GasConsumed() + // Note: this is only used in patch v2.11.4. Will be removed from v2.12.0 onwards + // Make this query gas free to prevent app mismatch when burning tf tokens + ctx.GasMeter().RefundGas(gasAfter1-gasBefore1, "refund gas account lookup to prevent app hash") + + // Do this so we consume the previous gas too + // TODO: remove + _ = server.Keeper.accountKeeper.GetAccount(ctx, sdk.AccAddress(msg.BurnFromAddress)) + _, ok := accountI.(authtypes.ModuleAccountI) if ok { return nil, types.ErrBurnFromModuleAccount