-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from coinbase/wilson/reputation-fix
Guard against concurrent withdraws causing unexpected reverts
- Loading branch information
Showing
11 changed files
with
159 additions
and
60 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,38 @@ | ||
PostOpTest:test_RevertsIfPostOpFailed(uint256,uint256,uint256) (runs: 256, μ: 94981, ~: 97095) | ||
GetHashTest:test_returnsValidHash() (gas: 46531) | ||
IsValidWithdrawalSignature:test_returnsFalseWithInvalidSignature() (gas: 53845) | ||
IsValidWithdrawalSignature:test_returnsTrueWithValidSignature() (gas: 51016) | ||
OwnerWithdrawTest:test_revertsIfNotOwner() (gas: 15305) | ||
OwnerWithdrawTest:test_transfersERC20Successfully(uint256) (runs: 256, μ: 97271, ~: 99711) | ||
OwnerWithdrawTest:test_transfersETHSuccessfully(uint256) (runs: 256, μ: 51418, ~: 53415) | ||
PostOpTest:test_RevertsIfPostOpFailed(uint256,uint256,uint256) (runs: 256, μ: 97259, ~: 99371) | ||
PostOpTest:test_entryPointAddStake(uint112,uint32) (runs: 256, μ: 56233, ~: 56233) | ||
PostOpTest:test_entryPointDeposit(uint112) (runs: 256, μ: 32331, ~: 32962) | ||
PostOpTest:test_entryPointUnlockStake() (gas: 54910) | ||
PostOpTest:test_entryPointWithdraw(uint112) (runs: 256, μ: 63500, ~: 65300) | ||
PostOpTest:test_entryPointWithdrawStake() (gas: 71825) | ||
PostOpTest:test_paymasterPaysForOp() (gas: 208402) | ||
PostOpTest:test_transfersExcess(uint256,uint256,uint256,uint256) (runs: 256, μ: 110216, ~: 111227) | ||
PostOpTest:test_entryPointDeposit(uint112) (runs: 256, μ: 32479, ~: 32962) | ||
PostOpTest:test_entryPointUnlockStake() (gas: 54888) | ||
PostOpTest:test_entryPointWithdraw(uint112) (runs: 256, μ: 63050, ~: 65300) | ||
PostOpTest:test_entryPointWithdrawStake() (gas: 71803) | ||
PostOpTest:test_paymasterPaysForOp() (gas: 210663) | ||
PostOpTest:test_transfersExcess(uint256,uint256,uint256,uint256) (runs: 256, μ: 112442, ~: 113477) | ||
SetMaxWithdrawDenominator:test_emitsCorrectly(uint256) (runs: 256, μ: 19851, ~: 20191) | ||
SetMaxWithdrawDenominator:test_reverts_whenNotCalledByOwner() (gas: 12257) | ||
SetMaxWithdrawDenominator:test_setsMaxWithdrawPercent(uint256) (runs: 256, μ: 19209, ~: 19549) | ||
Simulate:test() (gas: 12114) | ||
ValidatePaymasterUserOpTest:test_emitsCorrectly(address,uint256,uint256) (runs: 256, μ: 102564, ~: 103835) | ||
ValidatePaymasterUserOpTest:test_recordsNonceUsed(uint256) (runs: 256, μ: 109936, ~: 111025) | ||
ValidatePaymasterUserOpTest:test_returns1sIfWrongSignature() (gas: 94076) | ||
ValidatePaymasterUserOpTest:test_returnsCorrectly() (gas: 88920) | ||
ValidatePaymasterUserOpTest:test_emitsCorrectly(address,uint256,uint256) (runs: 256, μ: 104847, ~: 106080) | ||
ValidatePaymasterUserOpTest:test_recordsNonceUsed(uint256) (runs: 256, μ: 112158, ~: 113247) | ||
ValidatePaymasterUserOpTest:test_returns1sIfWrongSignature() (gas: 96298) | ||
ValidatePaymasterUserOpTest:test_returnsCorrectly() (gas: 91185) | ||
ValidatePaymasterUserOpTest:test_revertsIfMaxCostMoreThanRequested() (gas: 39141) | ||
ValidatePaymasterUserOpTest:test_revertsIfNonceUsed() (gas: 101280) | ||
ValidatePaymasterUserOpTest:test_revertsIfWithdrawAssetNotZero() (gas: 55974) | ||
ValidatePaymasterUserOpTest:test_revertsIfNonceUsed() (gas: 103502) | ||
ValidatePaymasterUserOpTest:test_revertsIfWithdrawAssetNotZero() (gas: 55952) | ||
ValidatePaymasterUserOpTest:test_reverts_whenWithdrawExceedsMaxAllowed(uint256,uint256,uint256) (runs: 256, μ: 100806, ~: 100992) | ||
ValidateTest:test_receive() (gas: 14687) | ||
WithdrawGasExcess:test_RevertsIfNoExcess(uint256) (runs: 256, μ: 68914, ~: 69177) | ||
WithdrawGasExcess:test_transferExcess(uint256,uint256,uint256) (runs: 256, μ: 102074, ~: 102074) | ||
WithdrawTest:test_emitsCorrectly(address,uint256,uint256) (runs: 256, μ: 115868, ~: 119073) | ||
WithdrawTest:test_emitsCorrectlyERC20Withdraw(address,uint256,uint256) (runs: 256, μ: 158052, ~: 160513) | ||
WithdrawTest:test_recordsNonceUsed(uint256) (runs: 256, μ: 109078, ~: 110167) | ||
WithdrawTest:test_revertsIfExpired(uint48,uint256) (runs: 256, μ: 59403, ~: 59535) | ||
WithdrawTest:test_revertsIfNonceUsed() (gas: 93506) | ||
WithdrawTest:test_revertsIfWrongSignature() (gas: 61536) | ||
WithdrawTest:test_transfersERC20Successfully(uint256) (runs: 256, μ: 136385, ~: 138825) | ||
WithdrawTest:test_transfersETHSuccessfully(uint256) (runs: 256, μ: 89398, ~: 91395) | ||
WithdrawGasExcess:test_RevertsIfNoExcess(uint256) (runs: 256, μ: 71133, ~: 71396) | ||
WithdrawGasExcess:test_transferExcess(uint256,uint256,uint256) (runs: 256, μ: 104290, ~: 104290) | ||
WithdrawTest:test_emitsCorrectly(address,uint256,uint256) (runs: 256, μ: 118270, ~: 121368) | ||
WithdrawTest:test_emitsCorrectlyERC20Withdraw(address,uint256,uint256) (runs: 256, μ: 162427, ~: 164773) | ||
WithdrawTest:test_recordsNonceUsed(uint256) (runs: 256, μ: 111372, ~: 112461) | ||
WithdrawTest:test_revertsIfExpired(uint48,uint256) (runs: 256, μ: 61664, ~: 61785) | ||
WithdrawTest:test_revertsIfNonceUsed() (gas: 95844) | ||
WithdrawTest:test_revertsIfWrongSignature() (gas: 63830) | ||
WithdrawTest:test_reverts_whenWithdrawExceedsMaxAllowed(uint256,uint256,uint256) (runs: 256, μ: 85119, ~: 85096) | ||
WithdrawTest:test_transfersERC20Successfully(uint256) (runs: 256, μ: 140626, ~: 143066) | ||
WithdrawTest:test_transfersETHSuccessfully(uint256) (runs: 256, μ: 91692, ~: 93689) |
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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
import "./MagicSpend.t.sol"; | ||
import {Ownable} from "./MagicSpend.t.sol"; | ||
|
||
contract SetMaxWithdrawDenominator is MagicSpendTest { | ||
function test_reverts_whenNotCalledByOwner() public { | ||
vm.prank(makeAddr("fake")); | ||
vm.expectRevert(Ownable.Unauthorized.selector); | ||
magic.setMaxWithdrawDenominator(20); | ||
} | ||
|
||
function test_setsMaxWithdrawPercent(uint256 newDenominator) public { | ||
vm.prank(owner); | ||
magic.setMaxWithdrawDenominator(newDenominator); | ||
assertEq(magic.maxWithdrawDenominator(), newDenominator); | ||
} | ||
|
||
function test_emitsCorrectly(uint256 newDenominator) public { | ||
vm.expectEmit(false, false, false, true); | ||
emit MagicSpend.MaxWithdrawDenominatorSet(newDenominator); | ||
vm.prank(owner); | ||
magic.setMaxWithdrawDenominator(newDenominator); | ||
} | ||
} |
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