Skip to content
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

deploy relay facet to gravity chain #961

Merged
merged 12 commits into from
Feb 4, 2025

Conversation

0xDEnYO
Copy link
Contributor

@0xDEnYO 0xDEnYO commented Jan 29, 2025

Which Jira task belongs to this PR?

https://lifi.atlassian.net/browse/LF-11660

Why did I implement it this way?

Checklist before requesting a review

Checklist for reviewer (DO NOT DEPLOY and contracts BEFORE CHECKING THIS!!!)

  • I have checked that any arbitrary calls to external contracts are validated and or restricted
  • I have checked that any privileged calls (i.e. storage modifications) are validated and or restricted
  • I have ensured that any new contracts have had AT A MINIMUM 1 preliminary audit conducted on by <company/auditor>

Copy link
Contributor

coderabbitai bot commented Jan 29, 2025

Walkthrough

The pull request introduces updates to deployment-related configuration files for the gravity component. It adds a new entry in the _deployments_log_file.json for the production environment of version "1.0.0", includes a new "RelayFacet" address in the gravity.json file, modifies the module import approach in a safe proposal script, and adjusts the deployment task script with refined logging and error handling mechanisms.

Changes

File Change Summary
deployments/_deployments_log_file.json Added new deployment entry for gravity production version "1.0.0" with specific address, optimizer runs, timestamp, and verification details
deployments/gravity.json Added new entry for "RelayFacet" with corresponding Ethereum address
deployments/gravity.diamond.json Added new facet "RelayFacet" with version "1.0.0" and address, retained "ReceiverAcrossV3" entry
script/deploy/safe/propose-to-safe.ts Modified module imports for Safe and SafeApiKit to use dynamic imports
script/tasks/diamondUpdateFacet.sh Adjusted logging and error handling for deployment tasks, including verbosity flag changes
script/scriptMaster.sh Updated user interface text for diamond log file updates

Possibly related PRs

  • Diamond cut auto propose to safe #764: The changes in the main PR, which add a new entry under the "gravity" key in the JSON log file, are related to the modifications in the retrieved PR that also involve updates to the deployments/_deployments_log_file.json, specifically adding and modifying entries for contract deployments.
  • Deploy DeBridgeDLNFacet to production #932: The changes in the main PR, which involve adding a new entry under the "gravity" key in a JSON file, are related to the modifications in the retrieved PR that also involve JSON entries for deployment details, specifically concerning the same address for the "RelayFacet".
  • Deploy CBridge to Gravity #856: The changes in the main PR, which add a new entry under the "gravity" key in the JSON structure for deployment details, are directly related to the modifications in the retrieved PR that also involve adding entries under the "gravity" key in the same JSON file, specifically for different versions.

Suggested labels

AuditRequired, AuditCompleted

Suggested reviewers

  • ezynda3
  • mirooon

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

📜 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 db18b69 and 4328805.

📒 Files selected for processing (1)
  • script/tasks/diamondUpdateFacet.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • script/tasks/diamondUpdateFacet.sh
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: enforce-min-test-coverage
  • GitHub Check: run-unit-tests
  • GitHub Check: generate-tag

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?

❤️ Share
🪧 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. (Beta)
  • @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.

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)
script/deploy/safe/propose-to-safe.ts (1)

81-81: Remove commented-out duplicate initialization.

The commented line is identical to the line below it, suggesting it's a leftover from debugging or refactoring.

-    // const safeService = new SafeApiKit(config)
     const safeService = new SafeApiKit(config)
script/tasks/diamondUpdateFacet.sh (1)

117-117: Fix potential word splitting issues in docker run command.

The id -u and id -g commands should be quoted to prevent word splitting.

