-
Notifications
You must be signed in to change notification settings - Fork 670
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-217: Charge a penalty payment for unused execution gas limit of a UserOp #356
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
ebbf21a
Makes comments and formatting consistent
gigamesh 64cbdf6
@inheritdoc IEntryPoint
gigamesh d43bc94
Reverts contracts/test/TestHelpers.sol
gigamesh 105d122
fix: entrypoint does not revert even first postOp reverts with short …
leekt 3a6b0a5
lint
leekt 66688cb
gas-report
leekt b56ef7b
Merge branch 'next_v0.7' into gigamesh/comments
forshtat 74ed53b
Update IEntryPoint.sol - add missing 'INonceManager'
forshtat 649daf8
Update EntryPoint.sol - fix lint errors
forshtat aa20d5d
Update gas-checker.txt manually
forshtat e3111fe
Update gas-checker.txt - add newline for the 'diff'
forshtat 10f0502
Merge pull request #235 from gigamesh/gigamesh/comments
forshtat 6a5ce09
Merge branch 'next_v0.7' into develop
forshtat 8116f81
Update gas-checker.txt manually
forshtat 74a3c37
Merge pull request #293 from leekt/develop
forshtat f96de6c
Remove "postOp" retry call mode and adjust tests
forshtat 4b76a32
Update gas-calc
forshtat 8903ae1
Update gas-checker.txt
forshtat ce519f6
Merge branch 'develop' of github.com:eth-infinitism/account-abstracti…
forshtat 9bd5263
Bump 'yarn.lock' versions
forshtat a218f79
Bump node version for Github Actions
forshtat 318a7ac
Weird
forshtat 0f24290
Disable new solhint rules
forshtat 83cb4e2
Uncomment TestCounter deployment
forshtat 53eda99
Fix
forshtat ba64217
Fix gas checks
forshtat 30d24ac
Use up to two times 'verificationGasLimit' in the 'requiredGas' calcu…
forshtat b6a2a64
AA-217: Charge a penalty payment for unused execution gas limit of a …
forshtat c3e808d
Add test for unused gas limit penalty charge
forshtat 60a0a1c
Fix
forshtat 821f758
Merge branch 'develop' into AA-217-payment-for-unused-gas
forshtat e2809a7
Use gas estimation instead of a hardcoded value
forshtat 6762541
Fix gas calc
forshtat cb4e7ca
wtf
forshtat 710f9e9
AA-217: Add the unused gas penalty description to the EIP text (#361)
forshtat a35c3c3
better estimation gas calculation
drortirosh d3f1ede
fix warmup.
drortirosh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -543,6 +543,64 @@ describe('EntryPoint', function () { | |
expect(await getBalance(account.address)).to.eq(inititalAccountBalance) | ||
}) | ||
|
||
it('account should pay a penalty for requiring too much gas and leaving it unused', async function () { | ||
if (process.env.COVERAGE != null) { | ||
return | ||
} | ||
const iterations = 10 | ||
const count = await counter.populateTransaction.gasWaster(iterations, '') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that a good estimate to the callGasUsed is |
||
const accountExec = await account.populateTransaction.execute(counter.address, 0, count.data!) | ||
const callGasLimit = await ethersSigner.provider.estimateGas({ | ||
from: entryPoint.address, | ||
to: account.address, | ||
data: accountExec.data | ||
}) | ||
// expect(callGasLimit.toNumber()).to.be.closeTo(270000, 10000) | ||
const beneficiaryAddress = createAddress() | ||
|
||
// "warmup" userop, for better gas calculation, below | ||
await entryPoint.handleOps([await fillAndSign({ sender: account.address, callData: accountExec.data }, accountOwner, entryPoint)], beneficiaryAddress) | ||
await entryPoint.handleOps([await fillAndSign({ sender: account.address, callData: accountExec.data }, accountOwner, entryPoint)], beneficiaryAddress) | ||
|
||
const op1 = await fillAndSign({ | ||
sender: account.address, | ||
callData: accountExec.data, | ||
verificationGasLimit: 1e5, | ||
callGasLimit: callGasLimit | ||
}, accountOwner, entryPoint) | ||
|
||
const rcpt1 = await entryPoint.handleOps([op1], beneficiaryAddress, { | ||
maxFeePerGas: 1e9, | ||
gasLimit: 20000000 | ||
}).then(async t => await t.wait()) | ||
const logs1 = await entryPoint.queryFilter(entryPoint.filters.UserOperationEvent(), rcpt1.blockHash) | ||
expect(logs1[0].args.success).to.be.true | ||
|
||
const gasUsed1 = logs1[0].args.actualGasUsed.toNumber() | ||
const veryBigCallGasLimit = 10000000 | ||
const op2 = await fillAndSign({ | ||
sender: account.address, | ||
callData: accountExec.data, | ||
verificationGasLimit: 1e5, | ||
callGasLimit: veryBigCallGasLimit | ||
}, accountOwner, entryPoint) | ||
const rcpt2 = await entryPoint.handleOps([op2], beneficiaryAddress, { | ||
maxFeePerGas: 1e9, | ||
gasLimit: 20000000 | ||
}).then(async t => await t.wait()) | ||
const logs2 = await entryPoint.queryFilter(entryPoint.filters.UserOperationEvent(), rcpt2.blockHash) | ||
|
||
const gasUsed2 = logs2[0].args.actualGasUsed.toNumber() | ||
|
||
// we cannot access internal transaction state, so we have to rely on two separate transactions for estimation | ||
// assuming 10% penalty is charged | ||
const expectedGasPenalty = (veryBigCallGasLimit - callGasLimit.toNumber()) * 0.1 | ||
const actualGasPenalty = gasUsed2 - gasUsed1 | ||
|
||
console.log(actualGasPenalty / expectedGasPenalty) | ||
expect(actualGasPenalty).to.be.closeTo(expectedGasPenalty, expectedGasPenalty * 0.001) | ||
}) | ||
|
||
it('legacy mode (maxPriorityFee==maxFeePerGas) should not use "basefee" opcode', async function () { | ||
const op = await fillAndSign({ | ||
sender: account.address, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as resolved.
Sorry, something went wrong.