Closed sherlock-admin closed 6 months ago
2 comment(s) were left on this issue during the judging contest.
0xLogos commented:
informational, module can be replaced in FlatcoinVault
takarez commented:
invalid
Invalid, as mentioned by the above comments, modules can always be replaced here without having to be explicitly upgraded.
LTDingZhen
medium
Keeperfee
will be miscalculated after Ecotone upgrade and cannot be upgradedSummary
Keeperfee
will be miscalculated after Ecotone upgrade on OP stack.Vulnerability Detail
Base Mainnet transaction fees are composed of an Execution Gas Fee and an L1 Data Fee. The total cost of a transaction is the sum of these two fees.
Prior to the Ecotone upgrade, the L1 Data Fee is calculated based on the following parameters:
The L1 Data Fee calculation first begins with counting the number of zero bytes and non-zero bytes in the transaction data. Each zero byte costs 4 gas and each non-zero byte costs 16 gas. This is the same way that Ethereum calculates the gas cost of transaction data.
In current
Keeperfee.sol
,_gasUnitsL1
is used as an estimate oftx_data_gas
.After calculating the gas cost of the transaction data, the fixed and dynamic overhead values are applied.
Finally, the total L1 Data Fee is calculated by multiplying the total gas cost by the current Ethereum base fee.
The above formula is exactly the logic executed by
getKeeperFee
:But, after the Ecotone upgrade, batch transactions will be sent to L1 as 4844 blobs instead of through L1 calldata. This updated function uses the following parameters:
At the exact point of the Ecotone upgrade, the dynamic overhead parameter value is used to initialize the Ecotone base fee scalar, and blob base fee is set to 0. The overhead parameter from the previous function becomes ignored.
The Ecotone L1 Data Fee calculation begins with counting the number of zero bytes and non-zero bytes in the transaction data. Each zero byte costs 4 gas and each non-zero byte costs 16 gas. This value, when divided by 16, can be thought of as a rough estimate of the size of the transaction data after compression.
Next, the two scalars are applied to the base fee and blob base fee parameters to compute a weighted gas price multiplier.
The l1 data fee is then:
Recall that
base_fee_scalar
is set todynamic_overhead
andblob_base_fee_scalar
is 0 immediately following the upgrade. Because the old overhead parameter becomes ignored, new L1 data prices will be lower than before the fork.It's worth noting that
KeeperFee.sol
doesn't inheritModuleUpgradeable.sol
or any proxy patterns, so it's currently not updatable. Users have to pay more forkeeperfee
than they should after the upgrade.Impact
Since the Ecotone upgrade(along with Dencun upgrade) will take place around the time Flatcoin is deployed on BASE mainnet, such error would affect users to pay more Keeperfee.
Code Snippet
https://github.com/sherlock-audit/2023-12-flatmoney/blob/main/flatcoin-v1/src/misc/KeeperFee.sol#L104-L105
Tool used
Manual Review
Recommendation
Let
Keeperfee.sol
inheritModuleUpgradeable.sol
so contract could be updated after Ecotone upgrade.