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

remediations #4

Merged
merged 60 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
98f2eb9
fix: H1
zeroknots Jun 17, 2024
0e34dad
fix: H2. using _msgSender for registry check
zeroknots Jun 17, 2024
2406309
fix: M1
zeroknots Jun 17, 2024
77b9157
fix: M3
zeroknots Jun 17, 2024
fae3c77
fix: M4
zeroknots Jun 17, 2024
fc5404b
fix: M5
zeroknots Jun 17, 2024
7a53178
fix: L1
zeroknots Jun 17, 2024
0ca432c
fix: L2
zeroknots Jun 17, 2024
18e86b3
fix: L4
zeroknots Jun 17, 2024
0c612da
fix: W4
zeroknots Jun 17, 2024
f7eb247
fix: W5
zeroknots Jun 17, 2024
487e8c9
wip
zeroknots Jun 17, 2024
535e8f2
fix: I2
zeroknots Jun 17, 2024
f76e42f
fix: I3
zeroknots Jun 17, 2024
817ef13
fix: internal finding
zeroknots Jun 17, 2024
79c0094
fix: use operation enum for executions
zeroknots Jun 17, 2024
63af900
fix: slight gas improvement
zeroknots Jun 17, 2024
be9e05a
fix: H1
zeroknots Jun 18, 2024
bab5361
chore: improve readability
zeroknots Jun 18, 2024
a5e21e6
fix: H1 with EP in 2771
zeroknots Jun 18, 2024
73a9924
fix: add multitype uninstall function
zeroknots Jun 18, 2024
f1fdf78
fix: hook uninstall dos
zeroknots Jun 18, 2024
6200ed4
fix: W8
zeroknots Jun 18, 2024
d36bfed
chore: add test case
zeroknots Jun 18, 2024
4918df8
Update src/core/ModuleManager.sol
kopy-kat Jun 19, 2024
ecf38b5
Merge pull request #5 from rhinestonewtf/feature/fix-hook-uninstall-dos
kopy-kat Jun 19, 2024
180f0ac
hotfix: fixed typos flagged by Lukas
zeroknots Jun 21, 2024
1e61385
feat: add 4337 storage
kopy-kat Jun 27, 2024
ebef70c
Revert "feat: add 4337 storage"
kopy-kat Jun 27, 2024
a8d25f7
feat: make storage 4337 compliant
kopy-kat Jun 27, 2024
0506673
chore: renaming initializeAccount
zeroknots Jun 27, 2024
0f89432
feat: testing launchpad for 4337 compliance
zeroknots Jun 27, 2024
e7151ea
feat: adding launchpad function to allow existing safes to use launch…
zeroknots Jun 27, 2024
4f6daa3
feat: prototype implementation to allow safe checknsignature signers
zeroknots Jun 27, 2024
349ff72
fixed bug in validation
zeroknots Jun 28, 2024
128bf6a
wip
zeroknots Jun 28, 2024
3cac556
WIPip
zeroknots Jun 28, 2024
67cd00c
feat: all tests passing
kopy-kat Jun 28, 2024
7a66b3b
feature: clean up safe owner verification in launchpad
kopy-kat Jun 29, 2024
5092f78
feature: add existing safe test
kopy-kat Jun 29, 2024
8df99dd
feat: add support viewer contract
kopy-kat Jun 29, 2024
80a6c7a
chore: add deployments
kopy-kat Jun 29, 2024
b4ced92
chore: update supportviewer
kopy-kat Jun 30, 2024
ec0ebdf
Merge pull request #8 from rhinestonewtf/feature/safe-owner-cleanup
kopy-kat Jul 1, 2024
ca2d1a1
Merge pull request #9 from rhinestonewtf/feature/safe-owner-launchpad
kopy-kat Jul 1, 2024
8a1bde5
fix: tests
kopy-kat Jul 1, 2024
4573126
fix: abstract contracts
kopy-kat Jul 1, 2024
3dc8fdb
fix: linting
kopy-kat Jul 1, 2024
ca4ce07
chore: internal review
zeroknots Jul 1, 2024
dd2b4c5
rm: broadcast
zeroknots Jul 1, 2024
3c57ecd
feat: add safe as validator module addr
zeroknots Jul 1, 2024
45ccd05
chore: update lock
kopy-kat Jul 1, 2024
d961421
fix: relative imports
kopy-kat Jul 1, 2024
9bf62e7
fix: typo
kopy-kat Jul 5, 2024
065da36
fix: remove unused using for
kopy-kat Jul 5, 2024
1d25d2d
fix: update checknsignatures to latest
kopy-kat Jul 8, 2024
1a08bda
feat: add audit report
kopy-kat Jul 8, 2024
bedaf2f
Merge pull request #11 from rhinestonewtf/fix/final-remediations
kopy-kat Jul 8, 2024
ff8df1d
Merge pull request #7 from rhinestonewtf/feature/4337-compliance
kopy-kat Jul 8, 2024
e8cbed6
fix: ignore userOp builder lint
kopy-kat Jul 8, 2024
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
1 change: 1 addition & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
test/
src/utils/Safe7579UserOperationBuilder.sol
Binary file not shown.
91 changes: 0 additions & 91 deletions broadcast/Deploy.s.sol/11155111/run-1715275639.json

