-
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
chore: updates to node deploy script #546
Conversation
Warning Rate limit exceeded@fbac has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 45 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThis pull request updates several deployment scripts. In both the GroupMessages and IdentityUpdates scripts, the check ensuring the admin is an Externally Owned Account has been removed and replaced with a new validation that confirms the private key is non-zero. A new constant, Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant DX as DeployXMTPNodeRegistry
participant Env as Environment
participant N as Nodes Contract
participant FS as File System
U->>DX: Call run()
DX->>Env: Retrieve admin & privateKey
Env-->>DX: Return admin & privateKey
DX->>DX: Validate privateKey is non-zero
DX->>N: Deploy new Nodes(admin)
N-->>DX: Return deployed contract instance
DX->>FS: Serialize and write deployment data to JSON file
FS-->>DX: Confirm write operation
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
contracts/script/DeployNodeRegistry.s.sol (1)
32-48
: Improve string constants and naming.Consider making the string literals constants and using a more descriptive name for the parent object.
Apply this diff to improve the code:
+ string private constant PARENT_OBJECT = "xmtp_node_registry"; + string private constant ADDRESSES_KEY = "addresses"; + string private constant DEPLOYER_KEY = "XMTPNodeRegistryDeployer"; + string private constant ADMIN_KEY = "XMTPNodeRegistryInitialAdmin"; + string private constant REGISTRY_KEY = "XMTPNodeRegistry"; + string private constant DEPLOYMENT_BLOCK_KEY = "deploymentBlock"; + string private constant UPGRADE_BLOCK_KEY = "latestUpgradeBlock"; + function _serializeDeploymentData() internal { - string memory parent_object = "parent object"; - string memory addresses = "addresses"; string memory addressesOutput; - addressesOutput = vm.serializeAddress(addresses, "XMTPNodeRegistryDeployer", deployer); - addressesOutput = vm.serializeAddress(addresses, "XMTPNodeRegistryInitialAdmin", admin); - addressesOutput = vm.serializeAddress(addresses, "XMTPNodeRegistry", address(nodes)); + addressesOutput = vm.serializeAddress(ADDRESSES_KEY, DEPLOYER_KEY, deployer); + addressesOutput = vm.serializeAddress(ADDRESSES_KEY, ADMIN_KEY, admin); + addressesOutput = vm.serializeAddress(ADDRESSES_KEY, REGISTRY_KEY, address(nodes)); string memory finalJson; - finalJson = vm.serializeString(parent_object, addresses, addressesOutput); - finalJson = vm.serializeUint(parent_object, "deploymentBlock", block.number); - finalJson = vm.serializeUint(parent_object, "latestUpgradeBlock", block.number); + finalJson = vm.serializeString(PARENT_OBJECT, ADDRESSES_KEY, addressesOutput); + finalJson = vm.serializeUint(PARENT_OBJECT, DEPLOYMENT_BLOCK_KEY, block.number); + finalJson = vm.serializeUint(PARENT_OBJECT, UPGRADE_BLOCK_KEY, block.number); writeOutput(finalJson, XMTP_NODE_REGISTRY_OUTPUT_JSON); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
contracts/script/DeployGroupMessages.s.sol
(0 hunks)contracts/script/DeployIdentityUpdates.s.sol
(0 hunks)contracts/script/DeployNodeRegistry.s.sol
(1 hunks)contracts/script/utils/Environment.sol
(1 hunks)
💤 Files with no reviewable changes (2)
- contracts/script/DeployIdentityUpdates.s.sol
- contracts/script/DeployGroupMessages.s.sol
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: abis
🔇 Additional comments (3)
contracts/script/utils/Environment.sol (1)
9-9
: LGTM!The new constant follows the established naming convention and aligns with the contract renaming in
DeployNodeRegistry.s.sol
.contracts/script/DeployNodeRegistry.s.sol (2)
4-10
: LGTM!The imports and contract inheritance are well-structured and follow good practices.
11-14
: LGTM!The state variables are well-defined and necessary for the deployment process.
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
contracts/script/DeployNodeRegistry.s.sol (1)
34-50
: Consider defining string literals as constants.The string literals "parent object" and "addresses" should be defined as constants for better maintainability and to avoid magic strings.
contract DeployXMTPNodeRegistry is Script, Environment, Utils { + string constant PARENT_OBJECT = "parent object"; + string constant ADDRESSES = "addresses"; Nodes nodes; // ... existing code ... function _serializeDeploymentData() internal { - string memory parent_object = "parent object"; - string memory addresses = "addresses"; + string memory addressesOutput; - string memory addressesOutput; - - addressesOutput = vm.serializeAddress(addresses, "XMTPNodeRegistryDeployer", deployer); - addressesOutput = vm.serializeAddress(addresses, "XMTPNodeRegistryInitialAdmin", admin); - addressesOutput = vm.serializeAddress(addresses, "XMTPNodeRegistry", address(nodes)); + addressesOutput = vm.serializeAddress(ADDRESSES, "XMTPNodeRegistryDeployer", deployer); + addressesOutput = vm.serializeAddress(ADDRESSES, "XMTPNodeRegistryInitialAdmin", admin); + addressesOutput = vm.serializeAddress(ADDRESSES, "XMTPNodeRegistry", address(nodes)); string memory finalJson; - finalJson = vm.serializeString(parent_object, addresses, addressesOutput); - finalJson = vm.serializeUint(parent_object, "deploymentBlock", block.number); - finalJson = vm.serializeUint(parent_object, "latestUpgradeBlock", block.number); + finalJson = vm.serializeString(PARENT_OBJECT, ADDRESSES, addressesOutput); + finalJson = vm.serializeUint(PARENT_OBJECT, "deploymentBlock", block.number); + finalJson = vm.serializeUint(PARENT_OBJECT, "latestUpgradeBlock", block.number);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
contracts/script/DeployGroupMessages.s.sol
(1 hunks)contracts/script/DeployIdentityUpdates.s.sol
(1 hunks)contracts/script/DeployNodeRegistry.s.sol
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- contracts/script/DeployIdentityUpdates.s.sol
- contracts/script/DeployGroupMessages.s.sol
🔇 Additional comments (3)
contracts/script/DeployNodeRegistry.s.sol (3)
4-8
: LGTM! Well-organized imports.The imports are logically organized and align with the contract's new functionality.
10-14
: LGTM! Clear contract structure.The contract name is descriptive, and the state variables are well-organized with appropriate inheritance.
16-32
: LGTM! Robust deployment flow with proper validations.The deployment flow includes all necessary validations, including the previously suggested private key check.
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
contracts/script/DeployNodeRegistryV2.s.sol (1)
34-50
: Consider using constants for string literals.The JSON keys and object names could be defined as constants to improve maintainability and prevent typos.
contract DeployXMTPNodeRegistry is Script, Environment, Utils { + string constant PARENT_OBJECT = "parent object"; + string constant ADDRESSES_OBJECT = "addresses"; + string constant DEPLOYER_KEY = "XMTPNodeRegistryDeployer"; + string constant ADMIN_KEY = "XMTPNodeRegistryInitialAdmin"; + string constant REGISTRY_KEY = "XMTPNodeRegistry"; + string constant DEPLOYMENT_BLOCK_KEY = "deploymentBlock"; + string constant UPGRADE_BLOCK_KEY = "latestUpgradeBlock"; function _serializeDeploymentData() internal { - string memory parent_object = "parent object"; - string memory addresses = "addresses"; + string memory addressesOutput; - string memory addressesOutput; - - addressesOutput = vm.serializeAddress(addresses, "XMTPNodeRegistryDeployer", deployer); - addressesOutput = vm.serializeAddress(addresses, "XMTPNodeRegistryInitialAdmin", admin); - addressesOutput = vm.serializeAddress(addresses, "XMTPNodeRegistry", address(nodes)); + addressesOutput = vm.serializeAddress(ADDRESSES_OBJECT, DEPLOYER_KEY, deployer); + addressesOutput = vm.serializeAddress(ADDRESSES_OBJECT, ADMIN_KEY, admin); + addressesOutput = vm.serializeAddress(ADDRESSES_OBJECT, REGISTRY_KEY, address(nodes)); string memory finalJson; - finalJson = vm.serializeString(parent_object, addresses, addressesOutput); - finalJson = vm.serializeUint(parent_object, "deploymentBlock", block.number); - finalJson = vm.serializeUint(parent_object, "latestUpgradeBlock", block.number); + finalJson = vm.serializeString(PARENT_OBJECT, ADDRESSES_OBJECT, addressesOutput); + finalJson = vm.serializeUint(PARENT_OBJECT, DEPLOYMENT_BLOCK_KEY, block.number); + finalJson = vm.serializeUint(PARENT_OBJECT, UPGRADE_BLOCK_KEY, block.number);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
contracts/script/DeployNodeRegistryV1.s.sol
(1 hunks)contracts/script/DeployNodeRegistryV2.s.sol
(1 hunks)
🔇 Additional comments (3)
contracts/script/DeployNodeRegistryV2.s.sol (3)
10-14
: LGTM!The contract inheritance and state variables are well-structured for a deployment script.
49-49
:✅ Verification successful
Verify the output file constant.
The
XMTP_NODE_REGISTRY_OUTPUT_JSON
constant should be defined in theEnvironment
contract.Let's verify the constant definition:
🏁 Script executed:
#!/bin/bash # Description: Check for XMTP_NODE_REGISTRY_OUTPUT_JSON constant in Environment contract rg "XMTP_NODE_REGISTRY_OUTPUT_JSON" contracts/script/utils/Environment.solLength of output: 154
Constant Verification: The
XMTP_NODE_REGISTRY_OUTPUT_JSON
constant is correctly defined in thecontracts/script/utils/Environment.sol
file with the value"XMTPNodeRegistry"
, as expected. No changes are needed here.
16-32
:✅ Verification successful
Verify the intentional removal of admin address validation.
The script only validates that the admin address is non-zero but doesn't check if it's a contract address. According to the AI summary, this is an intentional change aligned with other deployment scripts.
Let's verify this pattern in other deployment scripts:
🏁 Script executed:
#!/bin/bash # Description: Check for admin address validation in other deployment scripts rg -A 5 "XMTP_NODE_REGISTRY_ADMIN_ADDRESS" contracts/script/Length of output: 672
Confirm intentional omission of additional admin validation
After verifying the code in
contracts/script/DeployNodeRegistryV2.s.sol
, it's clear that the admin address is retrieved from the environment and only checked to ensure it isn’t the zero address. No extra validation (such as checking that the admin isn’t a contract) is performed, which is consistent with the behavior observed in similar deployment scripts.
- Verification findings:
- The deployment script only validates that the admin address is non-zero.
- A search in the deployment scripts did not reveal any extra contract address validation for the admin.
Please confirm that this minimal validation is an intentional design choice.
Closes #542
Summary by CodeRabbit
New Features
Refactor