-
Notifications
You must be signed in to change notification settings - Fork 1
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
CERT 7649 Allow dynamic price feed providers #20
Conversation
46925d2
to
87f3dd3
Compare
…m:Certora/Quorum into niv/CERT-7649-Support-Different-providers
e7bd5f0
to
e54fabe
Compare
e54fabe
to
b4a2bbb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments but overall looks good for what this PR aims to achieve.
# Replace the provider names with the actual API objects | ||
for i, provider in enumerate(providers): | ||
if provider == PriceFeedProvider.CHAINLINK: | ||
providers[i] = ChainLinkAPI() | ||
elif provider == PriceFeedProvider.CHRONICLE: | ||
providers[i] = ChronicleAPI() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think saving some kind of mapping may be better but for now (small number of providers) this is also ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree
@@ -45,7 +47,7 @@ def load_config(config_path: str) -> dict[str, Any] | None: | |||
pp.pretty_print(f"Failed to parse given config file {config_path}:\n{e}", pp.Colors.FAILURE) | |||
|
|||
|
|||
def proposals_check(customer: str, chain_name: str, proposal_addresses: list[str]) -> None: | |||
def proposals_check(customer: str, chain_name: str, proposal_addresses: list[str], providers: list[PriceFeedProviderBase]) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, for now, it doesn't seem like that big of a deal but I don't like that we need to pass providers just for a single check out of all other checks. I think letting the PriceFeedCheck itself have access to the config would have been better. I can live with this for now but as we'll implement more and more checks, extending the parameters to this function might become really ugly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree but its much better for testing to make it input instead of a dependancy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So i go with that solution
if cache_file.exists(): | ||
with open(cache_file, 'r') as file: | ||
data: dict = json.load(file) | ||
self.memory[chain] = {addr: PriceFeedData(**feed) for addr, feed in data.items()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be missing something here but price feed data isn't updating? I mean I see you never update the cache only create it or read from it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create is the update, the same as it worked before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know why but I don't really like the name ground_truth
but I also doesn't have a better name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed Configuration File:
Changed repos.json to ground_truth.json to better reflect its purpose.
https://certora.atlassian.net/browse/CERT-7649
PR Summary: Refactoring and Enhancements to Git Management and Price Feed Integration
This pull request introduces significant refactoring and enhancements to the Quorum project, focusing on improving the modularity, scalability, and maintainability of Git repository management and price feed integrations. Below are the key changes included in this PR:
1. Refactored GitManager
GitManager
class to accept aground_truth
configuration (gt_config
) directly during initialization.GitManager
to utilize pre-loaded configuration data, enhancing flexibility and testability.2. Implemented Price Feed Providers
Introduced
price_feed_utils.py
:PriceFeedProvider
enum,PriceFeedData
Pydantic model, andPriceFeedProviderBase
abstract base class.Updated Price Feed APIs:
PriceFeedProviderBase
.@singleton
decorator, replacing metaclass-based Singleton implementations._get_price_feeds_info
method to adhere to the abstract base class requirements.3. Introduced PriceFeedCheck
PriceFeedCheck
Class:FeedPriceCheck
class.PriceFeedProviderBase
instances, allowing dynamic integration of various providers.4. Configuration Enhancements
Renamed Configuration File:
repos.json
toground_truth.json
to better reflect its purpose.Added
config_loader.py
:ground_truth.json
.ChainLinkAPI
,ChronicleAPI
).5.
.gitignore
Update**cache**
to.gitignore
to exclude all cache directories from version control.6. Documentation and Packaging Updates
Updated
README.md
:repos.json
toground_truth.json
.Modified
setup.py
:ground_truth.json
is included in the package data for proper distribution.