230 Commits

Author SHA1 Message Date
shahafn
faf305e302 L-04 Fixing docstrings (#194) 2023-02-08 23:22:11 +02:00
shahafn
973c0ac1e5 AA-122 L-03 Fixing time range (#193) 2023-02-08 22:54:57 +02:00
shahafn
82685b233f Fixing upgrade comment (#192)
Co-authored-by: Dror Tirosh <dror@opengsn.org>
2023-02-08 22:03:23 +02:00
Dror Tirosh
1cc1c97a00 AA-119 H-01 Invalid aggregate signature (#195)
* H-01 Invalid aggregate signature
- BLSAccount (and any other account using signature-aggregator) must verify the public key in the initCode (as last 4 words, just as the BLSAggregator checks)
- validateSignatures must be called before (not after) all validateUserOp

This prevents creating an account that succeeds in simulation, but fails in when executed on-chain (by using different signature during creation)
2023-02-08 21:56:38 +02:00
Dror Tirosh
0d0230bdb1 Add deploy_SimpleAccountFactory (#189) 2023-02-02 17:04:06 +02:00
Dror Tirosh
2020bf913a AA-118 simulateHandleOp should support extra call (#190)
notes
- the test for simulateHandleOp now can be complete (previously, it was
very difficult/impossible to test for side-effects...
- added a "numberMarker" just before the call, so that tracing it can
easily distinguish execution from post-execution call
2023-02-02 17:02:42 +02:00
Derek Chiang
07934a4a5c Specify that the client should check for sigFailed (#166)
* Update EIP to specify that the client should check if signatures are valid (through simulation)
2023-02-02 12:10:01 +02:00
Derek Chiang
0fe3bff208 Create an execution method for Gnosis account that reverts (#186)
* Add an execution method to Safe that reverts if a call fails, so that EntryPoint can catch the revert and emit UserOperationRevertReason
* Add a test for execAndRevert
2023-02-02 12:01:49 +02:00
Dror Tirosh
c284f588ee paymaster should always call requireFromEntryPoint from validatePaymasterUserOp (#185)
* make internal _validatePaymasterUserOp the template method so we can add requireFromEntryPoint
* adding forced _requireFromEntryPoint
2023-01-25 15:42:21 +02:00
Derek Chiang
1dfb17366f Make the Gnosis wallet compliant with the spec by returning SIG_VALIDATION_FAILED instead of reverting when the signature fails to validate (#181) 2023-01-25 13:01:21 +02:00
shahafn
0b5186b85b Calling _simulateFindAggregator() to wrap in context for warm/cold storage 2023-01-21 03:21:27 +02:00
shahafn
05cdb130aa Adding cold/warm storage tests 2023-01-21 03:21:27 +02:00
shahafn
9c00e784fa Limiting revert reason length in contracts 2023-01-19 21:10:37 +02:00
shahafn
bb73ea150b Adding failed test to revert reason bombing of innerHandleOp() 2023-01-19 21:10:37 +02:00
Derek Chiang
8f5d060a8e Use the correct creation code (#173)
Reading creation code from the type "GnosisSafeProxy" opens up the risk that the creation code from the imported library is different than the one actually deployed on-chain.  Fortunately, we can read the creation code from the proxy factory itself: 767ef36bba/contracts/proxies/GnosisSafeProxyFactory.sol (L33)
2023-01-18 15:46:23 +02:00
taek
c8c33f4f1b changed to 8byte for match sigTimeRange spec of EIP (#172) 2023-01-18 15:03:39 +02:00
Derek Chiang
4afdf5ac8e Clarify that verifying the hash is not a requirement (#165)
The way it's worded right now, it sounds like the account needs to verify the `userOpHash`, when in fact it doesn't have to, since the entryPoint is trusted.  Just re-organizing the text to make it clearer.
2023-01-18 15:02:51 +02:00
Derek Chiang
5a1ad40724 Fix wording (#167) 2023-01-12 12:51:40 +02:00
shahafn
b34b7a0b61 Removing basefee from requiredPrefund calculation 2023-01-10 20:21:06 +02:00
shahafn
09375f147e Adding failed test of malicious account with leaked basefee 2023-01-10 20:21:06 +02:00
shahafn
6c6c5dc765 Adding reference bundler links (#168) 2023-01-08 18:17:35 +02:00
Dror Tirosh
6dea6d8752 update staking rules (#164) 2023-01-02 23:56:25 +02:00
Dror Tirosh
4fef857019 AA-101: validate gasLimit to leave more than callGasLimit to call (#163)
* AA-101: validate gasLimit to leave more than callGasLimit to target call.

Fix vulnerability reported by Richard Meisner in PR #162 

The added tests should show the scenario where a user operation with a high callGasLimit is submitted. In this case it is important that the gasLimit is correctly set, else it is possible to use the 1/64th rule of EIP-150 to make the user operation fail and the account pays for it.

If this is possible it could be used as an attack vector. The attacker would submit a bundle with the high gas usage tx with a too low gas value. Even when the user estimated everything correctly the transaction would fail because not enough gas is available. The costs for the execution would still be deducted from the account. Therefore the submitter could perform a denial of service attack for which the account that is being attacked would pay.

The first tests below shows that high gas transaction can be executed and refunded. The second test checks that the transaction is reverted in case the gas limit is set too low, to avoid the attack described above.
2023-01-02 22:42:26 +02:00
Dror Tirosh
65eb17cc3d Merge pull request #162 from rmeissner/dos_entrypoint
Add tests for high gas usage transactions
2023-01-02 22:13:10 +02:00
Richard Meissner
f342436b88 Adjust verificationGasLimit 2023-01-02 17:14:30 +01:00
Richard Meissner
de2f37b97f Fix linting 2023-01-02 16:02:00 +01:00
Richard Meissner
828974458b Clean up tests 2023-01-02 15:51:38 +01:00
Richard Meissner
efbdc42765 Use less gas 2023-01-02 15:22:44 +01:00
Richard Meissner
a7bcdb3c62 Add test for attack scenario 2023-01-02 15:10:07 +01:00
Dror Tirosh
c2a541bb8c AA-99 - update EIP (#161)
* AA-99 - update EIP
2023-01-02 04:25:08 +02:00
Dror Tirosh
cf9b8c2abc AA-99 time range (#159)
Account (and paymaster) can return (sigFail, validUntil, validAfter) values, packed as a single uint sigTimeRange return value.
2023-01-02 03:46:08 +02:00
Yoav Weiss
3e7d1157b6 Merge pull request #160 from eth-infinitism/bundling-rules-1
AA-100: Change bundling rules to prevent any cross-op access
2023-01-02 03:33:23 +02:00
Yoav Weiss
65372a1cf5 Bundling rules: separated the "sender" rule from the "create" rule 2023-01-01 18:56:59 +02:00
Yoav Weiss
fab340976b Change bundling rules to prevent any cross-op access 2023-01-01 18:43:21 +02:00
Dror Tirosh
036c3d4cc7 merge back EIP after submission to EIPs repository
After fixing all merge rules of https://github.com/ethereum/EIPs
2023-01-01 18:34:34 +02:00
Dror Tirosh
4bff5524e2 AA-94 update keccak rules.
seems that allowing keccak(X||OWN) opens an attack surface (shared
storage between accounts)
rule 3 alone is enough to access balances and allowances of 2 entties
(e.g. paymaster and account) - which is OK
2022-12-29 02:00:09 +02:00
Dror Tirosh
6aeb39663b v0.4.0 2022-12-27 18:00:56 +02:00
shahafn
5b898e4113 AA-93: Adding debug RPC APIs for the Bundler to use (#153)
* Adding debug rpc api for the bundler
2022-12-27 17:19:40 +02:00
Dror Tirosh
fc171eb64a AA 92 simulate execution (#152)
1. A new API for an account (or paymaster) to report signature check validation: instead of revert, they should return `SIG_VALIDATION_FAILED` (1) to mark signature validation.  checking for `tx.origin` as zero is no longer in use.
2. ValidateUserOp returns the SIG_VALIDATION_FAILED value (like any other deadline) for a bundler to check.
3. `handleOps`  reverts on such signature failure.
4. a new `simulateHandleOp()` helper method, which executes a full UserOp (validation+execution).
   like `validateUserOp`, it reverts so it never commits changes on-chain, and doesn't check for signatures, and only used for off-chain simulation. This way, a userOp can be "estimated", even if it depends on the deployed account (e.g. it is a method call on a newly deployed account, or depends on the account's state such as its balance)
2022-12-26 16:09:40 +02:00
Dror Tirosh
976d3f2758 AA-91 factories (#151)
* fix factories

BLSFactory use same model as SimpleAccount, using immutable wallet and
only user-specific params in initializer
add factory for TestAggregatedAccount sapmle contract
Create2Factory - use arachnid's de-facto standard deployer, instead of of
the nonstandard EIP2470 (specifically, arachnid's deployer revert on errors)

* gnosis account factory
now Gnosis-Safe  based account uses only standard gnosis contracts. The new GnosisSafeAcccountFactory only wraps the standard GnosisSafeProxyFactory to create the proxy (and initialize it with our modules)
2022-12-20 20:35:08 +02:00
Dror Tirosh
34afdaae28 AA85 check verificationGas (#148)
check verificationGas on all operations (create, validate, paymaster)
report descriptive error on out-of-gas in validateUserOp, validatePaymasterUserOp
2022-12-19 10:50:04 +02:00
Pandapip1
0676be30f6 Use canonical link and correct formatting for ERC-4337 (#150) 2022-12-18 14:21:54 +02:00
Alex Forshtat
35b16cdd21 AA-74: sample account cleanup: using ERC1967Proxy instead of instance (#149)
AA-74: sample account cleanup part 1 - using ERC1967Proxy instead of instance

* Remove the 'updateEntryPoint' API as it is not needed - the
'setImplementation' flow should take care of this.

* Make EntryPoint an immutable member of the SimpleAccount implementation

* Merge 'exec' and 'execFromEntryPoint' into single 'execute' method

* Remove '_requireFromAdmin' and 'transfer' functions

* use factory in getAccountInitCode/getAccountAddress, not implementation and ERC1967Proxy

Co-authored-by: Dror Tirosh <dror@opengsn.org>
2022-12-16 13:41:27 +02:00
Dror Tirosh
57c5d77c77 AA 73 unify reputation (#144)
* reputation (and stake) mechanism to apply to all entities (factory, paymaster, aggregator and account)
* event change: actualGasUsed instead of actualGasPrice
* all entities (sender, factory, paymaster, aggregator) return stake info from simulateValidation
* use "Factory" instead of "deployer"
* emit SignatureAggregatorChanged, AccountDeployed to help bundler with reputation calculation.

Co-authored-by: Yoav Weiss <yoavw@users.noreply.github.com>
2022-12-14 16:59:06 +02:00
Dror Tirosh
93cd881dca AA-68 rpc calls (#132)
* Add rpc methods definitions

better definition of the required RPC methods:

* eth_sendUserOperation
* eth_estimateUserOperationGas
* eth_getUserOperationReceipt
* eth_supportedEntryPoints

* fixed error codes, error examples, removed "mined"
2022-12-13 12:16:24 +02:00
Yoav Weiss
b41ba0e9db Update eip-4337.md (#141) 2022-11-30 02:39:30 +02:00
Dror Tirosh
695e490484 AA-61 rename wallet to account (#134)
* rename IWallet to IAccount (and all other contracts, e.g. SimpleWallet to SimpleAccount, etc..)
2022-11-27 17:22:37 +02:00
Dror Tirosh
49cec09eb4 AA-69: wallet support for simulation without signing (#133)
wallet is expected to silently ignore signature failure in case the request came from:address(0)
this way, we can implement eth_callUserOp without explicit use acceptance.
2022-11-24 19:27:46 +02:00
Dror Tirosh
cebd672bc5 AA-70 rename requestId to userOpHash (#138) 2022-11-22 17:59:59 +02:00
Jammyaa
2f25406d0e fix error add two numbers with different units (#137) 2022-11-22 17:53:56 +02:00