Skip to content

Commit

Permalink
updated overhead + events + test case
Browse files Browse the repository at this point in the history
  • Loading branch information
livingrockrises committed Dec 11, 2023
1 parent df92aa0 commit ff71663
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 35 deletions.
3 changes: 1 addition & 2 deletions contracts/interfaces/paymasters/ISponsorshipPaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ interface ISponsorshipPaymaster {
);
event PremiumCollected(
address indexed _paymasterId,
uint256 indexed _premium,
uint256 indexed _paymasterDepositDeducted
uint256 indexed _premium
);

/**
Expand Down
11 changes: 3 additions & 8 deletions contracts/sponsorship/SponsorshipPaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ contract SponsorshipPaymaster is
sstore(verifyingSigner.slot, _verifyingSigner)
sstore(feeCollector.slot, _feeCollector)
}
unaccountedEPGasOverhead = 24000;
unaccountedEPGasOverhead = 35500;
fixedPriceMarkup = 1100000; // 10%
}

Expand Down Expand Up @@ -279,14 +279,9 @@ contract SponsorshipPaymaster is
// "collect" premium
paymasterIdBalances[feeCollector] += actualPremium;

/*uint256 excessFunds = costIncludingPremium - actualGasCost;
if (excessFunds > 0) {
// return excess funds to paymaster
paymasterIdBalances[feeCollector] += excessFunds;
}*/

emit GasBalanceDeducted(paymasterId, costIncludingPremium, userOpHash);
emit PremiumCollected(paymasterId, actualPremium, actualGasCost);
// Review if we should emit balToDeduct as well
emit PremiumCollected(paymasterId, actualPremium);
}

/**
Expand Down
34 changes: 9 additions & 25 deletions test/sponsorship-paymaster/biconomy-sponsorship-paymaster-specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe("EntryPoint with VerifyingPaymaster Singleton", function () {

await sponsorshipPaymaster
.connect(deployer)
.setUnaccountedEPGasOverhead(24000);
.setUnaccountedEPGasOverhead(35500);

await sponsorshipPaymaster.depositFor(fundingId, {
value: ethers.utils.parseEther("1"),
Expand Down Expand Up @@ -244,25 +244,17 @@ describe("EntryPoint with VerifyingPaymaster Singleton", function () {

const chargedFromDappIncludingPremium = BigNumber.from(
receipt.logs[1].topics[2]
).toString();
);
console.log(
"chargedFromDappIncludingPremium ",
chargedFromDappIncludingPremium
chargedFromDappIncludingPremium.toString()
);

const premiumCollected = BigNumber.from(
receipt.logs[2].topics[2]
).toString();
console.log("premiumCollected ", premiumCollected);

const paymasterDepositCollectedByEP = BigNumber.from(
receipt.logs[2].topics[3]
).toString();
console.log(
"paymasterDepositCollectedByEP ",
paymasterDepositCollectedByEP
);

const bundlerPaid = receipt.effectiveGasPrice.mul(receipt.gasUsed);
console.log("bundler paid ", bundlerPaid.toString());

Expand All @@ -279,20 +271,12 @@ describe("EntryPoint with VerifyingPaymaster Singleton", function () {
const paymasterFundsDiff = paymasterFundsBefore.sub(paymasterFundsAfter);
console.log("paymasterFundsDiff ", paymasterFundsDiff.toString());

// Review
// 10/11 actual gas used
/* const paymasterIdBalanceDiffWithoutPremium = paymasterIdBalanceDiff
.mul(BigNumber.from(10))
.div(BigNumber.from(11));
console.log(
"paymasterIdBalanceDiffWithoutPremium ",
paymasterIdBalanceDiffWithoutPremium.toString()
); */

expect(paymasterIdBalanceDiff.sub(paymasterFundsDiff)).to.be.greaterThan(
BigNumber.from(0)
);
// paymasterIdBalanceDiffWithoutPremium should be greater than paymaster funds diff (that means unaccounted overhead is right)
expect(
chargedFromDappIncludingPremium
.sub(premiumCollected)
.sub(paymasterFundsDiff)
).to.be.greaterThan(BigNumber.from(0));

await expect(
entryPoint.handleOps([userOp], await offchainSigner.getAddress())
Expand Down

0 comments on commit ff71663

Please sign in to comment.