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: add ERC7739 compatibility #241

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Conversation

howydev
Copy link
Collaborator

@howydev howydev commented Oct 12, 2024

Switch the current ReplaySafeHash scheme to use an ERC7739 compatible signature scheme instead

Implementation uses pieces from, and/or is inspired by Solady and ERC7579's ERC7739 validator implementation

Copy link

Summary by Octane

New Contracts

  • ERC7739ReplaySafeWrapper.sol: The smart contract provides ERC-7739 compliance for efficient, secure, nested EIP-712 wrappers facilitating ERC-1271 signature validation for smart contract accounts.

Updated Contracts

  • ModularAccountBase.sol: Smart contract now includes unique name/version hashes for enhanced identity validation, improving domain separation integrity.
  • SemiModularAccountBase.sol: The smart contract integrates ERC7739ReplaySafeWrapper, updates signature validation, and removes replay-safe hash functionality.
  • SemiModularKnownSelectorsLib.sol: Removed the replaySafeHash selector from the smart contract's supported functions.
  • ECDSAValidationModule.sol: The smart contract now utilizes ERC7739ReplaySafeWrapper and includes ERC-7739 signature validation format.
  • WebauthnValidationModule.sol: The smart contract now uses ERC7739ReplaySafeWrapper instead of ReplaySafeWrapper for improved signature validation.

🔗 Commit Hash: 42a24a4

Copy link

Contract sizes:

 | Contract                      | Size (B) | Margin (B) |
 |-------------------------------|----------|------------|
 | AccountFactory                |    4,814 |     19,762 |
 | AllowlistModule               |    9,156 |     15,420 |
-| ECDSAValidationModule         |    3,646 |     20,930 |
+| ECDSAValidationModule         |    4,208 |     20,368 |
 | ModularAccount                |   26,520 |     -1,944 |
 | NativeTokenLimitModule        |    4,652 |     19,924 |
 | PaymasterGuardModule          |    1,718 |     22,858 |
-| SemiModularAccountBytecode    |   28,371 |     -3,795 |
-| SemiModularAccountStorageOnly |   28,906 |     -4,330 |
+| SemiModularAccountBytecode    |   28,937 |     -4,361 |
+| SemiModularAccountStorageOnly |   29,472 |     -4,896 |
 | TimeRangeModule               |    1,870 |     22,706 |
-| WebauthnValidationModule      |    7,854 |     16,722 |
+| WebauthnValidationModule      |    8,444 |     16,132 |

Code coverage:

File % Lines % Statements % Branches % Funcs
src/account/AccountStorageInitializable.sol 89.47% (17/19) 96.15% (25/26) 80.00% (4/5) 100.00% (2/2)
src/account/BaseAccount.sol 87.50% (7/8) 85.71% (6/7) 50.00% (1/2) 100.00% (4/4)
src/account/ModularAccount.sol 100.00% (1/1) 100.00% (1/1) 100.00% (0/0) 100.00% (2/2)
src/account/ModularAccountBase.sol 95.09% (252/265) 96.07% (318/331) 84.09% (37/44) 100.00% (37/37)
src/account/ModularAccountView.sol 100.00% (26/26) 100.00% (33/33) 100.00% (2/2) 100.00% (2/2)
src/account/ModuleManagerInternals.sol 86.99% (107/123) 85.89% (140/163) 40.00% (6/15) 100.00% (12/12)
src/account/SemiModularAccountBase.sol 86.89% (53/61) 90.70% (78/86) 66.67% (10/15) 94.12% (16/17)
src/account/SemiModularAccountBytecode.sol 100.00% (5/5) 100.00% (6/6) 100.00% (1/1) 50.00% (1/2)
src/account/SemiModularAccountStorageOnly.sol 100.00% (4/4) 100.00% (5/5) 100.00% (0/0) 100.00% (2/2)
src/account/TokenReceiver.sol 33.33% (1/3) 33.33% (1/3) 100.00% (0/0) 33.33% (1/3)
src/factory/AccountFactory.sol 70.59% (24/34) 76.09% (35/46) 40.00% (2/5) 58.33% (7/12)
src/helpers/ERC7739ReplaySafeWrapper.sol 68.35% (54/79) 67.86% (57/84) 0.00% (0/2) 71.43% (5/7)
src/libraries/ExecutionLib.sol 98.15% (212/216) 97.21% (209/215) 81.82% (18/22) 100.00% (19/19)
src/libraries/KnownSelectorsLib.sol 100.00% (29/29) 100.00% (64/64) 100.00% (0/0) 100.00% (3/3)
src/libraries/LinkedListSetLib.sol 94.00% (47/50) 96.25% (77/80) 66.67% (4/6) 100.00% (8/8)
src/libraries/MemManagementLib.sol 100.00% (47/47) 100.00% (63/63) 100.00% (0/0) 100.00% (9/9)
src/libraries/SemiModularKnownSelectorsLib.sol 100.00% (5/5) 100.00% (10/10) 100.00% (0/0) 100.00% (1/1)
src/libraries/SparseCalldataSegmentLib.sol 100.00% (17/17) 100.00% (21/21) 100.00% (4/4) 100.00% (4/4)
src/modules/BaseModule.sol 100.00% (11/11) 93.33% (14/15) 100.00% (1/1) 100.00% (2/2)
src/modules/permissions/AllowlistModule.sol 83.72% (72/86) 83.93% (94/112) 78.26% (18/23) 44.44% (8/18)
src/modules/permissions/NativeTokenLimitModule.sol 87.80% (36/41) 89.66% (52/58) 88.89% (8/9) 54.55% (6/11)
src/modules/permissions/PaymasterGuardModule.sol 80.00% (8/10) 66.67% (10/15) 100.00% (2/2) 57.14% (4/7)
src/modules/permissions/TimeRangeModule.sol 83.33% (10/12) 80.00% (16/20) 100.00% (1/1) 62.50% (5/8)
src/modules/validation/ECDSAValidationModule.sol 92.00% (23/25) 81.08% (30/37) 62.50% (5/8) 90.00% (9/10)
src/modules/validation/WebauthnValidationModule.sol 66.67% (12/18) 73.08% (19/26) 100.00% (3/3) 60.00% (6/10)
Total 90.38% (1080/1195) 90.64% (1384/1527) 74.71% (127/170) 82.55% (175/212)

Copy link

Overview

Octane AI analysis has finished. No vulnerabilities were found. Cheers! 🎉🎉🎉


🔗 Commit Hash: 42a24a4

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