Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EREP-010: paymaster should have deposit to cover all userops #194

Merged
merged 5 commits into from
May 22, 2024

Conversation

drortirosh
Copy link
Contributor

submitting a new UserOp into the mempool should revert if its deposit is not high enough.

@drortirosh drortirosh force-pushed the erep-10-paymaster-deposit branch from d091c26 to 1dddf61 Compare May 19, 2024 12:56
/**
* clear deposits after some known change on-chain
*/
clearCache (): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a bad idea to have the cache stored in DepositManager but trigger the clearing of the cache from the EventsManager. I suggest you keep the entire logic of the cache inside this class, i.e. let the getCachedDeposit() function do the clearCache once every X blocks or whatever.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the DepositManager manages the deposits. the simplest impl is to read from the blockchain everytime.
Instead, I wanted some optimization, and cache it until there is a network change - which is always signaled by a message.

if (userOp.paymaster != null) {
this.incrementEntryCount(userOp.paymaster)
}
this.incrementEntryCount(userOp.sender)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why move the incrementEntryCount(sender) to be below incrementEntryCount(paymaster)? Seems like an unnecessary change to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't increment before you solved all cases where it can crash (otherwise, you need to catch to undo increments)

@@ -331,7 +331,7 @@ describe('#ValidationManager', () => {
await testExistingUserOp('balance-self', undefined)
})

it('should fail with unstaked paymaster returning context', async () => {
it('should accept unstaked paymaster returning context', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change supposed to be included in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated. will separate.

@@ -33,7 +33,7 @@ export enum ValidationErrors {
SimulatePaymasterValidation = -32501,
OpcodeValidation = -32502,
NotInTimeRange = -32503,
Reputation = -32504,
BannedOrThrottledPaymaster = -32504,
Copy link
Contributor

@forshtat forshtat May 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this error is also returned for the "underfunded" paymaster, meaning there are now THREE separate issues that can cause this same ErrorID.
I would rather split these into THREE DIFFERENT error codes.

* the cost is the sum of the verification gas limits, multiplied by the maxFeePerGas.
* @param userOp
*/
export function getUserOpMaxCost (userOp: UserOperation): number {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like Go code. Shouldn't we make UserOperation a class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, should pack all userop related utils (resemble UserOperationLib in solidity - but we don't have "using" in TS..)

@drortirosh drortirosh merged commit 2c4684f into main May 22, 2024
4 checks passed
@drortirosh drortirosh deleted the erep-10-paymaster-deposit branch May 22, 2024 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants