diff --git a/x/oracle/client/cli/query_recent_params.go b/x/oracle/client/cli/query_recent_params.go index 04f848658..e14f8f943 100644 --- a/x/oracle/client/cli/query_recent_params.go +++ b/x/oracle/client/cli/query_recent_params.go @@ -1,3 +1,4 @@ +// nolint package cli import ( diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index ec61c801a..29e39da1d 100644 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -13,10 +13,10 @@ import ( var DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) -const ( - flagPacketTimeoutTimestamp = "packet-timeout-timestamp" - listSeparator = "," -) +//const ( +// flagPacketTimeoutTimestamp = "packet-timeout-timestamp" +// listSeparator = "," +//) // GetTxCmd returns the transaction commands for this module func GetTxCmd() *cobra.Command { diff --git a/x/oracle/keeper/aggregator/aggregator.go b/x/oracle/keeper/aggregator/aggregator.go index 4906750df..4380cf0b2 100644 --- a/x/oracle/keeper/aggregator/aggregator.go +++ b/x/oracle/keeper/aggregator/aggregator.go @@ -182,7 +182,7 @@ func (agc *AggregatorContext) SealRound(ctx sdk.Context, force bool) (success [] agc.aggregators[feederId] = nil } } - return + return success, failed } //func (agc *AggregatorContext) ForceSeal(ctx sdk.Context) (success []*priceItemKV, failed []int32) { @@ -208,29 +208,29 @@ func (agc *AggregatorContext) PrepareRound(ctx sdk.Context, block uint64) { left := delta % feeder.Interval count := delta / feeder.Interval latestBasedblock := block - left - latestNextRoundId := feeder.StartRoundId + count + latestNextRoundID := feeder.StartRoundId + count - feederIdUint64 := uint64(feederId) - round := agc.rounds[feederIdUint64] + feederIDUint64 := uint64(feederId) + round := agc.rounds[feederIDUint64] if round == nil { round = &roundInfo{ - basedBlock: uint64(latestBasedblock), - nextRoundId: uint64(latestNextRoundId), + basedBlock: latestBasedblock, + nextRoundId: latestNextRoundID, } if left >= common.MaxNonce { round.status = 2 } else { round.status = 1 } - agc.rounds[feederIdUint64] = round + agc.rounds[feederIDUint64] = round } else { // prepare a new round for exist roundInfo if left == 0 { - round.basedBlock = uint64(latestBasedblock) - round.nextRoundId = uint64(latestNextRoundId) + round.basedBlock = latestBasedblock + round.nextRoundId = latestNextRoundID round.status = 1 // drop previous worker - agc.aggregators[feederIdUint64] = nil + agc.aggregators[feederIDUint64] = nil } else if round.status == 1 && left >= common.MaxNonce { // this shouldn't happen, if do sealround properly before prepareRound, basically for test only round.status = 2 diff --git a/x/oracle/keeper/aggregator/aggregator_filter.go b/x/oracle/keeper/aggregator/aggregator_filter.go index c1f0d5a25..e33fd8fe4 100644 --- a/x/oracle/keeper/aggregator/aggregator_filter.go +++ b/x/oracle/keeper/aggregator/aggregator_filter.go @@ -16,10 +16,10 @@ type filter struct { validatorSource map[string]*common.Set[string] } -func newFilter(maxNonce, maxDetId int) *filter { +func newFilter(maxNonce, maxDetID int) *filter { return &filter{ maxNonce: maxNonce, - maxDetId: maxDetId, + maxDetId: maxDetID, validatorNonce: make(map[string]*common.Set[int32]), validatorSource: make(map[string]*common.Set[string]), } @@ -39,10 +39,10 @@ func (f *filter) addPSource(pSources []*types.PriceWithSource, validator string) // check conflicts or duplicate data for the same roundId within the same source if len(pSource.Prices[0].DetId) > 0 { k := validator + strconv.Itoa(int(pSource.SourceId)) - detIds := f.validatorSource[k] - if detIds == nil { - detIds = f.newVSSet() - f.validatorSource[k] = detIds + detIDs := f.validatorSource[k] + if detIDs == nil { + detIDs = f.newVSSet() + f.validatorSource[k] = detIDs } pSourceTmp := &types.PriceWithSource{ @@ -51,10 +51,10 @@ func (f *filter) addPSource(pSources []*types.PriceWithSource, validator string) Desc: pSource.Desc, } - for _, pDetId := range pSource.Prices { - if ok := detIds.Add(pDetId.DetId); ok { + for _, pDetID := range pSource.Prices { + if ok := detIDs.Add(pDetID.DetId); ok { // deterministic id has not seen in filter and limitation of ids this souce has not reached - pSourceTmp.Prices = append(pSourceTmp.Prices, pDetId) + pSourceTmp.Prices = append(pSourceTmp.Prices, pDetID) } } if len(pSourceTmp.Prices) > 0 { @@ -66,7 +66,7 @@ func (f *filter) addPSource(pSources []*types.PriceWithSource, validator string) list4Aggregator = append(list4Aggregator, pSource) } } - return + return list4Calculator, list4Aggregator } // filtrate checks data from MsgCreatePrice, and will drop the conflict or duplicate data, it will then fill data into calculator(for deterministic source data to get to consensus) and aggregator (for both deterministic and non0-deterministic source data run 2-layers aggregation to get the final price) diff --git a/x/oracle/keeper/aggregator/worker.go b/x/oracle/keeper/aggregator/worker.go index ff98dc9d3..a5cbb34a1 100644 --- a/x/oracle/keeper/aggregator/worker.go +++ b/x/oracle/keeper/aggregator/worker.go @@ -50,12 +50,12 @@ func (w *worker) seal() { w.a = nil } -func (w *worker) getPrice() (string, int32) { - if w.sealed { - return w.price, w.decimal - } - return "", 0 -} +//func (w *worker) getPrice() (string, int32) { +// if w.sealed { +// return w.price, w.decimal +// } +// return "", 0 +//} // newWorker new a instance for a tokenFeeder's specific round func newWorker(feederId uint64, agc *AggregatorContext) *worker { diff --git a/x/oracle/keeper/cache/caches.go b/x/oracle/keeper/cache/caches.go index 060272333..06569119f 100644 --- a/x/oracle/keeper/cache/caches.go +++ b/x/oracle/keeper/cache/caches.go @@ -156,10 +156,8 @@ func (c *Cache) AddCache(i any) { // func (c *Cache) RemoveCache(i any, k common.KeeperOracle) { func (c *Cache) RemoveCache(i any) { - switch item := i.(type) { - case *CacheItemM: + if item, isItemM := i.(*CacheItemM); isItemM { c.msg.remove(item) - default: } } diff --git a/x/oracle/keeper/index_recent_msg.go b/x/oracle/keeper/index_recent_msg.go index b12dc77f7..710d9bc2e 100644 --- a/x/oracle/keeper/index_recent_msg.go +++ b/x/oracle/keeper/index_recent_msg.go @@ -1,3 +1,4 @@ +// nolint package keeper import ( diff --git a/x/oracle/keeper/index_recent_params.go b/x/oracle/keeper/index_recent_params.go index 8bf433e79..769b0471a 100644 --- a/x/oracle/keeper/index_recent_params.go +++ b/x/oracle/keeper/index_recent_params.go @@ -1,3 +1,4 @@ +// nolint package keeper import ( diff --git a/x/oracle/keeper/msg_server_test.go b/x/oracle/keeper/msg_server_test.go index 850f66cdd..0eaa8d06a 100644 --- a/x/oracle/keeper/msg_server_test.go +++ b/x/oracle/keeper/msg_server_test.go @@ -4,12 +4,12 @@ import ( "context" "testing" + sdkerrors "cosmossdk.io/errors" keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" "github.com/ExocoreNetwork/exocore/x/oracle/keeper" "github.com/ExocoreNetwork/exocore/x/oracle/keeper/testdata" "github.com/ExocoreNetwork/exocore/x/oracle/types" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" // "github.com/cosmos/ibc-go/testing/mock" diff --git a/x/oracle/keeper/params.go b/x/oracle/keeper/params.go index 9d1b66bc5..34bf129e8 100644 --- a/x/oracle/keeper/params.go +++ b/x/oracle/keeper/params.go @@ -29,10 +29,9 @@ func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { } // SetParams set the params -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { store := ctx.KVStore(k.storeKey) // TODO: validation check bz := k.cdc.MustMarshal(¶ms) store.Set(types.ParamsKey, bz) - return nil } diff --git a/x/oracle/keeper/prices.go b/x/oracle/keeper/prices.go index 3ea23cb6b..dff5ed849 100644 --- a/x/oracle/keeper/prices.go +++ b/x/oracle/keeper/prices.go @@ -90,7 +90,7 @@ func (k Keeper) GetAllPrices(ctx sdk.Context) (list []types.Prices) { if price.TokenId > 0 { list = append(list, price) } - return + return list } func (k Keeper) AppendPriceTR(ctx sdk.Context, tokenId uint64, priceTR types.PriceWithTimeAndRound) { diff --git a/x/oracle/keeper/query_recent_params.go b/x/oracle/keeper/query_recent_params.go index 47add0b78..88b06ecd2 100644 --- a/x/oracle/keeper/query_recent_params.go +++ b/x/oracle/keeper/query_recent_params.go @@ -1,3 +1,4 @@ +// nolint package keeper import ( diff --git a/x/oracle/keeper/single.go b/x/oracle/keeper/single.go index a59be80cd..1971f0390 100644 --- a/x/oracle/keeper/single.go +++ b/x/oracle/keeper/single.go @@ -90,6 +90,7 @@ func recacheAggregatorContext(ctx sdk.Context, agc *aggregator.AggregatorContext if msgs := recentMsgs[from+1]; msgs != nil { for _, msg := range msgs { // these messages are retreived for recache, just skip the validation check and fill the memory cache + //nolint agc.FillPrice(&types.MsgCreatePrice{ Creator: msg.Validator, FeederId: msg.FeederId, diff --git a/x/oracle/module.go b/x/oracle/module.go index a6ab94454..0b5d434ca 100644 --- a/x/oracle/module.go +++ b/x/oracle/module.go @@ -74,7 +74,9 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module diff --git a/x/oracle/types/errors.go b/x/oracle/types/errors.go index ce36be548..2183923eb 100644 --- a/x/oracle/types/errors.go +++ b/x/oracle/types/errors.go @@ -3,7 +3,7 @@ package types // DONTCOVER import ( - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + sdkerrors "cosmossdk.io/errors" ) // x/oracle module sentinel errors diff --git a/x/oracle/types/message_create_price.go b/x/oracle/types/message_create_price.go index 2d37ff15d..b9137cbc2 100644 --- a/x/oracle/types/message_create_price.go +++ b/x/oracle/types/message_create_price.go @@ -1,8 +1,9 @@ package types import ( - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" ) const TypeMsgCreatePrice = "create_price" diff --git a/x/oracle/types/message_create_price_test.go b/x/oracle/types/message_create_price_test.go index de6d73404..ad9aee345 100644 --- a/x/oracle/types/message_create_price_test.go +++ b/x/oracle/types/message_create_price_test.go @@ -5,6 +5,8 @@ import ( "github.com/ExocoreNetwork/exocore/testutil/sample" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + //sdkerrors "cosmossdk.io/errors"" "github.com/stretchr/testify/require" ) diff --git a/x/oracle/types/message_update_params.go b/x/oracle/types/message_update_params.go index 9a0388b28..84822971f 100644 --- a/x/oracle/types/message_update_params.go +++ b/x/oracle/types/message_update_params.go @@ -1,8 +1,8 @@ package types import ( + sdkerrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) const TypeMsgUpdateParams = "update_params"