Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Conversation

@aljo242
Copy link
Contributor

@aljo242 aljo242 commented Sep 23, 2024

Closes CON-1749

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

@codecov
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

// MsgRemoveMarketsResponse defines the
// Msg/MsgRemoveMarketsResponse response type.
message MsgRemoveMarketsResponse {}

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 {

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

AfterMarketGenesis(ctx sdk.Context, tickers map[string]Market) error

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

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
@aljo242 aljo242 deleted the feat/removal-msg branch September 27, 2024 19:23
aljo242 pushed a commit that referenced this pull request Dec 12, 2024
Co-authored-by: Chenyao Yu <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants