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

Harmonize custom version tags [CalldataVerificationFacet v1.3.0,IAllBridge v1.0.0,ICBridge v1.0.0,ICircleBridgeProxy v1.0.0,IConnextHandler v1.0.0,IDiamondCut v2.0.0,IDiamondLoupe v1.0.0,IDlnSource v1.0.0,IERC165 v1.0.0,IERC173 v1.0.0,IERC20Proxy v1.0.0,IExecutor v1.0.0,IGasZip v1.0.0,IGatewayRouter v1.0.0,IHopBridge v1.0.0,IL1StandardBridge v1.0.0,ILiFi v1.0.0,IMayan v1.0.0,IOmniBridge v1.0.0,IRootChainManager v1.0.0,ISquidMulticall v1.0.0,ISquidRouter v1.0.0,IStargate v1.0.0,ISymbiosisMetaRouter v1.0.0,IThorSwap v1.0.0,IXDaiBridge v1.0.0,IXDaiBridgeL2 v1.0.0] #1021

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

0xDEnYO
Copy link
Contributor

@0xDEnYO 0xDEnYO commented Feb 24, 2025

Which Jira task belongs to this PR?

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

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 Feb 24, 2025

Walkthrough

A new JSON configuration file is introduced for Stargate endpoints, and import paths in demo scripts have been updated to reflect a new directory structure. Legacy configuration data in the existing Stargate config has been removed. Several Solidity interface files now include enhanced documentation (titles, authors, reordered version comments) and updated licenses in selected files. Additionally, validations for Amarok and legacy Stargate functionalities were removed from the calldata verification facet, and corresponding tests were deleted, while a health check script was adjusted.

Changes

