Skip to content

Commit

Permalink
refund only in finalize mode
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianElvis committed Oct 2, 2024
1 parent 2e07d93 commit b4d07e5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/e2e/configurer/chain/commands_btcstaking.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 3 additions & 1 deletion x/finality/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions x/finality/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b4d07e5

Please sign in to comment.