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

Upgrade post audit version 0.5.1 #10

Merged
merged 83 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
6f7ca6f
Update version number package.json
eloi010 Nov 10, 2023
fb4f93d
forge install: erc6551
eloi010 Nov 10, 2023
f27f454
Custom Registry not needed anymore
eloi010 Nov 10, 2023
6494760
Simplifying contracts and versions
eloi010 Nov 13, 2023
edcda41
Adapting ERC6551 & removing old files
eloi010 Nov 13, 2023
7a9ad2d
More cleanup
eloi010 Nov 13, 2023
dee8158
updated checkDeposits
eloi010 Nov 13, 2023
9c439f2
huge refactor sessionKeys and ERC6551
eloi010 Nov 13, 2023
1b682d7
Minor optimizations
eloi010 Nov 14, 2023
f2e1477
EIP1271 OF_MSG_TYPEHASH
eloi010 Nov 14, 2023
5b48eac
run fmt
eloi010 Nov 14, 2023
9f71805
Improving sigs and tests
eloi010 Nov 14, 2023
8b71e3b
Refactor for BaseOpenfort and sessionKeys not self
eloi010 Nov 15, 2023
be88daa
More adapted refactors
eloi010 Nov 15, 2023
a6997d2
Invalidate sessionKeys when owner changed
eloi010 Nov 15, 2023
17e8adc
Improving imports and linting
eloi010 Nov 15, 2023
f8b9344
More optimizations
eloi010 Nov 15, 2023
eab4a95
Naming the mappings
eloi010 Nov 16, 2023
075df67
Adding custom error
eloi010 Nov 16, 2023
3ccd7c3
Minor adjustments
eloi010 Nov 17, 2023
4732a2b
Improving local vscode config
eloi010 Nov 17, 2023
d0d1273
More improvements
eloi010 Nov 17, 2023
38f2e27
Towards 2step creation (allow multple guardians)
eloi010 Nov 17, 2023
129f161
Updated forge
eloi010 Nov 20, 2023
a1e24d7
Huge refactor under construction
eloi010 Nov 20, 2023
043ae2d
All tests working after big refactor
eloi010 Nov 20, 2023
e3ed943
More refactoring
eloi010 Nov 21, 2023
c4700e2
Renaming EIP6551 to ERC6551
eloi010 Nov 21, 2023
b5f3c5e
Improving testing
eloi010 Nov 21, 2023
73bab22
Adding fuzz tests
eloi010 Nov 22, 2023
cd53700
Added IBaseOpenfortAccount interface file
eloi010 Nov 22, 2023
5451500
Making OF_MSG_TYPEHASH internal
eloi010 Nov 22, 2023
2a2596f
Moved BaseOpenfortFactory logic, better modularity
eloi010 Nov 22, 2023
50a6eca
restructuring namings
eloi010 Nov 22, 2023
61da68b
Improving the tests
eloi010 Nov 22, 2023
63cf512
Improving test namings
eloi010 Nov 22, 2023
88ed5f1
Improving tests
eloi010 Nov 22, 2023
fd95e32
Naming convention _args
eloi010 Nov 22, 2023
d3350c9
Improving checks and added testAddDeposit() test
eloi010 Nov 22, 2023
0ffc5ee
Removing addDeposit and withdrawDepositTo. + tests
eloi010 Nov 23, 2023
09dbcb1
Moar tests
eloi010 Nov 23, 2023
8de7879
Small improvements
eloi010 Nov 23, 2023
ffde3c8
Testing ERC6551
eloi010 Nov 24, 2023
dbdc4e9
Commenting out ERC6551 temp
eloi010 Nov 24, 2023
7ac0f4f
Adding ReentrancyGuard
eloi010 Nov 24, 2023
15793d4
Moar tests
eloi010 Nov 24, 2023
acc6048
Moar test coverage
eloi010 Nov 24, 2023
766c2f6
Test keys from old owner should not work
eloi010 Nov 27, 2023
c12dbb5
Towards accepting multiple initial guardians
eloi010 Nov 27, 2023
4b414e5
updated forge
eloi010 Nov 27, 2023
29c1540
Initial guardians as array
eloi010 Nov 28, 2023
847c943
Only one (optional) guardian as initial setup
eloi010 Nov 28, 2023
3bd17e9
Removed SimpleAccount info
eloi010 Nov 28, 2023
3c861f6
Run fmt
eloi010 Nov 28, 2023
8bc8030
Raw commands in case bytecode does not match
eloi010 Nov 29, 2023
709a684
DeployMock cleaned
eloi010 Nov 29, 2023
cadb025
ERC6551 working non-upgradeable
eloi010 Nov 29, 2023
13ea266
Improving test coverage
eloi010 Nov 29, 2023
83e89b3
Adapt checkDeposits testnets
eloi010 Dec 1, 2023
2d43250
Migrating checkDeposit from Goerli to Sepolia
eloi010 Dec 1, 2023
b8312e0
Improved deployment scripts
eloi010 Dec 11, 2023
99c8d06
Refactor deployment scripts
eloi010 Dec 11, 2023
29ee767
Improved scripts, tests and initial guardian setup
eloi010 Dec 18, 2023
b9e652d
More cleanup
eloi010 Dec 18, 2023
d38d49c
Fixing BRA-01 from CertiK audit
eloi010 Dec 18, 2023
0a6084e
Fixing BOA-01 from CertiK audit
eloi010 Dec 18, 2023
9a5b198
Fixed some tests
eloi010 Dec 18, 2023
b497003
fmt
eloi010 Dec 18, 2023
dfe0dea
Fixing BOA-02 from CertiK audit
eloi010 Dec 18, 2023
1144be4
Fixing BOA-03 from CertiK audit
eloi010 Dec 18, 2023
9f28d42
Fixing BRA-02 from CertiK audit
eloi010 Dec 18, 2023
d18c692
Fixing BRA-03 from CertiK audit
eloi010 Dec 18, 2023
de75b35
Fixing BRA-05 from CertiK audit
eloi010 Dec 18, 2023
5c9ee0e
Improved ERC1155 test due to ERO-01 (CertiK)
eloi010 Dec 19, 2023
073798d
Fixing BOA-04 from CertiK audit
eloi010 Dec 20, 2023
d72d7a6
Fmt
eloi010 Dec 20, 2023
42724b8
Further fixing BRA-01 from CertiK audit
eloi010 Dec 22, 2023
f002327
Further fixing BOA-04 from CertiK audit
eloi010 Dec 22, 2023
622c2b5
Further fixing BRA-05 from CertiK audit
eloi010 Dec 22, 2023
6d19c2a
Partially fixing COR-04 from CertiK audit
eloi010 Dec 22, 2023
89ad211
running fmt
eloi010 Dec 22, 2023
9597226
Further fixing BOA-04 from CertiK audit
eloi010 Dec 22, 2023
b623ccc
Adding upgrade scripts
eloi010 Dec 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Entry point v0.6.0
ENTRY_POINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
ERC6551_REGISTRY_ADDRESS="0x000000006551c19487814612e58FE06813775758"
PAYMASTER_ADDRESS=
MNEMONIC="test test test test test test test test test test test junk"
VERSION_SALT=0x00
Expand All @@ -20,7 +21,8 @@ AVALANCHE_OPENFORT_RPC="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
GNOSIS_RPC="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
GNOSIS_CHIADO_RPC="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
BASE_RPC="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
BASE_TEST_RPC="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
BASE_GOERLI_RPC="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
BASE_SEPOLIA_RPC="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
OASYS_MAINNET_RPC="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
OASYS_TEST_RPC="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
KLAYTN_MAINNET_RPC="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "lib/account-abstraction"]
path = lib/account-abstraction
url = git@github.com:eth-infinitism/account-abstraction.git
[submodule "lib/erc6551"]
path = lib/erc6551
url = https://github.com/erc6551/reference
22 changes: 15 additions & 7 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
{
"extends": "solhint:recommended",
"rules": {
"compiler-version": ["error",">=0.7.5"],
"func-visibility": ["off",{"ignoreConstructors":true}],
"mark-callable-contracts": ["off"]
}
"extends": "solhint:recommended",
"rules": {
"avoid-low-level-calls": "off",
"code-complexity": ["error", 9],
"compiler-version": ["error", ">=0.8.19"],
"contract-name-camelcase": "off",
"const-name-snakecase": "off",
"func-name-mixedcase": "off",
"func-visibility": ["error", { "ignoreConstructors": true }],
"max-line-length": ["error", 123],
"named-parameters-mapping": "warn",
"no-empty-blocks": "off",
"not-rely-on-time": "off",
"var-name-mixedcase": "off"
}
}
16 changes: 15 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
{
"solidity.compileUsingRemoteVersion": "v0.8.19+commit.7dd6d404"
"solidity.compileUsingRemoteVersion": "v0.8.19+commit.7dd6d404",
"solidity.defaultCompiler": "localFile",
"solidity.compileUsingLocalVersion": "v0.8.19+commit.7dd6d404",
"solidity.packageDefaultDependenciesDirectory": "node_modules/, lib/",
"solidity.formatter": "forge",
"solidity.packageDefaultDependenciesContractsDirectory": "node_modules/, lib/",
"solidity.remappings": [
"@openzeppelin/=node_modules/@openzeppelin/",
"account-abstraction/=lib/account-abstraction/contracts/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"eth-gas-reporter/=node_modules/eth-gas-reporter/",
"forge-std/=lib/forge-std/src/",
"hardhat/=node_modules/hardhat/",
"erc6551/=lib/erc6551/",
]
}
40 changes: 9 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Use the `lcov` report format and `genhtml` to view the coverage data in a nice w
./script/gasProfile.sh
```

### Deploy Static and Upgradeable factories to all chains
### Deploy Upgradeable and Managed factories to all chains

```
./script/deployAllChains.sh
Expand All @@ -84,31 +84,17 @@ Use the `lcov` report format and `genhtml` to view the coverage data in a nice w
forge script CheckDeposits --force
```

### Deploy one static factory and one account

Simulation:

```
forge script StaticOpenfortDeploy --fork-url $<rpc_network>
```

Actual deployment:

```
forge script StaticOpenfortDeploy --fork-url $<rpc_network> --verify --broadcast
```

### Deploy one upgradeable factory and one account

Simulation:

```
forge script UpgradeableOpenfortDeploy --fork-url $<rpc_network>
forge script --force script/deployManagedAccounts.s.sol -vvvvv --optimizer-runs 1000000 --slow --fork-url $<rpc_network>
```

Actual deployment:
```
forge script UpgradeableOpenfortDeploy --fork-url $<rpc_network> --verify --broadcast
forge script --force script/deployManagedAccounts.s.sol -vvvvv --optimizer-runs 1000000 --slow --fork-url $<rpc_network> --broadcast --verify --etherscan-api-key $<api_key>
```

### Compare gas costs
Expand Down Expand Up @@ -147,14 +133,6 @@ If you run into the error `ImportError: cannot import name 'getargspec' from 'in

