-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add setup for the tool usage #59
Changes from 8 commits
70f4738
4bb3831
7909978
71fa3e3
f59e419
fd1ed0b
0c26368
fd6660d
2748883
66d3482
4030cf1
3d066cb
c2faa85
18eaa88
a3679c8
48850d8
f4bb555
4b21f76
c65e33b
7cf025e
88947a8
97fc36d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import requests | ||
from dataclasses import dataclass | ||
import json | ||
import json5 as json | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
|
||
|
||
BASE_BGD_CACHE_REPO = 'https://raw.githubusercontent.com/bgd-labs/v3-governance-cache/refs/heads/main/cache' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
from abc import ABC | ||
from datetime import datetime | ||
import json | ||
import json5 as json | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
from pathlib import Path | ||
|
||
import Quorum.config as config | ||
import Quorum.utils.config as config | ||
from Quorum.apis.block_explorers.source_code import SourceCode | ||
from Quorum.utils.chain_enum import Chain | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import argparse | ||
import json | ||
from json import JSONDecodeError | ||
import json5 as json | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
from typing import Any, Optional | ||
|
||
from Quorum.utils.chain_enum import Chain | ||
|
@@ -44,7 +45,7 @@ def load_config(config_path: str) -> dict[str, Any] | None: | |
with open(config_path, 'r') as file: | ||
config_data = json.load(file) | ||
return config_data | ||
except (FileNotFoundError, json.JSONDecodeError) as e: | ||
except (FileNotFoundError, JSONDecodeError) as e: | ||
pp.pretty_print(f"Failed to parse given config file {config_path}:\n{e}", pp.Colors.FAILURE) | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import shutil | ||
import argparse | ||
from pathlib import Path | ||
import Quorum.utils.pretty_printer as pp | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blank line above please :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
|
||
def get_working_directory() -> Path: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please change name to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer a more accurate name here. if ever we need to add more argument here ill re name it to parse args |
||
parser = argparse.ArgumentParser(description="Setup Quorum project.") | ||
parser.add_argument( | ||
'--working_dir', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest change the name to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Working dir is more accurate to the user as its going to be the directory he going work from. |
||
default=Path.cwd(), | ||
nivcertora marked this conversation as resolved.
Show resolved
Hide resolved
|
||
type=Path, | ||
help="Directory to set up the Quorum project." | ||
) | ||
args = parser.parse_args() | ||
return args.working_dir | ||
|
||
|
||
def setup_quorum(working_dir: Path): | ||
""" | ||
Initializes a Quorum environment by copying template files to the specified directory. | ||
nivcertora marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Args: | ||
working_dir (Path): Target directory for setting up Quorum. | ||
|
||
Raises: | ||
shutil.Error: If copying files fails. | ||
OSError: If directory creation fails. | ||
""" | ||
templates_dir = Path(__file__).parent.parent / 'templates' | ||
target_dir = working_dir.resolve() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey you actually named it "target_dir" here lol There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here it serves as a target for the copy file therefore the new variable name is introduced which adds additional clarity for the code readable. (For us not the user). |
||
|
||
if not target_dir.exists(): | ||
pp.pretty_print(f"Creating directory: {target_dir}", pp.Colors.INFO) | ||
target_dir.mkdir(parents=True, exist_ok=True) | ||
|
||
template_files = ['ground_truth.json', 'execution.json', '.env.example', 'Readme.md'] | ||
|
||
for file_name in template_files: | ||
src = templates_dir / file_name | ||
dest = target_dir / '.env' if file_name == '.env.example' else target_dir / file_name | ||
|
||
if dest.exists(): | ||
yoav-el-certora marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pp.pretty_print(f"File exists: {dest}. Skipping.", pp.Colors.WARNING) | ||
continue | ||
|
||
shutil.copy(src, dest) | ||
pp.pretty_print(f"Copied {file_name} to {dest}", pp.Colors.SUCCESS) | ||
Comment on lines
+41
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked and if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer the current state, and also i would suggest to not upload a .env to the repo. |
||
|
||
# Add export QUORUM_PATH="path_to_your_quorum_directory" to the new .env file | ||
with open(target_dir / '.env', 'a') as f: | ||
f.write(f'\nexport QUORUM_PATH="{target_dir}"\n') | ||
|
||
pp.pretty_print("Quorum setup completed successfully!", pp.Colors.SUCCESS) | ||
|
||
|
||
def main(): | ||
working_dir = get_working_directory() | ||
try: | ||
setup_quorum(working_dir) | ||
except Exception as e: | ||
pp.pretty_print(f"Setup failed: {e}", pp.Colors.FAILURE) | ||
exit(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file was deleted.
nivcertora marked this conversation as resolved.
Show resolved
Hide resolved
nivcertora marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Quorum Templates Guide | ||
|
||
This guide provides instructions on how to fill out the various template files in the Quorum project. | ||
|
||
## ground_truth.json | ||
|
||
This file contains the ground truth data for different protocols. Each protocol has its own section with the following fields: | ||
|
||
- `dev_repos`: A list of URLs to the development repositories. | ||
- `review_repo`: The URL to the review repository. | ||
- `price_feed_providers`: A list of price feed providers. | ||
- `token_validation_providers`: A list of token validation providers. | ||
|
||
### Example | ||
```json | ||
{ | ||
"Aave": | ||
{ | ||
"dev_repos": | ||
[ | ||
"https://github.com/bgd-labs/aave-helpers", | ||
"https://github.com/bgd-labs/aave-address-book", | ||
"https://github.com/aave-dao/aave-v3-origin" | ||
], | ||
"review_repo": "https://github.com/bgd-labs/aave-proposals-v3", | ||
"price_feed_providers": ["Chainlink"], | ||
"token_validation_providers": ["Coingecko"] | ||
} | ||
} | ||
``` | ||
|
||
## execution.json | ||
|
||
This file contains the execution details for different protocols and networks. For each protocol, you need to specify the proposal addresses for various networks. | ||
|
||
### Instructions | ||
- Replace `<protocol_name>` with the name of the protocol as specified in `ground_truth.json`. | ||
- Fill in the proposal addresses for each network. | ||
|
||
### Example | ||
```jsonc | ||
{ | ||
"Aave": { | ||
"Ethereum": { | ||
"Proposals": ["0x..."] // Insert Ethereum proposals address here | ||
}, | ||
"Arbitrum": { | ||
"Proposals": ["0x..."] // Insert Arbitrum proposals address here | ||
}, | ||
// ...other networks... | ||
} | ||
} | ||
``` | ||
|
||
## .env | ||
|
||
This file contains environment variables that need to be set for the project to run. | ||
nivcertora marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fill in the required values. | ||
|
||
### Instructions | ||
- `ETHSCAN_API_KEY`: Your Etherscan API key. | ||
- `ANTHROPIC_API_KEY`: Your Anthropic API key. | ||
- `QUORUM_PATH`: The path to your Quorum directory. | ||
|
||
### Example | ||
```bash | ||
export ETHSCAN_API_KEY="your_etherscan_api_key" | ||
export ANTHROPIC_API_KEY="your_anthropic_api_key" | ||
export QUORUM_PATH="path_to_your_quorum_directory" | ||
``` | ||
|
||
## Summary | ||
|
||
1. Fill in `ground_truth.json` with the appropriate data for each protocol. | ||
2. Update `execution.json` with the proposal addresses for each network. | ||
3. `.env` set the required environment variables. | ||
nivcertora marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
By following these instructions, you will ensure that the Quorum project is correctly configured and ready to use. | ||
nivcertora marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"<protocol_name>": { // Insert protocol / organization name here as specified in the ground_truth.json | ||
"Ethereum": { | ||
"Proposals": [] // Insert Ethereum proposals address here | ||
}, | ||
"Arbitrum": { | ||
"Proposals": [] // Insert Arbitrum proposals address here | ||
}, | ||
"Avalanche": { | ||
"Proposals": [] // Insert Avalanche proposals address here | ||
}, | ||
"Base": { | ||
"Proposals": [] // Insert Base proposals address here | ||
}, | ||
"BNBChain": { | ||
"Proposals": [] // Insert BNBChain proposals address here | ||
}, | ||
"Gnosis": { | ||
"Proposals": [] // Insert Gnosis proposals address here | ||
}, | ||
"Metis": { | ||
"Proposals": [] // Insert Metis proposals address here | ||
}, | ||
"Optimism": { | ||
"Proposals": [] // Insert Optimism proposals address here | ||
}, | ||
"Polygon": { | ||
"Proposals": [] // Insert Polygon proposals address here | ||
}, | ||
"Scroll": { | ||
"Proposals": [] // Insert Scroll proposals address here | ||
}, | ||
"zkSync": { | ||
"Proposals": [] // Insert zkSync proposals address here | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
// Protocol or organization with the same name to be specified in the execution json | ||
"<protocol_name>": | ||
{ | ||
// Main list of repositories for import diff checks | ||
"dev_repos": [ | ||
"<https://github.com/org/repo1>", | ||
"<https://github.com/org/repo2>" | ||
], | ||
|
||
// Pre-deployment review repository for code verification | ||
"review_repo": "<https://github.com/org/review-repo>", | ||
|
||
// Supported price feed providers for address validation e.g. Chainlink, Chronicle | ||
"price_feed_providers": [ | ||
"<price_feed_provider1>", | ||
"<price_feed_provider2>" | ||
], | ||
|
||
// Token validation services for address verification e.g. Coingecko | ||
"token_validation_providers": [ | ||
"<token_validation_provider1>", | ||
"<token_validation_provider2>" | ||
] | ||
} | ||
} |
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.
Please change that to simply
import json5
. I'm afraid that down the line it will get confusing because these 2 packages do act a little bit differently in certain things (as you saw).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.
The difference between them is agnostic, if it will cause any issue in the future we can change it. for now, i prefer it to be called json instead of a variable with number name just for apperance.