Skip to content

[Bug]: MsgGrantAllowance simulation is unprecise (0.45 -> 0.47 regression) #16020

Open
@webmaster128

Description

@webmaster128

Summary of Bug

I'm working on the ComsJS upgrade for testing against 0.47 backends. One existing test become unreliable for a gas multiplier of 1.3 (the default): A /cosmos.feegrant.v1beta1.MsgGrantAllowance.

The simulation passes but often the actual gas usage exceeds 1.3 * simulated gas. Until now, 1.3 has always been a reliable multiplier and is the default multiplier in CosmJS.

Logs of the test:

      ✗ works with feegrant granter (0.979 sec)
        - Error: Error when broadcasting tx F46373FB6B9D3589274729D71DB106AEF9C297AC0149B0DEE392ACE2134A61DF at height 57. Code: 11; Raw log: 
        github.com/cosmos/cosmos-sdk/baseapp.newOutOfGasRecoveryMiddleware.func1
                github.com/cosmos/[email protected]/baseapp/recovery.go:55
        github.com/cosmos/cosmos-sdk/baseapp.newRecoveryMiddleware.func1
                github.com/cosmos/[email protected]/baseapp/recovery.go:39
        github.com/cosmos/cosmos-sdk/baseapp.processRecovery
                github.com/cosmos/[email protected]/baseapp/recovery.go:28
        github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx.func1
                github.com/cosmos/[email protected]/baseapp/baseapp.go:630
        runtime.gopanic
                runtime/panic.go:890
        github.com/cosmos/cosmos-sdk/store/types.(*basicGasMeter).ConsumeGas
                github.com/cosmos/[email protected]/store/types/gas.go:116
        github.com/cosmos/cosmos-sdk/store/gaskv.(*Store).Set
                github.com/cosmos/[email protected]/store/gaskv/store.go:53
        github.com/cosmos/cosmos-sdk/x/feegrant/keeper.Keeper.GrantAllowance
                github.com/cosmos/[email protected]/x/feegrant/keeper/keeper.go:114
        github.com/cosmos/cosmos-sdk/x/feegrant/keeper.msgServer.GrantAllowance
                github.com/cosmos/[email protected]/x/feegrant/keeper/msg_server.go:50
        github.com/cosmos/cosmos-sdk/x/feegrant._Msg_GrantAllowance_Handler.func1
                github.com/cosmos/[email protected]/x/feegrant/tx.pb.go:351
        github.com/cosmos/cosmos-sdk/baseapp.(*MsgServiceRouter).RegisterService.func2.1
                github.com/cosmos/[email protected]/baseapp/msg_service_router.go:113
        github.com/cosmos/cosmos-sdk/x/feegrant._Msg_GrantAllowance_Handler
                github.com/cosmos/[email protected]/x/feegrant/tx.pb.go:353
        github.com/cosmos/cosmos-sdk/baseapp.(*MsgServiceRouter).RegisterService.func2
                github.com/cosmos/[email protected]/baseapp/msg_service_router.go:121
        github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runMsgs
                github.com/cosmos/[email protected]/baseapp/baseapp.go:789
        github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx
                github.com/cosmos/[email protected]/baseapp/baseapp.go:732
        github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).DeliverTx
                github.com/cosmos/[email protected]/baseapp/abci.go:408
        github.com/cometbft/cometbft/abci/client.(*localClient).DeliverTxAsync
                github.com/cometbft/[email protected]/abci/client/local_client.go:82
        github.com/cometbft/cometbft/proxy.(*appConnConsensus).DeliverTxAsync
                github.com/cometbft/[email protected]/proxy/app_conn.go:106
        github.com/cometbft/cometbft/state.execBlockOnProxyApp
                github.com/cometbft/[email protected]/state/execution.go:376
        github.com/cometbft/cometbft/state.(*BlockExecutor).ApplyBlock
                github.com/cometbft/[email protected]/state/execution.go:197
        github.com/cometbft/cometbft/consensus.(*State).finalizeCommit
                github.com/cometbft/[email protected]/consensus/state.go:1700
        github.com/cometbft/cometbft/consensus.(*State).tryFinalizeCommit
                github.com/cometbft/[email protected]/consensus/state.go:1609
        github.com/cometbft/cometbft/consensus.(*State).enterCommit.func1
                github.com/cometbft/[email protected]/consensus/state.go:1544
        github.com/cometbft/cometbft/consensus.(*State).enterCommit
                github.com/cometbft/[email protected]/consensus/state.go:1582
        github.com/cometbft/cometbft/consensus.(*State).addVote
                github.com/cometbft/[email protected]/consensus/state.go:2213
        github.com/cometbft/cometbft/consensus.(*State).tryAddVote
                github.com/cometbft/[email protected]/consensus/state.go:2002
        github.com/cometbft/cometbft/consensus.(*State).handleMsg
                github.com/cometbft/[email protected]/consensus/state.go:861
        github.com/cometbft/cometbft/consensus.(*State).receiveRoutine
                github.com/cometbft/[email protected]/consensus/state.go:788
        out of gas in location: WritePerByte; gasWanted: 53425, gasUsed: 56230: out of gas

where gasWanted is set to 1.3 times the simulated gas:

  • Estimated: 41096
  • gasWanted: 53425
  • gasUsed (at the time of error): 56230

When increasing the multiplier to 2, I get a succeeding transaction with:

  • Estimated: 41096
  • Gas used: 56230 (137%)

Version

0.47.2-lfg.1 from ghcr.io/cosmos/simapp

Steps to Reproduce

Create MsgGrantAllowance transaction with a multiplier of 1.3.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions