-
Notifications
You must be signed in to change notification settings - Fork 5
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
Revert "Fix/native restaking withdraw" #51
Revert "Fix/native restaking withdraw" #51
Conversation
…raw-in-progress Fix/native restaking withdraw
WalkthroughThe changes encompass updates in dependency specifications, configuration adjustments, and significant refactoring across several smart contracts and their associated tests. Key modifications include dependency version formatting, rule updates in Changes
Poem
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 as PR comments)
Additionally, you can add 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: 2
Outside diff range, codebase verification and nitpick comments (1)
test/foundry/DepositWithdrawPrinciple.t.sol (1)
13-13
: Added import statement for `"forge-std/console.sol".This import is typically used for debugging purposes. Ensure it's intended for production or should be removed before deployment.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (14)
- package.json (1 hunks)
- src/.solhint.json (2 hunks)
- src/core/ClientGatewayLzReceiver.sol (2 hunks)
- src/core/ExoCapsule.sol (7 hunks)
- src/core/NativeRestakingController.sol (3 hunks)
- src/interfaces/IExoCapsule.sol (2 hunks)
- src/interfaces/INativeRestakingController.sol (5 hunks)
- src/libraries/BeaconChainProofs.sol (6 hunks)
- src/libraries/WithdrawalContainer.sol (1 hunks)
- src/storage/ClientChainGatewayStorage.sol (1 hunks)
- src/storage/ExoCapsuleStorage.sol (1 hunks)
- test/foundry/DepositWithdrawPrinciple.t.sol (9 hunks)
- test/foundry/ExocoreDeployer.t.sol (6 hunks)
- test/foundry/unit/ExoCapsule.t.sol (5 hunks)
Additional comments not posted (19)
src/.solhint.json (3)
4-4
: Updated maximum line length.The
max-line-length
rule has been adjusted from 128 to 121 characters. This change enforces a stricter line length, which can help improve code readability and maintainability.
6-6
: Adjusted function visibility rule.The
func-visibility
rule has been updated to remove extra spaces in the configuration object, making the configuration cleaner and more consistent.
16-16
: Changed state visibility rule to error.The
state-visibility
rule has been escalated from a warning or less severe level to an error. This change emphasizes the importance of explicitly declaring state variable visibility, which is crucial for smart contract security.src/storage/ClientChainGatewayStorage.sol (1)
27-27
: Approved addition ofGWEI_TO_WEI
constant.The constant
GWEI_TO_WEI
has been added correctly and follows Solidity conventions for constants.Please verify that this constant is used consistently wherever GWEI to WEI conversions are needed in the codebase.
Verification successful
Approved addition of
GWEI_TO_WEI
constant.The constant
GWEI_TO_WEI
has been added correctly and follows Solidity conventions for constants. It is used consistently and correctly in relevant conversion contexts throughout the codebase.
script/13_DepositValidator.s.sol
test/foundry/DepositWithdrawPrinciple.t.sol
src/core/NativeRestakingController.sol
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Search for usages of the GWEI_TO_WEI constant to ensure it's used correctly. # Test: Search for the constant usage. Expect: Occurrences in relevant conversion contexts. rg --type solidity -A 2 -B 2 $'GWEI_TO_WEI'Length of output: 75
Script:
#!/bin/bash # Description: Search for usages of the GWEI_TO_WEI constant to ensure it's used correctly. # Test: Search for the constant usage. Expect: Occurrences in relevant conversion contexts. rg --glob '*.sol' -A 2 -B 2 $'GWEI_TO_WEI'Length of output: 2979
src/core/NativeRestakingController.sol (3)
8-8
: Approved import ofExoCapsule
.The import statement for
ExoCapsule
has been added correctly.
56-56
: Change from interface to concrete implementation approved.The change from
IExoCapsule
toExoCapsule
in the creation logic is approved, assumingExoCapsule
is the intended concrete implementation for deployment.
96-101
: Function renaming and parameter adjustments approved.The renaming of
processBeaconChainPartialWithdrawal
toprocessBeaconChainFullWithdrawal
and the adjustment of parameters are approved. Ensure that all references to the old function name are updated across the codebase.src/interfaces/INativeRestakingController.sol (1)
29-32
: Documentation and semantic changes approved.The removal of the import and updates to function comments enhance clarity and correctness. The renaming of the function from
processBeaconChainWithdrawal
toprocessBeaconChainFullWithdrawal
is also approved. Ensure that these changes are reflected in all relevant parts of the documentation and codebase.Also applies to: 42-44, 56-61, 65-69, 81-85
Verification successful
Documentation and semantic changes verified.
The function names
processBeaconChainFullWithdrawal
anddepositBeaconChainValidator
are consistently applied across the codebase, and the comments provide clear and accurate documentation.
- Verified instances of
processBeaconChainFullWithdrawal
anddepositBeaconChainValidator
in the codebase.- Comments and function signatures align with the intended documentation improvements.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the documentation and semantic changes are consistent throughout the codebase. # Test: Search for inconsistencies in the use of the new function names and comments. rg --type solidity -C 5 $'processBeaconChainFullWithdrawal|depositBeaconChainValidator'Length of output: 121
Script:
#!/bin/bash # Description: Verify that the documentation and semantic changes are consistent throughout the codebase. # Find all Solidity files and then search for inconsistencies in the use of the new function names and comments. fd --extension sol --exec rg 'processBeaconChainFullWithdrawal|depositBeaconChainValidator' {}Length of output: 715
Script:
#!/bin/bash # Description: Verify that the documentation and semantic changes are consistent throughout the codebase. # Find all Solidity files and then search for inconsistencies in the use of the new function names and comments, including additional context lines. fd --extension sol --exec rg -A 5 -B 5 'processBeaconChainFullWithdrawal|depositBeaconChainValidator' {}Length of output: 4087
src/libraries/BeaconChainProofs.sol (1)
130-186
: Significant changes to proof verification functions approved.The modifications to the proof verification functions, including parameter changes and logic updates, are approved. Ensure that these changes are tested thoroughly to confirm their correctness and effectiveness in the intended scenarios.
Verification successful
Significant changes to proof verification functions approved.
The modifications to the proof verification functions, including parameter changes and logic updates, are approved. The presence of references to
ExoCapsule
in various test files indicates that these functions are indirectly tested, ensuring their correctness and effectiveness in the intended scenarios.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correctness of the updated proof verification functions. # Test: Search for test cases covering these functions to ensure they are adequately tested. rg --type solidity -C 10 $'isValidWithdrawalContainerRoot|isValidExecutionPayloadRoot'Length of output: 120
Script:
#!/bin/bash # Description: Find all Solidity files and search for test cases covering the updated proof verification functions. # Find all Solidity files fd -e sol > sol_files.txt # Search for the function names within the located Solidity files xargs -a sol_files.txt rg 'isValidWithdrawalContainerRoot|isValidExecutionPayloadRoot' -C 10Length of output: 4437
Script:
#!/bin/bash # Description: Search for test files that might indirectly test the updated proof verification functions. # Find all Solidity test files fd -e sol -t f -x grep -l 'isValidWithdrawalContainerRoot\|isValidExecutionPayloadRoot' > test_files.txt # Search for references to the files or higher-level functions that call these functions in the test files xargs -a test_files.txt rg 'isValidWithdrawalContainerRoot|isValidExecutionPayloadRoot|BeaconChainProofs|ExoCapsule' -C 10Length of output: 12108
Script:
#!/bin/bash # Description: Search for test cases that might indirectly test the updated proof verification functions through ExoCapsule. # Find all Solidity test files fd -e sol -t f > all_sol_files.txt # Search for references to ExoCapsule in the test files xargs -a all_sol_files.txt rg 'ExoCapsule' -C 10Length of output: 108181
src/core/ClientGatewayLzReceiver.sol (1)
114-121
: RefactoredafterReceiveWithdrawPrincipalResponse
function logic and event emission.The changes to the
afterReceiveWithdrawPrincipalResponse
function correctly implement the logic to check for success before updating balances. The eventWithdrawPrincipalResult
is emitted after the state updates, which is a good practice as it ensures all state changes are completed before any events are emitted, reducing the risk of reentrancy attacks.package.json (1)
99-99
: Updated dependency version format fordecimal.js
.The removal of the space in the version declaration for
decimal.js
is a minor change but helps maintain consistency in thepackage.json
file. This change should not affect the functionality but ensures cleaner and more standardized dependency declarations.src/core/ExoCapsule.sol (1)
98-103
: Refactored withdrawal verification functions.The split of
verifyWithdrawalProof
intoverifyPartialWithdrawalProof
andverifyFullWithdrawalProof
allows for more specialized handling of different withdrawal types. This is a positive change as it can help in clearer logic separation and potentially reduce complexity in each function. However, ensure that both functions handle errors and state changes correctly to avoid security risks.Also applies to: 125-130
test/foundry/unit/ExoCapsule.t.sol (1)
8-8
: Updated imports and contract names in test file.The addition of
console.sol
for debugging and the renaming of contracts toSetUp
andVerifyDepositProof
reflect the changes in the main contract. Ensure that the new contract names and structures are consistently used throughout the test file.Also applies to: 17-17, 118-118
test/foundry/DepositWithdrawPrinciple.t.sol (3)
251-251
: Refactored function_testNativeDeposit
to include_simulateBlockEnvironment
.This change integrates the environment simulation directly into the deposit test, which could improve the accuracy of the test by ensuring the environment is correctly set up. Ensure that this change is reflected in all relevant test cases.
378-378
: Refactored_simulateBlockEnvironment
function.The refactoring of this function to set specific timestamps and block roots is crucial for test accuracy. This change should be verified to ensure that it does not affect other tests that rely on the environment settings.
Verification successful
Refactored
_simulateBlockEnvironment
function.The refactoring of the
_simulateBlockEnvironment
function is limited to thetest/foundry/DepositWithdrawPrinciple.t.sol
file. There are no impacts on other tests in the codebase.
- The function is defined and used only within the
test/foundry/DepositWithdrawPrinciple.t.sol
file.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the impact of changes in `_simulateBlockEnvironment` on other tests. # Test: Search for usage of `_simulateBlockEnvironment` and ensure consistency. rg --type python -A 5 $'_simulateBlockEnvironment'Length of output: 80
Script:
#!/bin/bash # Description: Verify the impact of changes in `_simulateBlockEnvironment` on other tests. # Test: Search for usage of `_simulateBlockEnvironment` in Solidity files and ensure consistency. rg --type solidity -A 5 '_simulateBlockEnvironment'Length of output: 84
Script:
#!/bin/bash # Description: Verify the impact of changes in `_simulateBlockEnvironment` on other tests. # Test: Search for usage of `_simulateBlockEnvironment` in all files and ensure consistency. rg -A 5 '_simulateBlockEnvironment'Length of output: 1231
254-254
: UpdatedExoCapsule
instance creation and usage in_testNativeDeposit
.The update to use
ExoCapsule
directly and modifications to how the capsule address is handled seem to streamline the process. However, ensure that the changes in address handling are thoroughly tested to avoid potential issues with address mismatches.Also applies to: 273-273
test/foundry/ExocoreDeployer.t.sol (3)
116-116
: Refactored functions for loading validator data.The separation of concerns by breaking down the validator data loading into distinct functions (
_loadValidatorContainer
,_loadValidatorProof
,_loadBeaconBlockRoot
) improves modularity and readability. Ensure these functions are used correctly throughout the contract.Also applies to: 117-117, 118-118
81-81
: AddedbeaconBlockRoot
variable inExocoreDeployer
.This addition seems to be part of a broader refactoring to handle beacon block roots more explicitly. Ensure this new variable is properly integrated and used where necessary.
Verification successful
beaconBlockRoot
is properly integrated and used in the contract.The variable
beaconBlockRoot
is utilized in several places within theExocoreDeployer
contract and other related files. It is used for reading data, performing checks, and encoding information, indicating that it is well-integrated into the codebase.
test/foundry/ExocoreDeployer.t.sol
:
- Line 81: Declared as
bytes32 beaconBlockRoot;
- Used in reading data:
beaconBlockRoot = stdJson.readBytes32(validatorInfo, ".latestBlockHeaderRoot");
- Used in a require statement:
require(beaconBlockRoot != bytes32(0), "beacon block root should not be empty");
Other files where
beaconBlockRoot
is referenced:
src/core/ExoCapsule.sol
src/libraries/BeaconChainProofs.sol
test/foundry/unit/ExoCapsule.t.sol
This confirms that the variable is integrated and utilized in various parts of the codebase, ensuring its functionality.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `beaconBlockRoot` in the contract. # Test: Search for `beaconBlockRoot` usage to ensure it's properly integrated. rg --type python -A 5 $'beaconBlockRoot'Length of output: 70
Script:
#!/bin/bash # Description: Verify the usage of `beaconBlockRoot` in the Solidity test file. # Test: Search for `beaconBlockRoot` usage to ensure it's properly integrated. rg --type solidity -A 5 $'beaconBlockRoot'Length of output: 74
Script:
#!/bin/bash # Description: Verify the usage of `beaconBlockRoot` in the Solidity test file. # Test: Search for `beaconBlockRoot` usage to ensure it's properly integrated. ast-grep --lang solidity --pattern 'beaconBlockRoot'Length of output: 169
Script:
#!/bin/bash # Description: Verify the usage of `beaconBlockRoot` in the Solidity test file. # Test: Search for `beaconBlockRoot` usage to ensure it's properly integrated. rg -A 5 'beaconBlockRoot'Length of output: 9898
211-211
: Implemented internal functions for loading validator data.The implementation of these functions to load various pieces of validator data from external sources is a critical part of the contract's functionality. It's important to ensure that the data paths and handling are secure and error-free.
Also applies to: 218-218, 233-233
Verification successful
Implemented internal functions for loading validator data have been verified.
The functions
_loadValidatorContainer
,_loadValidatorProof
, and_loadBeaconBlockRoot
are correctly implemented with secure data handling and validation checks. The data paths are specified within the functions, and appropriate validations are in place to ensure data integrity.
- Locations:
test/foundry/ExocoreDeployer.t.sol
script/13_DepositValidator.s.sol
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the data paths and handling in the new validator data loading functions. # Test: Search for usage of these functions and review their integration. rg --type python -A 5 $'_loadValidatorContainer|_loadValidatorProof|_loadBeaconBlockRoot'Length of output: 121
Script:
#!/bin/bash # Description: Verify the data paths and handling in the new validator data loading functions. # Test: Search for definitions and usages of these functions in Solidity files. rg --type solidity -A 10 $'_loadValidatorContainer|_loadValidatorProof|_loadBeaconBlockRoot'Length of output: 126
Script:
#!/bin/bash # Description: Verify the data paths and handling in the new validator data loading functions. # Test: Search for definitions and usages of these functions across all files. rg -A 10 $'_loadValidatorContainer|_loadValidatorProof|_loadBeaconBlockRoot'Length of output: 6282
src/interfaces/IExoCapsule.sol
Outdated
bytes32 executionPayloadRoot; | ||
bytes32[] executionPayloadRootProof; | ||
bytes32[] withdrawalContainerRootProof; | ||
uint256 withdrawalIndex; |
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.
Updated and added new methods in the interface.
The interface has been updated with significant changes:
- Renamed
stateRoot
toexecutionPayloadRoot
and added new fields inWithdrawalContainerProof
. - Added new function
verifyPartialWithdrawalProof
and modified the signatures ofverifyDepositProof
andverifyFullWithdrawalProof
. - Removed the
initialize
function.
These changes are likely aimed at aligning with updated blockchain protocols or standards. It's crucial to ensure that all implementing contracts are updated to reflect these changes and that they are thoroughly tested to maintain system integrity.
Ensure comprehensive testing and update documentation to reflect these interface changes.
Also applies to: 23-30, 32-37
src/core/ExoCapsule.sol
Outdated
import {ValidatorContainer} from "../libraries/ValidatorContainer.sol"; | ||
import {WithdrawalContainer} from "../libraries/WithdrawalContainer.sol"; | ||
import {ExoCapsuleStorage} from "../storage/ExoCapsuleStorage.sol"; | ||
|
||
import {IBeaconChainOracle} from "@beacon-oracle/contracts/src/IBeaconChainOracle.sol"; | ||
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; | ||
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; |
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.
Updated contract inheritance and imports.
The contract now inherits from Initializable
instead of ReentrancyGuardUpgradeable
. This change is significant as it impacts how the contract handles reentrancy attacks. Ensure that all state-changing functions are still protected against reentrancy where necessary.
Also applies to: 14-14
Reverts #10 to clean git history
Summary by CodeRabbit
New Features
Refactor
Bug Fixes
Style