-            RAW_RETURN_DATA=$(docker run --rm -it --volume .:/foundry -u $(id -u):$(id -g) -e FOUNDRY_PROFILE=zksync -e NO_BROADCAST=true -e NETWORK=$NETWORK -e FILE_SUFFIX=$FILE_SUFFIX -e USE_DEF_DIAMOND=$USE_MUTABLE_DIAMOND -e PRIVATE_KEY=$PRIVATE_KEY foundry-zksync forge script "$UPDATE_SCRIPT" -f $NETWORK --json --skip-simulation --legacy --slow --zksync)
+            RAW_RETURN_DATA=$(docker run --rm -it --volume .:/foundry -u "$(id -u):$(id -g)" -e FOUNDRY_PROFILE=zksync -e NO_BROADCAST=true -e NETWORK=$NETWORK -e FILE_SUFFIX=$FILE_SUFFIX -e USE_DEF_DIAMOND=$USE_MUTABLE_DIAMOND -e PRIVATE_KEY=$PRIVATE_KEY foundry-zksync forge script "$UPDATE_SCRIPT" -f $NETWORK --json --skip-simulation --legacy --slow --zksync)
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 117-117: Quote this to prevent word splitting.

(SC2046)


[warning] 117-117: Quote this to prevent word splitting.

(SC2046)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 305600c and cf12b19.

📒 Files selected for processing (5)
  • config/relay.json (1 hunks)
  • deployments/_deployments_log_file.json (1 hunks)
  • deployments/gravity.json (1 hunks)
  • script/deploy/safe/propose-to-safe.ts (2 hunks)
  • script/tasks/diamondUpdateFacet.sh (4 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
script/tasks/diamondUpdateFacet.sh

[warning] 117-117: Quote this to prevent word splitting.

(SC2046)


[warning] 117-117: Quote this to prevent word splitting.

(SC2046)


[warning] 119-119: This assignment is only seen by the forked process.

(SC2097)


[warning] 119-119: This expansion will not see the mentioned assignment.

(SC2098)


[warning] 131-131: This assignment is only seen by the forked process.

(SC2097)


[warning] 131-131: This expansion will not see the mentioned assignment.

(SC2098)


[warning] 140-140: This assignment is only seen by the forked process.

(SC2097)


[warning] 140-140: This expansion will not see the mentioned assignment.

(SC2098)


[warning] 150-150: This assignment is only seen by the forked process.

(SC2097)


[warning] 150-150: This expansion will not see the mentioned assignment.

(SC2098)

🪛 Biome (1.9.4)
config/relay.json

[error] 40-40: expected , but instead found "relayReceiver"

Remove "relayReceiver"

(parse)


[error] 38-38: The key gravity was already declared.

This where a duplicated key was declared again.

If a key is defined multiple times, only the last definition takes effect. Previous definitions are ignored.

(lint/suspicious/noDuplicateObjectKeys)

🪛 GitHub Actions: JSON Checker
config/relay.json

[error] 39-39: JSON syntax error: Missing comma after 'chainId': 1625. Expected comma before 'relayReceiver' property.

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: enforce-min-test-coverage
  • GitHub Check: run-unit-tests
🔇 Additional comments (6)
deployments/gravity.json (1)

30-30: Verify the RelayFacet contract address.

Please ensure that the deployed RelayFacet contract at 0x3C9a1eb020448792F299f2Fa88cbDf6dF0C51f17 has been properly verified on the block explorer and audited according to the PR checklist requirements.

✅ Verification successful

RelayFacet contract verification successful

The RelayFacet contract at 0x3C9a1eb020448792F299f2Fa88cbDf6dF0C51f17 has been:

  • Audited (report dated Dec 2, 2024)
  • Properly implemented and tested
  • Deployed with matching version (v1.0.0)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the RelayFacet contract is verified on the block explorer
# Note: This is a placeholder as we don't have access to the gravity chain's block explorer API

# Verify that the address format is valid
if ! echo "0x3C9a1eb020448792F299f2Fa88cbDf6dF0C51f17" | grep -E '^0x[a-fA-F0-9]{40}$' > /dev/null; then
    echo "Invalid Ethereum address format"
    exit 1
fi

# Check if this address is used consistently across the codebase
rg -l "0x3C9a1eb020448792F299f2Fa88cbDf6dF0C51f17"

Length of output: 196


Script:

#!/bin/bash
# Check deployment log details
cat deployments/_deployments_log_file.json

# Search for audit-related files or references
fd -t f -e pdf audit
fd -t f -e md audit
rg -i "audit" -g "!node_modules"

# Look for verification scripts
fd verify
rg -i "verify.*contract" -g "!node_modules"

Length of output: 65759


Script:

#!/bin/bash
# Search for RelayFacet verification and deployment references
rg -i "relayfacet" -g "!node_modules" -A 5 -B 5

# Look for verification scripts
fd -t f "verify" -x grep -l "RelayFacet" {} \;

# Search for audit documentation
fd -t f -e pdf . 
fd -t f -e md . -x grep -l "audit" {} \;

# Check deployment history
git log -p --all --full-history -- "deployments/gravity.json"

Length of output: 58308

script/deploy/safe/propose-to-safe.ts (1)

4-6: Verify dynamic imports compatibility.

The change from static to dynamic imports for Safe-related modules might affect bundling and tree-shaking. Ensure this change is compatible with your build system and doesn't impact load times.

✅ Verification successful

Dynamic imports are implemented consistently and appropriately

The dynamic imports for Safe-related modules follow a consistent pattern across all script files, with types and essential adapters imported statically while main functionality is loaded dynamically. This implementation is appropriate for CLI scripts and won't negatively impact performance.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if dynamic imports are used consistently across the codebase

# Check for mixed usage of static and dynamic imports for Safe modules
rg "import.*@safe-global/(protocol-kit|api-kit)" --type ts

Length of output: 1392

script/tasks/diamondUpdateFacet.sh (1)

158-175: Verify the production deployment logic.

The script now assumes successful SAFE proposal based on return code alone. Consider adding additional verification steps for production deployments.

deployments/_deployments_log_file.json (3)

27757-27757: ⚠️ Potential issue

Invalid deployment timestamp.

The timestamp "2025-01-23 08:52:35" shows a future date, which suggests an issue with the deployment process or system time configuration.

Please:

  1. Verify if this was an actual recent deployment
  2. Check the system time configuration used during deployment
  3. Update the timestamp to reflect the actual deployment time
⛔ Skipped due to learnings
Learnt from: ezynda3
PR: lifinance/contracts#861
File: deployments/_deployments_log_file.json:22488-22488
Timestamp: 2024-11-22T07:19:51.143Z
Learning: In `deployments/_deployments_log_file.json`, deployment timestamps may appear to be set in the future and should not be flagged as invalid.

27755-27755: Verify the deployed RelayFacet contract code.

Given the PR objectives regarding validation of external calls and privileged operations, we need to verify the deployed contract at 0x3C9a1eb020448792F299f2Fa88cbDf6dF0C51f17.

Let's analyze the contract implementation:

✅ Verification successful

Contract implementation verified and meets security requirements

The deployed RelayFacet contract at 0x3C9a1eb020448792F299f2Fa88cbDf6dF0C51f17 implements robust security measures for external calls and privileged operations:

  • Comprehensive signature verification system
  • Protection against reentrancy attacks
  • Quote validation and replay protection
  • Safe handling of both native and ERC20 token transfers
  • Proper access controls through the relay solver mechanism
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Analyze the RelayFacet contract implementation for security concerns

# Search for external calls in the contract
echo "Checking for external calls..."
ast-grep --pattern 'call($$$)'

# Search for privileged operations
echo "Checking for privileged operations..."
ast-grep --pattern 'require(
  $$$,
  $$$
)'

# Search for potential reentrancy vulnerabilities
echo "Checking for potential reentrancy..."
ast-grep --pattern 'function $_ {
  $$$
  $_.call($$$)
  $$$
}'

Length of output: 482


Script:

#!/bin/bash
# Find the RelayFacet contract file
echo "Searching for RelayFacet contract..."
fd -e sol -e json "RelayFacet"

# Look for any references to this contract in deployment scripts
echo -e "\nChecking deployment references..."
rg -l "RelayFacet" --type json