File(s) Change Summary
archive/config/stargateV1.json New JSON configuration file added with blockchain endpoints, chains, composers, and routers data.
archive/scripts/demoScripts/demoDeBridge.ts, archive/scripts/demoScripts/demoSynapseBridge.ts Updated import paths to reflect directory restructuring for configuration and deployment files.
config/stargate.json Removed legacy sections (“chains”, “composers”, “routers”), leaving only the endpointIds array.
script/deploy/healthCheck.ts Removed the 'Receiver' entry from the corePeriphery array.
src/Facets/CalldataVerificationFacet.sol Removed conditional checks for Amarok and Stargate calldata validation and bumped version from 1.2.0 to 1.3.0.
archive/.../Interfaces/*.sol, src/.../Interfaces/*.sol Added documentation (titles, authors) and adjusted version comments; updated SPDX license identifiers in selected files.
test/solidity/Facets/CalldataVerificationFacet.t.sol Removed tests for Amarok and Stargate calldata validations along with related import statements.

Possibly related PRs

Suggested labels

AuditRequired

Suggested reviewers

  • ezynda3
  • maxklenk

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

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.

@lifi-action-bot lifi-action-bot marked this pull request as draft February 24, 2025 04:27
@lifi-action-bot lifi-action-bot changed the title Harmonize custom version tags Harmonize custom version tags [CalldataVerificationFacet v1.3.0,IAllBridge v1.0.0,ICBridge v1.0.0,ICircleBridgeProxy v1.0.0,IConnextHandler v1.0.0,IDiamondCut v2.0.0,IDiamondLoupe v1.0.0,IDlnSource v1.0.0,IERC165 v1.0.0,IERC173 v1.0.0,IERC20Proxy v1.0.0,IExecutor v1.0.0,IGasZip v1.0.0,IGatewayRouter v1.0.0,IHopBridge v1.0.0,IL1StandardBridge v1.0.0,ILiFi v1.0.0,IMayan v1.0.0,IOmniBridge v1.0.0,IRootChainManager v1.0.0,ISquidMulticall v1.0.0,ISquidRouter v1.0.0,IStargate v1.0.0,ISymbiosisMetaRouter v1.0.0,IThorSwap v1.0.0,IXDaiBridge v1.0.0,IXDaiBridgeL2 v1.0.0] Feb 24, 2025
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: 1

🔭 Outside diff range comments (2)
src/Facets/CalldataVerificationFacet.sol (2)

6-6: ⚠️ Potential issue

Remove duplicate import of AcrossFacetV3.

The AcrossFacetV3 import is duplicated.

 import { ILiFi } from "../Interfaces/ILiFi.sol";
 import { LibSwap } from "../Libraries/LibSwap.sol";
 import { AcrossFacetV3 } from "./AcrossFacetV3.sol";
 import { StargateFacetV2 } from "./StargateFacetV2.sol";
-import { AcrossFacetV3 } from "./AcrossFacetV3.sol";
 import { CelerIMFacetBase, CelerIM } from "lifi/Helpers/CelerIMFacetBase.sol";

Also applies to: 8-8


354-412: ⚠️ Potential issue

Remove duplicate AcrossV3 validation logic.

The AcrossV3 validation logic is duplicated. The entire block from lines 383-412 is identical to the block from lines 354-381.

        // Case: AcrossV3
        if (selector == AcrossFacetV3.startBridgeTokensViaAcrossV3.selector) {
            (, AcrossFacetV3.AcrossV3Data memory acrossV3Data) = abi.decode(
                callData.slice(4, callData.length - 4),
                (ILiFi.BridgeData, AcrossFacetV3.AcrossV3Data)
            );

            return
                keccak256(dstCalldata) == keccak256(acrossV3Data.message) &&
                keccak256(callTo) ==
                keccak256(abi.encode(acrossV3Data.receiverAddress));
        }
        if (
            selector ==
            AcrossFacetV3.swapAndStartBridgeTokensViaAcrossV3.selector
        ) {
            (, , AcrossFacetV3.AcrossV3Data memory acrossV3Data) = abi.decode(
                callData.slice(4, callData.length - 4),
                (
                    ILiFi.BridgeData,
                    LibSwap.SwapData[],
                    AcrossFacetV3.AcrossV3Data
                )
            );
            return
                keccak256(dstCalldata) == keccak256(acrossV3Data.message) &&
                keccak256(callTo) ==
                keccak256(abi.encode(acrossV3Data.receiverAddress));
        }

-        // ---------------------------------------
-        // Case: AcrossV3
-        if (selector == AcrossFacetV3.startBridgeTokensViaAcrossV3.selector) {
-            (, AcrossFacetV3.AcrossV3Data memory acrossV3Data) = abi.decode(
-                callData.slice(4, callData.length - 4),
-                (ILiFi.BridgeData, AcrossFacetV3.AcrossV3Data)
-            );
-
-            return
-                keccak256(dstCalldata) == keccak256(acrossV3Data.message) &&
-                keccak256(callTo) ==
-                keccak256(abi.encode(acrossV3Data.receiverAddress));
-        }
-        if (
-            selector ==
-            AcrossFacetV3.swapAndStartBridgeTokensViaAcrossV3.selector
-        ) {
-            (, , AcrossFacetV3.AcrossV3Data memory acrossV3Data) = abi.decode(
-                callData.slice(4, callData.length - 4),
-                (
-                    ILiFi.BridgeData,
-                    LibSwap.SwapData[],
-                    AcrossFacetV3.AcrossV3Data
-                )
-            );
-            return
-                keccak256(dstCalldata) == keccak256(acrossV3Data.message) &&
-                keccak256(callTo) ==
-                keccak256(abi.encode(acrossV3Data.receiverAddress));
-        }
🧹 Nitpick comments (5)
src/Interfaces/IL1StandardBridge.sol (1)

4-7: Standardize the version tag format.

While the documentation additions are great, consider using the standard NatSpec @version tag instead of @custom:version to align with common practices.

Apply this diff:

 /// @title Interface for L1StandardBridge
 /// @author LI.FI (https://li.fi)
-/// @custom:version 1.0.0
+/// @version 1.0.0
archive/config/stargateV1.json (3)

134-185: Composers Addresses Review
The "composers" object maps various network identifiers to their respective addresses. The mixture of valid addresses and placeholder zero addresses appears intentional. As a good-to-have refinement, consider ensuring that any non-placeholder address is correctly checksummed (if required by your standards) and documented so that future maintainers can validate them more easily.


186-231: Routers Addresses Consistency
The "routers" object is comprehensive and lists router addresses for many networks. Verify that each address is correct according to the latest deployment details and consider standardizing the casing/format of these hexadecimal addresses for consistency. Additionally, a good-to-have improvement might be to include a comment or supplementary documentation (outside the JSON file, since JSON does not support comments) indicating the source or audit status of these addresses.


1-231: Overall Configuration Enhancement Suggestion
Since the PR objective mentions "Harmonize custom version tags," consider including a configuration version field at the root level. This can help track changes and ensure compatibility in future upgrades. For example, you might insert the following line after the opening brace:

 {
+  "configVersion": "1.0",

This addition would facilitate smoother version management and documentation alignment across different configuration files.

src/Facets/CalldataVerificationFacet.sol (1)

269-416: Consider refactoring validateDestinationCalldata for better maintainability.

The validateDestinationCalldata function is quite long and contains repetitive validation patterns for different bridges. Consider refactoring it to use a map of validators or a switch pattern to improve maintainability and reduce the likelihood of errors like the duplicate AcrossV3 validation.

Here's a suggested approach:

// Define a validator type
type Validator = (bytes memory callData, bytes calldata callTo, bytes calldata dstCalldata) => bool;

// Create a mapping of selectors to validators
mapping(bytes4 => Validator) private validators;

// Initialize validators in the constructor
constructor() {
    validators[StargateFacetV2.startBridgeTokensViaStargate.selector] = validateStargateV2;
    validators[StargateFacetV2.swapAndStartBridgeTokensViaStargate.selector] = validateStargateV2WithSwap;
    // ... add other validators
}

// Example validator function
function validateStargateV2(bytes memory callData, bytes calldata callTo, bytes calldata dstCalldata) private pure returns (bool) {
    (, StargateFacetV2.StargateData memory stargateDataV2) = abi.decode(
        callData.slice(4, callData.length - 4),
        (ILiFi.BridgeData, StargateFacetV2.StargateData)
    );

    return
        keccak256(dstCalldata) == keccak256(stargateDataV2.sendParams.composeMsg) &&
        _compareBytesToBytes32CallTo(callTo, stargateDataV2.sendParams.to);
}

// Main validation function
function validateDestinationCalldata(
    bytes calldata data,
    bytes calldata callTo,
    bytes calldata dstCalldata
) external pure returns (bool isValid) {
    bytes memory callData = data;

    if (bytes4(data[:4]) == StandardizedCallFacet.standardizedCall.selector) {
        callData = abi.decode(data[4:], (bytes));
    }

    bytes4 selector = abi.decode(callData, (bytes4));
    
    // Get and execute the validator
    Validator validator = validators[selector];
    if (validator != null) {
        return validator(callData, callTo, dstCalldata);
    }

    return false;
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 40e5cda and adc4d67.

📒 Files selected for processing (43)
  • archive/config/stargateV1.json (1 hunks)
  • archive/scripts/demoScripts/demoDeBridge.ts (1 hunks)
  • archive/scripts/demoScripts/demoSynapseBridge.ts (1 hunks)
  • archive/src/Interfaces/IDeBridgeGate.sol (1 hunks)
  • archive/src/Interfaces/IHyphenRouter.sol (1 hunks)
  • archive/src/Interfaces/IMultichainRouter.sol (1 hunks)
  • archive/src/Interfaces/IMultichainToken.sol (1 hunks)
  • archive/src/Interfaces/IStargateRouter.sol (1 hunks)
  • archive/src/Interfaces/ISynapseRouter.sol (1 hunks)
  • archive/src/Interfaces/ITeleportGateway.sol (1 hunks)
  • archive/src/Interfaces/ITokenMessenger.sol (1 hunks)
  • archive/src/Interfaces/ITransactionManager.sol (1 hunks)
  • config/stargate.json (1 hunks)
  • script/deploy/healthCheck.ts (0 hunks)
  • src/Facets/CalldataVerificationFacet.sol (1 hunks)
  • src/Interfaces/IAcrossSpokePool.sol (1 hunks)
  • src/Interfaces/IAllBridge.sol (1 hunks)
  • src/Interfaces/ICBridge.sol (1 hunks)
  • src/Interfaces/ICircleBridgeProxy.sol (1 hunks)
  • src/Interfaces/IConnextHandler.sol (1 hunks)
  • src/Interfaces/IDiamondCut.sol (1 hunks)
  • src/Interfaces/IDiamondLoupe.sol (1 hunks)
  • src/Interfaces/IDlnSource.sol (1 hunks)
  • src/Interfaces/IERC165.sol (1 hunks)
  • src/Interfaces/IERC173.sol (1 hunks)
  • src/Interfaces/IERC20Proxy.sol (1 hunks)
  • src/Interfaces/IExecutor.sol (1 hunks)
  • src/Interfaces/IGasZip.sol (1 hunks)
  • src/Interfaces/IGatewayRouter.sol (1 hunks)
  • src/Interfaces/IHopBridge.sol (1 hunks)
  • src/Interfaces/IL1StandardBridge.sol (1 hunks)
  • src/Interfaces/ILiFi.sol (1 hunks)
  • src/Interfaces/IMayan.sol (1 hunks)
  • src/Interfaces/IOmniBridge.sol (1 hunks)
  • src/Interfaces/IRootChainManager.sol (1 hunks)
  • src/Interfaces/ISquidMulticall.sol (1 hunks)
  • src/Interfaces/ISquidRouter.sol (1 hunks)
  • src/Interfaces/IStargate.sol (1 hunks)
  • src/Interfaces/ISymbiosisMetaRouter.sol (1 hunks)
  • src/Interfaces/IThorSwap.sol (1 hunks)
  • src/Interfaces/IXDaiBridge.sol (1 hunks)
  • src/Interfaces/IXDaiBridgeL2.sol (1 hunks)
  • test/solidity/Facets/CalldataVerificationFacet.t.sol (0 hunks)
💤 Files with no reviewable changes (2)
  • script/deploy/healthCheck.ts
  • test/solidity/Facets/CalldataVerificationFacet.t.sol
✅ Files skipped from review due to trivial changes (38)
  • archive/scripts/demoScripts/demoDeBridge.ts
  • archive/src/Interfaces/IHyphenRouter.sol
  • src/Interfaces/ISquidMulticall.sol
  • archive/src/Interfaces/IDeBridgeGate.sol
  • archive/src/Interfaces/IMultichainToken.sol
  • src/Interfaces/IAcrossSpokePool.sol
  • src/Interfaces/IERC20Proxy.sol
  • src/Interfaces/IGasZip.sol
  • src/Interfaces/IThorSwap.sol
  • src/Interfaces/IXDaiBridgeL2.sol
  • src/Interfaces/IXDaiBridge.sol
  • src/Interfaces/IExecutor.sol
  • src/Interfaces/IERC173.sol
  • src/Interfaces/ISymbiosisMetaRouter.sol
  • archive/src/Interfaces/ISynapseRouter.sol
  • src/Interfaces/ILiFi.sol
  • src/Interfaces/IConnextHandler.sol
  • archive/src/Interfaces/ITransactionManager.sol
  • src/Interfaces/IMayan.sol
  • src/Interfaces/IAllBridge.sol
  • archive/src/Interfaces/ITokenMessenger.sol
  • src/Interfaces/ICircleBridgeProxy.sol
  • src/Interfaces/IStargate.sol
  • src/Interfaces/IDlnSource.sol
  • archive/src/Interfaces/IMultichainRouter.sol
  • src/Interfaces/IOmniBridge.sol
  • src/Interfaces/IRootChainManager.sol
  • archive/scripts/demoScripts/demoSynapseBridge.ts
  • config/stargate.json
  • src/Interfaces/IDiamondCut.sol
  • src/Interfaces/ICBridge.sol
  • src/Interfaces/IHopBridge.sol
  • src/Interfaces/IGatewayRouter.sol
  • archive/src/Interfaces/ITeleportGateway.sol
  • src/Interfaces/IERC165.sol
  • src/Interfaces/ISquidRouter.sol
  • src/Interfaces/IDiamondLoupe.sol
  • archive/src/Interfaces/IStargateRouter.sol
🧰 Additional context used
🧠 Learnings (1)
src/Facets/CalldataVerificationFacet.sol (1)
Learnt from: 0xDEnYO
PR: lifinance/contracts#1003
File: src/Facets/CalldataVerificationFacet.sol:16-16
Timestamp: 2025-02-19T08:30:20.501Z
Learning: The project does not actively maintain a changelog, and suggestions about adding changelog entries should be avoided.
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: enforce-min-test-coverage
  • GitHub Check: run-unit-tests
🔇 Additional comments (3)
src/Interfaces/IL1StandardBridge.sol (1)

1-1: LGTM! Good choice of license.

The change from BUSL-1.1 to MIT license is appropriate for an interface file, making it more accessible for integration by other projects.

archive/config/stargateV1.json (2)

1-71: Endpoint IDs Configuration Check
The "endpointIds" array is structured correctly with each entry providing a numeric "chainId" and its corresponding "endpointId". Ensure that all endpoint IDs are accurate and truly reflect the deployed environment details. As this configuration is critical for network routing, double-check that these IDs match the intended endpoints and that any future additions follow the same consistent format.


72-133: Chains Mapping Consistency
The "chains" array maps "chainId" to "lzChainId" appropriately. However, note the following potential discrepancies:

  • The "endpointIds" array includes chain IDs such as 167000, 30, and 122 which are missing from this "chains" array.
  • Conversely, the "chains" array includes a chainId of 5000 that does not appear in "endpointIds".

Please verify whether these differences are intentional or if they might lead to configuration mismatches during cross-chain operations.

@lifi-action-bot
Copy link
Collaborator

Test Coverage Report

Line Coverage: 78.75% (2079 / 2640 lines)
Function Coverage: 83.68% ( 359 / 429 functions)
Branch Coverage: 45.24% ( 233 / 515 branches)
Test coverage (78.75%) is above min threshold (76%). Check passed.

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.

3 participants