Describe the bug
In the UpgradeL1Bridge contract, the function forceWithdrawClaim and claim use string memory _hash as a parameter, which could be optimized by changing it to string calldata _hash. This change can reduce gas costs by avoiding the unnecessary copying of data into memory.
Affected Functions:
// code before
function forceWithdrawClaim(address _position, string memory _hash, address _token, uint _amount) external {
claim(_position, _hash, _token, _amount);
}
// code before
function claim(address _position, string memory _hash, address _token, uint _amount) internal {
// function body
}
Configuration
Severity: LOW
Impact
Changing the parameter type to calldata can lead to reduced gas costs, making the function more efficient, especially for external calls.
Recommendation
Change the parameter type from memory to calldata in both functions:
// code after
function forceWithdrawClaim(address _position, string calldata _hash, address _token, uint _amount) external {
claim(_position, _hash, _token, _amount);
}
// code after
function claim(address _position, string calldata _hash, address _token, uint _amount) internal {
// function body
}
Exploit Scenario
This issue does not pose a direct security risk but leads to higher gas costs for users interacting with these functions.
Describe the bug In the UpgradeL1Bridge contract, the function forceWithdrawClaim and claim use string memory _hash as a parameter, which could be optimized by changing it to string calldata _hash. This change can reduce gas costs by avoiding the unnecessary copying of data into memory.
Affected Functions:
Configuration
Impact Changing the parameter type to calldata can lead to reduced gas costs, making the function more efficient, especially for external calls.
Recommendation Change the parameter type from memory to calldata in both functions:
Exploit Scenario This issue does not pose a direct security risk but leads to higher gas costs for users interacting with these functions.
Demo using the gas reporter
GAS USED with MEMORY:
Gas used: 92074
GAS USED with CALLDATA:
Gas used: 91437