From e62d445bcd2099dac9a2da0192b561c0b819c9ae Mon Sep 17 00:00:00 2001 From: Leon <156270887+leonz789@users.noreply.github.com> Date: Mon, 14 Oct 2024 18:01:52 +0800 Subject: [PATCH] fix: update cache when assetID updated in params (#214) * fix: update cache when assetID updated in params * fix:update params with latest params when do recache * remove debug log --- x/oracle/keeper/params.go | 4 ++++ x/oracle/keeper/single.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/x/oracle/keeper/params.go b/x/oracle/keeper/params.go index f9eeaa657..18db1ea69 100644 --- a/x/oracle/keeper/params.go +++ b/x/oracle/keeper/params.go @@ -73,6 +73,10 @@ func (k Keeper) RegisterNewTokenAndSetTokenFeeder(ctx sdk.Context, oInfo *types. if t.Name == oInfo.Token.Name && t.ChainID == chainID { t.AssetID = strings.Join([]string{t.AssetID, oInfo.AssetID}, ",") k.SetParams(ctx, p) + if !ctx.IsCheckTx() { + _ = GetAggregatorContext(ctx, k) + cs.AddCache(cache.ItemP(p)) + } // there should have been existing tokenFeeder running(currently we register tokens from assets-module and with infinite endBlock) return nil } diff --git a/x/oracle/keeper/single.go b/x/oracle/keeper/single.go index 8b327b622..c1f60e652 100644 --- a/x/oracle/keeper/single.go +++ b/x/oracle/keeper/single.go @@ -153,6 +153,12 @@ func recacheAggregatorContext(ctx sdk.Context, agc *aggregator.AggregatorContext if updated := c.GetCache(&pRet); !updated { c.AddCache(cache.ItemP(*p)) } + // TODO: these 4 lines are mainly used for hot fix + // since the latest params stored in KV for recache should be the same with the latest params, so these lines are just duplicated actions if everything is fine. + *p = k.GetParams(ctx) + agc.SetParams(p) + setCommonParams(p) + c.AddCache(cache.ItemP(*p)) return true }