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

AA-184: Remove second postOp retry #311

Merged
merged 30 commits into from
Oct 22, 2023
Merged

Conversation

forshtat
Copy link
Collaborator

No description provided.

@leekt
Copy link
Contributor

leekt commented Jun 28, 2023

@yoavw
Copy link
Contributor

yoavw commented Jul 1, 2023

if postOp retry is getting removed, shouldn't this be lowered to 2 instead of 3? https://github.com/eth-infinitism/account-abstraction/blob/033b4be2a606defd5cd5226bdde3afcea21db5fa/contracts/core/EntryPoint.sol#L329C11-L329C11

I think so. @drortirosh @forshtat any reason not to?

@hazim-j
Copy link

hazim-j commented Jul 2, 2023

What's the rationale behind removing postOp retry? Wouldn't this prevent paymasters from protecting their reputation incase something like a transfer doesn't work out?

@drortirosh
Copy link
Contributor

Wouldn't this prevent paymasters from protecting their reputation incase something like a transfer doesn't work out?
removing the 2nd postOp means a paymaster can't revert entire bundle: it can revert the user's action (though he still pays for the execution's revert including the paymaster's revert)
This way, it actually protects its reputation...

The invariant we add is that passing all validation means transaction will always get paid for.

@drortirosh
Copy link
Contributor

The change in the paymaster's code is in cases where it wants to perform different action upon reverting the user's execution.
Say a paymaster want to count the times it reverts user's code. In current model, it would revet in 1st postOp, and increment the counter in the 2nd postOp.

In the suggested new model, it will increment the counter in the validatePaymasterUserOp, and decrement it in the postOp.
While the flow looks a little strage, the outcome is the same in reverting and non-reverting flows.

The only thing that we know of that can be done in the two-postOp mode and can't be with the new model is emitting an event in the 2nd postOp. We argue that this is not that useful, and any app that want a log to track reverts can use UserOperationEvent instead.

@yoavw
Copy link
Contributor

yoavw commented Aug 3, 2023

What's the rationale behind removing postOp retry? Wouldn't this prevent paymasters from protecting their reputation incase something like a transfer doesn't work out?

This mechanism was needed when validatePaymasterUserOp was a view function, and the paymaster couldn't do its own bookkeeping during validation. E.g. a TokenPaymaster couldn't use the precharge+refund model and had to charge in postOp.

With "view" being removed (long ago), paymasters can defend themselves during validation. A TokenPaymaster can precharge the max cost and then refund the unused part in postOp. A paymaster that wants to verify that the transaction performed some action and ban the user otherwise, could raise the "ban" flag for the user during validation and then reset it in postOp (or revert there, which leaves the user in a banned state. Any logic could be handled similarly.

As for protecting the paymaster's reputation, postOp becomes irrelevant for reputation purposes since it can never revert the bundle anymore. The bundler doesn't care if postOp reverts because it only reverts the UserOp, and the paymaster still pays for it. Therefore such reverts don't affect the paymaster's reputation anymore.

Base automatically changed from next_v0.7 to tmpdev August 15, 2023 11:44
Base automatically changed from tmpdev to develop August 15, 2023 12:07
@forshtat forshtat changed the title Remove second postOp retry AA-184: Remove second postOp retry Sep 3, 2023
Copy link
Contributor

@drortirosh drortirosh left a comment

Choose a reason for hiding this comment

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

missing fix for the code that calls postOp with postOpReverted (in executeUserOp

@forshtat
Copy link
Collaborator Author

missing fix for the code that calls postOp with postOpReverted (in executeUserOp

@drortirosh please elaborate what specifically do you think requires fixing?

shahafn
shahafn previously approved these changes Oct 22, 2023
@shahafn shahafn self-requested a review October 22, 2023 12:39
@shahafn shahafn dismissed their stale review October 22, 2023 12:39

Still checking postOpReverted mode

@@ -664,20 +664,6 @@ contract EntryPoint is IEntryPoint, StakeManager, NonceManager, ReentrancyGuard,
IPaymaster(paymaster).postOp{
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we still need mode here?

@@ -163,11 +162,6 @@ contract TokenPaymaster is BasePaymaster, UniswapHelper, OracleHelper {
address userOpSender
) = abi.decode(context, (uint256, uint256, uint256, address));
uint256 gasPrice = getGasPrice(maxFeePerGas, maxPriorityFeePerGas);
if (mode == PostOpMode.postOpReverted) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe change _handlePostOp() to _postExecution()? It's no longer handling post op only

@@ -664,20 +664,6 @@ contract EntryPoint is IEntryPoint, StakeManager, NonceManager, ReentrancyGuard,
IPaymaster(paymaster).postOp{
Copy link
Contributor

Choose a reason for hiding this comment

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

in case the PostOp reverts, the "outer" postExecution will report the error (success=false), but there is no indication that it was a paymaster (postOp) that reverted, instead of user-code that reverted.
I suggest emit PostOpRevertReason to report it.
(technically, it is not here, but at the "catch" of the innerHandleOp)

@forshtat forshtat merged commit 8215b88 into develop Oct 22, 2023
8 checks passed
@forshtat forshtat deleted the remove_second_postop_retry branch October 22, 2023 14:29
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.

7 participants