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

fix: various bugs/missing features #7

Merged
merged 29 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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
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
Next Next commit
feat: make storage 4337 compliant
  • Loading branch information
kopy-kat committed Jun 27, 2024
commit a8d25f7fe07e04af02738f806c78bd21f134dc01
3 changes: 1 addition & 2 deletions src/core/Initializer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import { ISafe7579 } from "../ISafe7579.sol";
import { ISafe } from "../interfaces/ISafe.sol";
import "../DataTypes.sol";

Check warning on line 6 in src/core/Initializer.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

global import of path ../DataTypes.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)
import { ModuleInstallUtil } from "../utils/DCUtil.sol";
import { ModuleManager } from "./ModuleManager.sol";

import {
IValidator,

Check warning on line 11 in src/core/Initializer.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

imported name IValidator is not used
MODULE_TYPE_VALIDATOR,
MODULE_TYPE_HOOK,
MODULE_TYPE_EXECUTOR,
Expand Down Expand Up @@ -106,9 +106,8 @@
revert InvalidInitData(msg.sender);
}

SentinelListLib.SentinelList storage $executors = $executorStorage[msg.sender];
// this will revert if already initialized.
$executors.init();
$executors.init({ account: msg.sender });

length = executors.length;
for (uint256 i; i < length; i++) {
Expand Down
57 changes: 31 additions & 26 deletions src/core/ModuleManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { IModule, IHook } from "../interfaces/IERC7579Module.sol";
import { ISafe } from "../interfaces/ISafe.sol";
import { ISafe7579 } from "../ISafe7579.sol";
import "../DataTypes.sol";

Check warning on line 9 in src/core/ModuleManager.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

global import of path ../DataTypes.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)

import { RegistryAdapter } from "./RegistryAdapter.sol";
import { Receiver } from "erc7579/core/Receiver.sol";
Expand Down Expand Up @@ -116,8 +116,8 @@
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* EXECUTOR MODULES */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
mapping(address smartAccount => SentinelListLib.SentinelList _executors) internal
$executorStorage;

SentinelList4337Lib.SentinelList internal $executors;

modifier onlyExecutorModule() {
if (!_isExecutorInstalled(_msgSender())) revert InvalidModule(_msgSender());
Expand All @@ -138,8 +138,7 @@
withRegistry(executor, MODULE_TYPE_EXECUTOR)
returns (bytes memory moduleInitData)
{
SentinelListLib.SentinelList storage $executors = $executorStorage[msg.sender];
$executors.push(executor);
$executors.push({ account: msg.sender, newEntry: executor });
return data;
}

Expand All @@ -156,38 +155,44 @@
internal
returns (bytes memory moduleDeInitData)
{
SentinelListLib.SentinelList storage $executors = $executorStorage[msg.sender];
address prev;
(prev, moduleDeInitData) = abi.decode(data, (address, bytes));
$executors.pop(prev, executor);
$executors.pop({ account: msg.sender, prevEntry: prev, popEntry: executor });
}

function _isExecutorInstalled(address executor) internal view virtual returns (bool) {
SentinelListLib.SentinelList storage $executors = $executorStorage[msg.sender];
return $executors.contains(executor);
function _isExecutorInstalled(address executor)
internal
view
virtual
returns (bool isInstalled)
{
isInstalled = $executors.contains({ account: msg.sender, entry: executor });
}

/**
* Get paginated list of installed executors
*/
function getExecutorsPaginated(
address cursor,
uint256 size
uint256 pageSize
)
external
view
virtual
returns (address[] memory array, address next)
{
SentinelListLib.SentinelList storage $executors = $executorStorage[msg.sender];
return $executors.getEntriesPaginated(cursor, size);
return $executors.getEntriesPaginated({
account: msg.sender,
start: cursor,
pageSize: pageSize
});
}

/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* FALLBACK MODULES */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

mapping(address smartAccount => mapping(bytes4 selector => FallbackHandler handlerConfig))
mapping(bytes4 selector => mapping(address smartAccount => FallbackHandler handlerConfig))
internal $fallbackStorage;

function _installFallbackHandler(
Expand Down Expand Up @@ -215,15 +220,15 @@

if (_isFallbackHandlerInstalled(functionSig)) revert FallbackInstalled(functionSig);

FallbackHandler storage $fallbacks = $fallbackStorage[msg.sender][functionSig];
FallbackHandler storage $fallbacks = $fallbackStorage[functionSig][msg.sender];
$fallbacks.calltype = calltype;
$fallbacks.handler = handler;

return initData;
}

function _isFallbackHandlerInstalled(bytes4 functionSig) internal view virtual returns (bool) {
FallbackHandler storage $fallbacks = $fallbackStorage[msg.sender][functionSig];
FallbackHandler storage $fallbacks = $fallbackStorage[functionSig][msg.sender];
return $fallbacks.handler != address(0);
}

Expand All @@ -238,7 +243,7 @@
bytes4 functionSig;
(functionSig, moduleDeInitData) = abi.decode(context, (bytes4, bytes));

FallbackHandler storage $fallbacks = $fallbackStorage[msg.sender][functionSig];
FallbackHandler storage $fallbacks = $fallbackStorage[functionSig][msg.sender];
delete $fallbacks.handler;
}

Expand All @@ -253,7 +258,7 @@
{
bytes4 functionSig = abi.decode(additionalContext, (bytes4));

FallbackHandler storage $fallbacks = $fallbackStorage[msg.sender][functionSig];
FallbackHandler storage $fallbacks = $fallbackStorage[functionSig][msg.sender];
return $fallbacks.handler == _handler;
}

Expand Down Expand Up @@ -284,7 +289,7 @@
returns (bytes memory fallbackRet)
{
// get handler for specific function selector
FallbackHandler storage $fallbacks = $fallbackStorage[msg.sender][msg.sig];
FallbackHandler storage $fallbacks = $fallbackStorage[msg.sig][msg.sender];
address handler = $fallbacks.handler;
CallType calltype = $fallbacks.calltype;
// if no handler is set for the msg.sig, revert
Expand Down Expand Up @@ -315,7 +320,7 @@
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

mapping(address smartAccount => address globalHook) internal $globalHook;
mapping(address smartAccount => mapping(bytes4 => address hook)) internal $hookManager;
mapping(bytes4 selector => mapping(address smartAccount => address hook)) internal $hookManager;

/**
* Run precheck hook for global and function selector specific
Expand Down Expand Up @@ -381,15 +386,15 @@
*/
modifier withHook(bytes4 selector) {
address globalHook = $globalHook[msg.sender];
address sigHook = $hookManager[msg.sender][selector];
address sigHook = $hookManager[selector][msg.sender];
(bytes memory global, bytes memory sig) = _preHooks(globalHook, sigHook);
_;
_postHooks(globalHook, sigHook, global, sig);
}

modifier tryWithHook(address module, bytes4 selector) {
address globalHook = $globalHook[msg.sender];
address sigHook = $hookManager[msg.sender][selector];
address sigHook = $hookManager[selector][msg.sender];

if (module != globalHook && module != sigHook) {
(bytes memory global, bytes memory sig) = _preHooks(globalHook, sigHook);
Expand Down Expand Up @@ -429,13 +434,13 @@
}
$globalHook[msg.sender] = hook;
} else if (hookType == HookType.SIG) {
currentHook = $hookManager[msg.sender][selector];
currentHook = $hookManager[selector][msg.sender];
// Dont allow hooks to be overwritten. If a hook is currently installed, it must be
// uninstalled first
if (currentHook != address(0)) {
revert HookAlreadyInstalled(currentHook);
}
$hookManager[msg.sender][selector] = hook;
$hookManager[selector][msg.sender] = hook;
} else {
revert InvalidHookType();
}
Expand All @@ -457,7 +462,7 @@
if (hookType == HookType.GLOBAL && selector == 0x0) {
delete $globalHook[msg.sender];
} else if (hookType == HookType.SIG) {
delete $hookManager[msg.sender][selector];
delete $hookManager[selector][msg.sender];
} else {
revert InvalidHookType();
}
Expand All @@ -476,7 +481,7 @@
hook = $globalHook[msg.sender];
}
if (hookType == HookType.SIG) {
hook = $hookManager[msg.sender][selector];
hook = $hookManager[selector][msg.sender];
}
}

Expand All @@ -494,7 +499,7 @@
}

function getActiveHook(bytes4 selector) public view returns (address hook) {
return $hookManager[msg.sender][selector];
return $hookManager[selector][msg.sender];
}

function getActiveHook() public view returns (address hook) {
Expand Down
Loading