You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EthosVouch.sol contract might run out of gas due following wrong pattern
Summary
In EthosVouch.sol:slash() func we are copying storage mapping data to the storage array
uint256 totalSlashed;
uint256[] storage vouchIds = vouchIdsByAuthor[authorProfileId]; //for (uint256 i =0; i < vouchIds.length; i++) {//
Vouch storage vouch = vouches[vouchIds[i]]; //// Only slash active vouchesif (!vouch.archived) {
uint256 slashAmount = vouch.balance.mulDiv(
slashBasisPoints,
BASIS_POINT_SCALE,
Math.Rounding.Floor
);
if (slashAmount >0) {
vouch.balance -= slashAmount;
totalSlashed += slashAmount;
}
what we exactly does here, we accessing storage mapping = 2k of gas per unit, and writing the value to the storage array 20k gas per unit, after all of this we going throw for loop accessing it once again
This mappings we accessing might have up to 256 values, which we are coppying to array, it hugely consumes our gas.
Such pattern persist in EthosVouch.sol:slash(), EthosVouch.sol: _rewardPreviousVouchers(), EthosVouch.sol:_removeVouchFromArrays(),
Recumbent Cerulean Fish
Medium
EthosVouch.sol contract might run out of gas due following wrong pattern
Summary
In EthosVouch.sol:slash() func we are copying storage mapping data to the storage array
what we exactly does here, we accessing storage mapping = 2k of gas per unit, and writing the value to the storage array 20k gas per unit, after all of this we going throw for loop accessing it once again
This mappings we accessing might have up to 256 values, which we are coppying to array, it hugely consumes our gas.
Such pattern persist in EthosVouch.sol:slash(), EthosVouch.sol: _rewardPreviousVouchers(), EthosVouch.sol:_removeVouchFromArrays(),
Root Cause
EthosVouch.sol:slash(), EthosVouch.sol: _rewardPreviousVouchers(), EthosVouch.sol:_removeVouchFromArrays()
Internal pre-conditions
No response
External pre-conditions
No response
Attack Path
Run function above for ProfileIds which have big amount of vouchers
Impact
Contract won't be able to execute functions above
PoC
No response
Mitigation
No response
The text was updated successfully, but these errors were encountered: