From 04e126f2ad30adb2136ac1b99a33c5b818c5120c Mon Sep 17 00:00:00 2001 From: toteki <63419657+toteki@users.noreply.github.com> Date: Mon, 23 Jan 2023 09:43:33 -0700 Subject: [PATCH 1/3] fix: oracle accept list no longer automatically adds blacklisted tokens --- CHANGELOG.md | 4 ++++ x/oracle/keeper/hooks.go | 5 +++++ x/oracle/keeper/hooks_test.go | 9 +++++++++ 3 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50a67f431e..25ce5235d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Fixes + +- [1XXX](https://github.com/umee-network/umee/pull/1XXX) Blacklisted tokens no longer add themselves back to the oracle accept list. + ## [v4.0.0](https://github.com/umee-network/umee/releases/tag/v4.0.0) - 2023-01-20 ### API Breaking diff --git a/x/oracle/keeper/hooks.go b/x/oracle/keeper/hooks.go index 2c6d830f70..ebba49529b 100644 --- a/x/oracle/keeper/hooks.go +++ b/x/oracle/keeper/hooks.go @@ -26,6 +26,11 @@ func (k Keeper) Hooks() Hooks { func (h Hooks) AfterTokenRegistered(ctx sdk.Context, token leveragetypes.Token) { acceptList := h.k.AcceptList(ctx) + if token.Blacklist { + // Blacklisted tokens should not trigger updates to the oracle accept list + return + } + var tokenExists bool for _, t := range acceptList { if t.BaseDenom == token.BaseDenom { diff --git a/x/oracle/keeper/hooks_test.go b/x/oracle/keeper/hooks_test.go index 3c53592bea..c31ca9c254 100644 --- a/x/oracle/keeper/hooks_test.go +++ b/x/oracle/keeper/hooks_test.go @@ -24,4 +24,13 @@ func (s *IntegrationTestSuite) TestHooks_AfterTokenRegistered() { Exponent: 6, }) s.Require().Len(s.app.OracleKeeper.AcceptList(s.ctx), 3) + + // require a blacklisted token does not update the accept list + h.AfterTokenRegistered(s.ctx, leveragetypes.Token{ + BaseDenom: "unope", + SymbolDenom: "NOPE", + Exponent: 6, + Blacklist: true, + }) + s.Require().Len(s.app.OracleKeeper.AcceptList(s.ctx), 3) } From e5d0346f8aa8cb32ec94de15d7aa13b5bcd40342 Mon Sep 17 00:00:00 2001 From: toteki <63419657+toteki@users.noreply.github.com> Date: Mon, 23 Jan 2023 09:45:22 -0700 Subject: [PATCH 2/3] cl++ --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25ce5235d2..b8bcf74801 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,7 +48,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Fixes -- [1XXX](https://github.com/umee-network/umee/pull/1XXX) Blacklisted tokens no longer add themselves back to the oracle accept list. +- [1736](https://github.com/umee-network/umee/pull/1736) Blacklisted tokens no longer add themselves back to the oracle accept list. ## [v4.0.0](https://github.com/umee-network/umee/releases/tag/v4.0.0) - 2023-01-20 From 56769ac745eb90ed2bc7cd2d82ba60348f4d58e6 Mon Sep 17 00:00:00 2001 From: toteki <63419657+toteki@users.noreply.github.com> Date: Mon, 23 Jan 2023 09:46:57 -0700 Subject: [PATCH 3/3] switch order --- x/oracle/keeper/hooks.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/oracle/keeper/hooks.go b/x/oracle/keeper/hooks.go index ebba49529b..74cc1c8053 100644 --- a/x/oracle/keeper/hooks.go +++ b/x/oracle/keeper/hooks.go @@ -24,13 +24,13 @@ func (k Keeper) Hooks() Hooks { // it checks if the provided Token should be added to the existing accepted list // of assets for the x/oracle module. func (h Hooks) AfterTokenRegistered(ctx sdk.Context, token leveragetypes.Token) { - acceptList := h.k.AcceptList(ctx) - if token.Blacklist { // Blacklisted tokens should not trigger updates to the oracle accept list return } + acceptList := h.k.AcceptList(ctx) + var tokenExists bool for _, t := range acceptList { if t.BaseDenom == token.BaseDenom {