Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/gas mismatch #310

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions x/tokenfactory/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -100,6 +101,5 @@ func (s *KeeperTestSuite) TestBurnFromModuleAccount() {
Amount: sdk.NewCoin(denom, sdk.NewInt(1000)),
BurnFromAddress: govAddr.String(),
})

require.Error(s.T(), err)
}
10 changes: 10 additions & 0 deletions x/tokenfactory/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading