Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion l1-contracts/src/core/libraries/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions l1-contracts/src/core/libraries/RollupLibs/FeeMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
36 changes: 21 additions & 15 deletions l1-contracts/src/core/libraries/RollupLibs/ProposeLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion l1-contracts/test/Rollup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading