File location:
The 'createMultipleConfigs' function makes 'createSingleConfig' function calls in the loop, which can cause inefficient gas usage and increase the potential for transaction failure due to block gas limitations.
In the 'createMultipleConfigs' function, the 'createSingleConfig' function is called inside the loop for each element in the 'modules' and 'datas' arrays. Each time the function is called, the gas used will increase. In cases where the 'modules' and 'datas' arrays are large, this may cause the transaction to run out of gas or exceed the allowed block gas limit, thereby causing transaction failure.
Transaction failure due to running out of gas.
Unnecessary increase in transaction costs.
Potential DoS (Denial of Service) attack if an attacker deliberately exploits this weakness by entering very large data.
Inspection manual
Solidity
Foundry
To fix this problem, we can consider several approaches. One way is to avoid calling the 'createSingleConfig' function inside the loop. Because the 'createSingleConfig' function only initializes the 'BootstrapConfig' struct, we can do this directly inside the loop without calling the function.
Code snippet:
L41-L43
Fixed code:
Code when testing using Foundry:
Foundry output:
Ran 2 tests for test/TestBootstrapLib.sol:TestBootstrapLib
[PASS] testCreateMultipleConfigs() (gas: 17419)
[PASS] testCreateMultipleConfigsLengthMismatch() (gas: 12175)
Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 55.27ms (29.33ms CPU time)
Ran 1 test suite in 110.40ms (55.27ms CPU time): 2 tests passed, 0 failed, 0 skipped (2 total tests)
Invalid [known issue [NonCritical-16]](https://github.com/Cyfrin/2024-07-biconomy/issues/1)
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.