# Try to find the specific address in other files
echo -e "\nChecking for address references..."
rg "0x3C9a1eb020448792F299f2Fa88cbDf6dF0C51f17" -l

Length of output: 1873


Script:

#!/bin/bash
# Examine the RelayFacet contract implementation
echo "RelayFacet contract content:"
cat src/Facets/RelayFacet.sol

echo -e "\nChecking deployment script:"
cat script/deploy/facets/DeployRelayFacet.s.sol

echo -e "\nChecking gravity chain deployment:"
cat deployments/gravity.json | jq '.RelayFacet'

Length of output: 9384


27758-27758: Verify the constructor argument addresses.

The constructor arguments contain two addresses that need verification:

Address 1: 0x7f4babd2c7d35221e72ab67ea72cba99573a0089
Address 2: 0xf70da97812cb96acdf810712aa562db8dfa3dbef

Let's verify these addresses and their roles:

✅ Verification successful

Constructor argument addresses verified successfully

The addresses are correctly configured:

  • 0x7f4babd2c7d35221e72ab67ea72cba99573a0089 as relayReceiver for native token transfers
  • 0xf70da97812cb96acdf810712aa562db8dfa3dbef as relaySolver for ERC20 transfers and signature verification
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the contract code and transactions for the constructor argument addresses

# Check if addresses have verified contract code
echo "Checking contract code for constructor argument addresses..."
for addr in "0x7f4babd2c7d35221e72ab67ea72cba99573a0089" "0xf70da97812cb96acdf810712aa562db8dfa3dbef"
do
  # Search for address references in the codebase
  echo "Searching for address references in the codebase..."
  rg -i "$addr"
  
  # Search for any configuration files containing these addresses
  echo "Searching for address in config files..."
  fd -e json -e yaml -e toml -x grep -l "$addr" {}
done

# Check the deployed RelayFacet contract code
echo "Checking RelayFacet contract implementation..."
ast-grep --pattern 'contract RelayFacet {
  $$$
}'

Length of output: 3505


Script:

#!/bin/bash
# Find and examine the RelayFacet contract implementation
echo "Searching for RelayFacet contract file..."
fd -e sol RelayFacet

echo "Checking contract implementation..."
# Look for constructor and storage variables
ast-grep --pattern 'contract RelayFacet {
  $$$
  constructor($$$) {
    $$$
  }
  $$$
}'

# Look for functions using relayReceiver
ast-grep --pattern 'function $$$relayReceiver$$$'

# Look for functions using relaySolver
ast-grep --pattern 'function $$$relaySolver$$$'

Length of output: 586


Script:

#!/bin/bash
# Examine the RelayFacet implementation
echo "Checking RelayFacet.sol content..."
cat src/Facets/RelayFacet.sol

echo "Checking test file for address usage..."
cat test/solidity/Facets/RelayFacet.t.sol

echo "Checking deployment script..."
cat script/deploy/facets/DeployRelayFacet.s.sol

Length of output: 35062

config/relay.json Outdated Show resolved Hide resolved
config/relay.json Outdated Show resolved Hide resolved
script/tasks/diamondUpdateFacet.sh Outdated Show resolved Hide resolved
deployments/_deployments_log_file.json Outdated Show resolved Hide resolved
@lifi-action-bot
Copy link
Collaborator

Test Coverage Report

Line Coverage: 78.66% (2238 / 2845 lines)
Function Coverage: 84.71% ( 388 / 458 functions)
Branch Coverage: 39.60% ( 221 / 558 branches)
Test coverage (78.66%) is above min threshold (76%). Check passed.

@0xDEnYO 0xDEnYO marked this pull request as ready for review January 30, 2025 01:52
@0xDEnYO 0xDEnYO enabled auto-merge (squash) February 4, 2025 07:13
@0xDEnYO 0xDEnYO merged commit 8ea9f3e into main Feb 4, 2025
20 of 22 checks passed
@0xDEnYO 0xDEnYO deleted the LF-11660-Deploy-RelayFacet-to-Gravity-chain branch February 4, 2025 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants