Skip to content

fix: do not override comments#1414

Merged
hmzakhalid merged 2 commits into
mainfrom
fix/config-updater
Mar 12, 2026
Merged

fix: do not override comments#1414
hmzakhalid merged 2 commits into
mainfrom
fix/config-updater

Conversation

@ctrlc03

@ctrlc03 ctrlc03 commented Mar 11, 2026

Copy link
Copy Markdown
Collaborator

fix #1051

Summary by CodeRabbit

  • Chores
    • Updated contract deployment configuration with revised deployment block values for multiple contracts
    • Refreshed contract address formatting in configuration files
    • Extended node configuration with additional networking and authentication parameters
    • Improved configuration update mechanism for deployment settings

@vercel

vercel Bot commented Mar 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
crisp Ready Ready Preview, Comment Mar 12, 2026 0:05am
enclave-docs Ready Ready Preview, Comment Mar 12, 2026 0:05am

Request Review

@coderabbitai

coderabbitai Bot commented Mar 11, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The pull request updates the enclave configuration file with new contract deploy block values and expanded node configuration, while refactoring the config updater script to use a line-oriented state machine instead of YAML parsing, thereby preserving comments and formatting.

Changes

Cohort / File(s) Summary
Configuration File
examples/CRISP/enclave.config.yaml
Updated contract addresses quote style and increased deploy_block values for multiple contracts (e3_program, enclave, ciphernode_registry, bonding_registry, slashing_manager, fee_token). Expanded cn1 node entry with quic_port, autonetkey, and autopassword fields. Added commented risc0 development configuration block.
Config Update Utility
packages/enclave-contracts/scripts/utils.ts
Replaced YAML parsing with line-oriented state machine approach to preserve comments, blank lines, and quote styles. Added pre-processing to collect deployment updates, traverses config to locate and update contract entries, handles chain creation if target doesn't exist, tracks updates with verbose logging, and writes modified content back to file without YAML serialization.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • ryardley
  • cedoor
  • 0xjei
  • hmzakhalid

Poem

🐰 A config updater hops so bright,
Where comments dance and quotes align,
No YAML chains to strip away the light,
The state machine makes configs shine!
Through chains of blocks we now preserve,
What once was lost, now wisely saved. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: do not override comments' directly corresponds to the main objective of the PR, which is to preserve comments in the config updater.
Linked Issues check ✅ Passed The code changes implement the core requirement to preserve comments and maintain quote styles when updating the enclave config, replacing YAML-based manipulation with text line parsing.
Out of Scope Changes check ✅ Passed All changes focus on the config updater functionality and YAML configuration file updates, directly aligned with the issue objective of preserving comments.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/config-updater

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
packages/enclave-contracts/scripts/utils.ts (2)

331-351: Partial field updates not handled.

If an existing contract has address but is missing deploy_block, the current logic marks the contract as "found" (line 277) but won't add the missing deploy_block field. The contract would be skipped by the "missing contracts" logic since it's in foundKeys.

This is likely acceptable if all existing contracts have both fields, but worth noting as a potential edge case.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/enclave-contracts/scripts/utils.ts` around lines 331 - 351, Existing
contracts that are marked as found (foundKeys) but are missing specific fields
(e.g., deploy_block) are not updated; modify the logic that processes found keys
so it checks each found contract's existing lines for missing fields and inserts
only the missing fields (address and/or deploy_block) instead of treating the
whole contract as complete. Use the existing variables and structures
(foundKeys, updates, lines, contractEntryIndent, contractsKeyIndent,
lastContractsLine) to locate the contract block in lines, detect whether
"address:" and "deploy_block:" exist for a given configKey, and push or splice
the necessary line(s) with correct indentation and values from
updates.get(configKey) when a field is absent. Ensure you still avoid
duplicating fields and preserve indenting using contractEntryIndent/valIndent.

317-330: Hardcoded indentation assumes 2-space YAML style.

The new chain entry uses hardcoded 2-space indentation. This works for the current configs but could produce inconsistent formatting if a config file uses different indentation. Consider deriving the indentation from the existing chains: section structure for better robustness.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/enclave-contracts/scripts/utils.ts` around lines 317 - 330, The
newLines creation hardcodes 2-space indentation; change it to derive indentation
from the surrounding YAML by detecting the leading whitespace of the existing
"chains:" section (or the line at insertIdx) and compute per-level indent, then
build the entry using that indent for the chain name, rpc_url, contracts, and
nested contract fields (use the same indent variable when pushing strings
instead of literal two spaces); update the code that constructs newLines
(referencing newLines, chainToConfig, rpcUrl, updates, insertIdx, and lines) to
use the computed indent so added entries match the file's existing indentation
style.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/enclave-contracts/scripts/utils.ts`:
- Around line 331-351: Existing contracts that are marked as found (foundKeys)
but are missing specific fields (e.g., deploy_block) are not updated; modify the
logic that processes found keys so it checks each found contract's existing
lines for missing fields and inserts only the missing fields (address and/or
deploy_block) instead of treating the whole contract as complete. Use the
existing variables and structures (foundKeys, updates, lines,
contractEntryIndent, contractsKeyIndent, lastContractsLine) to locate the
contract block in lines, detect whether "address:" and "deploy_block:" exist for
a given configKey, and push or splice the necessary line(s) with correct
indentation and values from updates.get(configKey) when a field is absent.
Ensure you still avoid duplicating fields and preserve indenting using
contractEntryIndent/valIndent.
- Around line 317-330: The newLines creation hardcodes 2-space indentation;
change it to derive indentation from the surrounding YAML by detecting the
leading whitespace of the existing "chains:" section (or the line at insertIdx)
and compute per-level indent, then build the entry using that indent for the
chain name, rpc_url, contracts, and nested contract fields (use the same indent
variable when pushing strings instead of literal two spaces); update the code
that constructs newLines (referencing newLines, chainToConfig, rpcUrl, updates,
insertIdx, and lines) to use the computed indent so added entries match the
file's existing indentation style.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 08dcf991-3ac4-43cd-9596-a4fe9ffae6ec

📥 Commits

Reviewing files that changed from the base of the PR and between e81d4fe and 03e9738.

📒 Files selected for processing (2)
  • examples/CRISP/enclave.config.yaml
  • packages/enclave-contracts/scripts/utils.ts

@hmzakhalid hmzakhalid enabled auto-merge (squash) March 12, 2026 12:03
@hmzakhalid hmzakhalid merged commit f02f165 into main Mar 12, 2026
26 checks passed
@github-actions github-actions Bot deleted the fix/config-updater branch March 20, 2026 03:12
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.

Make config updater not remove comments

2 participants