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

update executor options for solana client controller #120

Merged
merged 7 commits into from
Oct 30, 2024

Conversation

magj2006
Copy link
Contributor

@magj2006 magj2006 commented Oct 28, 2024

update for #119 :
add definition of Solana devnet & mainnet ChinaID
set unordered options when sending message to Solana Chain
set value when calling addWhitelistToken to add token on Solana Chain

Summary by CodeRabbit

  • New Features

    • Enhanced response handling for token transfers and reward operations, providing additional context for specific chain actions.
    • Introduced constants for Solana blockchain messaging operations.
    • Added support for interactions with Solana client chains in the testing framework.
  • Bug Fixes

    • Improved interchain communication logic for better functionality.
  • Documentation

    • Updated function signatures to reflect new response formats and conditions.

Copy link
Contributor

coderabbitai bot commented Oct 28, 2024

Walkthrough

The changes in this pull request focus on enhancing the response handling and messaging logic within the ExocoreGateway and ExocoreGatewayStorage contracts. Modifications include updates to several functions to include additional data in responses for specific source chain IDs related to Solana. New constants for Solana's mainnet and devnet chain IDs, along with a messaging value, have been introduced. Function signatures have also been updated to reflect these changes, ensuring improved interchain communication.

Changes

File Change Summary
src/core/ExocoreGateway.sol Updated response handling in handleLSTTransfer, handleNSTTransfer, and handleRewardOperation to include token and staker data. Altered _sendInterchainMsg and quote functions to conditionally set options based on source chain ID and action type. Function signatures modified to include public onlyCalledFromThis and internal whenNotPaused modifiers.
src/storage/ExocoreGatewayStorage.sol Added constants for Solana blockchain: SOLANA_MAINNET_CHAIN_ID, SOLANA_DEVNET_CHAIN_ID, and SOLANA_WHITELIST_TOKEN_MSG_VALUE. Introduced _isSolana function to check if a chain ID corresponds to Solana. No changes to existing logic or control flow.
test/foundry/unit/ExocoreGateway.t.sol Enhanced test suite for Solana client chain support, added new variables, overloaded generateUID, and introduced test_Success_AddWhiteListTokenOnSolana function. Updated RegisterOrUpdateClientChain for Solana client chain handling.

Possibly related PRs

Suggested reviewers

  • MaxMustermann2
  • cloud8little
  • bwhour
  • TimmyExogenous

Poem

🐰 In the realm of chains where tokens flow,
New constants gleam, like stars aglow.
Responses richer, with data to share,
In the world of Solana, we leap without care.
With each transfer, a hop and a cheer,
Our gateway's magic brings us near! ✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6cb7622 and f5fbb86.

📒 Files selected for processing (1)
  • src/core/ExocoreGateway.sol (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/core/ExocoreGateway.sol

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 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 or @coderabbitai title 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: 1

🧹 Outside diff range and nitpick comments (3)
src/storage/ExocoreGatewayStorage.sol (2)

22-24: LGTM! Consider enhancing the documentation.

The constant declaration is correct and uses appropriate type (uint32) and visibility (internal). The value 30_168 matches the LayerZero chain ID for Solana mainnet.

Consider expanding the NatSpec comment to be more descriptive:

-    /// @dev the solana mainnet chain id
+    /// @dev The LayerZero chain ID for Solana mainnet (30_168)

26-28: LGTM! Consider enhancing the documentation.

The constant declaration is correct and consistent with the mainnet chain ID declaration.

Consider expanding the NatSpec comment to be more descriptive:

-    /// @dev the solana devnet chain id
+    /// @dev The LayerZero chain ID for Solana devnet (40_168)
src/core/ExocoreGateway.sol (1)

528-539: Consider using named constants for gas limits and values

While the implementation correctly handles different message options for Solana and non-Solana chains, the gas limits and values should be defined as named constants for better maintainability and clarity.

Consider defining these constants at the contract level:

+ /// @dev Gas limit for destination chain execution
+ uint256 private constant DESTINATION_GAS_LIMIT = /* current value */;
+ /// @dev Message value for destination chain execution
+ uint256 private constant DESTINATION_MSG_VALUE = /* current value */;
+ /// @dev Message value for Solana whitelist token operations
+ uint256 private constant SOLANA_MSG_VALUE = /* current value */;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d21c7d6 and 5c1bdb2.

📒 Files selected for processing (2)
  • src/core/ExocoreGateway.sol (4 hunks)
  • src/storage/ExocoreGatewayStorage.sol (1 hunks)
🔇 Additional comments (3)
src/storage/ExocoreGatewayStorage.sol (1)

30-31: 🛠️ Refactor suggestion

Verify the hardcoded message value and improve naming.

The constant declaration has a few potential improvements:

  1. The constant name SOLANA_MSG_VALUE is generic while the comment suggests it's specific to token whitelisting
  2. The hardcoded value (3,000,000) needs verification to ensure it's sufficient for token whitelisting operations

Consider these improvements:

-    /// @dev the msg.value for send addTokenWhiteList message
-    uint128 internal constant SOLANA_MSG_VALUE = 3_000_000;
+    /// @dev The required msg.value (in wei) for sending addTokenWhiteList messages to Solana chains
+    /// This covers the gas costs for token whitelisting operations
+    uint128 internal constant SOLANA_WHITELIST_TOKEN_MSG_VALUE = 3_000_000;

Let's verify the value is sufficient:

✅ Verification successful

Based on the evidence gathered, I can now provide a final response:

The SOLANA_MSG_VALUE constant is correctly set for token whitelisting operations

The code analysis shows that:

  1. The constant is specifically used in ExocoreGateway.sol for token whitelisting operations via LayerZero messaging
  2. It's only applied when the source chain is Solana (either devnet or mainnet) and the action is REQUEST_ADD_WHITELIST_TOKEN
  3. The value is used as the executor gas limit for LayerZero cross-chain message execution
  4. The naming suggestion in the review comment would not improve clarity as the current name and documentation already clearly indicate its purpose
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any existing token whitelisting operations or gas estimations
rg -l 'addWhitelistToken|whitelist.*token' --type sol

# Look for any gas-related constants or configurations
rg -i 'gas.*constant|msg\.value' --type sol

Length of output: 157


Script:

#!/bin/bash
# Search for any existing token whitelisting operations or gas estimations
# Using ripgrep without file type filter since .sol extension isn't recognized
rg -l 'addWhitelistToken|whitelist.*token'

# Look for any gas-related constants or configurations
rg -i 'gas.*constant|msg\.value'

# Find all Solidity files to analyze their content
fd '\.sol$'

Length of output: 6816


Script:

#!/bin/bash
# Let's examine the specific usage of SOLANA_MSG_VALUE
rg -A 5 -B 5 'SOLANA_MSG_VALUE' 

# Check for any token whitelisting related functions or tests
rg -A 10 'addWhitelistToken|addTokenWhiteList'

Length of output: 107584

src/core/ExocoreGateway.sol (2)

357-361: LGTM: Enhanced response handling for Solana networks

The implementation correctly provides additional context (token and staker) in responses for Solana networks while maintaining compatibility with other chains.


426-432: LGTM: Consistent response handling for Solana networks

The implementation maintains consistency with the LST transfer pattern, providing additional context for Solana networks.

Copy link

Linting failed. Please check the logs.

Copy link

The build has failed. Please check the logs.

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: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5c1bdb2 and 5d5ca4c.

📒 Files selected for processing (1)
  • src/core/ExocoreGateway.sol (4 hunks)
🔇 Additional comments (2)
src/core/ExocoreGateway.sol (2)

357-361: LGTM! Response handling for Solana chains.

The implementation correctly adds additional context (token and staker/avsOrWithdrawer) in responses for Solana chains while maintaining backward compatibility for other chains.

Also applies to: 426-432


578-597: LGTM! Well-structured helper function.

The _buildOptions function effectively extracts the duplicated options-building logic, improving code maintainability and following the DRY principle. The implementation is consistent with the original logic and well-documented.

@magj2006 magj2006 force-pushed the solana-client-controller branch from 5d5ca4c to 430cd28 Compare October 28, 2024 13:19
@ExocoreNetwork ExocoreNetwork deleted a comment from coderabbitai bot Oct 28, 2024
@ExocoreNetwork ExocoreNetwork deleted a comment from coderabbitai bot Oct 28, 2024
@ExocoreNetwork ExocoreNetwork deleted a comment from coderabbitai bot Oct 28, 2024
@magj2006 magj2006 force-pushed the solana-client-controller branch from 430cd28 to b1640df Compare October 28, 2024 13:29
Copy link
Collaborator

@MaxMustermann2 MaxMustermann2 left a comment

Choose a reason for hiding this comment

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

Please make similar edits in ExocoreGatewayMock.sol and add unit tests to verify the event emission in ExocoreGateway.t.sol

src/core/ExocoreGateway.sol Outdated Show resolved Hide resolved
@magj2006
Copy link
Contributor Author

Please make similar edits in ExocoreGatewayMock.sol and add unit tests to verify the event emission in ExocoreGateway.t.sol

Added, please review again.

@magj2006 magj2006 force-pushed the solana-client-controller branch 2 times, most recently from 5ea5cd9 to 8b18c40 Compare October 29, 2024 05:50
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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (1)
src/core/ExocoreGateway.sol (1)

549-568: Consider renaming parameter for consistency.

The parameter srcChainId should be renamed to chainId to match the function's documentation.

Apply this diff to improve parameter naming consistency:

-    function _buildOptions(uint32 srcChainId, Action act) private pure returns (bytes memory) {
+    function _buildOptions(uint32 chainId, Action act) private pure returns (bytes memory) {
         bytes memory options = OptionsBuilder.newOptions();

-        if (srcChainId == SOLANA_DEVNET_CHAIN_ID || srcChainId == SOLANA_MAINNET_CHAIN_ID) {
+        if (chainId == SOLANA_DEVNET_CHAIN_ID || chainId == SOLANA_MAINNET_CHAIN_ID) {
🛑 Comments failed to post (2)
test/foundry/unit/ExocoreGateway.t.sol (2)

119-128: ⚠️ Potential issue

Potential endpoint misconfiguration for Solana client

In line 119, the exocoreLzEndpoint is setting the destination endpoint for solanaClientGateway to clientLzEndpoint, which is intended for the EVM-compatible client chain. This could lead to incorrect communication between the Exocore and Solana gateways. The solanaClientGateway should be paired with solanaClientLzEndpoint to ensure proper endpoint mapping.

Apply this diff to correct the endpoint configuration:

 exocoreLzEndpoint.setDestLzEndpoint(address(clientGateway), address(clientLzEndpoint));
 exocoreGateway.registerOrUpdateClientChain(
     clientChainId,
     address(clientGateway).toBytes32(),
     20,
     "clientChain",
     "EVM compatible client chain",
     "secp256k1"
 );
 
-exocoreLzEndpoint.setDestLzEndpoint(address(solanaClientGateway), address(clientLzEndpoint));
+exocoreLzEndpoint.setDestLzEndpoint(address(solanaClientGateway), address(solanaClientLzEndpoint));
 exocoreGateway.registerOrUpdateClientChain(
     solanaClientChainId,
     address(solanaClientGateway).toBytes32(),
     20,
     "solanaClientChain",
     "Non-EVM compatible client chain",
     "ed25519"
 );

Committable suggestion was skipped due to low confidence.


140-168: 🛠️ Refactor suggestion

Refactor generateUID function to eliminate code duplication

The generateUID function contains duplicated logic for handling EVM and non-EVM chains. Refactoring the function to reduce duplication will enhance maintainability and readability.

Apply this diff to refactor the function:

 function generateUID(uint64 nonce, bool fromClientChainToExocore) internal view returns (bytes32 uid) {
     uid = generateUID(nonce, fromClientChainToExocore, true);
 }
 
-function generateUID(uint64 nonce, bool fromClientChainToExocore, bool isEVM) internal view returns (bytes32 uid) {
-    if (fromClientChainToExocore) {
-        if (isEVM) {
-            uid = GUID.generate(
-                nonce, clientChainId, address(clientGateway), exocoreChainId, address(exocoreGateway).toBytes32()
-            );
-        } else {
-            uid = GUID.generate(
-                nonce,
-                solanaClientChainId,
-                address(solanaClientGateway),
-                exocoreChainId,
-                address(exocoreGateway).toBytes32()
-            );
-        }
-    } else {
-        if (isEVM) {
-            uid = GUID.generate(
-                nonce, exocoreChainId, address(exocoreGateway), clientChainId, address(clientGateway).toBytes32()
-            );
-        } else {
-            uid = GUID.generate(
-                nonce,
-                exocoreChainId,
-                address(exocoreGateway),
-                solanaClientChainId,
-                address(solanaClientGateway).toBytes32()
-            );
-        }
-    }
-}
+function generateUID(uint64 nonce, bool fromClientChainToExocore, bool isEVM) internal view returns (bytes32 uid) {
+    uint16 srcChainId;
+    address srcGateway;
+    uint16 dstChainId;
+    bytes32 dstGateway;
+
+    if (fromClientChainToExocore) {
+        srcChainId = isEVM ? clientChainId : solanaClientChainId;
+        srcGateway = isEVM ? address(clientGateway) : address(solanaClientGateway);
+        dstChainId = exocoreChainId;
+        dstGateway = address(exocoreGateway).toBytes32();
+    } else {
+        srcChainId = exocoreChainId;
+        srcGateway = address(exocoreGateway);
+        dstChainId = isEVM ? clientChainId : solanaClientChainId;
+        dstGateway = isEVM ? address(clientGateway).toBytes32() : address(solanaClientGateway).toBytes32();
+    }
+    uid = GUID.generate(nonce, srcChainId, srcGateway, dstChainId, dstGateway);
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    function generateUID(uint64 nonce, bool fromClientChainToExocore) internal view returns (bytes32 uid) {
        uid = generateUID(nonce, fromClientChainToExocore, true);
    }

    function generateUID(uint64 nonce, bool fromClientChainToExocore, bool isEVM) internal view returns (bytes32 uid) {
        uint16 srcChainId;
        address srcGateway;
        uint16 dstChainId;
        bytes32 dstGateway;

        if (fromClientChainToExocore) {
            srcChainId = isEVM ? clientChainId : solanaClientChainId;
            srcGateway = isEVM ? address(clientGateway) : address(solanaClientGateway);
            dstChainId = exocoreChainId;
            dstGateway = address(exocoreGateway).toBytes32();
        } else {
            srcChainId = exocoreChainId;
            srcGateway = address(exocoreGateway);
            dstChainId = isEVM ? clientChainId : solanaClientChainId;
            dstGateway = isEVM ? address(clientGateway).toBytes32() : address(solanaClientGateway).toBytes32();
        }
        uid = GUID.generate(nonce, srcChainId, srcGateway, dstChainId, dstGateway);
    }

@magj2006 magj2006 force-pushed the solana-client-controller branch 2 times, most recently from b5afc5d to 85638a2 Compare October 29, 2024 05:57
@magj2006 magj2006 force-pushed the solana-client-controller branch from 85638a2 to 27043e4 Compare October 29, 2024 05:59
src/core/ExocoreGateway.sol Outdated Show resolved Hide resolved
src/core/ExocoreGateway.sol Outdated Show resolved Hide resolved
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: 2

🧹 Outside diff range and nitpick comments (3)
src/storage/ExocoreGatewayStorage.sol (1)

142-148: Add @return tag to NatSpec documentation.

The function implementation is clean and correct. Consider adding an @return tag to the NatSpec documentation to describe the return value:

 /**
  * @dev return true if chain is either Solana devnet or Solana mainnet
  * @param srcChainId remote Chain Id
+ * @return bool true if the chain ID matches Solana networks, false otherwise
  */
src/core/ExocoreGateway.sol (2)

549-568: Consider improving the options building function documentation.

While the function implementation is solid, the documentation could be more detailed about the specific options being set and their implications.

Update the function documentation:

-    /// @dev Builds options for interchain messages based on chain and action
-    /// @param srcChainId The source chain ID
-    /// @param act The action being performed
-    /// @return options The built options
+    /// @dev Builds LayerZero options for interchain messages based on chain type and action
+    /// @param srcChainId The source chain ID
+    /// @param act The action being performed
+    /// @return options The built options containing:
+    ///         - Ordered execution option (except for Solana chains)
+    ///         - Gas limit and value for message execution
+    ///         Note: Solana chains use a different message value for whitelist token actions

561-564: Consider using named constants for better code readability.

The conditional expression for determining the message value could be more readable with named constants.

Consider this improvement:

+    /// @dev Message value multiplier for Solana whitelist token operations
+    uint128 private constant SOLANA_WHITELIST_MULTIPLIER = 2;

     function _buildOptions(uint32 srcChainId, Action act) private pure returns (bytes memory) {
         // ...
-        uint128 value = _isSolana(srcChainId) && act == Action.REQUEST_ADD_WHITELIST_TOKEN
-            ? SOLANA_WHITELIST_TOKEN_MSG_VALUE
-            : DESTINATION_MSG_VALUE;
+        uint128 value = (_isSolana(srcChainId) && act == Action.REQUEST_ADD_WHITELIST_TOKEN)
+            ? DESTINATION_MSG_VALUE * SOLANA_WHITELIST_MULTIPLIER
+            : DESTINATION_MSG_VALUE;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1c245c8 and cd0eb2a.

📒 Files selected for processing (3)
  • src/core/ExocoreGateway.sol (4 hunks)
  • src/storage/ExocoreGatewayStorage.sol (2 hunks)
  • test/foundry/unit/ExocoreGateway.t.sol (8 hunks)
🔇 Additional comments (6)
src/storage/ExocoreGatewayStorage.sol (1)

22-31: Verify Solana chain IDs and message value.

The constants are well-defined and follow best practices. However, please verify:

  1. Are these the official Solana chain IDs used by LayerZero?
  2. Is the SOLANA_WHITELIST_TOKEN_MSG_VALUE of 3,000,000 sufficient for gas costs?
✅ Verification successful

Let me search for more specific patterns to verify these constants.


Based on the search results, I can now generate the final response:

Chain IDs and message value constants are correctly implemented and consistently used.

The verification shows:

  • Chain IDs (30168, 40168) are consistently used across the codebase in ExocoreGatewayStorage.sol and ExocoreGateway.sol
  • SOLANA_WHITELIST_TOKEN_MSG_VALUE (3,000,000) is properly referenced in the token whitelisting logic in ExocoreGateway.sol
  • Constants are used in appropriate contexts for Solana chain identification and message value determination
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any other occurrences of these chain IDs in the codebase
# to ensure consistency
rg -g '!*.md' -g '!*.json' '30168|40168|3000000'

Length of output: 986


Script:

#!/bin/bash
# Search for Solana chain ID declarations or references
rg -g '*.sol' 'SOLANA.*CHAIN_ID|chainId.*[34]0168'

# Search for any LayerZero endpoint configurations or chain mappings
rg -g '*.sol' 'LayerZero.*endpoint|chainId.*mapping'

# Search for any msg.value constants related to Solana
rg -g '*.sol' 'msg\.value.*3.*000.*000|WHITELIST.*MSG.*VALUE'

Length of output: 2278

src/core/ExocoreGateway.sol (2)

528-530: LGTM: Clean refactoring of options building logic.

The extraction of options building logic into a separate function improves code organization and reusability.

Also applies to: 540-545


556-559: Verify the impact of unordered execution for Solana chains.

The code explicitly disables ordered execution for Solana chains. This could have implications for transaction ordering and consistency.

Let's verify the impact:

✅ Verification successful

Based on the extensive codebase analysis, I can now provide a definitive response about the impact of unordered execution for Solana chains:

Solana unordered execution is an intentional and handled limitation

The code explicitly handles this LayerZero limitation for Solana chains by:

  1. Defining specific Solana chain IDs in ExocoreGatewayStorage.sol:

    • SOLANA_MAINNET_CHAIN_ID = 30_168
    • SOLANA_DEVNET_CHAIN_ID = 40_168
  2. Implementing proper message value handling for Solana chains:

    • Uses SOLANA_WHITELIST_TOKEN_MSG_VALUE = 3_000_000 for Solana transactions
    • Has specific response payload formatting for Solana chains in ExocoreGateway.sol
  3. The unordered execution is compensated by including necessary context in the messages:

    • Solana responses include additional data (nonce, token, staker info)
    • This ensures transaction consistency without relying on ordered execution
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any dependencies on ordered execution in Solana-related code
rg -l "ordered.*execution.*solana" --type sol

# Search for any comments or documentation about Solana execution ordering
rg -i "solana.*order" --type sol

Length of output: 138


Script:

#!/bin/bash
# Search for any dependencies on ordered execution in Solana-related code
rg -l "ordered.*execution.*solana"

# Search for any comments or documentation about Solana execution ordering
rg -i "solana.*order"

# Search for other occurrences of Solana-related code and execution options
rg -i "solana" -A 3 -B 3

# Look for LayerZero related configurations and options
rg -i "layerzero|lz.*option" -A 3 -B 3

Length of output: 242614

test/foundry/unit/ExocoreGateway.t.sol (3)

42-47: LGTM: SetUp contract properly initialized with Solana client configuration.

The setup correctly initializes Solana-specific test components including gateway, endpoint, and chain ID. The chain ID 40_168 appears to be the correct identifier for Solana.

Also applies to: 52-52, 72-73, 97-97


565-565: LGTM: Proper fee calculation for Solana transactions.

The implementation correctly calculates native fees for Solana transactions by constructing the appropriate message structure.

Also applies to: 574-576


630-646: Verify decimal precision for Solana token.

The test correctly adds whitelist token support for Solana, but there's a notable difference in decimal precision (9 for Solana vs 18 for EVM). Ensure this matches Solana's SPL token standard.

✅ Verification successful

Based on the code review and search results, I can now generate the final response:

Decimal precision of 9 for Solana token is correct and verified.

The test is correctly using 9 decimals for Solana token which aligns with Solana's SPL token standard. This is further supported by the implementation where special handling for Solana chains (both mainnet 30168 and devnet 40168) is present in the codebase, showing awareness of Solana's specific requirements. The TVL limit in the test is also appropriately scaled with 1e9 (9 decimals) instead of 1e18 used for EVM chains.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the decimal precision used in other Solana token tests
rg -A 2 "decimals.*9.*Solana"

Length of output: 31


Script:

#!/bin/bash
# Let's search for any Solana token decimal patterns in the codebase
rg -A 5 "solanaClientChainId.*decimals|solana.*decimals|spl.*decimals" -i

# Also search for any token decimal constants or configurations
ast-grep --pattern 'decimals = $_;'

Length of output: 113


Script:

#!/bin/bash
# Let's also check the contract implementation for decimal handling
fd "ExocoreGateway" --exec cat {}

Length of output: 96786


Script:

#!/bin/bash
# Let's search for any decimal-related constants or configurations for Solana
rg -A 2 "SOLANA|decimal.*9|9.*decimal" --type sol

# Also search for any Solana token-related tests or configurations
rg -A 5 "solana.*token|spl.*token" --type sol

Length of output: 155


Script:

#!/bin/bash
# Let's search for any decimal-related constants or configurations for Solana without file type restriction
rg -A 2 "SOLANA|decimal.*9|9.*decimal"

# Also search for any Solana token-related tests or configurations
rg -A 5 "solana.*token|spl.*token"

Length of output: 2315

src/core/ExocoreGateway.sol Outdated Show resolved Hide resolved
test/foundry/unit/ExocoreGateway.t.sol Outdated Show resolved Hide resolved
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: 0

🧹 Outside diff range and nitpick comments (2)
test/foundry/unit/ExocoreGateway.t.sol (2)

52-52: Document the significance of the Solana chain ID.

Consider adding a comment explaining why the specific value 40_168 was chosen for solanaClientChainId. This helps other developers understand the significance of this magic number.


622-638: Enhance test coverage for Solana whitelist token.

While the test validates the basic flow, consider adding assertions to verify:

  1. The token was actually whitelisted
  2. The correct decimals (9) were stored
  3. The metadata was properly set

Example assertion:

// Add after line 637
assertEq(exocoreGateway.getWhitelistedToken(solanaClientChainId, bytes32(bytes20(address(restakeToken)))).decimals, 9);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between cd0eb2a and b992561.

📒 Files selected for processing (2)
  • src/core/ExocoreGateway.sol (4 hunks)
  • test/foundry/unit/ExocoreGateway.t.sol (8 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/core/ExocoreGateway.sol
🔇 Additional comments (1)
test/foundry/unit/ExocoreGateway.t.sol (1)

140-154: LGTM! Well-structured function overloading.

The refactored generateUID function is well-organized with:

  • Clear separation of concerns between EVM and Solana clients
  • Reduced nesting through early returns
  • Improved readability with concise conditional logic

@magj2006 magj2006 force-pushed the solana-client-controller branch from 6cb7622 to f5fbb86 Compare October 29, 2024 15:19
Copy link
Collaborator

@bwhour bwhour left a comment

Choose a reason for hiding this comment

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

looks good.

@magj2006 magj2006 added this pull request to the merge queue Oct 30, 2024
Merged via the queue into main with commit 54cb293 Oct 30, 2024
7 checks passed
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.

4 participants