Skip to content

Commit

Permalink
Merge pull request AztecProtocol#308 from AztecProtocol/lh/handle-bas…
Browse files Browse the repository at this point in the history
…e-fee-0

Lh/handle base fee 0
  • Loading branch information
Maddiaa0 authored Jan 10, 2023
2 parents ccbe514 + 4e7631c commit ea32fd4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/aztec/DataProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,9 @@ contract DataProvider is Ownable {

uint256 criteria = abi.decode(returnData, (uint256));
uint256 ethSub = SUBSIDY.getAccumulatedSubsidyAmount(vars.bridgeAddress, criteria);
uint256 gasCovered = block.basefee == 0 ? 0 : ethSub / block.basefee;

return (criteria, ethSub, ethSub / block.basefee);
return (criteria, ethSub, gasCovered);
}

function _aztecAsset(uint256 _assetId) internal view returns (AztecTypes.AztecAsset memory) {
Expand Down
16 changes: 16 additions & 0 deletions src/test/aztec/dataprovider/DataProvider.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,20 @@ contract DataProviderTest is BridgeTestBase {
assertGe(subsidy, gasUnits * block.basefee, "Invalid gas units accrued");
assertEq(gasUnits, subsidy / block.basefee, "Invalid gas units accrued");
}

function testZeroBaseFee() public {
AztecTypes.AztecAsset memory eth = ROLLUP_ENCODER.getRealAztecAsset(address(0));
AztecTypes.AztecAsset memory virtualAsset =
AztecTypes.AztecAsset({id: 0, erc20Address: address(0), assetType: AztecTypes.AztecAssetType.VIRTUAL});

uint256 bridgeCallData = ROLLUP_ENCODER.encodeBridgeCallData(7, virtualAsset, eth, virtualAsset, eth, 0);

vm.fee(0);

(uint256 criteria, uint256 subsidy, uint256 gasUnits) = provider.getAccumulatedSubsidyAmount(bridgeCallData);
assertEq(criteria, 0, "Wrong criteria");
assertEq(subsidy, 0, "No subsidy accrued");
assertEq(subsidy, 0, "Invalid gas units accrued");
assertEq(gasUnits, 0, "Invalid gas units accrued");
}
}

0 comments on commit ea32fd4

Please sign in to comment.