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

Feat/solidity 0.8.26 #81

Merged
merged 43 commits into from
Jun 3, 2024
Merged

Feat/solidity 0.8.26 #81

merged 43 commits into from
Jun 3, 2024

Conversation

Aboudjem
Copy link
Contributor

@Aboudjem Aboudjem commented May 26, 2024

Gas Report Comparison

Protocol Actions / Function Account Type Is Deployed With Paymaster? Receiver Access Gas Used Gas Difference
ERC20 transfer EOA False False 🧊 ColdAccess 49429 🥳 -492
ERC20 transfer EOA False False 🔥 WarmAccess 24729 🥳 -492
ERC20 transfer Smart Account True False 🧊 ColdAccess 91671 🥳 -3108
ERC20 transfer Smart Account True False 🔥 WarmAccess 71771 🥳 -3109
ERC20 transfer Smart Account False True 🧊 ColdAccess 328180 🥳 -7684
ERC20 transfer Smart Account False True 🔥 WarmAccess 308280 🥳 -7684
ERC20 transfer Smart Account False False 🧊 ColdAccess 313048 🥳 -6030
ERC20 transfer Smart Account False False 🔥 WarmAccess 293148 🥳 -6030
ERC20 transfer Smart Account False False 🧊 ColdAccess 361075 🥳 -6107
ERC20 transfer Smart Account False False 🔥 WarmAccess 341175 🥳 -6108
ERC20 transfer Smart Account True True 🧊 ColdAccess 106454 🥳 -4833
ERC20 transfer Smart Account True True 🔥 WarmAccess 86554 🥳 -4833
ERC721 transferFrom EOA False False 🧊 ColdAccess 47632 🥳 -851
ERC721 transferFrom EOA False False 🔥 WarmAccess 27732 🥳 -851
ERC721 transferFrom Smart Account True False 🧊 ColdAccess 94998 🥳 -3267
ERC721 transferFrom Smart Account True False 🔥 WarmAccess 75098 🥳 -3267
ERC721 transferFrom Smart Account False True 🧊 ColdAccess 326716 🥳 -7837
ERC721 transferFrom Smart Account False True 🔥 WarmAccess 306816 🥳 -7837
ERC721 transferFrom Smart Account False False 🧊 ColdAccess 311582 🥳 -6186
ERC721 transferFrom Smart Account False False 🔥 WarmAccess 291682 🥳 -6186
ERC721 transferFrom Smart Account False False 🧊 ColdAccess 359608 🥳 -6265
ERC721 transferFrom Smart Account False False 🔥 WarmAccess 339708 🥳 -6265
ERC721 transferFrom Smart Account True True 🧊 ColdAccess 109814 🥳 -4988
ERC721 transferFrom Smart Account True True 🔥 WarmAccess 89914 🥳 -4988
ETH transfer EOA False False 🧊 ColdAccess 52882 🥳 -191
ETH transfer EOA False False 🔥 WarmAccess 27882 🥳 -191
ETH call EOA False False 🧊 ColdAccess 52946 🥳 -255
ETH call EOA False False 🔥 WarmAccess 27946 🥳 -255
ETH send EOA False False 🧊 ColdAccess 52955 🥳 -246
ETH send EOA False False 🔥 WarmAccess 27946 🥳 -255
ETH transfer Smart Account True False 🧊 ColdAccess 99766 🥳 -2862
ETH transfer Smart Account True False 🔥 WarmAccess 74766 🥳 -2862
ETH transfer Smart Account False True 🧊 ColdAccess 331441 🥳 -7449
ETH transfer Smart Account False True 🔥 WarmAccess 306441 🥳 -7449
ETH transfer Smart Account False False 🧊 ColdAccess 316331 🥳 -5783
ETH transfer Smart Account False False 🔥 WarmAccess 291331 🥳 -5783
ETH transfer Smart Account False False 🧊 ColdAccess 364358 🥳 -5861
ETH transfer Smart Account False False 🔥 WarmAccess 339358 🥳 -5861
ETH transfer Smart Account True True 🧊 ColdAccess 114520 🥳 -4593
ETH transfer Smart Account True True 🔥 WarmAccess 89520 🥳 -4593
UniswapV2 swapExactETHForTokens EOA False False N/A 148666 🥳 -597
UniswapV2 swapExactETHForTokens Smart Account True False N/A 196378 🥳 -2876
UniswapV2 swapExactETHForTokens Smart Account False True N/A 428194 🥳 -7434
UniswapV2 swapExactETHForTokens Smart Account False False N/A 412962 🥳 -5797
UniswapV2 swapExactETHForTokens Smart Account False False N/A 460988 🥳 -5876
UniswapV2 swapExactETHForTokens Smart Account True True N/A 211244 🥳 -4585
UniswapV2 swapExactTokensForTokens EOA False False N/A 117590 🥳 -662
UniswapV2 swapExactTokensForTokens Smart Account True False N/A 165355 🥳 -2877
UniswapV2 swapExactTokensForTokens Smart Account False True N/A 397174 🥳 -7434
UniswapV2 swapExactTokensForTokens Smart Account False False N/A 381928 🥳 -5798
UniswapV2 approve+swapExactTokensForTokens Smart Account True False N/A 197896 🥳 -2334
UniswapV2 approve+swapExactTokensForTokens Smart Account False True N/A 429959 🥳 -6860
UniswapV2 approve+swapExactTokensForTokens Smart Account False False N/A 414493 🥳 -5256
UniswapV2 approve+swapExactTokensForTokens Smart Account False False N/A 462519 🥳 -5334
UniswapV2 swapExactTokensForTokens Smart Account True True N/A 180238 🥳 -4582

Base automatically changed from feat/clean-refactor to dev May 29, 2024 10:29
Copy link

codecov bot commented May 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.40%. Comparing base (7040338) to head (c5fb300).
Report is 3 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev      #81      +/-   ##
==========================================
+ Coverage   87.95%   89.40%   +1.44%     
==========================================
  Files          35       13      -22     
  Lines         772      434     -338     
  Branches      108      109       +1     
