-
Notifications
You must be signed in to change notification settings - Fork 10
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
Ensure all config vars are present #20
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Ethereum key checkk | ||
|
||
on: | ||
push: | ||
pull_request: | ||
schedule: | ||
- cron: '0 0 * * *' # Daily at 00:00 UTC | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install PyYAML | ||
run: pip install PyYAML | ||
|
||
- name: Check keys | ||
# --dev checks against an unpinned commit. since new vars can be added at any time unpinned commits | ||
# are checked on a cron, not on regular flows. | ||
run: python scripts/assert_declare_ethereum_vars.py ${{ github.event_name == 'schedule' && '--dev' || '' }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ | |
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import urllib.request | ||
import yaml | ||
import sys | ||
import argparse | ||
import difflib | ||
|
||
# Install dependecies: | ||
# | ||
# $ pip install PyYAML | ||
# | ||
# Run: | ||
# | ||
# python3 scripts/assert_declare_ethereum_vars.py | ||
|
||
# Default commit for the pinned version | ||
DEFAULT_COMMIT = 'v1.4.0-beta.4' | ||
|
||
# URL of the YAML file in the GitHub repo | ||
# 'https://raw.githubusercontent.com/ethereum/consensus-specs/dev/configs/mainnet.yaml' | ||
remote_base_url = 'https://raw.githubusercontent.com/ethereum/consensus-specs' | ||
|
||
# Path to the local YAML file | ||
files = [ | ||
('mainnet/config.yaml', 'configs/mainnet.yaml'), | ||
('presets/gnosis/phase0.yaml', 'presets/mainnet/phase0.yaml'), | ||
('presets/gnosis/altair.yaml', 'presets/mainnet/altair.yaml'), | ||
('presets/gnosis/bellatrix.yaml', 'presets/mainnet/bellatrix.yaml'), | ||
('presets/gnosis/capella.yaml', 'presets/mainnet/capella.yaml'), | ||
('presets/gnosis/deneb.yaml', 'presets/mainnet/deneb.yaml'), | ||
] | ||
|
||
def load_yaml_from_github(url): | ||
with urllib.request.urlopen(url) as response: | ||
if response.status == 200: | ||
return response.read().decode('utf-8') | ||
else: | ||
raise Exception("Failed to download file from GitHub") | ||
|
||
def load_yaml_from_local(path): | ||
with open(path, 'r') as file: | ||
return file.read() | ||
|
||
def compare_yaml_keys(github_yaml, local_yaml): | ||
github_keys = set(github_yaml.keys()) | ||
local_keys = set(local_yaml.keys()) | ||
|
||
# Keys in GitHub YAML but not in local YAML | ||
new_keys = github_keys.difference(local_keys) | ||
|
||
# Keys in local YAML but not in GitHub YAML | ||
missing_keys = local_keys.difference(github_keys) | ||
|
||
return new_keys, missing_keys | ||
|
||
parser = argparse.ArgumentParser(description='Compare YAML keys.') | ||
parser.add_argument('--dev', action='store_true', help='check against dev branch') | ||
args = parser.parse_args() | ||
|
||
for local_file_path, remote_url_path in files: | ||
commit = 'dev' if args.dev else DEFAULT_COMMIT | ||
|
||
url = f"{remote_base_url}/{commit}/{remote_url_path}" | ||
github_yaml_str = load_yaml_from_github(url) | ||
local_yaml_str = load_yaml_from_local(local_file_path) | ||
github_yaml = yaml.safe_load(github_yaml_str) | ||
local_yaml = yaml.safe_load(local_yaml_str) | ||
|
||
new_keys, missing_keys = compare_yaml_keys(github_yaml, local_yaml) | ||
|
||
print(local_file_path, commit, remote_url_path) | ||
if new_keys: | ||
print("New keys found in GitHub YAML not used in local YAML:", new_keys) | ||
sys.exit(1) | ||
elif missing_keys: | ||
print("Keys in local YAML not found in GitHub YAML:", missing_keys) | ||
sys.exit(1) | ||
else: | ||
print("No differences in keys found.") | ||
|
||
diff = difflib.unified_diff( | ||
github_yaml_str.splitlines(), | ||
local_yaml_str.splitlines(), | ||
lineterm='' | ||
) | ||
print('\n'.join(line for line in diff if line.startswith(('+', '-')))) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This used to be 2304 before this PR. Intended change? The new number does not match the comment anymore.
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.
Actually, it was 33024 already before (inherited from the preset). But the comment still is wrong and suggests 2304.
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.
status-im/nimbus-eth2#5590
Fixed it in Nimbus. Because
config.yaml
didn't specify it, we defaulted to 2304 based on the computation in the comment.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 variable
MIN_EPOCHS_FOR_BLOCK_REQUESTS
was not defined in the config before this change. It was added 6 months ago in Ethereum's config on a effort to define network variables ethereum/consensus-specs@f87e143Thanks for noticing, does Nimbus prune blocks according to
MIN_EPOCHS_FOR_BLOCK_REQUESTS
?