Skip to content

Update rippled.cfg file #824

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Update rippled.cfg file #824

wants to merge 7 commits into from

Conversation

ckeshava
Copy link
Collaborator

@ckeshava ckeshava commented Apr 7, 2025

High Level Overview of Change

This PR aims to bring parity between new rippled amendments and the ones enabled in the xrpl-py integration tests. Developers often forget to include new amendments. This could result in behavioral differences between testing the client libraries and usage in real-world production environments.

The PR defines a new Python script to fetch amendments. A new Github Actions step is defined for committing an updated rippled.cfg file.

This update is triggered on every pull-request triggered from a branch residing in this remote: https://github.com/XRPLF/xrpl-py (i.e. no external forks). This step requires write-permissions into the said branch.

Context of Change

Note:

  1. The develop branch of rippled repository is monitored for new amendments.
  2. Owing to the implementation of the ConfigParser library, comments inside the configuration file are not preserved. While this is not ideal behavior, I'm open to hearing alternative library suggestions. All the comments in the cfg file are non-essential. They have already been covered elsewhere in the XRPL documentation.
  3. This step is configured to run on internal-PRs. I'd like to hear your opinion about running this step on PRs from external forks.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Documentation Updates
  • Release

Did you update CHANGELOG.md?

  • Yes
  • No, this change does not impact library users

Test Plan

Copy link
Contributor

coderabbitai bot commented Apr 7, 2025

Walkthrough

The changes include a cleanup and update of the .ci-config/rippled.cfg file by removing commented-out lines and revising configuration syntax. The GitHub Actions workflow in .github/workflows/integration_test.yml is modified to add new steps that fetch and commit the latest configuration amendments and reorder existing steps. Additionally, a new Python script at tools/fetch_rippled_amendments.py is introduced to retrieve amendments from a remote source and update the configuration file when new entries are found.

Changes

File(s) Change Summary
.ci-config/rippled.cfg Removed commented-out configuration lines; updated syntax (colon to equals) in [rpc_startup] and [node_db]; streamlined and added new features.
.github/workflows/integration_test.yml Added steps to fetch and commit the latest rippled amendments; repositioned the Docker execution step; enhanced the checkout process for PRs.
tools/fetch_rippled_amendments.py Introduced a new script that fetches amendments via an HTTP GET request, uses regex to extract amendment data, and updates the configuration if needed.

Sequence Diagram(s)

sequenceDiagram
    participant PR as "Pull Request"
    participant CI as "GitHub Actions"
    participant Script as "Fetch Amendments Script"
    participant Server as "Remote Server"
    
    PR->>CI: Open Pull Request
    CI->>Script: Run "Fetch latest rippled amendments"
    Script->>Server: HTTP GET request for amendments
    Server-->>Script: Return amendments data
    Script->>CI: Update rippled.cfg if changes found
    CI->>CI: Run "Add and commit rippled.cfg" step
    CI->>CI: Execute Docker step in background
Loading
sequenceDiagram
    participant Script as "Fetch Amendments Script"
    participant Regex as "Regex Extraction"
    participant Config as "rippled.cfg"
    
    Script->>Script: Fetch amendments from remote source
    Script->>Regex: Extract amendments and fixes
    Regex-->>Script: Return parsed amendment list
    Script->>Config: Compare and update configuration if new entries exist
Loading

Suggested reviewers

  • anissa-ripple
  • justinr1234
  • mvadari

Poem

In a world of code, I bound and hop, 🐇
Cleaning configs until errors stop.
Amendments fetched with a friendly wink,
Committing changes before you blink.
Hip, hop, hooray—code flows non-stop!


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc6b797 and 4236ca6.

📒 Files selected for processing (1)
  • tools/fetch_rippled_amendments.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tools/fetch_rippled_amendments.py
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Integration test (3.13)
  • GitHub Check: Integration test (3.11)
  • GitHub Check: Integration test (3.8)
  • GitHub Check: Integration test (3.9)
  • GitHub Check: Integration test (3.12)
  • GitHub Check: Integration test (3.10)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ckeshava ckeshava marked this pull request as ready for review April 7, 2025 22:50
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (2)
tools/fetch_rippled_amendments.py (1)

67-69: Consider handling ConfigParser limitations.

As noted in the PR objectives, ConfigParser doesn't preserve comments. Consider adding a warning that comments will be removed or implementing a more robust solution.

            with open(CONFIG_FILE, "w", encoding="utf-8") as rippled_cfg_file:
+                print("WARNING: ConfigParser will remove comments from the file.")
                config.write(rippled_cfg_file)

Alternatively, you could implement a more robust solution using a different library or approach that preserves comments.

.ci-config/rippled.cfg (1)

54-54: Inconsistent JSON syntax in rpc_startup section.

The configuration uses an equals sign for "command" but a colon for "severity", which is inconsistent.

-{ "command" = "log_level", "severity": "info" }
+{ "command": "log_level", "severity": "info" }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 109c413 and 82693e6.

