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

fix: EREP-015 rule Paymaster opsSeen decrement #905

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

shunsukew
Copy link
Contributor

[Closes/Fixes] #904

Proposed Changes

  • Paymaster opsSeen decrement when 2nd validation of User Operation fails due to factory or account revert, as defined in ERC4337.

@shunsukew shunsukew changed the title [WIP] Fix EREP-015 rule Paymaster opsSeen decrement Fix: EREP-015 rule Paymaster opsSeen decrement Nov 5, 2024
@shunsukew shunsukew marked this pull request as ready for review November 5, 2024 22:20
..
}) => {
// [EREP-015] If user operations error derived from factory or account, paymaster opsSeen amendment is required.
let re = Regex::new(r"^AA[21]").unwrap();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of bringing in regex, can we keep the same pattern that we use above? Something like

paymaster_amendment_required |= matches!(&message[..3], "AA1" | "AA2")

@shunsukew shunsukew changed the title Fix: EREP-015 rule Paymaster opsSeen decrement fix: EREP-015 rule Paymaster opsSeen decrement Nov 5, 2024
Copy link
Collaborator

@dancoombs dancoombs left a comment

Choose a reason for hiding this comment

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

Great work! Thank you for the contribution. A few small comments and would love if you could add a unit test for this condition.

..
}) => {
// [EREP-015] If user operations error derived from factory or account, paymaster opsSeen amendment is required.
let re = Regex::new(r"^AA[21]").unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of bringing in regex, can we keep the same pattern that we use above? Something like

paymaster_amendment_required |= matches!(&message[..3], "AA1" | "AA2")

Comment on lines +1552 to +1558
if !entity.is_paymaster() {
warn!(
"Attempted to add EREP-015 paymaster amendment for non-paymaster entity: {:?}",
entity
);
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should use an assert! instead of a log here as this indicates a coding error.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if !entity.is_paymaster() {
warn!(
"Attempted to add EREP-015 paymaster amendment for non-paymaster entity: {:?}",
entity
);
return;
}
assert!(entity.is_paymaster(), "Attempted to add EREP-015 paymaster amendment for non-paymaster entity")

update_type: EntityUpdateType::PaymasterAmendment,
},
);
}
}

#[cfg(test)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a test for this case?

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