As of June 2023, the current average gas cost for deploying or using the different smart contracts of this project is:

### Static Accounts
| Smart Contract | Description | # of deployments per game/ecosystem | Avg gas cost |
| :----------------- | :---------------------------------- | :---------------------------------- | :------------------------ |
| StaticOpenfortFactory | Deploy factory (containing StaticOpenfortAccount's implementation) | 1 | ~2,500,000 |
| StaticOpenfortAccount | Create a new static account using the `createAccountWithNonce()` of the factory | indefinite | ~150,000 |
| StaticOpenfortAccount | Updating the EntryPoint address using `updateEntryPoint()` | indefinite | ~1,500 |
| StaticOpenfortAccount | Transferring the ownership using `transferOwnership()` | indefinite | ~25,000 |

### Upgradeable Accounts
| Smart Contract | Description | # of deployments per game/ecosystem | Avg gas cost |
| :----------------- | :---------------------------------- | :---------------------------------- | :------------------------ |
Expand All @@ -171,9 +149,9 @@ As of June 2023, the current average gas cost for deploying or using the differe
## Gas Stats in USD
The gas price range is reported as the daily average gas price for the first 90 days of 2023 ± one standard deviation.

| Blockchain | Gas Price Range | Token Price | Create an Static account | Create an Upgradeable account |
| :------------- | :-------------------- | :---------------- | :------ | :------ |
| Ethereum | 30.5 ± 10.5 gwei | ~$1800 | $5.5-$11 | $7.5-15 |
| Polygon | 220 ± 108 gwei | ~$0.67 | $0.01-$0.035 | $0.015-$0.045 |
| Avalanche | 36 ± 4.5 nAVAX | ~$12.8 | $0.06-0.08 | $0.08-$0.11 |
| BSC | 7 ± 0.55 gwei | ~$240 | $0.24-$0.28 | $0.32-$0.36|
| Blockchain | Gas Price Range | Token Price | Create an Upgradeable account |
| :------------- | :-------------------- | :---------------- | :------ |
| Ethereum | 30.5 ± 10.5 gwei | ~$1800 | $7.5-15 |
| Polygon | 220 ± 108 gwei | ~$0.67 | $0.015-$0.045 |
| Avalanche | 36 ± 4.5 nAVAX | ~$12.8 | $0.08-$0.11 |
| BSC | 7 ± 0.55 gwei | ~$240 | $0.32-$0.36 |
Loading