==========================================
- Hits          679      388     -291     
+ Misses         79       44      -35     
+ Partials       14        2      -12     
Files Coverage Δ
contracts/Nexus.sol 87.17% <100.00%> (-2.89%) ⬇️
contracts/base/BaseAccount.sol 84.61% <100.00%> (-11.82%) ⬇️
contracts/base/ExecutionHelper.sol 81.81% <ø> (-18.19%) ⬇️
contracts/base/ModuleManager.sol 94.25% <100.00%> (-2.49%) ⬇️
contracts/base/Storage.sol 66.66% <ø> (-33.34%) ⬇️
contracts/common/Stakeable.sol 100.00% <100.00%> (ø)
contracts/factory/AbstractNexusFactory.sol 100.00% <100.00%> (ø)
contracts/factory/BiconomyMetaFactory.sol 93.33% <100.00%> (-6.67%) ⬇️
contracts/factory/K1ValidatorFactory.sol 90.47% <100.00%> (-0.44%) ⬇️
contracts/factory/ModuleWhitelistFactory.sol 94.11% <100.00%> (-5.89%) ⬇️
... and 3 more

... and 22 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d63d015...c5fb300. Read the comment docs.

…d of isWhitelisted

The commit updates the ModuleWhitelistFactory contract to use the isModuleWhitelisted function instead of the deprecated isWhitelisted function. This change ensures that all modules are properly whitelisted before execution.
Copy link

openzeppelin-code bot commented Jun 3, 2024

Feat/solidity 0.8.26

Generated at commit: c5fb3002266499789012c5e3d59691812e675d52

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
0
1
0
6
22
29

For more details view the full report in OpenZeppelin Code Inspector

Copy link

github-actions bot commented Jun 3, 2024

Changes to gas cost

Generated at commit: 7ddcba9bfe18d11b9e7877c729199fc0290eccb5, compared to commit: d63d015758ff894a0c77111394b201a4cc321881

🧾 Summary (5% most significant diffs)

Contract Method Avg (+/-) %
Nexus accountId
isModuleInstalled
+289 ❌
-317 ✅
+47.45%
-28.35%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
Nexus 4,378,265 (-66,497) accountId
execute
executeFromExecutor
initializeAccount
installModule
isModuleInstalled
uninstallModule
validateUserOp
898 (+289)
6,159 (-209)
9,078 (-208)
79,891 (-1,996)
28,118 (+197)
609 (-244)
8,080 (+108)
6,983 (-547)
+47.45%
-3.28%
-2.24%
-2.44%
+0.71%
-28.60%
+1.35%
-7.26%
898 (+289)
47,466 (-162)
14,369 (-351)
99,726 (-1,996)
33,439 (+315)
801 (-317)
10,219 (+200)
8,558 (-549)
+47.45%
-0.34%
-2.38%
-1.96%
+0.95%
-28.35%
+2.00%
-6.03%
898 (+289)
35,781 (-451)
14,178 (-470)
99,791 (-1,996)
34,972 (+257)
783 (-318)
9,823 (+214)
6,983 (-547)
+47.45%
-1.24%
-3.21%
-1.96%
+0.74%
-28.88%
+2.23%
-7.26%
898 (+289)
142,937 (-209)
20,043 (-257)
99,791 (-1,996)
38,795 (-49)
2,806 (-339)
12,755 (+277)
35,773 (-619)
+47.45%
-0.15%
-1.27%
-1.96%
-0.13%
-10.78%
+2.22%
-1.70%
8 (0)
76 (0)
4 (0)
309 (0)
23 (0)
331 (0)
6 (0)
351 (0)
MockValidator 656,373 (+29,089) isModuleType
isOwner
293 (-10)
475 (-203)
-3.30%
-29.94%
293 (-10)
475 (-203)
-3.30%
-29.94%
293 (-10)
475 (-203)
-3.30%
-29.94%
293 (-10)
475 (-203)
-3.30%
-29.94%
4 (0)
275 (0)
MockHandler 428,645 (+42,132) isModuleType 381 (+56) +17.23% 381 (+56) +17.23% 381 (+56) +17.23% 381 (+56) +17.23% 7 (0)
MockHook 242,479 (+3,461) isModuleType 268 (-46) -14.65% 268 (-46) -14.65% 268 (-46) -14.65% 268 (-46) -14.65% 6 (0)
BootstrapLib 344,596 (-31,240) createArrayConfig
createSingleConfig
1,601 (-25)
912 (-140)
-1.54%
-13.31%
1,601 (-25)
912 (-140)
-1.54%
-13.31%
1,601 (-25)
912 (-140)
-1.54%
-13.31%
1,601 (-25)
912 (-140)
-1.54%
-13.31%
918 (0)
918 (0)
NexusAccountFactory 795,770 (+67,215) computeAccountAddress
createAccount
1,165 (-37)
180,155 (-1,948)
-3.08%
-1.07%
1,165 (-37)
197,776 (-1,948)
-3.08%
-0.98%
1,165 (-37)
200,295 (-1,948)
-3.08%
-0.96%
1,165 (-37)
200,295 (-1,948)
-3.08%
-0.96%
609 (0)
8 (0)
Bootstrap 1,759,072 (+98,284) getInitNexusScopedCalldata
initNexusScoped
4,632 (-100)
31,411 (-799)
-2.11%
-2.48%
4,632 (-100)
51,246 (-799)
-2.11%
-1.54%
4,632 (-100)
51,311 (-799)
-2.11%
-1.53%
4,632 (-100)
51,311 (-799)
-2.11%
-1.53%
918 (0)
309 (0)
MockPaymaster 1,161,593 (-37,992) addStake
getHash
60,121 (-340)
2,087 (-76)
-0.56%
-3.51%
60,121 (-340)
2,286 (-42)
-0.56%
-1.80%
60,121 (-340)
2,366 (-35)
-0.56%
-1.46%
60,121 (-340)
2,635 (+20)
-0.56%
+0.76%
15 (0)
17 (0)
MockNFT 1,224,110 (-59,988) balanceOf
mint
ownerOf
transferFrom
588 (-10)
68,195 (-245)
549 (-3)
37,138 (-398)
-1.67%
-0.36%
-0.54%
-1.06%
1,588 (-10)
68,339 (-245)
549 (-3)
45,688 (-398)
-0.63%
-0.36%
-0.54%
-0.86%
1,588 (-10)
68,411 (-245)
549 (-3)
45,688 (-398)
-0.63%
-0.36%
-0.54%
-0.86%
2,588 (-10)
68,411 (-245)
549 (-3)
54,238 (-398)
-0.38%
-0.36%
-0.54%
-0.73%
12 (0)
18 (0)
12 (0)
2 (0)
MockExecutor 823,567 (-93,319) isModuleType 348 (+1) +0.29% 348 (+1) +0.29% 348 (+1) +0.29% 348 (+1) +0.29% 12 (0)
BiconomyMetaFactory 717,038 (+19,748) addFactoryToWhitelist 46,199 (+29) +0.06% 46,199 (+29) +0.06% 46,199 (+29) +0.06% 46,199 (+29) +0.06% 86 (0)

