diff --git a/contracts/sponsorship/SponsorshipPaymasterWithDynamicAdjustment.sol b/contracts/sponsorship/SponsorshipPaymasterWithDynamicAdjustment.sol index ce689cd..906e9d2 100644 --- a/contracts/sponsorship/SponsorshipPaymasterWithDynamicAdjustment.sol +++ b/contracts/sponsorship/SponsorshipPaymasterWithDynamicAdjustment.sol @@ -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( @@ -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; @@ -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; diff --git a/test/foundry/unit/concrete/TestSponsorshipPaymasterWithDynamicAdjustmentTest.t.sol b/test/foundry/unit/concrete/TestSponsorshipPaymasterWithDynamicAdjustmentTest.t.sol index dc7bf64..cec6c95 100644 --- a/test/foundry/unit/concrete/TestSponsorshipPaymasterWithDynamicAdjustmentTest.t.sol +++ b/test/foundry/unit/concrete/TestSponsorshipPaymasterWithDynamicAdjustmentTest.t.sol @@ -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 ); } @@ -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); }