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-507 Min Penalty Threshold #534

Merged
merged 12 commits into from
Feb 16, 2025
Merged

AA-507 Min Penalty Threshold #534

merged 12 commits into from
Feb 16, 2025

Conversation

shahafn
Copy link
Contributor

@shahafn shahafn commented Feb 10, 2025

No description provided.

uint256 private constant PENALTY_PERCENT = 10;
// Threshold below which no penalty would be charged
uint256 private constant PENALTY_GAS_THRESHOLD = 4e4;
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. don't use exponential notation in solidity code. better 40_000
  2. what is the rationale for this value?

@@ -819,7 +822,7 @@ contract EntryPoint is IEntryPoint, StakeManager, NonceManager, ReentrancyGuardT

function _getUnusedGasPenalty(uint256 gasUsed, uint256 gasLimit) internal pure returns (uint256) {
unchecked {
if (gasLimit <= gasUsed) {
if (gasLimit <= gasUsed || gasLimit - gasUsed <= PENALTY_GAS_THRESHOLD) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Damn solidity, doesn't optimize gasLimit-gasUsed which is done twice...
better add below if (unusedGas<=PENALTY_GAS_THRESHOLD) return 0;
(which is also slightly more readable)

@drortirosh drortirosh merged commit d8b8076 into develop Feb 16, 2025
8 checks passed
@drortirosh drortirosh deleted the penalty-threshold branch February 16, 2025 10:17
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