Describe the bug
In the getForcePosition function of the UpgradeL1Bridge contract, the _key parameter is defined as memory but it can be more efficiently defined as calldata.
Affected Function:
function getForcePosition(string memory _key) external view returns (address)
Configuration
Severity: LOW
Impact
Inefficient Memory Usage: Using memory for the _key parameter consumes more gas than necessary. calldata is more efficient for external function parameters, especially when dealing with strings.
Recommendation
Change the _key parameter from memory to calldata to optimize gas usage.
Change the function signature to:
function getForcePosition(string calldata _key) external view returns (address)
Describe the bug In the getForcePosition function of the UpgradeL1Bridge contract, the _key parameter is defined as memory but it can be more efficiently defined as calldata.
Affected Function:
function getForcePosition(string memory _key) external view returns (address)
Configuration
Impact Inefficient Memory Usage: Using memory for the _key parameter consumes more gas than necessary. calldata is more efficient for external function parameters, especially when dealing with strings.
Recommendation Change the _key parameter from memory to calldata to optimize gas usage.
Change the function signature to:
function getForcePosition(string calldata _key) external view returns (address)
Exploit Scenario
Demo