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: Reduce blast radius of errors in MarketMap #736

Merged
merged 5 commits into from
Sep 11, 2024

Conversation

Eric-Warehime
Copy link
Collaborator

Adds a method to the marketmap type, GetValidSubset. This is used in the update lifecycle in order to be able to accept updates to the marketmap which do not fully pass ValidateBasic.

It will attempt to remove any ProviderConfig with an invalid NormalizeByPair, and then remove any Market which fails to pass ValidateBasic.

If a market has some valid ProviderConfigs it can still run as long as it still satisfies the min provider count.

Copy link

codecov bot commented Sep 10, 2024

Codecov Report

Attention: Patch coverage is 90.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 55.58%. Comparing base (6174714) to head (58a5c5a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
x/marketmap/types/market.go 91.66% 1 Missing and 1 partial ⚠️
oracle/update.go 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #736      +/-   ##
==========================================
+ Coverage   55.52%   55.58%   +0.06%     
==========================================
  Files         208      208              
  Lines       11586    11613      +27     
==========================================
+ Hits         6433     6455      +22     
- Misses       4554     4557       +3     
- Partials      599      601       +2     

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

//
// In particular, this will eliminate anything which would otherwise cause a failure in ValidateBasic.
// The resulting MarketMap should be able to pass ValidateBasic.
func (mm *MarketMap) GetValidSubset() MarketMap {
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this function should return an error as well and call Validate to ensure that the returned map is valid

Copy link
Contributor

Choose a reason for hiding this comment

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

There is a case where there is no valid subset and we should just return nil, error

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think you're right--if the entire set of markets is invalid we should just keep everything the same. Returning an error will do that while I think returning an empty subset would just stop fetching any prices at all.

Copy link
Contributor

@aljo242 aljo242 left a comment

Choose a reason for hiding this comment

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

otherwise lgtm

Copy link
Contributor

@technicallyty technicallyty left a comment

Choose a reason for hiding this comment

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

LGTM pending @aljo242's suggestion

@Eric-Warehime Eric-Warehime enabled auto-merge (squash) September 11, 2024 05:10
@Eric-Warehime Eric-Warehime merged commit e97bcc5 into main Sep 11, 2024
17 checks passed
@Eric-Warehime Eric-Warehime deleted the eric/blast-radius branch September 11, 2024 15:34
aljo242 pushed a commit that referenced this pull request Dec 10, 2024
… (#850)

Co-authored-by: Eric Warehime <eric.warehime@gmail.com>
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