📒 Files selected for processing (3)
  • .ci-config/rippled.cfg (3 hunks)
  • .github/workflows/integration_test.yml (2 hunks)
  • tools/fetch_rippled_amendments.py (1 hunks)
🔇 Additional comments (6)
.github/workflows/integration_test.yml (4)

25-27: Good addition of PR-specific checkout parameters.

The workflow now properly checks out the code from the pull request's repository and branch, which is essential for the commit step to work correctly later in the workflow.


55-59: Good implementation of the amendment fetching step.

This step correctly executes the new Python script and only runs during pull requests, which aligns with the PR objectives.


60-70: Proper implementation of automated commit step.

The workflow uses the EndBug/add-and-commit action to automatically commit any changes to the rippled.cfg file. The commit message and author details are appropriately set.


71-74: Strategic reordering of Docker step.

Moving the Docker run step after the amendment fetching and commit steps ensures that the Docker container uses the updated configuration file.

.ci-config/rippled.cfg (2)

27-30: Good formatting improvements in node_db section.

The spacing around equals signs improves readability and consistency.


142-149: Good addition of new amendments.

These new amendments have been added correctly to the features section, which is the main purpose of the PR.

ckeshava and others added 2 commits April 7, 2025 16:04
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (2)
tools/fetch_rippled_amendments.py (2)

52-54: Add null check for fetch_rippled_amendments result.

Even though the function now returns an empty list on error, it's still good practice to validate the result before using it.

        existing_amendments = [v for v in config[FEATURES_SECTION] if v]
        new_rippled_amendments = fetch_rippled_amendments()
+        
+        if not new_rippled_amendments:
+            print("WARNING: No amendments fetched. Using existing configuration.")

10-14: 🛠️ Refactor suggestion

Add error handling for network failures.

The script makes HTTP requests but doesn't handle network-related exceptions that could be raised by requests.get().

import configparser
import os
import re
+import sys

import requests

CONFIG_FILE = os.path.join(os.getcwd(), ".ci-config", "rippled.cfg")
FEATURES_SECTION = "features"
RIPPLED_FEATURES_FILE = "https://raw.githubusercontent.com/XRPLF/rippled/develop/include/xrpl/protocol/detail/features.macro"
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82693e6 and cc6b797.

📒 Files selected for processing (1)
  • tools/fetch_rippled_amendments.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
tools/fetch_rippled_amendments.py

37-37: SyntaxError: Expected ',', found name


43-43: SyntaxError: Expected ',', found name


43-44: SyntaxError: Expected ')', found newline

🪛 GitHub Actions: Integration test
tools/fetch_rippled_amendments.py

[error] 37-37: SyntaxError: invalid syntax

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Snippet test (3.11)
  • GitHub Check: Snippet test (3.13)
  • GitHub Check: Snippet test (3.10)
  • GitHub Check: Snippet test (3.12)
  • GitHub Check: Snippet test (3.8)

Comment on lines 23 to 47
def fetch_rippled_amendments():
# Send a GET request
response = requests.get(RIPPLED_FEATURES_FILE, timeout=30) # 30 second timeout

