Skip to content

Commit

Permalink
make UNACCOUNTED_GAS_LIMIT a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivaanshK committed Jul 10, 2024
1 parent 36d854b commit d59cfd5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ contract BiconomySponsorshipPaymaster is
// note: could rename to PAYMASTER_ID_OFFSET
uint256 private constant VALID_PND_OFFSET = PAYMASTER_DATA_OFFSET;

// Limit for unaccounted gas cost
uint16 private constant UNACCOUNTED_GAS_LIMIT = 10_000;

mapping(address => uint256) public paymasterIdBalances;

constructor(
Expand All @@ -60,7 +63,7 @@ contract BiconomySponsorshipPaymaster is
revert VerifyingSignerCanNotBeZero();
} else if (_feeCollector == address(0)) {
revert FeeCollectorCanNotBeZero();
} else if (_unaccountedGas > 200_000) {
} else if (_unaccountedGas > UNACCOUNTED_GAS_LIMIT) {
revert UnaccountedGasTooHigh();
}
verifyingSigner = _verifyingSigner;
Expand Down Expand Up @@ -124,7 +127,7 @@ contract BiconomySponsorshipPaymaster is
* @notice only to be called by the owner of the contract.
*/
function setUnaccountedGas(uint48 value) external payable onlyOwner {
if (value > 200_000) {
if (value > UNACCOUNTED_GAS_LIMIT) {
revert UnaccountedGasTooHigh();
}
uint256 oldValue = unaccountedGas;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ contract TestSponsorshipPaymasterWithDynamicAdjustment is TestBase {
function test_RevertIf_DeployWithUnaccountedGasCostTooHigh() external {
vm.expectRevert(abi.encodeWithSelector(UnaccountedGasTooHigh.selector));
new BiconomySponsorshipPaymaster(
PAYMASTER_OWNER.addr, ENTRYPOINT, PAYMASTER_SIGNER.addr, PAYMASTER_FEE_COLLECTOR.addr, 200_001
PAYMASTER_OWNER.addr, ENTRYPOINT, PAYMASTER_SIGNER.addr, PAYMASTER_FEE_COLLECTOR.addr, 10_001
);
}

Expand Down Expand Up @@ -130,7 +130,7 @@ contract TestSponsorshipPaymasterWithDynamicAdjustment is TestBase {
}

function test_RevertIf_SetUnaccountedGasToHigh() external prankModifier(PAYMASTER_OWNER.addr) {
uint48 newUnaccountedGas = 200_001;
uint48 newUnaccountedGas = 10_001;
vm.expectRevert(abi.encodeWithSelector(UnaccountedGasTooHigh.selector));
bicoPaymaster.setUnaccountedGas(newUnaccountedGas);
}
Expand Down

0 comments on commit d59cfd5

Please sign in to comment.