From 4531d9238f2076099f4c92352f2e6afa2590f5eb Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 3 Apr 2024 10:09:02 +0530 Subject: [PATCH 1/4] Use custom KV store gas config for set record operation --- x/registry/keeper/msg_server.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/x/registry/keeper/msg_server.go b/x/registry/keeper/msg_server.go index 9a16463c..647e3354 100644 --- a/x/registry/keeper/msg_server.go +++ b/x/registry/keeper/msg_server.go @@ -3,6 +3,8 @@ package keeper import ( "context" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cerc-io/laconicd/x/registry/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) { ctx := sdk.UnwrapSDKContext(c) + ctx = *m.ctxWithCustomKVGasConfig(&ctx) + _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return nil, err @@ -284,3 +288,16 @@ func (m msgServer) ReAssociateRecords(c context.Context, msg *types.MsgReAssocia }) 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 +} -- 2.45.1 From ea30697b509be4371d41682c00223cebb054f206 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 3 Apr 2024 11:44:03 +0530 Subject: [PATCH 2/4] Use custom KV store gas config for all laconic txs --- utils/context.go | 20 +++++++++++++++++ x/auction/keeper/msg_server.go | 6 ++++- x/bond/keeper/msg_server.go | 12 +++++++++- x/registry/keeper/msg_server.go | 39 +++++++++++++++++++-------------- 4 files changed, 58 insertions(+), 19 deletions(-) create mode 100644 utils/context.go diff --git a/utils/context.go b/utils/context.go new file mode 100644 index 00000000..f7393662 --- /dev/null +++ b/utils/context.go @@ -0,0 +1,20 @@ +package utils + +import ( + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func 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 +} diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go index 75a97ab6..08fa8755 100644 --- a/x/auction/keeper/msg_server.go +++ b/x/auction/keeper/msg_server.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cerc-io/laconicd/utils" "github.com/cerc-io/laconicd/x/auction/types" ) @@ -20,6 +21,7 @@ var _ types.MsgServer = msgServer{} func (s msgServer) CreateAuction(c context.Context, msg *types.MsgCreateAuction) (*types.MsgCreateAuctionResponse, error) { ctx := sdk.UnwrapSDKContext(c) + ctx = *utils.CtxWithCustomKVGasConfig(&ctx) signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { @@ -53,6 +55,7 @@ func (s msgServer) CreateAuction(c context.Context, msg *types.MsgCreateAuction) //nolint: all func (s msgServer) CommitBid(c context.Context, msg *types.MsgCommitBid) (*types.MsgCommitBidResponse, error) { ctx := sdk.UnwrapSDKContext(c) + ctx = *utils.CtxWithCustomKVGasConfig(&ctx) signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { @@ -80,10 +83,11 @@ func (s msgServer) CommitBid(c context.Context, msg *types.MsgCommitBid) (*types return &types.MsgCommitBidResponse{Bid: resp}, nil } -//RevealBid is the command for revealing a bid +// RevealBid is the command for revealing a bid //nolint: all func (s msgServer) RevealBid(c context.Context, msg *types.MsgRevealBid) (*types.MsgRevealBidResponse, error) { ctx := sdk.UnwrapSDKContext(c) + ctx = *utils.CtxWithCustomKVGasConfig(&ctx) signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { diff --git a/x/bond/keeper/msg_server.go b/x/bond/keeper/msg_server.go index 7db7394f..cc197237 100644 --- a/x/bond/keeper/msg_server.go +++ b/x/bond/keeper/msg_server.go @@ -3,8 +3,10 @@ package keeper import ( "context" - "github.com/cerc-io/laconicd/x/bond/types" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cerc-io/laconicd/utils" + "github.com/cerc-io/laconicd/x/bond/types" ) type msgServer struct { @@ -20,6 +22,8 @@ var _ types.MsgServer = msgServer{} func (k msgServer) CreateBond(c context.Context, msg *types.MsgCreateBond) (*types.MsgCreateBondResponse, error) { ctx := sdk.UnwrapSDKContext(c) + ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return nil, err @@ -48,6 +52,8 @@ func (k msgServer) CreateBond(c context.Context, msg *types.MsgCreateBond) (*typ //nolint: all func (k msgServer) RefillBond(c context.Context, msg *types.MsgRefillBond) (*types.MsgRefillBondResponse, error) { ctx := sdk.UnwrapSDKContext(c) + ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return nil, err @@ -78,6 +84,8 @@ func (k msgServer) RefillBond(c context.Context, msg *types.MsgRefillBond) (*typ //nolint: all func (k msgServer) WithdrawBond(c context.Context, msg *types.MsgWithdrawBond) (*types.MsgWithdrawBondResponse, error) { ctx := sdk.UnwrapSDKContext(c) + ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return nil, err @@ -107,6 +115,8 @@ func (k msgServer) WithdrawBond(c context.Context, msg *types.MsgWithdrawBond) ( func (k msgServer) CancelBond(c context.Context, msg *types.MsgCancelBond) (*types.MsgCancelBondResponse, error) { ctx := sdk.UnwrapSDKContext(c) + ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return nil, err diff --git a/x/registry/keeper/msg_server.go b/x/registry/keeper/msg_server.go index 647e3354..7f695ee8 100644 --- a/x/registry/keeper/msg_server.go +++ b/x/registry/keeper/msg_server.go @@ -3,10 +3,10 @@ package keeper import ( "context" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - - "github.com/cerc-io/laconicd/x/registry/types" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cerc-io/laconicd/utils" + "github.com/cerc-io/laconicd/x/registry/types" ) type msgServer struct { @@ -22,7 +22,7 @@ var _ types.MsgServer = msgServer{} func (m msgServer) SetRecord(c context.Context, msg *types.MsgSetRecord) (*types.MsgSetRecordResponse, error) { ctx := sdk.UnwrapSDKContext(c) - ctx = *m.ctxWithCustomKVGasConfig(&ctx) + ctx = *utils.CtxWithCustomKVGasConfig(&ctx) _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { @@ -54,6 +54,8 @@ func (m msgServer) SetRecord(c context.Context, msg *types.MsgSetRecord) (*types //nolint: all func (m msgServer) SetName(c context.Context, msg *types.MsgSetName) (*types.MsgSetNameResponse, error) { ctx := sdk.UnwrapSDKContext(c) + ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return nil, err @@ -80,6 +82,8 @@ func (m msgServer) SetName(c context.Context, msg *types.MsgSetName) (*types.Msg func (m msgServer) ReserveName(c context.Context, msg *types.MsgReserveAuthority) (*types.MsgReserveAuthorityResponse, error) { ctx := sdk.UnwrapSDKContext(c) + ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return nil, err @@ -111,6 +115,8 @@ func (m msgServer) ReserveName(c context.Context, msg *types.MsgReserveAuthority //nolint: all func (m msgServer) SetAuthorityBond(c context.Context, msg *types.MsgSetAuthorityBond) (*types.MsgSetAuthorityBondResponse, error) { ctx := sdk.UnwrapSDKContext(c) + ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return nil, err @@ -137,6 +143,8 @@ func (m msgServer) SetAuthorityBond(c context.Context, msg *types.MsgSetAuthorit func (m msgServer) DeleteName(c context.Context, msg *types.MsgDeleteNameAuthority) (*types.MsgDeleteNameAuthorityResponse, error) { ctx := sdk.UnwrapSDKContext(c) + ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return nil, err @@ -162,6 +170,8 @@ func (m msgServer) DeleteName(c context.Context, msg *types.MsgDeleteNameAuthori func (m msgServer) RenewRecord(c context.Context, msg *types.MsgRenewRecord) (*types.MsgRenewRecordResponse, error) { ctx := sdk.UnwrapSDKContext(c) + ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return nil, err @@ -188,6 +198,8 @@ func (m msgServer) RenewRecord(c context.Context, msg *types.MsgRenewRecord) (*t //nolint: all func (m msgServer) AssociateBond(c context.Context, msg *types.MsgAssociateBond) (*types.MsgAssociateBondResponse, error) { ctx := sdk.UnwrapSDKContext(c) + ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return nil, err @@ -215,6 +227,8 @@ func (m msgServer) AssociateBond(c context.Context, msg *types.MsgAssociateBond) func (m msgServer) DissociateBond(c context.Context, msg *types.MsgDissociateBond) (*types.MsgDissociateBondResponse, error) { ctx := sdk.UnwrapSDKContext(c) + ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return nil, err @@ -240,6 +254,8 @@ func (m msgServer) DissociateBond(c context.Context, msg *types.MsgDissociateBon func (m msgServer) DissociateRecords(c context.Context, msg *types.MsgDissociateRecords) (*types.MsgDissociateRecordsResponse, error) { ctx := sdk.UnwrapSDKContext(c) + ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return nil, err @@ -265,6 +281,8 @@ func (m msgServer) DissociateRecords(c context.Context, msg *types.MsgDissociate func (m msgServer) ReAssociateRecords(c context.Context, msg *types.MsgReAssociateRecords) (*types.MsgReAssociateRecordsResponse, error) { //nolint: all ctx := sdk.UnwrapSDKContext(c) + ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return nil, err @@ -288,16 +306,3 @@ func (m msgServer) ReAssociateRecords(c context.Context, msg *types.MsgReAssocia }) 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 -} -- 2.45.1 From 25c438aa373467c5e66e312c35ae95dc73ac8f31 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 3 Apr 2024 14:10:05 +0530 Subject: [PATCH 3/4] Log gas consumed for laconic txs --- x/auction/keeper/keeper.go | 6 ++++++ x/auction/keeper/msg_server.go | 12 +++++++++++ x/bond/keeper/keeper.go | 6 ++++++ x/bond/keeper/msg_server.go | 14 +++++++++++++ x/registry/keeper/msg_server.go | 35 +++++++++++++++++++++++++++++++++ 5 files changed, 73 insertions(+) diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index c8774e9d..6f09d563 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -15,6 +15,7 @@ import ( auth "github.com/cosmos/cosmos-sdk/x/auth/keeper" bank "github.com/cosmos/cosmos-sdk/x/bank/keeper" params "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/tendermint/tendermint/libs/log" wnsUtils "github.com/cerc-io/laconicd/utils" ) @@ -78,6 +79,11 @@ func NewKeeper(accountKeeper auth.AccountKeeper, } } +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", types.ModuleName) +} + func (k *Keeper) SetUsageKeepers(usageKeepers []types.AuctionUsageKeeper) { k.usageKeepers = usageKeepers } diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go index 08fa8755..e2ef1ae8 100644 --- a/x/auction/keeper/msg_server.go +++ b/x/auction/keeper/msg_server.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "fmt" sdk "github.com/cosmos/cosmos-sdk/types" @@ -48,6 +49,8 @@ func (s msgServer) CreateAuction(c context.Context, msg *types.MsgCreateAuction) ), }) + s.logTxGasConsumed(ctx, "CreateAuction") + return &types.MsgCreateAuctionResponse{Auction: resp}, nil } @@ -80,6 +83,8 @@ func (s msgServer) CommitBid(c context.Context, msg *types.MsgCommitBid) (*types ), }) + s.logTxGasConsumed(ctx, "CommitBid") + return &types.MsgCommitBidResponse{Bid: resp}, nil } @@ -112,5 +117,12 @@ func (s msgServer) RevealBid(c context.Context, msg *types.MsgRevealBid) (*types ), }) + s.logTxGasConsumed(ctx, "RevealBid") + return &types.MsgRevealBidResponse{Auction: resp}, nil } + +func (m msgServer) logTxGasConsumed(ctx sdk.Context, tx string) { + gasConsumed := ctx.GasMeter().GasConsumed() + m.Keeper.Logger(ctx).Info("tx executed", "method", tx, "gas_consumed", fmt.Sprintf("%d", gasConsumed)) +} diff --git a/x/bond/keeper/keeper.go b/x/bond/keeper/keeper.go index 044b890e..1d518967 100644 --- a/x/bond/keeper/keeper.go +++ b/x/bond/keeper/keeper.go @@ -14,6 +14,7 @@ import ( auth "github.com/cosmos/cosmos-sdk/x/auth/keeper" bank "github.com/cosmos/cosmos-sdk/x/bank/keeper" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/tendermint/tendermint/libs/log" ) // prefixIDToBondIndex is the prefix for ID -> Bond index in the KVStore. @@ -62,6 +63,11 @@ func NewKeeper(cdc codec.BinaryCodec, } } +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", types.ModuleName) +} + // Generates Bond ID -> Bond index key. func getBondIndexKey(id string) []byte { return append(prefixIDToBondIndex, []byte(id)...) diff --git a/x/bond/keeper/msg_server.go b/x/bond/keeper/msg_server.go index cc197237..8d33893d 100644 --- a/x/bond/keeper/msg_server.go +++ b/x/bond/keeper/msg_server.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "fmt" sdk "github.com/cosmos/cosmos-sdk/types" @@ -46,6 +47,8 @@ func (k msgServer) CreateBond(c context.Context, msg *types.MsgCreateBond) (*typ ), }) + k.logTxGasConsumed(ctx, "CreateBond") + return &types.MsgCreateBondResponse{}, nil } @@ -78,6 +81,8 @@ func (k msgServer) RefillBond(c context.Context, msg *types.MsgRefillBond) (*typ ), }) + k.logTxGasConsumed(ctx, "RefillBond") + return &types.MsgRefillBondResponse{}, nil } @@ -110,6 +115,8 @@ func (k msgServer) WithdrawBond(c context.Context, msg *types.MsgWithdrawBond) ( ), }) + k.logTxGasConsumed(ctx, "WithdrawBond") + return &types.MsgWithdrawBondResponse{}, nil } @@ -139,5 +146,12 @@ func (k msgServer) CancelBond(c context.Context, msg *types.MsgCancelBond) (*typ ), }) + k.logTxGasConsumed(ctx, "CancelBond") + return &types.MsgCancelBondResponse{}, nil } + +func (m msgServer) logTxGasConsumed(ctx sdk.Context, tx string) { + gasConsumed := ctx.GasMeter().GasConsumed() + m.Keeper.Logger(ctx).Info("tx executed", "method", tx, "gas_consumed", fmt.Sprintf("%d", gasConsumed)) +} diff --git a/x/registry/keeper/msg_server.go b/x/registry/keeper/msg_server.go index 7f695ee8..542cae18 100644 --- a/x/registry/keeper/msg_server.go +++ b/x/registry/keeper/msg_server.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "fmt" sdk "github.com/cosmos/cosmos-sdk/types" @@ -48,6 +49,8 @@ func (m msgServer) SetRecord(c context.Context, msg *types.MsgSetRecord) (*types ), }) + m.logTxGasConsumed(ctx, "SetRecord") + return &types.MsgSetRecordResponse{Id: record.ID}, nil } @@ -77,6 +80,9 @@ func (m msgServer) SetName(c context.Context, msg *types.MsgSetName) (*types.Msg sdk.NewAttribute(types.AttributeKeySigner, msg.Signer), ), }) + + m.logTxGasConsumed(ctx, "SetName") + return &types.MsgSetNameResponse{}, nil } @@ -109,6 +115,9 @@ func (m msgServer) ReserveName(c context.Context, msg *types.MsgReserveAuthority sdk.NewAttribute(types.AttributeKeySigner, msg.Signer), ), }) + + m.logTxGasConsumed(ctx, "ReserveName") + return &types.MsgReserveAuthorityResponse{}, nil } @@ -138,6 +147,9 @@ func (m msgServer) SetAuthorityBond(c context.Context, msg *types.MsgSetAuthorit sdk.NewAttribute(types.AttributeKeySigner, msg.Signer), ), }) + + m.logTxGasConsumed(ctx, "SetAuthorityBond") + return &types.MsgSetAuthorityBondResponse{}, nil } @@ -165,6 +177,9 @@ func (m msgServer) DeleteName(c context.Context, msg *types.MsgDeleteNameAuthori sdk.NewAttribute(types.AttributeKeySigner, msg.Signer), ), }) + + m.logTxGasConsumed(ctx, "DeleteName") + return &types.MsgDeleteNameAuthorityResponse{}, nil } @@ -192,6 +207,9 @@ func (m msgServer) RenewRecord(c context.Context, msg *types.MsgRenewRecord) (*t sdk.NewAttribute(types.AttributeKeySigner, msg.Signer), ), }) + + m.logTxGasConsumed(ctx, "RenewRecord") + return &types.MsgRenewRecordResponse{}, nil } @@ -222,6 +240,9 @@ func (m msgServer) AssociateBond(c context.Context, msg *types.MsgAssociateBond) sdk.NewAttribute(types.AttributeKeySigner, msg.Signer), ), }) + + m.logTxGasConsumed(ctx, "AssociateBond") + return &types.MsgAssociateBondResponse{}, nil } @@ -249,6 +270,9 @@ func (m msgServer) DissociateBond(c context.Context, msg *types.MsgDissociateBon sdk.NewAttribute(types.AttributeKeySigner, msg.Signer), ), }) + + m.logTxGasConsumed(ctx, "DissociateBond") + return &types.MsgDissociateBondResponse{}, nil } @@ -276,6 +300,9 @@ func (m msgServer) DissociateRecords(c context.Context, msg *types.MsgDissociate sdk.NewAttribute(types.AttributeKeySigner, msg.Signer), ), }) + + m.logTxGasConsumed(ctx, "DissociateRecords") + return &types.MsgDissociateRecordsResponse{}, nil } @@ -304,5 +331,13 @@ func (m msgServer) ReAssociateRecords(c context.Context, msg *types.MsgReAssocia sdk.NewAttribute(types.AttributeKeySigner, msg.Signer), ), }) + + m.logTxGasConsumed(ctx, "ReAssociateRecords") + return &types.MsgReAssociateRecordsResponse{}, nil } + +func (m msgServer) logTxGasConsumed(ctx sdk.Context, tx string) { + gasConsumed := ctx.GasMeter().GasConsumed() + m.Keeper.Logger(ctx).Info("tx executed", "method", tx, "gas_consumed", fmt.Sprintf("%d", gasConsumed)) +} -- 2.45.1 From 21675b45744fdc0d4358fd8bcf0f67d0a2ec8423 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 3 Apr 2024 14:39:59 +0530 Subject: [PATCH 4/4] Handle lint errors --- .golangci.yml | 1 - Makefile | 2 +- rpc/websockets.go | 5 ++--- x/auction/keeper/msg_server.go | 6 ++---- x/bond/keeper/msg_server.go | 6 ++---- x/evm/simulation/operations.go | 7 +++---- x/registry/keeper/msg_server.go | 3 --- 7 files changed, 10 insertions(+), 20 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 84dea2d3..d65f510f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -8,7 +8,6 @@ linters: - bodyclose # - depguard # 20231120 disable until https://github.com/golangci/golangci-lint/issues/3906 is released - dogsled - - dupl - errcheck - goconst - gocritic diff --git a/Makefile b/Makefile index 4d9c77e9..dbc5b767 100644 --- a/Makefile +++ b/Makefile @@ -389,7 +389,7 @@ format-fix: ############################################################################### # ------ -# NOTE: Link to the tendermintdev/sdk-proto-gen docker images: +# NOTE: Link to the tendermintdev/sdk-proto-gen docker images: # https://hub.docker.com/r/tendermintdev/sdk-proto-gen/tags # protoVer=v0.7 diff --git a/rpc/websockets.go b/rpc/websockets.go index 179c996d..c98014d7 100644 --- a/rpc/websockets.go +++ b/rpc/websockets.go @@ -94,11 +94,10 @@ func (s *websocketsServer) Start() { go func() { var err error - /* #nosec G114 -- http functions have no support for timeouts */ if s.certFile == "" || s.keyFile == "" { - err = http.ListenAndServe(s.wsAddr, ws) + err = http.ListenAndServe(s.wsAddr, ws) /* #nosec G114 -- http functions have no support for timeouts */ } else { - err = http.ListenAndServeTLS(s.wsAddr, s.certFile, s.keyFile, ws) + err = http.ListenAndServeTLS(s.wsAddr, s.certFile, s.keyFile, ws) // #nosec G114 } if err != nil { diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go index e2ef1ae8..c7467974 100644 --- a/x/auction/keeper/msg_server.go +++ b/x/auction/keeper/msg_server.go @@ -55,7 +55,6 @@ func (s msgServer) CreateAuction(c context.Context, msg *types.MsgCreateAuction) } // CommitBid is the command for committing a bid -//nolint: all func (s msgServer) CommitBid(c context.Context, msg *types.MsgCommitBid) (*types.MsgCommitBidResponse, error) { ctx := sdk.UnwrapSDKContext(c) ctx = *utils.CtxWithCustomKVGasConfig(&ctx) @@ -89,7 +88,6 @@ func (s msgServer) CommitBid(c context.Context, msg *types.MsgCommitBid) (*types } // RevealBid is the command for revealing a bid -//nolint: all func (s msgServer) RevealBid(c context.Context, msg *types.MsgRevealBid) (*types.MsgRevealBidResponse, error) { ctx := sdk.UnwrapSDKContext(c) ctx = *utils.CtxWithCustomKVGasConfig(&ctx) @@ -122,7 +120,7 @@ func (s msgServer) RevealBid(c context.Context, msg *types.MsgRevealBid) (*types return &types.MsgRevealBidResponse{Auction: resp}, nil } -func (m msgServer) logTxGasConsumed(ctx sdk.Context, tx string) { +func (s msgServer) logTxGasConsumed(ctx sdk.Context, tx string) { gasConsumed := ctx.GasMeter().GasConsumed() - m.Keeper.Logger(ctx).Info("tx executed", "method", tx, "gas_consumed", fmt.Sprintf("%d", gasConsumed)) + s.Keeper.Logger(ctx).Info("tx executed", "method", tx, "gas_consumed", fmt.Sprintf("%d", gasConsumed)) } diff --git a/x/bond/keeper/msg_server.go b/x/bond/keeper/msg_server.go index 8d33893d..cc462341 100644 --- a/x/bond/keeper/msg_server.go +++ b/x/bond/keeper/msg_server.go @@ -52,7 +52,6 @@ func (k msgServer) CreateBond(c context.Context, msg *types.MsgCreateBond) (*typ return &types.MsgCreateBondResponse{}, nil } -//nolint: all func (k msgServer) RefillBond(c context.Context, msg *types.MsgRefillBond) (*types.MsgRefillBondResponse, error) { ctx := sdk.UnwrapSDKContext(c) ctx = *utils.CtxWithCustomKVGasConfig(&ctx) @@ -86,7 +85,6 @@ func (k msgServer) RefillBond(c context.Context, msg *types.MsgRefillBond) (*typ return &types.MsgRefillBondResponse{}, nil } -//nolint: all func (k msgServer) WithdrawBond(c context.Context, msg *types.MsgWithdrawBond) (*types.MsgWithdrawBondResponse, error) { ctx := sdk.UnwrapSDKContext(c) ctx = *utils.CtxWithCustomKVGasConfig(&ctx) @@ -151,7 +149,7 @@ func (k msgServer) CancelBond(c context.Context, msg *types.MsgCancelBond) (*typ return &types.MsgCancelBondResponse{}, nil } -func (m msgServer) logTxGasConsumed(ctx sdk.Context, tx string) { +func (k msgServer) logTxGasConsumed(ctx sdk.Context, tx string) { gasConsumed := ctx.GasMeter().GasConsumed() - m.Keeper.Logger(ctx).Info("tx executed", "method", tx, "gas_consumed", fmt.Sprintf("%d", gasConsumed)) + k.Keeper.Logger(ctx).Info("tx executed", "method", tx, "gas_consumed", fmt.Sprintf("%d", gasConsumed)) } diff --git a/x/evm/simulation/operations.go b/x/evm/simulation/operations.go index 7f8960ca..e11366d7 100644 --- a/x/evm/simulation/operations.go +++ b/x/evm/simulation/operations.go @@ -32,11 +32,10 @@ import ( "github.com/ethereum/go-ethereum/crypto" ) -// #nosec 101 const ( - OpWeightMsgEthSimpleTransfer = "op_weight_msg_eth_simple_transfer" - OpWeightMsgEthCreateContract = "op_weight_msg_eth_create_contract" - OpWeightMsgEthCallContract = "op_weight_msg_eth_call_contract" + OpWeightMsgEthSimpleTransfer = "op_weight_msg_eth_simple_transfer" // #nosec G101 + OpWeightMsgEthCreateContract = "op_weight_msg_eth_create_contract" // #nosec G101 + OpWeightMsgEthCallContract = "op_weight_msg_eth_call_contract" // #nosec G101 ) const ( diff --git a/x/registry/keeper/msg_server.go b/x/registry/keeper/msg_server.go index 542cae18..b244e654 100644 --- a/x/registry/keeper/msg_server.go +++ b/x/registry/keeper/msg_server.go @@ -54,7 +54,6 @@ func (m msgServer) SetRecord(c context.Context, msg *types.MsgSetRecord) (*types return &types.MsgSetRecordResponse{Id: record.ID}, nil } -//nolint: all func (m msgServer) SetName(c context.Context, msg *types.MsgSetName) (*types.MsgSetNameResponse, error) { ctx := sdk.UnwrapSDKContext(c) ctx = *utils.CtxWithCustomKVGasConfig(&ctx) @@ -121,7 +120,6 @@ func (m msgServer) ReserveName(c context.Context, msg *types.MsgReserveAuthority return &types.MsgReserveAuthorityResponse{}, nil } -//nolint: all func (m msgServer) SetAuthorityBond(c context.Context, msg *types.MsgSetAuthorityBond) (*types.MsgSetAuthorityBondResponse, error) { ctx := sdk.UnwrapSDKContext(c) ctx = *utils.CtxWithCustomKVGasConfig(&ctx) @@ -213,7 +211,6 @@ func (m msgServer) RenewRecord(c context.Context, msg *types.MsgRenewRecord) (*t return &types.MsgRenewRecordResponse{}, nil } -//nolint: all func (m msgServer) AssociateBond(c context.Context, msg *types.MsgAssociateBond) (*types.MsgAssociateBondResponse, error) { ctx := sdk.UnwrapSDKContext(c) ctx = *utils.CtxWithCustomKVGasConfig(&ctx) -- 2.45.1