# Check for successful request
if response.status_code == 200:
features_contents = response.text
feature_hits = re.findall(
feature_hits = re.findall(
r"^ *XRPL_FEATURE *\(([a-zA-Z0-9_]+), * Supported::yes, VoteBehavior::Default(Yes|No)",
features_contents,
re.MULTILINE,
)

fix_hits = re.findall(
r"^ *XRPL_FIX *\(([a-zA-Z0-9_]+), * Supported::yes,",
features_contents,
re.MULTILINE,
)

all_supported_amendments = feature_hits + ["fix" + f for f in fix_hits]
return all_supported_amendments
else:
print(f"Failed to fetch file. Status code: {response.status_code}")
return []
Copy link
Contributor

@coderabbitai coderabbitai bot Apr 7, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add try-except block to handle request exceptions.

The current implementation doesn't handle exceptions that might be raised during the HTTP request, such as connection errors or timeouts.

def fetch_rippled_amendments():
    # Send a GET request
-    response = requests.get(RIPPLED_FEATURES_FILE, timeout=30)  # 30 second timeout
-
-    # Check for successful request
-    if response.status_code == 200:
-        features_contents = response.text
+    try:
+        response = requests.get(RIPPLED_FEATURES_FILE, timeout=30)  # 30 second timeout
+        
+        # Check for successful request
+        if response.status_code == 200:
+            features_contents = response.text
+            feature_hits = re.findall(
+                r"^ *XRPL_FEATURE *\(([a-zA-Z0-9_]+), * Supported::yes, VoteBehavior::Default(Yes|No)",
+                features_contents,
+                re.MULTILINE,
+            )
+    
+            fix_hits = re.findall(
+                r"^ *XRPL_FIX *\(([a-zA-Z0-9_]+), * Supported::yes,",
+                features_contents,
+                re.MULTILINE,
+            )
+    
+            all_supported_amendments = feature_hits + ["fix" + f for f in fix_hits]
+            return all_supported_amendments
+        else:
+            print(f"Failed to fetch file. Status code: {response.status_code}")
+            return []
+    except requests.exceptions.RequestException as e:
+        print(f"Error making request: {e}")
+        return []
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def fetch_rippled_amendments():
# Send a GET request
response = requests.get(RIPPLED_FEATURES_FILE, timeout=30) # 30 second timeout
# Check for successful request
if response.status_code == 200:
features_contents = response.text
feature_hits = re.findall(
feature_hits = re.findall(
r"^ *XRPL_FEATURE *\(([a-zA-Z0-9_]+), * Supported::yes, VoteBehavior::Default(Yes|No)",
features_contents,
re.MULTILINE,
)
fix_hits = re.findall(
r"^ *XRPL_FIX *\(([a-zA-Z0-9_]+), * Supported::yes,",
features_contents,
re.MULTILINE,
)
all_supported_amendments = feature_hits + ["fix" + f for f in fix_hits]
return all_supported_amendments
else:
print(f"Failed to fetch file. Status code: {response.status_code}")
return []
def fetch_rippled_amendments():
# Send a GET request
try:
response = requests.get(RIPPLED_FEATURES_FILE, timeout=30) # 30 second timeout
# Check for successful request
if response.status_code == 200:
features_contents = response.text
feature_hits = re.findall(
r"^ *XRPL_FEATURE *\(([a-zA-Z0-9_]+), * Supported::yes, VoteBehavior::Default(Yes|No)",
features_contents,
re.MULTILINE,
)
fix_hits = re.findall(
r"^ *XRPL_FIX *\(([a-zA-Z0-9_]+), * Supported::yes,",
features_contents,
re.MULTILINE,
)
all_supported_amendments = feature_hits + ["fix" + f for f in fix_hits]
return all_supported_amendments
else:
print(f"Failed to fetch file. Status code: {response.status_code}")
return []
except requests.exceptions.RequestException as e:
print(f"Error making request: {e}")
return []
🧰 Tools
🪛 Ruff (0.8.2)

37-37: SyntaxError: Expected ',', found name


43-43: SyntaxError: Expected ',', found name


43-44: SyntaxError: Expected ')', found newline

🪛 GitHub Actions: Integration test

[error] 37-37: SyntaxError: invalid syntax

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can you give me examples of errors (or) circumstances where this try-catch block is helpful? I'd prefer to keep the code concise rather than catch all possible errors.

Certain errors are acceptable in this case. It is not used in production. Developers can look at the logs of the CI/CD pipeline, in case of any errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ckeshava You're right about keeping CI/CD code concise. The try-catch block would primarily help with network-related issues like:

  1. Temporary GitHub outages or rate limiting
  2. Network connectivity problems
  3. Request timeouts
  4. DNS resolution failures

Without exception handling, these would cause the script to crash with a potentially confusing traceback rather than a clear error message. However, since this is for CI/CD only and developers can check the logs, letting it fail with the default Python traceback is a reasonable approach if you prefer concise code.

I'll defer to your judgment on this one, as your preference for simplicity makes sense in this context.

✏️ Learnings added
Learnt from: ckeshava
PR: XRPLF/xrpl-py#824
File: tools/fetch_rippled_amendments.py:0-0
Timestamp: 2025-04-07T23:32:27.045Z
Learning: For CI/CD scripts in the xrpl-py repository, ckeshava prefers concise code over comprehensive error handling since developers can check the logs for error details.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

path=/var/lib/rippled/db/nudb
advisory_delete=0

# How many ledgers do we want to keep (history)?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are all the comments removed?

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've explained in point-2 under "Context of Change": #824 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

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

The comments are for us, not for rippled - they're supposed to be ignored by rippled


import requests

CONFIG_FILE = os.path.join(os.getcwd(), ".ci-config", "rippled.cfg")
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be much more efficient to use the feature RPC on Devnet

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are cases where new rippled amendments have been merged into the cpp code, but haven't been deployed into a devnet yet. I suspect this happens frequently for new amendments. Parsing the develop branch of the rippled repository covers this case.

I'm not strongly opposed to using the feature command on the devnet.

run: |
poetry run python tools/fetch_rippled_amendments.py

- name: Add and commit rippled.cfg
Copy link
Collaborator

@mvadari mvadari Apr 8, 2025

Choose a reason for hiding this comment

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

Why run this as a part of integration tests rather than have a separate PR open on a cron job to update it? Feels potentially confusing to anyone submitting a PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Integration tests make use of a docker container. The rippled.cfg file is used to kick-start the rippled server with custom amendments. The results of the integration tests differ based on which amendments have been enabled in the standalone mode.

separate PR open on a cron job to update it

Are you suggesting Github Actions cron jobs (or) running a cron-job from my personal machine to periodically fetch rippled PRs ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

A GitHub Action cron job.

@ckeshava
Copy link
Collaborator Author

ckeshava commented Apr 10, 2025 via email

@mvadari
Copy link
Collaborator

mvadari commented Apr 11, 2025

Why do you need the library? Why not just append text to the end of the file?

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