diff --git a/l1-contracts/src/core/libraries/Errors.sol b/l1-contracts/src/core/libraries/Errors.sol index 1c3473ec5148..f873d0ace2bd 100644 --- a/l1-contracts/src/core/libraries/Errors.sol +++ b/l1-contracts/src/core/libraries/Errors.sol @@ -73,7 +73,6 @@ library Errors { error Rollup__TryingToProveNonExistingBlock(); // 0x34ef4954 error Rollup__UnavailableTxs(bytes32 txsHash); // 0x414906c3 error Rollup__NonZeroDaFee(); // 0xd9c75f52 - error Rollup__NonZeroL2Fee(); // 0x7e728abc error Rollup__InvalidBasisPointFee(uint256 basisPointFee); // 0x4292d136 error Rollup__InvalidManaBaseFee(uint256 expected, uint256 actual); // 0x73b6d896 error Rollup__StartAndEndNotSameEpoch(Epoch start, Epoch end); diff --git a/l1-contracts/src/core/libraries/RollupLibs/FeeMath.sol b/l1-contracts/src/core/libraries/RollupLibs/FeeMath.sol index f9c7bfc3e9b6..47a4e035fc80 100644 --- a/l1-contracts/src/core/libraries/RollupLibs/FeeMath.sol +++ b/l1-contracts/src/core/libraries/RollupLibs/FeeMath.sol @@ -22,6 +22,7 @@ uint256 constant CONGESTION_UPDATE_FRACTION = 854700854; uint256 constant BLOB_GAS_PER_BLOB = 2 ** 17; uint256 constant GAS_PER_BLOB_POINT_EVALUATION = 50_000; +uint256 constant BLOBS_PER_BLOCK = 3; struct OracleInput { int256 feeAssetPriceModifier; @@ -116,9 +117,11 @@ library FeeMath { ); EthValue dataCostPerMana = EthValue.wrap( - Math.mulDiv(3 * BLOB_GAS_PER_BLOB, _fees.blobFee, MANA_TARGET, Math.Rounding.Ceil) + Math.mulDiv( + BLOBS_PER_BLOCK * BLOB_GAS_PER_BLOB, _fees.blobFee, MANA_TARGET, Math.Rounding.Ceil + ) ); - uint256 gasUsed = L1_GAS_PER_BLOCK_PROPOSED + 3 * GAS_PER_BLOB_POINT_EVALUATION + uint256 gasUsed = L1_GAS_PER_BLOCK_PROPOSED + BLOBS_PER_BLOCK * GAS_PER_BLOB_POINT_EVALUATION + L1_GAS_PER_EPOCH_VERIFIED / _epochDuration; EthValue gasCostPerMana = EthValue.wrap(Math.mulDiv(gasUsed, _fees.baseFee, MANA_TARGET, Math.Rounding.Ceil)); diff --git a/l1-contracts/src/core/libraries/RollupLibs/ProposeLib.sol b/l1-contracts/src/core/libraries/RollupLibs/ProposeLib.sol index 32f67e228332..1f2e5f3d5a0f 100644 --- a/l1-contracts/src/core/libraries/RollupLibs/ProposeLib.sol +++ b/l1-contracts/src/core/libraries/RollupLibs/ProposeLib.sol @@ -158,9 +158,21 @@ library ProposeLib { view returns (ManaBaseFeeComponents memory) { - // @todo If we are not canonical we can just return mostly zeros here. - RollupStore storage rollupStore = STFLib.getStorage(); + + // If we are not the canonical rollup, we cannot claim any fees, so we return 0s + // The congestion multiplier could be computed, but as it could only be used to guide + // might as well save the gas and anyone interested can do it off-chain. + if (address(this) != rollupStore.config.feeAssetPortal.canonicalRollup()) { + return ManaBaseFeeComponents({ + congestionCost: 0, + provingCost: 0, + congestionMultiplier: 0, + dataCost: 0, + gasCost: 0 + }); + } + // If we can prune, we use the proven block, otherwise the pending block uint256 blockOfInterest = STFLib.canPruneAtTime(_timestamp) ? rollupStore.tips.provenBlockNumber @@ -275,19 +287,13 @@ library ProposeLib { Errors.Rollup__UnavailableTxs(_args.header.contentCommitment.blobsHash) ); - // If not canonical rollup, require that the fees are zero - if (address(this) != rollupStore.config.feeAssetPortal.canonicalRollup()) { - require(_args.header.globalVariables.gasFees.feePerDaGas == 0, Errors.Rollup__NonZeroDaFee()); - require(_args.header.globalVariables.gasFees.feePerL2Gas == 0, Errors.Rollup__NonZeroL2Fee()); - } else { - require(_args.header.globalVariables.gasFees.feePerDaGas == 0, Errors.Rollup__NonZeroDaFee()); - require( - _args.header.globalVariables.gasFees.feePerL2Gas == _args.manaBaseFee, - Errors.Rollup__InvalidManaBaseFee( - _args.manaBaseFee, _args.header.globalVariables.gasFees.feePerL2Gas - ) - ); - } + require(_args.header.globalVariables.gasFees.feePerDaGas == 0, Errors.Rollup__NonZeroDaFee()); + require( + _args.header.globalVariables.gasFees.feePerL2Gas == _args.manaBaseFee, + Errors.Rollup__InvalidManaBaseFee( + _args.manaBaseFee, _args.header.globalVariables.gasFees.feePerL2Gas + ) + ); } /** diff --git a/l1-contracts/test/Rollup.t.sol b/l1-contracts/test/Rollup.t.sol index a1153e990c7d..579d615696ce 100644 --- a/l1-contracts/test/Rollup.t.sol +++ b/l1-contracts/test/Rollup.t.sol @@ -335,7 +335,8 @@ contract RollupTest is RollupBase { skipBlobCheck(address(rollup)); - vm.expectRevert(abi.encodeWithSelector(Errors.Rollup__NonZeroL2Fee.selector)); + // When not canonical, we expect the fee to be 0 + vm.expectRevert(abi.encodeWithSelector(Errors.Rollup__InvalidManaBaseFee.selector, 0, 1)); ProposeArgs memory args = ProposeArgs({ header: header, archive: data.archive,