The commit restricts the manipulation of the fallback handler in the ModuleManager contract to ensure the account's security and integrity. It prevents unauthorized uninstallation and reinstallation of the validator module, which could compromise the account's security. Additionally, it checks for the presence of an existing fallback handler to avoid overwriting it and causing unexpected behavior.
The commit adds error handling for an invalid EntryPoint address in the Stakeable contract. This ensures that only valid addresses can be used when adding, unlocking, or withdrawing stakes.
…ead of revert

The commit updates the constructor of the AbstractNexusFactory contract to use the require statement instead of revert. This change improves code readability and follows best practices for error handling.
…ad of revert

The commit updates the constructor of the BiconomyMetaFactory contract to use the require statement instead of revert. This change improves code readability and follows best practices for error handling.
…structor and addModuleToWhitelist function

The commit updates the constructor of the ModuleWhitelistFactory contract to use the require statement instead of revert. This change improves code readability and follows best practices for error handling.

It also updates the addModuleToWhitelist function to use require instead of revert. This ensures that the module address being added to the whitelist is not a zero address.

Refactor the ModuleWhitelistFactory contract to improve code readability and maintainability.
The commit adds the InnerCallFailed error to the INexusEventsAndErrors.sol interface. This error is thrown when an inner call fails. This addition enhances the error handling capabilities of the interface.

Refactor the INexusEventsAndErrors.sol interface to include the InnerCallFailed error.
…ctor

The commit updates the constructor of the K1ValidatorFactory contract to use the require statement instead of revert. This change improves code readability and follows best practices for error handling.
@Aboudjem Aboudjem marked this pull request as ready for review June 3, 2024 21:23
@Aboudjem Aboudjem self-assigned this Jun 3, 2024
Copy link

github-actions bot commented Jun 3, 2024

🤖 Slither Analysis Report 🔎

Slither report

# Slither report

THIS CHECKLIST IS NOT COMPLETE. Use --show-ignored-findings to show all the results.
Summary
🔴 - uninitialized-state (1 results) (High)

uninitialized-state

🔴 Impact: High
🔴 Confidence: High

factory/AbstractNexusFactory.sol#L28

_This comment was automatically generated by the GitHub Actions workflow._

@Aboudjem Aboudjem merged commit 48a73ee into dev Jun 3, 2024
10 checks passed
@Aboudjem Aboudjem deleted the feat/solidity-0.8.26 branch June 3, 2024 23:59
Aboudjem added a commit that referenced this pull request Jun 4, 2024
* update factory, add more factories and foundry test cases

* module manager tests

* refactor meta factory

* test + ignore ModeLib + comment unused methods

* added tests for account access + smart account.nonce

* refactor + natspecs + logs

* added test for K1Validator.validateUserOp

* testing isValidSignature

