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

L04 inconsistent minimum stake delay #59

Merged
merged 3 commits into from Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions contracts/EntryPoint.sol
Expand Up @@ -40,6 +40,9 @@ contract EntryPoint is StakeManager {
* @param _unstakeDelaySec - minimum time (in seconds) a paymaster stake must be locked
*/
constructor(address _create2factory, uint _paymasterStake, uint32 _unstakeDelaySec) StakeManager(_unstakeDelaySec) {
require(_unstakeDelaySec > 0);
require(_create2factory != address(0));

create2factory = _create2factory;
paymasterStake = _paymasterStake;
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/StakeManager.sol
Expand Up @@ -84,6 +84,7 @@ contract StakeManager {
*/
function addStake(uint32 _unstakeDelaySec) public payable {
DepositInfo storage info = deposits[msg.sender];
require(_unstakeDelaySec >= unstakeDelaySec, "unstake delay too low");
require(_unstakeDelaySec >= info.unstakeDelaySec, "cannot decrease unstake time");
uint112 amount = info.amount + uint112(msg.value);
deposits[msg.sender] = DepositInfo(
Expand Down Expand Up @@ -126,7 +127,6 @@ contract StakeManager {
info.amount - uint112(withdrawAmount),
0,
0);

emit Withdrawn(msg.sender, withdrawAddress, withdrawAmount);
(bool success,) = withdrawAddress.call{value : withdrawAmount}("");
require(success, "failed to withdraw");
Expand Down
18 changes: 9 additions & 9 deletions reports/gas-used-output.txt
Expand Up @@ -7,23 +7,23 @@
·······················|······················|·············|·············|·············|···············|··············
| DepositPaymaster · addDepositFor · 71514 · 88554 · 77194 · 3 · - │
·······················|······················|·············|·············|·············|···············|··············
| DepositPaymaster · addStake · - · - · 61142 · 1 · - │
| DepositPaymaster · addStake · - · - · 61183 · 1 · - │
·······················|······················|·············|·············|·············|···············|··············
| DepositPaymaster · addToken · - · - · 46830 · 1 · - │
·······················|······················|·············|·············|·············|···············|··············
| EntryPoint · addStake · 29027 · 46127 · 34727 · 3 · - │
| EntryPoint · addStake · 29068 · 46168 · 34768 · 3 · - │
·······················|······················|·············|·············|·············|···············|··············
| EntryPoint · handleOp · 106927 · 174459 · 129739 · 6 · - │
| EntryPoint · handleOp · 106947 · 174427 · 129749 · 6 · - │
·······················|······················|·············|·············|·············|···············|··············
| EntryPoint · handleOps · 98181 · 1188795 · 512256 · 21 · - │
| EntryPoint · handleOps · 98193 · 1188763 · 512253 · 21 · - │
·······················|······················|·············|·············|·············|···············|··············
| EntryPoint · simulateValidation · - · - · 1002725 · 1 · - │
| EntryPoint · simulateValidation · - · - · 1002713 · 1 · - │
·······················|······················|·············|·············|·············|···············|··············
| EntryPoint · unstakeDeposit · - · - · 28469 · 1 · - │
·······················|······················|·············|·············|·············|···············|··············
| EntryPoint · withdrawTo · 59304 · 64205 · 61755 · 2 · - │
·······················|······················|·············|·············|·············|···············|··············
| TokenPaymaster · addStake · - · - · 61142 · 1 · - │
| TokenPaymaster · addStake · - · - · 61183 · 1 · - │
·······················|······················|·············|·············|·············|···············|··············
| TokenPaymaster · approve · - · - · 46551 · 1 · - │
·······················|······················|·············|·············|·············|···············|··············
Expand All @@ -35,19 +35,19 @@
·······················|······················|·············|·············|·············|···············|··············
| TokenPaymaster · withdrawTo · - · - · 67004 · 1 · - │
·······················|······················|·············|·············|·············|···············|··············
| VerifyingPaymaster · addStake · - · - · 61119 · 1 · - │
| VerifyingPaymaster · addStake · - · - · 61160 · 1 · - │
·······················|······················|·············|·············|·············|···············|··············
| Deployments · · % of limit · │
··············································|·············|·············|·············|···············|··············
| DepositPaymaster · - · - · 1328186 · 4.4 % · - │
··············································|·············|·············|·············|···············|··············
| TestCounter · - · - · 191371 · 0.6 % · - │
··············································|·············|·············|·············|···············|··············
| TestOracle · - · - · 100245 · 0.3 % · - │
| TestOracle · - · - · 100257 · 0.3 % · - │
··············································|·············|·············|·············|···············|··············
| TestUtil · - · - · 283509 · 0.9 % · - │
··············································|·············|·············|·············|···············|··············
| TokenPaymaster · - · - · 1577602 · 5.3 % · - │
| TokenPaymaster · - · - · 1577578 · 5.3 % · - │
··············································|·············|·············|·············|···············|··············
| VerifyingPaymaster · - · - · 1020071 · 3.4 % · - │
·---------------------------------------------|-------------|-------------|-------------|---------------|-------------·
2 changes: 1 addition & 1 deletion test/deposit-paymaster.test.ts
Expand Up @@ -31,7 +31,7 @@ describe("DepositPaymaster", async () => {
let paymaster: DepositPaymaster
before(async function () {

entryPoint = await deployEntryPoint(0, 0)
entryPoint = await deployEntryPoint(1, 1)
entryPointStatic = entryPoint.connect(AddressZero)

paymaster = await new DepositPaymaster__factory(ethersSigner).deploy(entryPoint.address)
Expand Down
2 changes: 1 addition & 1 deletion test/verifying_paymaster.test.ts
Expand Up @@ -29,7 +29,7 @@ describe("EntryPoint with VerifyingPaymaster", function () {
let paymaster: VerifyingPaymaster
before(async function () {

entryPoint = await deployEntryPoint(0, 0)
entryPoint = await deployEntryPoint(1, 1)
entryPointStatic = entryPoint.connect(AddressZero)

offchainSigner = createWalletOwner()
Expand Down
2 changes: 1 addition & 1 deletion test/z-batch.test.ts
Expand Up @@ -51,7 +51,7 @@ describe("Batch gas testing", function () {

await checkForGeth()
testUtil = await new TestUtil__factory(ethersSigner).deploy()
entryPoint = await deployEntryPoint(0, 0)
entryPoint = await deployEntryPoint(1, 1)
//static call must come from address zero, to validate it can only be called off-chain.
entryPointView = entryPoint.connect(ethers.provider.getSigner(AddressZero))
walletOwner = createWalletOwner()
Expand Down