Closed adu-web3 closed 3 months ago
The changes focus on optimizing the ClientChainGateway
and Bootstrap
contracts to address code size limitations. By streamlining functionalities, enhancing event handling, and refactoring response processes, the codebase is made more organized and maintainable. Key contracts such as ClientGatewayLzReceiver
and ExocoreGateway
have been improved for clarity and efficiency, ensuring compliance with deployment constraints while retaining essential functionalities.
File | Change Summary |
---|---|
src/core/ClientChainGateway.sol |
Removed redundant response hooks; simplified whitelist management. |
src/core/ClientGatewayLzReceiver.sol |
Centralized response handling in _handleResponse ; added internal methods for better organization. |
src/core/ExocoreGateway.sol |
Enhanced event emissions; introduced a result variable for capturing success status. |
src/interfaces/IClientChainGateway.sol |
Simplified inheritance by removing ITokenWhitelister . |
src/storage/BootstrapStorage.sol |
Deleted the DepositThenDelegateResult event and its documentation. |
src/storage/ClientChainGatewayStorage.sol |
Replaced WithdrawRewardResult with RequestFinished ; removed _registeredResponseHooks . |
src/storage/ExocoreGatewayStorage.sol |
Added new event declarations for asset and staking results. |
src/storage/GatewayStorage.sol |
Introduced a private __gap array; updated nonce verification; added inbound nonce mapping. |
test/foundry/Delegation.t.sol |
Modified event definitions; replaced some emissions with RequestFinished . |
test/foundry/DepositThenDelegateTo.t.sol |
Replaced DepositThenDelegateResult with DepositResult and DelegateResult , adjusting parameters. |
test/foundry/DepositWithdrawPrinciple.t.sol |
Updated events to use bytes32 , added new functions and checks, modified event emissions. |
test/foundry/ExocoreDeployer.t.sol |
Added RequestFinished event. |
test/foundry/WithdrawReward.t.sol |
Updated WithdrawRewardResult to use bytes32 ; introduced RequestFinished event. |
test/foundry/unit/ClientChainGateway.t.sol |
Removed functions related to whitelist token management. |
sequenceDiagram
participant User
participant ClientGatewayLzReceiver
participant ExocoreGateway
participant Storage
User->>ClientGatewayLzReceiver: Send Request
ClientGatewayLzReceiver->>ClientGatewayLzReceiver: _handleResponse
ClientGatewayLzReceiver->>ExocoreGateway: Process Request
ExocoreGateway->>Storage: Update State
ExocoreGateway->>User: Emit Event
Note over ClientGatewayLzReceiver, ExocoreGateway: Refactored internal handling and event emissions
Objective (Issues) | Addressed | Explanation |
---|---|---|
Reduce code size of ClientChainGateway and Bootstrap (#42) |
✅ | |
Improve code readability and organization | ✅ | |
Refactor response handling and event emissions | ✅ | |
Simplify interface inheritance in IClientChainGateway |
✅ |
In the blockchain's enchanted land,
Contracts trimmed with a careful hand,
Refactored code, events that bloom,
In smart contracts' endless room.
Whitelist trimmed, responses clear,
Code size limits, no more fear!
🐰✨
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?
Description
closes: #42
before refactoring, the code size of
ClientChainGateway
has exceeded the size limit (24576 bytes):One of the approaches to reduce code size is to removing redundant functions, so I tried to use a single internal function
_handleResponse
to deal with all kinds of responses, instead of the original response hook functions that are public(public functions seem occupy more space). After refactoring, the code size has been significantly reduced:Roughly 2 kb size is saved after refactoring. Removing
ITokenWhitelister
also helps with this issue. So we might be able to find more approaches to optimize the code size while this PR aims to solve the most urgent issue.Summary by CodeRabbit
New Features
Refactor
Events
Interface Updates
Bug Fixes
Dependency Update