Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: removal message #772

Merged
merged 42 commits into from
Sep 27, 2024
Merged

feat: removal message #772

merged 42 commits into from
Sep 27, 2024

Conversation

aljo242
Copy link
Contributor

@aljo242 aljo242 commented Sep 23, 2024

Closes CON-1749

  • adds notion of ValidationHooks
  • adds Options configuration to keeper instantiation

Copy link

codecov bot commented Sep 23, 2024

Codecov Report

Attention: Patch coverage is 61.11111% with 42 lines in your changes missing coverage. Please review.

Project coverage is 57.01%. Comparing base (b11a57b) to head (846cd22).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
x/marketmap/keeper/keeper.go 70.37% 6 Missing and 2 partials ⚠️
x/marketmap/types/hooks.go 0.00% 7 Missing ⚠️
x/marketmap/keeper/options.go 0.00% 6 Missing ⚠️
x/oracle/keeper/hooks.go 0.00% 6 Missing ⚠️
x/marketmap/types/codec.go 0.00% 5 Missing ⚠️
x/marketmap/keeper/msg_server.go 84.61% 2 Missing and 2 partials ⚠️
x/marketmap/types/errors.go 0.00% 4 Missing ⚠️
x/marketmap/types/msg.go 84.61% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #772   +/-   ##
=======================================
  Coverage   57.01%   57.01%           
=======================================
  Files         208      210    +2     
  Lines       11626    11718   +92     
=======================================
+ Hits         6628     6681   +53     
- Misses       4394     4429   +35     
- Partials      604      608    +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aljo242 aljo242 marked this pull request as ready for review September 24, 2024 15:56
x/marketmap/types/msg.go Outdated Show resolved Hide resolved

// MsgRemoveMarketsResponse defines the
// Msg/MsgRemoveMarketsResponse response type.
message MsgRemoveMarketsResponse {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we are only succeeded if all markets to be removed exist, and are successfully removed which is why we don't need a response, maybe.

We could support making this message idempotent where we instead succeed if either the market does not exist, or was successfully removed. In that case it might make sense to return how many markets were actually removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to return []string which is the array of markets that were successfully removed.

if err != nil {
return err
}
if market.Ticker.Enabled {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bit of asymmetry here since we typically check for Enabled markets for updating in the ante handlers, but here are making it part of policy for all integrations.

Perhaps we should call this method "DeleteMarket", and write something like,

for _, handler := k.deleteMarketHandlers {
  if err := handler(ctx, market); err != nil {
    return err
  }
}
return k.markets.Remove(ctx, types.TickerString(tickerStr))

We can define a DefaultDeleteMarketHandlers() somewhere and use that to initialize the keeper.

Not sure if handler, verifier, validator is better.

This also ensures if we want to add more complex logic later for a specific integration, we can do so without changing connect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the notion of ValidationHooks which can be configured for the keeper.

Right now just passing them via options at instantiation which keeps the NewKeeper function signature the same

@@ -14,6 +14,9 @@ type MarketMapHooks interface {

// AfterMarketGenesis is called after x/marketmap init genesis.
AfterMarketGenesis(ctx sdk.Context, tickers map[string]Market) error

// AfterMarketRemoved is called after a market is removed.
AfterMarketRemoved(ctx sdk.Context, market Market) error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this hook errors, does the message fail?

Could we check if the removed market was enabled here, and just fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes if these hooks fail, the message would fail

@aljo242 aljo242 merged commit 849ec62 into main Sep 27, 2024
15 checks passed
@aljo242 aljo242 deleted the feat/removal-msg branch September 27, 2024 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants