Fix progressively increasing gas usage #146

Merged
ashwin merged 4 commits from deep-stack/laconicd-deprecated:pm-registry-hot-fix into main 2024-04-03 12:14:50 +00:00
Showing only changes of commit 4531d9238f - Show all commits

View File

@ -3,6 +3,8 @@ package keeper
import ( import (
"context" "context"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cerc-io/laconicd/x/registry/types" "github.com/cerc-io/laconicd/x/registry/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
) )
@ -20,6 +22,8 @@ var _ types.MsgServer = msgServer{}
func (m msgServer) SetRecord(c context.Context, msg *types.MsgSetRecord) (*types.MsgSetRecordResponse, error) { func (m msgServer) SetRecord(c context.Context, msg *types.MsgSetRecord) (*types.MsgSetRecordResponse, error) {
ctx := sdk.UnwrapSDKContext(c) ctx := sdk.UnwrapSDKContext(c)
ctx = *m.ctxWithCustomKVGasConfig(&ctx)
_, err := sdk.AccAddressFromBech32(msg.Signer) _, err := sdk.AccAddressFromBech32(msg.Signer)
if err != nil { if err != nil {
return nil, err return nil, err
@ -284,3 +288,16 @@ func (m msgServer) ReAssociateRecords(c context.Context, msg *types.MsgReAssocia
}) })
return &types.MsgReAssociateRecordsResponse{}, nil return &types.MsgReAssociateRecordsResponse{}, nil
} }
func (m msgServer) ctxWithCustomKVGasConfig(ctx *sdk.Context) *sdk.Context {
updatedCtx := ctx.WithKVGasConfig(storetypes.GasConfig{
HasCost: 0,
DeleteCost: 0,
ReadCostFlat: 0,
ReadCostPerByte: 0,
WriteCostFlat: 0,
WriteCostPerByte: 0,
IterNextCostFlat: 0,
})
return &updatedCtx
}