Skip to content

Commit

Permalink
fix: update cache when assetID updated in params (#214)
Browse files Browse the repository at this point in the history
* fix: update cache when assetID updated in params

* fix:update params with latest params when do recache

* remove debug log
  • Loading branch information
leonz789 authored and MaxMustermann2 committed Oct 14, 2024
1 parent ce43d2e commit e62d445
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions x/oracle/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 6 additions & 0 deletions x/oracle/keeper/single.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit e62d445

Please sign in to comment.