This file was deleted.

91 changes: 0 additions & 91 deletions broadcast/Deploy.s.sol/11155111/run-latest.json

This file was deleted.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@
"test:optimized": "pnpm run build:optimized && FOUNDRY_PROFILE=test-optimized forge test"
},
"dependencies": {
"@rhinestone/module-bases": "github:rhinestonewtf/module-bases",
"@ERC4337/account-abstraction": "github:kopy-kat/account-abstraction#develop",
"@ERC4337/account-abstraction-v0.6": "github:eth-infinitism/account-abstraction#v0.6.0",
"@rhinestone/erc4337-validation": "0.0.1-alpha.2",
"@rhinestone/module-bases": "github:rhinestonewtf/module-bases",
"@rhinestone/sentinellist": "github:rhinestonewtf/sentinellist",
"@rhinestone/checknsignatures": "github:rhinestonewtf/checknsignatures",
"@safe-global/safe-contracts": "^1.4.1",
"ds-test": "github:dapphub/ds-test",
"erc7579": "github:erc7579/erc7579-implementation",
Expand Down
742 changes: 442 additions & 300 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import { Safe7579 } from "src/Safe7579.sol";
import { Safe7579Launchpad } from "src/Safe7579Launchpad.sol";
import { IERC7484 } from "src/interfaces/IERC7484.sol";
import { MockRegistry } from "test/mocks/MockRegistry.sol";

Check warning on line 8 in script/Deploy.s.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

imported name MockRegistry is not used
import { Safe } from "@safe-global/safe-contracts/contracts/Safe.sol";

Check warning on line 9 in script/Deploy.s.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

imported name Safe is not used
import { SafeProxyFactory } from

Check warning on line 10 in script/Deploy.s.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

imported name SafeProxyFactory is not used
"@safe-global/safe-contracts/contracts/proxies/SafeProxyFactory.sol";
import { MockValidator } from "test/mocks/MockValidator.sol";

Check warning on line 12 in script/Deploy.s.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

imported name MockValidator is not used

/**
* @title Deploy
Expand All @@ -15,10 +20,16 @@
bytes32 salt = bytes32(uint256(0));

address entryPoint = address(0x0000000071727De22E5E9d8BAf0edAc6f37da032);
IERC7484 registry = IERC7484(0xe0cde9239d16bEf05e62Bbf7aA93e420f464c826);
IERC7484 registry = IERC7484(0x25A4b2F363678E13A0A5DB79b712dE00347a593E);

vm.startBroadcast(vm.envUint("PK"));

// new MockValidator{ salt: salt }();

// new Safe{ salt: salt }();
// new SafeProxyFactory{ salt: salt }();

// IERC7484 registry = new MockRegistry{ salt: salt }();
new Safe7579{ salt: salt }();
new Safe7579Launchpad{ salt: salt }(entryPoint, registry);

Expand Down
43 changes: 12 additions & 31 deletions src/ISafe7579.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
pragma solidity ^0.8.20;

import "./DataTypes.sol";
import { IERC7579Account } from "./interfaces//IERC7579Account.sol";

import { IERC7579Account } from "./interfaces/IERC7579Account.sol";
import { ModeCode } from "./lib/ModeLib.sol";
import { PackedUserOperation } from
"@ERC4337/account-abstraction/contracts/core/UserOperationLib.sol";
import { ISafeOp } from "./interfaces/ISafeOp.sol";

/**
* @title ERC7579 Adapter for Safe accounts.
* creates full ERC7579 compliance to Safe accounts
* @author rhinestone | zeroknots.eth, Konrad Kopp (@kopy-kat)
*/
interface ISafe7579 is IERC7579Account {
interface ISafe7579 is IERC7579Account, ISafeOp {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* Validation */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
Expand All @@ -30,7 +30,6 @@ interface ISafe7579 is IERC7579Account {
uint256 missingAccountFunds
)
external
payable
returns (uint256 packedValidSig);

/**
Expand Down Expand Up @@ -71,7 +70,7 @@ interface ISafe7579 is IERC7579Account {
* @param mode The encoded execution mode of the transaction. See ModeLib.sol for details
* @param executionCalldata The encoded execution call data
*/
function execute(ModeCode mode, bytes memory executionCalldata) external payable;
function execute(ModeCode mode, bytes memory executionCalldata) external;

/**
* @dev Executes a transaction on behalf of the Safe account.
Expand All @@ -95,7 +94,6 @@ interface ISafe7579 is IERC7579Account {
bytes memory executionCalldata
)
external
payable
returns (bytes[] memory returnDatas);

/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
Expand All @@ -117,13 +115,7 @@ interface ISafe7579 is IERC7579Account {
* @param initData arbitrary data that may be required on the module during `onInstall`
* initialization.
*/
function installModule(
uint256 moduleType,
address module,
bytes memory initData
)
external
payable;
function installModule(uint256 moduleType, address module, bytes memory initData) external;

/**
* Uninstalls a Module of a certain type on the smart account.
Expand All @@ -142,8 +134,7 @@ interface ISafe7579 is IERC7579Account {
address module,
bytes memory deInitData
)
external
payable;
external;

/**
* Function to check if the account has a certain module installed
Expand Down Expand Up @@ -190,8 +181,7 @@ interface ISafe7579 is IERC7579Account {
ModuleInit[] memory hooks,
RegistryInit memory registryInit
)
external
payable;
external;

/**
* This function is intended to be called by Launchpad.validateUserOp()
Expand All @@ -201,7 +191,7 @@ interface ISafe7579 is IERC7579Account {
* @dev Note: this function DOES NOT call onInstall() on the validator modules or emit
* ModuleInstalled events. this has to be done by the launchpad
*/
function launchpadValidators(ModuleInit[] memory validators) external payable;
function initializeAccountWithValidators(ModuleInit[] memory validators) external;

/**
* Configure the Safe7579 with a IERC7484 registry
Expand All @@ -214,8 +204,8 @@ interface ISafe7579 is IERC7579Account {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* Query Account Details */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
function getValidatorPaginated(
address start,
function getValidatorsPaginated(
address cursor,
uint256 pageSize
)
external
Expand Down Expand Up @@ -243,14 +233,7 @@ interface ISafe7579 is IERC7579Account {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* Query Misc */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
function supportsExecutionMode(ModeCode encodedMode) external pure returns (bool supported);
function supportsModule(uint256 moduleTypeId) external pure returns (bool);
function accountId() external view returns (string memory accountImplementationId);

/**
* Domain Separator for EIP-712.
*/
function domainSeparator() external view returns (bytes32);
/**
* Safe7579 is using validator selection encoding in the userop nonce.
* to make it easier for SDKs / devs to integrate, this function can be
Expand All @@ -264,18 +247,16 @@ interface ISafe7579 is IERC7579Account {
/* Custom Errors */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
error InvalidModule(address module);
error LinkedListError();
error InitializerError();
error ValidatorStorageHelperError();
error InvalidModuleType(address module, uint256 moduleType);

// fallback handlers
error InvalidInput();
error InvalidCallType(CallType callType);
error NoFallbackHandler(bytes4 msgSig);
error InvalidFallbackHandler(bytes4 msgSig);
error FallbackInstalled(bytes4 msgSig);

// Hooks
error HookPostCheckFailed();
error HookAlreadyInstalled(address currentHook);
error InvalidHookType();

Expand Down
Loading
Loading