* Feat/sma 828 fuzz invariant tests (#67)

* chore: update .solhintignore to exclude contracts/mocks directory

* lint fix

* test: add test for AccountFactory deployment consistency

* chore: Add test for ERC4337Account deposit balance consistency

* invariant test for ERC4337Account ValidateUserOp invariant

* add TestInvariant_ModuleManager to test module management functionality

* test: add fuzz test for AccountFactory deployment

* chore: Add fuzz tests for ERC4337Account and ModuleManager

* Lint fix SmartAccountTestLab.t.sol for readability

* chore: Refactor test setup for Foundry invariant testing

* chore: Add InvariantModuleManagementHandler for module installation and uninstallation tests

* chore: Update solhint npm dependency to version 5.0.0

* Update solhint npm dependency to version 5.0.0

* Add ExecutionInvariantTests contract for testing execution-related invariants

* Add AccountInvariantTests contract for testing account creation invariants

* chore: Add InvariantModuleManagementHandler for module installation and uninstallation tests

* chore: Add InvariantExecutionHandler for testing execution-related invariants

* chore: Add InvariantDepositManagementHandler for testing deposit-related invariants

* feat: Add InvariantAccountCreationHandler for testing account creation invariants

* Add BaseInvariantTest contract for foundational test setup

* chore: Add TestInvariantNexus contract for testing invariant consistency

* Add TestInvariantExecutor contract for testing invariant execution

* Add TestInvariantExecutionHelper contract for testing authorized executor invariants

* feat: Add TestInvariantBaseAccount contract for testing base account invariants

* chore: Refactor TestInvariant_ModuleManager.t.sol for improved readability and consistency

* feat: Refactor TestInvariant_ERC4337Account_ValidateUserOp for improved readability and consistency

* chore: Add ActorManager contract for coordinating test actions across different actors

* feat: Refactor TestInvariant_AccountFactory_Deployment.t.sol for improved readability and consistency

* Refactor TestInvariant_ERC4337Account_DepositBalance.t.sol for improved readability and consistency

* Import IExecutor and MockToken contracts for testing

* 🔥 remove unused test files

* 🔥 Remove unused test files

* Refactor test files for improved readability and consistency

* Add Tests + Invariants + Refactor test files for improved readability and consistency

* BaseInvariantTest.t.sol for improved testing

* ✅ add Handlers for Invariantstest files

* ✅ Add ActorManager for invariant testing

* chore: Update solhint dependency to version 5.0.1

* 🔥 remove unused tests

* Refactor ActorManager test file

* Refactor AccountCreationHandler test file

* Add fuzz testing on TestFuzz_ValidateUserOp contract

* feat: Add TestFuzz_ExecuteFromExecutor contract for fuzz testing

* chore: Exclude VALIDATOR_MODULE in AccountValidateUserOpInvariantTests setup

* refactor: Improve test file structure and naming conventions

* refactor: Update TestAccountFactory_CreateAndGetCounterFactualAddress.t.sol

* refactor: Add fuzz testing for ERC4337Account withdrawal and signature validation

* refactor: Add execute fuzz testing with mocks

* ✅ add fuzz testing on module manager + edge cases

* ✅ add new Uninstall test cases

* refactor: Improve isContract function in Helpers.sol and testFuzz_TokenTransfer in TestFuzz_Execute.t.sol

* refactor: Fix formatting

* 🖼️ fix lint + reorder

* 📄 update Natspec security message

* refactor: Fix module msg installation test case

* chore: Update .solcover.js to skip "contracts/mocks" file in code coverage

* chore: Add hardhat-foundry plugin for Nexus project

* chore: Update post-checkout hook to include forge install command

* chore: Update comment.js to include details in a collapsible section

* chore: Update slither-action to v0.4.0 and node-version to 20

* Rename variable to remove shadowed var

* 🔥 remove unused variables in Nexus.sol

* chore: Add defender.config.json for contract inspector configuration

* ⚙️Update slither-action to exclude additional checks in ci.yml

* 🚀 gas optimization: Improve execution mode decoding in Nexus.sol

* 🔥 Remove unused delegate functions in ExecutionHelper.sol

* chore: Update BaseAccount.sol header comments

* Update ModuleManager.sol slither fix

* Add check for non-zero address slither fix

* chore: Add error handling for zero implementation address

* Add IValidator interface to K1Validator contract - slither fix

* use assertTrue for balance check

* lint fix

* add tests validate user operation from entry point

* add accesscontrol+unauthorized access tests

* refactor: add InvalidSignature error to EventsAndErrors.sol

* add tests cases + fix wrong asserts

* chore: Update deployment account funding amount in test

* Remove unnecessary code in TestERC4337Account_ValidateUserOp.t.sol

* add test for validation of user operation nonce

* Merge branch 'dev' of https://github.com/bcnmy/erc7579-modular-smart-account into dev

* 🖼️ Refactor project architecture / and rename files

* chore: Remove unused functions, improve comments and formatting in CheatCodes.sol

* chore: Update account balance initialization with default method

* chore: Update contract deployment and account labeling in Helpers.sol with default method

* Renamed preparePackedUserOperation to buildPackedUserOperation for consistancy

* Refactor project architecture and rename functions

* Update function name from preparePackedUserOperation to buildPackedUserOperation for consistency

* move functions to helpers

* Refactor helpers and rename functions

* chore: Refactor code and update function names for consistency

* Refactor NexusTest contract and update function names for consistency

* Refactor NexusTest contract and update function names for consistency

* Refactor Imports.sol and update import statement for TestHelper.t.sol

* Refactor SmartAccountTestLab contract and remove unused code

* Refactor imports and update test contracts for consistency

* Refactor NexusTest_Base contract and remove unused code

* Refactor code and remove unused imports and functions

* ✅ fix solc warning compiler

* ✅ Refactor code add negative tests

* chore: Refactor code and update function names for consistency

* Refactor code and add prefunding for smart account in TestFuzz_ValidateUserOp.t.sol

* Refactor code and remove inline comments

* Refactor code and improve inline comments

* Refactor code and improve inline comments add additional tests

* Refactor code, add natspecs, and improve inline comments in InvariantBaseTest contract

* Refactor AccountCreationHandlerTest contract, improve comments, and add validation for account creation

* Refactor DepositManagementHandlerTest contract, improve comments, and update Solidity version to ^0.8.0

* feat: Add ExecutionHandlerTest contract for executing operations on Nexus account and add natspec

* add natspecs

* feat: Add test for AccountDepositBalanceInvariantTest

* refactor: Improve comments and update Solidity version in AccountValidateUserOpInvariantTest

* chore: Update BaseAccountInvariantTest with natspec comments and improve code readability

* chore: Refactor ExecutorInvariantTest for improved code readability and maintainability

* refactor: Improve comments and update natspec in ModuleManagerInvariantTest

* refactor: Improve comments and update natspec in NexusInvariantTest

* refactor: Update TestAccountExecution_Base contract with natspec comments and improve code readability

* refactor: Update TestModuleManagement_Base contract with natspec comments and improve code readability

* refactor: Improve comments and update natspec in TestAccountConfig_AccountId.t.sol

* refactor: Improve comments and update natspec in TestAccountConfig_SupportsExecutionMode.t.sol

* refactor: Improve comments and update natspec in TestAccountExecution_TryExecuteSingle.t.sol

* refactor: Improve comments and update natspec

* renamed file

* refactor: Add missing events and update natspec

* refactor: Update Solidity version to 0.8.24 in multiple files

* refactor: improve and categorize events and errors

* add check on onUninstall hook

* fix test on invariants and fuzz

* fix test on invariants and fuzz

* fix invariant by adding check for installed module in onInstall function

* refactor: Skip precompiles in testFuzz_WithdrawDepositTo function

* fix warning and remove unused variables

* remove empty file

* add accountImplementationAddress test on ArbitrumSmartAccountUpgradeTest

* refactor: Add getImplementation function to IBiconomySmartAccountV2 interface

* refactor: Add UpgradeSmartAccountTest to test smart account implementation upgrade

* refactor: Rename tests

* refactor: Improve UpgradeSmartAccountTest with additional tests

* refactor: Exclude FACTORY contract from BaseAccountInvariantTest

* refactor: Exclude unnecessary contracts from AccountDepositBalanceInvariantTest setup

* fix invariant by ensuring signer has enough ether before adding deposit

* Renamed .t.sol test files + Exclude unnecessary contracts from NexusInvariantTest setup

* refactor: Add givenTheAccountConfiguration modifier to TestAccountConfig_AccountId

* add .tree to comply with BTT testing

* Update Solidity version to >=0.8.0 <0.9.0

* Chore/remove unused funcs (#77)

* refactor: Remove onlyValidatorModule modifier from ModuleManager.sol

* refactor: Add test cases for unsupported call types in TestAccountExecution_ExecuteSingle

* refactor: Update MockExecutor to support tryExecuteViaAccount and customExecuteViaAccount methods

* feat: Add MockInvalidModule contract for testing purposes

* refactor: Update MockExecutor to support tryExecuteViaAccount and customExecuteViaAccount methods

* refactor: Update TestAccountExecution_ExecuteFromExecutor.tree with descriptive test cases

* refactor: Update TestAccountExecution_ExecuteSingle.t.sol with more descriptive test cases

* refactor: Update TestAccountExecution_ExecuteSingle.tree with descriptive test cases for unsupported call types

* refactor: Add test case for installing a module as an invalid module type ID

* refactor: Add test case for installing a module with an invalid module type ID

* refactor: Update Imports.sol to import MockInvalidModule for testing purposes

* refactor: Update EventsAndErrors.sol to add error messages for unsupported module and call types

* Improve Natspecs in invariants

* ⚠️ fix compiler warning

* ⚠️ fix compilers / lint warnings

* 🖼️ lint fix

* chore: Update foundry-gas-diff workflow to continue on error

* chore: Skip posting comment if Slither report is empty

* chore: add warning comment on privatekey

* chore: Update CI workflow to include ARBITRUM_RPC_URL environment variable

* chore: Update ArbitrumSmartAccountUpgradeTest to use environment variable for RPC URL

* chore: Update ArbitrumSettings with default Arbitrum RPC URL

---------

Co-authored-by: livingrockrises <[email protected]>

* update factories + refactor + working foundry tests + update hardhat tests with K1 factory

* refactor

* resolve conflicts with helper contract

* refactor: update imports in TestHelper.t.sol, remove unused and reorder

* refactor: update Stakeable contract with natspecs

* refactor: update IStakeable interface with natspecs

* refactor: rename to test_DeployAccount_CreateAccount function + natspecs

* refactor: update TestAccountFactory_Deployments contract with natspecs

* typo fix + update Bootstrap functions to comply with styleguide

* refactor: Update natspecs and refactor names

* refactor: Update K1ValidatorFactory to use correct function name for getting init nexus calldata

* refactor: Update ArbitrumSmartAccountUpgradeTest.t.sol to use updated BOOTSTRAPPER.getInitNexusScopedCalldata function

* refactor: Update func names, remove unused and reorder

* refactor: Update BootstrapUtil.sol to comply with styleguide

* lint fix

* refactor: Update Stakeable contract with constructor parameter name change

* lint fix

* refactor: Update K1ValidatorFactory to use correct function name for getting init nexus calldata

* fix typo FactoryNotWhotelisted to FactoryNotWhitelisted in

* gas optimization, remove memory var + named returns

* refactor: Update DEFAULT_ARBITRUM_RPC_URL in ArbitrumSettings contract

* Update Stakeable Natspec

* refactor: Update IStakeable.sol with improved natspec and consistency

* refactor: Add unit tests for module support in TestModuleManager_SupportsModule.t.sol

* chore: Update Solidity version to 0.8.24

* refactor: Remove unnecessary imports in TestModuleManager_UninstallModule.t.sol

* Add test_RevertIf_UninstallNonInstalledFallbackHandler test + support calltypes

* Add Fallback testcases

* remove unrreachable condition on uninstall for unsupported module type error

* refactor: Improve module support unit tests in TestModuleManager_SupportsModule.t.sol

* chore: Update Solidity version to 0.8.24

* Add new test cases + coverage

* fix bug where additional iszero check make the success to not returns properly

* Update Solidity version to 0.8.24 + remove unused imports

* refactor: Remove unused imports in TestHelper.t.sol

* Add withdrawDepositTo tests

* test: Add test for addDeposit function with wrong entry point

* fix tests + Add test for TryExecuteBatch_RevertIf_HandleFailure_WithPrank function

* test: Add batch execution tests with failure scenarios

* test: Add test for unauthorized access during smart account upgrade

* refactor: Remove unused test function in K1Validator.sol

* fix fallback handler onuninstall

* Update Solidity version to 0.8.24

* remove unused imports

* Add new functions for testing purpose + Remove unused imports and update Solidity version to 0.8.24

* remove compiler warnings

* Remove compiler warnings

* remove compiler warnings

* [tmp] Refactor invariant tests

* fix whitelist factory test

* refactor + act on PR

* chore: Remove unused _mint function call in NFT.sol

* chore: Update BUNDLER_ADDRESS to be payable in TestHelper contract

* chore: Add MockPaymaster import in Imports.sol

* chore: Add ERC20 and Uniswap interfaces

* chore: Add TestNexusERC721Integration contract for testing Nexus smart account functionalities with ERC721 token transfers

* chore: Refactor code for testing Nexus smart account functionalities with uniswap swap tx

* chore: Refactor code for testing Nexus smart account functionalities with uniswap swap tx

* chore: Add MockPaymaster contract for testing Nexus smart account functionalities

* chore: Update MockPaymaster instantiation in integration tests

* chore: Refactor TestFuzz_ERC4337Account contract to use ENTRYPOINT.handleOps for withdrawUserOps

* chore: Add BaseSettings contract for setting up constants required for Base fork tests

* chore: Refactor Invariant tests

* remove invariants temp

* handle additional context length in fallback handler check, which revert

* chore: Update gas report command to include test_Gas match and fixed fuzz seed

* feat: Add gas benchmark tests

* lint fix

* Rename NFT.sol -> MockNFT.sol

* lint fixes

* refactor and fix conflicts

* chore: Update BASE_RPC_URL in CI configuration

* coverage: Add unsupported exec type revert tests

* chore: Add script to generate coverage report

* chore: Update lcov command in generate_coverage_report.sh

* chore: Update generate_coverage_report.sh to use forge coverage command with lcov report

* chore: Update coverage report script to use new generate_coverage_report.sh script

* chore: Update changed-files action to latest version

* chore: Update actions/checkout to v4.1.6 in ci.yml

* chore: Update actions/checkout to v4.1.6

* chore: Remove unused `test()` functions

* chore: Update generate_coverage_report.sh to use forge coverage command with lcov report

* clean+attempt to fix

* dev notes

* chore: Update skipFiles in .solcover.js to exclude more directories

* chore: Update generate_coverage_report.sh to create necessary directories if they do not exist

* chore: Update file path for Foundry Coverage Report in ci.yml

* compiler warning: Update test_SupportsModule functions to be view functions

* fix compiler warnings

* warning fix

* chore: Update ci.yml to enable verbose mode and fail CI on error

* chore: Update ci.yml to enable verbose mode and fail CI on error

* chore: Update ci.yml to enable verbose mode and fail CI on error

* chore: Update generate_coverage_report.sh to check if coverage file is created and list generated files

* update the tests

* revert solc warning

* lint fixes

* chore: Refactor TestAccountExecution_ExecuteFromExecutor.t.sol

* chore: Remove hardhat-foundry import from hardhat.config.ts

* chore: Update ci.yml to enable verbose mode and fail CI on error

* chore: Update codecov-action configuration to use the correct file path for coverage report

* chore: Update ci.yml to exclude additional Slither checks

* chore: Update ci.yml to include coverage/foundry directory for Codecov upload

* chore: Update comment.js to handle empty Slither reports

* chore: Refactor comment.js to handle empty Slither reports more efficiently

* Refactor comment.js to handle empty Slither reports more efficiently

* lint fix + Refactor comment.js to handle empty Slither reports more efficiently

* chore: Update ci.yml to only trigger on pull requests

* Refactor comment.js to handle empty Slither reports more efficiently

* Refactor comment.js to handle empty Slither reports more efficiently

* fix comment.js

* Refactor comment.js to handle empty Slither reports more efficiently

* Refactor comment.js to handle empty Slither reports more efficiently

* Refactor comment.js to handle empty Slither reports more efficiently

* Refactor comment.js to handle empty Slither reports more efficiently

* revert changes

* refactor wording in 1271

* handle upgrade case for getImplementation

* chore: Refactor contracts names

* refactor: Update MockPaymaster to extend VerifyingPaymaster

* feat: Add NexusTest_Base import to ArbitrumSettings

* refactor: Remove unused function getArbitrumRpcUrl

* refactor: Update BaseSettings to include NexusTest_Base import and getBaseRpcUrl function

* lint fix

* refactor: Update BaseSettings to include NexusTest_Base import and getBaseRpcUrl function

* refactor: Update BaseSettings to include NexusTest_Base import and getBaseRpcUrl function

* refactor: Update MockPaymaster to extend VerifyingPaymaster

* refactor: Adjust preVerificationGas in buildPackedUserOp function

* remove duplicate test

* refactor: Add MockPaymaster import to TestHelper.t.sol

* refactor: Add checkPaymasterBalance modifier to NexusTest_Base

* refactor paymaster tests, fix issues

* refactor: Generate Gas Report script

* refactor: Add generate-and-push-gas-report script

* refactor: Add gas consumption test for swapping ETH for USDC with deployed Nexus account and Paymaster

* refactor: Remove unused Husky hooks

* refactor: Add gas consumption test for swapping WETH for USDC with deployed Nexus account and Paymaster

* refactor: Remove unused Husky hooks

* refactor: Update prepare script in package.json

* refactor: Add gas consumption test for transferring ERC20 tokens from an already deployed Nexus smart account using a paymaster

* refactor: Remove unused Husky hooks

* refactor: Update pre-push Husky hook to include lint-fix and generate-and-push-gas-report scripts

* refactor: Add gas consumption test for transferring ERC20 tokens from an already deployed Nexus smart account using a paymaster

* refactor: Add gas consumption test for transferring ERC721 tokens from an already deployed Nexus smart account using a paymaster

* refactor: Add gas consumption test for transferring ETH from an already deployed Nexus smart account using a paymaster

* refactor: Add gas consumption test for transferring ERC721 tokens from an already deployed Nexus smart account using a paymaster

* refactor: Update pre-push Husky hook to include lint:fix and generate-and-push-gas-report scripts

* refactor: Add gas consumption test for transferring ETH from an already deployed Nexus smart account using a paymaster

* refactor: Update gas consumption test for transferring ERC20 tokens from an already deployed Nexus smart account using a paymaster

* Update gas report

* fix lint

* Update gas report

* refactor: Update fallback function tests to use successFunction instead of staticFunction and singleFunction

* refactor: Update MockHandler contract to remove unused functions and improve code readability

* Update gas report

* refactor: Remove gasIntensiveFunction from MockHandler contract

* Update gas report

* Update gas report

* Update gas report

* Update gas report

* merge and fix

* slot reads + ready for review

* chore: Fix indentation

* 🔒 Improve security on fallback handler installation process

* factory and module manager basic tests

* Update gas report file name to uppercase + run prettier

* feat: Update gas report file name to uppercase

* refactor

* chore: Update CI workflow to trigger only on pull requests

* chore: Refactor TestNexusSwapWETH_Integration.t.sol

* refactor: Add K1Validator to Imports.sol

* chore: Add EntryPointCannotBeZero error to EventsAndErrors.sol

* add k1 validator tests

* lint fix

* remove branch coverage option (not working properly)

* lint fix (indent)

* coverage: Add ERC-6492 signature validation tests (need check)

* Use K1Validator module instead of MockValidator

* feat: Add test for Nexus contract constructor with zero entry point address

* update gas report

* rename to Nexus

* stakeable contract tests + utils

* fix typos in MetaFactory and change path for Stakeable

* check and update two slots

* improved testing, implemented more factory tests

* skip files

* added missing import

* refactor: Add TestStakeable contract for unit testing Stakeable contract

* chore: Add Unauthorized error to EventsAndErrors.sol

* respond to PR comments

* lint and rename

* refactor: Update BaseAccount.sol natspec

* fix lint

* chore: Improve fallback handler comments

* Feat/improve gas report (#90)

* chore: numbered tests for gas report

* Update gas report

* chore: Update gas report script and add gas report comparison

* chore: Update gas report script and improve gas report generation

* chore: Update gas report script paths for gas report generation and comparison

* chore: Update gas report script paths and improve gas report generation

* chore: Improve gas report workflow

* chore: Add error handling for missing previous gas report

* chore: Update gas report workflow and script paths

* chore: Update gas report workflow and script paths

* chore: Update gas report workflow and script paths

* chore: Update gas report workflow and script paths

* chore: Update gas report workflow and script paths

* chore: Update gas report workflow and script paths

* negative test cases

* refactor: Update gas report script paths and improve generation

* Feat/fix gas ci (#91)

* chore: Update gas report script paths and improve gas report generation

* chore: Update gas report script paths and improve gas report generation

* chore: Update gas report script paths and improve gas report generation

* feat: Update gas report script paths and improve generation

* refactor: Update gas report script paths and improve generation

* negative test + refactor

* Feat/refactor factory and tests (#92)

* feat: Add AbstractNexusFactory contract

This commit adds the `AbstractNexusFactory` contract, which provides common functionality for Nexus factories. It enables the creation and management of Modular Smart Accounts. The contract includes a constructor to set the smart account implementation address and the factory owner. It also includes functions to create a new Nexus with initialization data and compute the expected address of a Nexus contract using the factory's deterministic deployment algorithm.

* Refactor the Nexus contract to improve code readability and maintainability. Also, fix the revert message from "EntryPointCannotBeZero" to "EntryPointCanNotBeZero" for consistency.

* feat: Whitelist factory address in BiconomyMetaFactory

This commit adds functionality to whitelist factory addresses in the BiconomyMetaFactory contract. It ensures that only whitelisted factories can be used for deployment. Additionally, it includes error handling for invalid factory addresses and zero owner addresses in the constructor.

* feat: Improve K1ValidatorFactory contract

This commit improves the K1ValidatorFactory contract by making the following changes:
- Renaming the contract to "K1ValidatorFactory for Nexus Account" for clarity.
- Removing the dependency on the BootstrapUtil library and updating the import statement accordingly.
- Adding error handling for zero addresses in the constructor.
- Refactoring the createAccount function to compute the actual salt for deterministic deployment.
- Using the BootstrapLib library to create the validator configuration.
- Initializing the account only if it was not already deployed.
- Updating the computeAccountAddress function to compute the actual salt for deterministic deployment.
- Predicting the deterministic address using the LibClone library.

These changes enhance the readability, maintainability, and functionality of the K1ValidatorFactory contract.

* feat: Improve K1ValidatorFactory contract

* feat: Refactor NexusAccountFactory contract for improved readability and maintainability

This commit refactors the NexusAccountFactory contract to enhance its readability and maintainability. The following changes were made:
- Renamed the contract to "Nexus Account Factory" for clarity.
- Removed unnecessary comments and unused imports.
- Inherited from the AbstractNexusFactory contract to leverage common functionality.
- Updated the constructor to set the smart account implementation address and owner using the AbstractNexusFactory constructor.
- Updated the createAccount function to compute the actual salt for deterministic deployment.
- Removed the unused computeAccountAddress function.
- Improved code formatting and documentation.

These changes improve the overall quality and maintainability of the NexusAccountFactory contract.

* feat: Fix typo in INexus contract error message

* feat: Add IAbstractNexusFactory interface

This commit adds the `IAbstractNexusFactory` interface, which defines the essential structure for Nexus factories. It includes functions to create a new Nexus with initialization data and compute the expected address of a Nexus contract using the factory's deterministic deployment algorithm. The interface also includes events and error handling for the creation of Smart Accounts.

* feat: Add BootstrapLib library for creating and managing BootstrapConfig structures

This commit adds the `BootstrapLib` library, which provides utility functions for creating and managing `BootstrapConfig` structures. The library includes functions to create a single `BootstrapConfig` structure, an array with a single `BootstrapConfig` structure, and an array of `BootstrapConfig` structures. These functions allow for easy configuration of modules and their initialization data. The library enhances the readability and maintainability of the code by providing a standardized way to create and manage `BootstrapConfig` structures.

* feat: Refactor NexusAccountFactory contract for improved readability and maintainability

* refactor: Update NexusAccountUpgradeTest contract to use BootstrapLib for creating BootstrapConfig structures

This commit updates the NexusAccountUpgradeTest contract to utilize the newly added BootstrapLib library for creating and managing BootstrapConfig structures. By using the library's utility functions, the code becomes more readable and maintainable. This change enhances the overall quality of the contract and improves the developer experience.

* lint fix

* refactor: Remove unused code in UpgradeSmartAccountTest.t.sol

* refactor: Rename variable in TestStakeable contract for clarity

This commit renames the variable `stakeable` to `_stakeable` in the TestStakeable contract. The new name provides better clarity and improves the readability of the code.

* feat: Add TestBiconomyMetaFactory_Deployments contract for managing factory whitelist and deploying accounts

This commit adds the TestBiconomyMetaFactory_Deployments contract, which is responsible for managing the factory whitelist and deploying accounts using the BiconomyMetaFactory. The contract includes functions to add and remove factories from the whitelist, deploy accounts using whitelisted factories, and validate factory addresses. Additionally, it tests various scenarios related to factory whitelisting and account deployment. This new contract enhances the functionality and flexibility of the system.

* feat: Add TestK1ValidatorFactory_Deployments contract for deploying accounts using the K1ValidatorFactory

This commit adds the TestK1ValidatorFactory_Deployments contract, which is responsible for deploying accounts using the K1ValidatorFactory. The contract includes functions to set up the testing environment, test the constructor's functionality, and validate the deployment of accounts. This new contract enhances the testing capabilities and ensures the correct deployment of accounts using the K1ValidatorFactory.

* feat: Add TestK1ValidatorFactory_Deployments contract for deploying accounts using the K1ValidatorFactory

* feat: Add TestK1ValidatorFactory_Deployments contract for deploying accounts using the K1ValidatorFactory

* rename lib

* refactor: add error message in EventsAndErrors.sol + new imports

* fix fuzz test for account factory

* feat: Add input validation for random function selector in fuzz test

* refactor: Rename BootstrapUtil to BootstrapLib for clarity

* add libraries and fixed tests

* feat: Add Nexus contracts for Modular Smart Account compliance

This commit adds the Nexus contracts for Modular Smart Account compliance. These contracts are developed by Biconomy and are compliant with ERC-7579 and ERC-4337. The Nexus contracts provide a suite of contracts for creating modular smart accounts. They include the AbstractNexusFactory, ModuleWhitelistFactory, and NexusAccountFactory contracts. These contracts enhance the functionality and flexibility of the system. Learn more at https://biconomy.io.

* refactor: Add error message in EventsAndErrors.sol

* refactor: Organize imports in Imports.sol

* refactor: Backup current gas report before generating a new one

* refactor:   current gas report before generating a new one

* refactor: Backup current gas report before generating a new one

* refactor: Update gas report generation process and file names

* Feat/missing coverage (#93)

* refactor: Add unit tests for TestAccountExecution_ExecuteUserOp contract

* refactor: Update gas report generation process and file names

* refactor: Improve executeUserOp function in Nexus.sol

* refactor: Remove  errors in INexus.sol

* refactor: moved Nexus Errors / Events to INexusEventsAndErrors.sol

* remove compiler warnings

* refactor and improve style of tests and namings

* refactor: Improve executeUserOp function and comments in Nexus.sol

* refactor: Remove original lcov.info and coverage.json files

* refactor: Add codecov configuration file

* Remove gas logging + fix pr comment

* refactor: Improve test coverage and naming conventions

* refactor: Update codecov configuration to ignore scripts and test directories

* Chore/clean repo update comments (#94)

* remove todo

* Add natspec + inline comments + description

* feat: Refactor test tree descriptions for improved readability and clarity

* fix natspecs+ Refactor NexusAccountFactory constructor parameter names

* update report

* feat: Refactor codecov.yml

* feat: Fix uninitialized variable in Nexus.sol

* feat: Refactor NexusAccountFactory contract for improved readability and maintainability

* Refactor NexusAccountFactory contract for improved readability and maintainability

* Feat/solidity 0.8.26 (#81)

* chore: Update solc version to 0.8.26

* chore: Update solc version to 0.8.26

* chore: Update solc version to 0.8.26

* chore: Update solc version to 0.8.26

* refactor: Change external functions to internal in TestNexusERC721Integration contract

* refactor: Change function visibility from external to internal in TestHelper contract

* chore: Update npm dependencies to latest versions

* chore: Update solidity version to 0.8.26 with viaIR optimization

* chore: Update solidity version to 0.8.26 with viaIR optimization

* lint fix

* refactor: Update coverage script to use --ir-minimum flag

* refactor: Update coverage script to use --ir-minimum flag

* refactor: Update coverage script to use --ir-minimum flag

* chore: Update CI workflow to include git pull before committing gas report changes

* chore: Update CI workflow to include git pull before committing gas report changes

* refactor: Update coverage script to remove --ir-minimum flag

* chore: Update CI workflow to work on pr only

* feat: Update ModuleWhitelistFactory to use isModuleWhitelisted instead of isWhitelisted

The commit updates the ModuleWhitelistFactory contract to use the isModuleWhitelisted function instead of the deprecated isWhitelisted function. This change ensures that all modules are properly whitelisted before execution.

* push new gas report

* feat: Update solidity version to 0.8.26 in AbstractNexusFactory.sol

* Update solidity version to 0.8.26 in AbstractNexusFactory.sol

* feat: Update solidity version to 0.8.26 in BootstrapLib.sol

* feat: Add error messages for new events in EventsAndErrors.sol

* feat: Update TestBiconomyMetaFactory_Deployments contract to handle revert message change

* refactor: Update NexusAccountFactory contract for improved readability and maintainability

* refactor: Restrict fallback handler manipulation in ModuleManager.sol

The commit restricts the manipulation of the fallback handler in the ModuleManager contract to ensure the account's security and integrity. It prevents unauthorized uninstallation and reinstallation of the validator module, which could compromise the account's security. Additionally, it checks for the presence of an existing fallback handler to avoid overwriting it and causing unexpected behavior.

* feat: Add error handling for invalid EntryPoint address

The commit adds error handling for an invalid EntryPoint address in the Stakeable contract. This ensures that only valid addresses can be used when adding, unlocking, or withdrawing stakes.

* refactor: Update AbstractNexusFactory constructor to use require instead of revert

The commit updates the constructor of the AbstractNexusFactory contract to use the require statement instead of revert. This change improves code readability and follows best practices for error handling.

* refactor: Update BiconomyMetaFactory constructor to use require instead of revert

The commit updates the constructor of the BiconomyMetaFactory contract to use the require statement instead of revert. This change improves code readability and follows best practices for error handling.

* refactor: Use require instead of revert in ModuleWhitelistFactory constructor and addModuleToWhitelist function

The commit updates the constructor of the ModuleWhitelistFactory contract to use the require statement instead of revert. This change improves code readability and follows best practices for error handling.

It also updates the addModuleToWhitelist function to use require instead of revert. This ensures that the module address being added to the whitelist is not a zero address.

Refactor the ModuleWhitelistFactory contract to improve code readability and maintainability.

* refactor: Update Stakeable contract error handling for invalid EntryPoint address

* remove natspec

* refactor: Add InnerCallFailed error to INexusEventsAndErrors.sol

The commit adds the InnerCallFailed error to the INexusEventsAndErrors.sol interface. This error is thrown when an inner call fails. This addition enhances the error handling capabilities of the interface.

Refactor the INexusEventsAndErrors.sol interface to include the InnerCallFailed error.

* refactor: Use require instead of revert in K1ValidatorFactory constructor

The commit updates the constructor of the K1ValidatorFactory contract to use the require statement instead of revert. This change improves code readability and follows best practices for error handling.

* Update  GAS_REPORT.md and gas_report.json

* lint fix

* lint fix

* refactor: Update Stakeable contract error handling for invalid EntryPoint address

* update versions nexus to 1.0.0-beta

* lint fix

* fix conflicts

* remove Husky hooks and gas report generation + lint fix + clean + badge update

---------

Co-authored-by: livingrockrises <[email protected]>
Co-authored-by: GabiDev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant