Skip to content

Normalize contract deployment keys #600

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

Merged
merged 3 commits into from
Mar 11, 2025
Merged

Normalize contract deployment keys #600

merged 3 commits into from
Mar 11, 2025

Conversation

fbac
Copy link
Collaborator

@fbac fbac commented Mar 10, 2025

Use standard naming for contract deployment JSON files.
Start using constructorArgs section for contracts that requires constructor args.

Summary by CodeRabbit

  • Refactor

    • Standardized naming in serialized output for addresses across deployments and upgrades, ensuring a more consistent structure.
  • Chore

    • Updated environment configurations and address retrieval processes to streamline deployment and integration workflows.
    • Adjusted extraction of contract addresses in environment files to reference updated JSON fields.
    • Simplified address retrieval methods in testing utilities for improved flexibility.

@fbac fbac requested a review from a team as a code owner March 10, 2025 09:41
Copy link
Contributor

coderabbitai bot commented Mar 10, 2025

Walkthrough

The pull request updates the JSON key names used in various deployment and upgrade scripts. The changes standardize key naming by replacing custom prefixes with generic names (e.g., "deployer", "proxyAdmin", "proxy", "implementation") and by restructuring serialization in one case to separate constructor arguments. Additionally, environment variable extraction and helper functions have been updated to reflect these new key names, ensuring consistent address retrieval across deployment, upgrade, and testing workflows.

Changes

Affected Files Change Summary
contracts/script/DeployGroupMessages.s.sol, contracts/script/DeployIdentityUpdates.s.sol,
contracts/script/DeployRatesManager.s.sol
Renamed serialization keys in the _serializeDeploymentData function, replacing contract-specific prefixes (e.g., "groupMessagesDeployer", "identityUpdatesProxy", "ratesManagerImpl") with generic keys: "deployer", "proxyAdmin", "proxy", and "implementation".
contracts/script/DeployNodeRegistry.s.sol Modified the _serializeDeploymentData function: removed serialization of some addresses, grouped deployer and implementation under an addresses key, and introduced a new constructorArgs key to hold the initial admin address.
contracts/script/upgrades/UpgradeGroupMessages.s.sol,
contracts/script/upgrades/UpgradeIdentityUpdates.s.sol
Updated JSON key names in the _initializeProxy and _serializeUpgradeData functions. Changed the proxy and implementation keys (e.g., from "groupMessagesProxy"/"identityUpdatesProxy" and "groupMessagesImpl"/"identityUpdatesImpl") to use "proxy" and "implementation", respectively.
dev/baked/Dockerfile, dev/local.env Updated environment variable assignments to extract contract addresses using the updated JSON keys. For instance, references to fields like .addresses.XMTPNodeRegistry, .addresses.groupMessagesProxy, and .addresses.identityUpdatesProxy are replaced with .addresses.implementation and .addresses.proxy.
pkg/testutils/config.go Updated the getContractAddress function: added an extra key parameter for more flexible, generic retrieval of contract addresses, replacing previous conditional logic based on file names.
contracts/dev/lib/common Simplified address retrieval in the forge_verify_contract function by directly accessing the implementation field in the JSON file instead of constructing a key based on the contract name.

Sequence Diagram(s)

sequenceDiagram
  participant DS as DeployScript
  participant JSON as JSON Output File
  participant U as UpgradeScript
  participant E as Environment Setup
  
  DS->>JSON: Serialize deployment data using updated keys<br/>(deployer, proxyAdmin, proxy, implementation, constructorArgs)
  JSON-->>U: Provide contract addresses for upgrades via generic keys
  JSON-->>E: Supply contract addresses for environment variable extraction
Loading

Possibly related PRs

Suggested reviewers

  • neekolas

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f3a7fd4 and 21df28c.

📒 Files selected for processing (1)
  • contracts/dev/lib/common (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build pre-baked anvil-xmtpd
  • GitHub Check: Test (Node)
🔇 Additional comments (1)
contracts/dev/lib/common (1)

119-119:

❓ Verification inconclusive

Good standardization of contract address retrieval.

The update simplifies the contract address retrieval by using a standardized path .addresses.implementation instead of constructing a custom key based on the contract name. This change aligns with the PR objectives to implement standard naming conventions for contract deployment JSON files.

Make sure all deployment JSON files have been updated to use this new structure with the implementation key. You can verify this with:


🏁 Script executed:

#!/bin/bash
# Check all deployment JSON files to ensure they use the new standardized format
find config -name "*.json" -type f -exec grep -l "implementation" {} \; | xargs cat | jq -c 'if has("addresses") and .addresses | has("implementation") then "✓ Valid format" else "✗ Missing implementation key in standard format" end'

Length of output: 278


Action Required: Manually Verify Deployment JSON Structure

The refactoring of the contract address retrieval to use the standardized .addresses.implementation key looks good. However, our automated check couldn’t locate a config directory, which suggests that deployment JSON files may reside in a different location than expected. Please manually verify that all deployment JSON files—wherever they reside—have been updated to follow the new structure with the implementation key.

  • Verify the target location of your deployment JSON files if it differs from config/….
  • Ensure that each deployment JSON file includes the .addresses.implementation key according to the new standard.

🪧 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 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@fbac fbac merged commit 0768a8f into main Mar 11, 2025
13 of 14 checks passed
@fbac fbac deleted the 03-10-normalize_impl_keys branch March 11, 2025 10:42
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.

2 participants