230 Commits

Author SHA1 Message Date
Dror Tirosh
11cb5aaac3 AA-67 relax storage rules in opcode banning (#121)
allow a wallet to access wallet-specific storage in other contracts (based on its own address)
2022-11-16 03:38:30 +02:00
Dror Tirosh
4c0b1eeff4 AA-63 remove paymaster stake value from EntryPoint (#119)
- stake-value and unstake delay are not managed by entryPoint.
- `simulateValidation()` does return them (in its `SimulationResult`, so that the bundler can validate the paymaster stake is valid (and reject the UserOp if not)
- stake values for a signature aggregator are also returned (in SimulationResultWithAggregation`, ) if the wallet uses an aggregator.
2022-11-16 01:07:31 +02:00
Dror Tirosh
403f682854 AA-51: simpler simulation api, including aggregation
- simulateValidation() always reverts - successful result is error `SimulationResult`
- (no need to call from address(0), but always need to catch revert reason)
- returns also aggregator address, and never calls it.
- bundler should either reject UserOP or validate the signature using `aggregator.validateUserOpSignature()` (or an equivalent native library code)
2022-11-15 16:54:07 +02:00
Andrew Wahid
4661b0939d fix deposit withdrawal (#122)
Fix a vulnerability where any withdrawn deposits are not actually reflected in the deposit info storage.
The vulnerability allows any wallet or paymaster to withdraw all funds deposited in an Entrypoint contract.
2022-11-13 14:19:52 +02:00
Dror Tirosh
79e383653d compile EntryPoint using viaIR compilation path (#125)
There is no need to compile the entire project (as it is far slower)
saves ~1200gas per op.
2022-11-03 16:34:31 +02:00
Dror Tirosh
573ec0f909 AA-62 getSenderAddress after creation (#120)
* SimpleWalletDeployer: return address even for an existing wallet.
2022-10-31 16:08:36 +02:00
Dror Tirosh
46d1310191 AA-60 validate timestamp (#117)
`validateUserOp()`, `validatePaymaterUserOp()` may return the "deadline" time this operation is valid.
They may not use the block. timestamp opcode, but the EntryPoint does validate the return value.
bundlers may also use this value (returned also from `simulateValidation()`) to drop UserOps that are "just about" to expire.
2022-10-31 16:04:10 +02:00
Derek Chiang
c5565b3356 Clarify wallet factory behavior when the wallet already exists (#118)
Currently, when a wallet already exists, it's not clear if `entryPoint.getSenderAddress()` will revert or not, since that depends on the internal logic of the wallet factory.  I'm updating the spec to clarify that the wallet factory should try to return the address if the wallet already exists, since that's more friendly to clients who don't want to keep track of deployed wallet addresses.
2022-10-24 18:52:19 +03:00
soham
347cfd99a7 Allow _validateSignature to be non-view (#114)
* Allow _validateSignature to be non-view
2022-10-23 21:38:49 +03:00
Yoav Weiss
699ecca177 No calls to codeless addresses
Mitigation suggested by @Agusx1211
2022-09-28 16:24:46 -07:00
Dror Tirosh
5b7130c264 internal audit fixes (#113)
- initCode to be used through CreateSender
- EIP wording.
2022-09-22 21:06:52 +03:00
Dror Tirosh
bd64f3c109 update npm package (#110)
* update npm package

solidity:
```
import "@account-abstraction/contracts/core/BaseWallet.sol";
import "@account-abstraction/contracts/interfaces/IPaymaster.sol";
```

typescript:
```
import { IEntryPoint, UserOperationStruct } from "@account-abstraction/contracts"
```

ABI:
```
import { abi as entryPointAbi }
   from '@account-abstraction/contracts/artifacts/IEntryPoint.json'
```
2022-09-05 12:46:37 +03:00
zhangshengjie
8083c53504 fix link (#111)
https://github.com/opengsn/account-abstraction/tree/main/contcts
is an invalid address, may need to be changed to: 
https://github.com/eth-infinitism/account-abstraction/tree/main/contracts
2022-08-31 17:15:23 +03:00
Dror Tirosh
42b643caab AA-46: rename gas parameters
rename callGas to callGasLimit
rename verificationGas to verificationGasLimit
to reflect the fact these are limits, and the user pays for actual gas used.
Note that "preVerificationGas" is always paid in full.
2022-08-24 01:56:56 +03:00
Dror Tirosh
d45442739a AA-48 extract interfaces (#109)
extract IEntryPoint, IStakeManager
all core interfaces in "interfaces"
all core contracts in "core"
2022-08-24 01:48:30 +03:00
Dror Tirosh
bba11afb0f AA-39 make validatePaymasterUserOp non-view method (#107)
* gas checks
2022-08-24 00:39:06 +02:00
Dror Tirosh
458be8f254 AA-47: paymaster and paymasterData in a single field (paymasterAndData) (#108) 2022-08-24 00:53:27 +03:00
Dror Tirosh
6fbc3cf006 AA-36: Support deterministic mutli-chain addresses (#100)
initCode as deployer+data, instead of constructor code
- supports any deployer contract
- initCode doesn't have to include entire CREATE2 constructor code (it is only a method call to the deployer contract)
2022-08-23 21:09:48 +03:00
Dror Tirosh
0cddeaa720 AA-22: Support aggregated signatures and BLS ref. implementation (#92)
* update the EIP to support aggregated signatures

* support creation of aggregated wallet (simulateValidation)

* simulateValidation with param offChainSigCheck

if false, calls aggregator.validateUserOpSignature
if true, returns also offChainSigInfo to be used by off-chain code to
validate the signature

* hash pubkey into requestId

Vitalik Buterin [01/08/2022 10:40]:
Basically, if one account has a pubkey P, someone can make an evil
account with key Q - P, where they know q (the privkey of Q), and then
they pass off a signature with q as being an "aggregate" signature of
the same message signed by both K1 = P and K2 = Q-P (because K1 + K2 =
Q)

The fix to this is to hash the pubkey into the msghash, so you never get
two different keys signing the same message.
And I think this has to be enforced at the BLS aggregate verifier layer

Co-authored-by: Alex Forshtat <forshtat1@gmail.com>
2022-08-21 15:19:20 +02:00
Dror Tirosh
a7f4a6cafc AA-45 Refactor handle ops (#105)
* refactor handleOps

* remove paymasterMode

use "paymaster!=address(0)"
saves 2 accesses to calldata member, and 460 gas per userOp
(moved the requiredPerfund logic into ep.getPaymentInfo)

* read UserOp static fields into MemoryUserOp

Co-authored-by: Alex Forshtat <forshtat1@gmail.com>
2022-08-20 17:29:54 +02:00
Dror Tirosh
32858c2d71 fix gas-calc (#103) 2022-07-28 19:27:04 +02:00
Dror Tirosh
d1b316012e AA-40: Gaschecks with geth (#102)
* A-32-enforce-checkin-gas-reports
* use geth for local gas checks
* changed "big" to 10 (avoid getting close to 128k tx limit)
2022-07-28 10:04:27 +03:00
Dror Tirosh
925528be5a AA-29: gnosis proxy (#96)
* inital code

import Gnosis code as-is.
probably can remove all non-essential contracts (e.g. test, samples)
or better, import as external library.

* removed unused contracts (not used,fail compilation)

* initial Gnosis-Safe Proxy account

* refactor:

- use @gnosis.pm/safe-contracts package
- separate contracts into separate files.

* cleanup, single owner

* cleanup contracts

simpler fallback handler

* added tests

failure cases
counterfactual creation

* change to "Manager"

- manager is not a module, only fallback, entrypoint
- replaceManager now works

* ignore from coverage

(fails to compile for coverage)

* fix dangling test

* Fix lint

* Set expected code lenght to be 324

Co-authored-by: Alex Forshtat <forshtat1@gmail.com>
2022-07-27 18:40:57 +02:00
Dror Tirosh
e74604e3b7 AA-21: gas usage tests for different batch scenarios (#93)
use with "yarn gas-checker"
currently deploys batches of 1,2,20,21, and display the gas diff
2022-07-24 11:27:36 +03:00
Dror Tirosh
5a711806d3 fix typechain error (#101) 2022-07-23 15:45:40 +02:00
Dror Tirosh
5fd84aa054 AA-25: npm package for contracts (#99)
solidity contracts, json artifacts and typechain files

usage:
yarn install @account-abstraction/contracts

solidity:
```
import "@account-abstraction/contracts/BaseWallet.sol";
```

json
```
artifact =
require('@account-abstraction/contracts/artifacts/EntryPoint.json')
```

js/ts:
```
const {EntryPoint__factory} =
require("@account-abstraction/contracts/typechain/factories/EntryPoint__factory");
...
const entryPoint = EntryPoint__factory.connect(entryPointAddress,
signer)

```
2022-07-11 22:40:20 +02:00
Alex Forshtat
f5fed715b8 AA-30: Add eslint task to the repository (#97)
Co-authored-by: Dror Tirosh <dror@opengsn.org>
2022-07-07 23:23:20 +03:00
Dror Tirosh
e2333dbb86 github actions: env vars (#95)
global env vars:
- transpile-only
- force-colors
2022-07-05 21:58:11 +03:00
Alex Forshtat
67737edd61 Log stuff 2022-04-22 22:29:12 +03:00
Dror Tirosh
dadbafcb09 deployment files on goerli 2022-04-22 21:18:22 +02:00
Dror Tirosh
a2f4b7be4d remove obsolete ECDSA (#89)
we no longer need to modify ECDSA library (GAS opcode is now allowed
(just before CALL) on wallet validation code, so no need to work around it)
2022-04-12 13:16:25 +03:00
Dror Tirosh
074672b6cc typos (#88) 2022-04-12 02:44:06 +03:00
Dror Tirosh
4efa5fc296 fix contract versions
align all to 0.8.12
2022-04-11 20:19:08 +03:00
Dror Tirosh
258527cb51 Add get sender storage (#87)
return the storage cells in the entrypoint the sender is allowed to access during simulation
2022-04-11 20:18:23 +03:00
Dror Tirosh
720390fcd5 [N11] IWallet doesn't strongly enforce required functionality (#82)
introduce BaseWallet, which provides basic wallet functionality to subclasses.
2022-03-31 13:22:48 +03:00
Dror Tirosh
b82c7e029a L11 missing docstrings (#81) 2022-03-30 16:18:25 +03:00
Dror Tirosh
ed175c5ea6 [M02] Separate stake and prepayment (#76)
* [M02] Separate stake and prepayment

seperate "stake" from deposit
- keep separate stake and deposit balances.
- stake is unmodified. paymaster only pays from its deposit.
- paymaster pre-pay for the request, just like the wallet does (and refunded at the end)
2022-03-30 14:03:12 +03:00
shahafn
37051eb421 [N01] Suggested EIP changes (#83)
* eip fixes
* Added missing interfaces and fixed minor errors.
* Explicitly say that op must pay at least the current `block.basefee` to be added to mempool.
* Adding COINBASE to forbidden opcodes
* Removed SELFDESTRUCT limitation.
* depositTo appeared twice. Removed the unneeded one.
* Elaborate the mutable state includes value, and mention that bundle should be first in the block or protected by access-list.
* Forbid value-bearing calls during validation. Thanks tjade273.
* Require all calls during validation to pass max gas.  tjade273 :)
* No OOG reverts in any context during validation.
* Allow GAS+*CALL pattern.

Co-authored-by: Yoav Weiss <yoav+github@hidden.domain.name>
2022-03-30 13:25:13 +03:00
Dror Tirosh
59f6eacd26 [N02] Imprecise gas limits (#86)
clearer definition the guard condition as "all components are<=uint120.max"
fixes #86
2022-03-30 13:23:32 +03:00
Dror Tirosh
34669f32ff [N24] Naming suggestions (#80)
suggested method and param namings.
fixes #36
2022-03-07 18:26:16 +02:00
Dror Tirosh
ebb717f69c [N25] Typographical errors (#79)
fixes #47
2022-03-07 17:59:01 +02:00
Dror Tirosh
d3fd9df7bf [N27] Declare uint as uint256 (#77) 2022-03-07 17:55:54 +02:00
Dror Tirosh
3bf808e6c4 N16 undocumented assembly (#72) 2022-03-07 17:48:47 +02:00
Dror Tirosh
2e77f9dea5 [L03] token paymaster allowance (#75)
When transfering ownership, move the allowance to withdraw funds to the
new owner
2022-03-07 17:44:28 +02:00
Dror Tirosh
3701638dfb N15 inconsistent solidity version (#71) 2022-03-07 17:03:09 +02:00
Dror Tirosh
3f2419aaee [N06] document unset opIndex parameter (#78)
document that opIndex is unused when called from innerHandleOp
fixes #28
2022-03-07 16:15:46 +02:00
Dror Tirosh
103cebf228 [N12] Not all state variables have explicit visibility (#70)
fixes #34
fixes #36 (remove OwnerNonce struct)
2022-03-06 13:15:32 +02:00
Dror Tirosh
56e865047a [N18,19,20] imports, redundant code (#73)
* [N18,19,20] imports, redundant code

fixes #40
fixes #41
fixes #42
2022-03-06 13:09:42 +02:00
Dror Tirosh
1ec95b5a42 [N08] Explicitly identify and name constants (#68) 2022-03-02 22:18:22 +02:00
Dror Tirosh
7fb03cbd50 update to solc 0.8.12 2022-03-02 21:45:45 +02:00