-
Notifications
You must be signed in to change notification settings - Fork 226
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
Conversation
d091c26
to
1dddf61
Compare
/** | ||
* clear deposits after some known change on-chain | ||
*/ | ||
clearCache (): void { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 () => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated. will separate.
packages/utils/src/Utils.ts
Outdated
@@ -33,7 +33,7 @@ export enum ValidationErrors { | |||
SimulatePaymasterValidation = -32501, | |||
OpcodeValidation = -32502, | |||
NotInTimeRange = -32503, | |||
Reputation = -32504, | |||
BannedOrThrottledPaymaster = -32504, |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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..)
submitting a new UserOp into the mempool should revert if its deposit is not high enough.