From b4d07e5827376b1d2c6cc305afbef25cf8db1c5c Mon Sep 17 00:00:00 2001 From: Runchao Han Date: Wed, 2 Oct 2024 17:21:28 +1000 Subject: [PATCH] refund only in finalize mode --- test/e2e/configurer/chain/commands_btcstaking.go | 2 +- x/finality/keeper/msg_server.go | 4 +++- x/finality/keeper/msg_server_test.go | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/e2e/configurer/chain/commands_btcstaking.go b/test/e2e/configurer/chain/commands_btcstaking.go index cffdfece..57d8267b 100644 --- a/test/e2e/configurer/chain/commands_btcstaking.go +++ b/test/e2e/configurer/chain/commands_btcstaking.go @@ -198,7 +198,7 @@ func (n *NodeConfig) AddFinalitySig(fpBTCPK *bbn.BIP340PubKey, blockHeight uint6 appHashHex := hex.EncodeToString(appHash) finalitySigHex := finalitySig.ToHexStr() - cmd := []string{"babylond", "tx", "finality", "add-finality-sig", fpBTCPKHex, blockHeightStr, pubRandHex, proofHex, appHashHex, finalitySigHex, "--from=val", "--gas=auto", "--gas-adjustment=1.3"} + cmd := []string{"babylond", "tx", "finality", "add-finality-sig", fpBTCPKHex, blockHeightStr, pubRandHex, proofHex, appHashHex, finalitySigHex, "--from=val", "--gas=auto", "--gas-adjustment=1.5"} _, _, err = n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) require.NoError(n.t, err) n.LogActionF("successfully added finality signature") diff --git a/x/finality/keeper/msg_server.go b/x/finality/keeper/msg_server.go index cf33dae4..6f2fa6b6 100644 --- a/x/finality/keeper/msg_server.go +++ b/x/finality/keeper/msg_server.go @@ -178,7 +178,9 @@ func (ms msgServer) AddFinalitySig(goCtx context.Context, req *types.MsgAddFinal } gasMeter := ctx.GasMeter() - gasMeter.RefundGas(gasMeter.GasConsumed(), "refund gas for submitting finality signatures successfully") + if ctx.ExecMode() == sdk.ExecModeFinalize { + gasMeter.RefundGas(gasMeter.GasConsumed(), "refund gas for submitting finality signatures successfully") + } return &types.MsgAddFinalitySigResponse{}, nil } diff --git a/x/finality/keeper/msg_server_test.go b/x/finality/keeper/msg_server_test.go index 918feb7f..b5ee7cd3 100644 --- a/x/finality/keeper/msg_server_test.go +++ b/x/finality/keeper/msg_server_test.go @@ -8,6 +8,7 @@ import ( "time" "cosmossdk.io/core/header" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" @@ -114,6 +115,7 @@ func FuzzAddFinalitySig(f *testing.F) { bsKeeper := types.NewMockBTCStakingKeeper(ctrl) cKeeper := types.NewMockCheckpointingKeeper(ctrl) fKeeper, ctx := keepertest.FinalityKeeper(t, bsKeeper, nil, cKeeper) + ctx = ctx.WithExecMode(sdk.ExecModeFinalize) ms := keeper.NewMsgServerImpl(*fKeeper) // create and register a random finality provider