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: Events and AccountLoupe revamp for data availability #122

Merged
merged 5 commits into from
Aug 1, 2024

Conversation

fangting-alchemy
Copy link
Collaborator

Revamp AccountLoupe and events for data availability

@fangting-alchemy fangting-alchemy requested a review from a team July 31, 2024 22:58
Copy link
Contributor

@adamegyed adamegyed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall! Some small comments

// Whether or not a global validation function may be used to validate this function.
bool allowGlobalValidation;
// The execution hooks for this function selector.
bytes32[] executionHooks;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should probably have the HookConfig type, so the caller can interpret them in the same way as they're used in the install interfaces

Copy link
Collaborator Author

@fangting-alchemy fangting-alchemy Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was thinking and choose to do the conversion on the SDK to avoid loops on the contract (same reason for the other two fields). Maybe it is worth it for callers not using our SDK.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see. I think we can merge the two loops if we want (loop 1 within .values(), and loop 2 in the loupe function). Left a comment with details.

src/interfaces/IAccountLoupe.sol Outdated Show resolved Hide resolved
src/interfaces/IAccountLoupe.sol Outdated Show resolved Hide resolved
Comment on lines 310 to 318
onUninstallSuccess = _onUninstall(hookModule, hookData);
hookIndex++;
}

for (uint256 i = 0; i < _validationData.permissionHooks.length(); ++i) {
bytes calldata hookData = hookUninstallDatas[hookIndex];
(address hookModule,) =
ModuleEntityLib.unpack(toModuleEntity(_validationData.permissionHooks.at(i)));
_onUninstall(hookModule, hookData);
onUninstallSuccess = _onUninstall(hookModule, hookData);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output of these two calls will be ignored when the value of onUninstallSuccess is overwritten on line 341.

If we want the variable to mean "did any of the calls fail", we can change this to be onUninstallSuccess = onUninstallSuccess && _onUninstall(...);, so that any failure bubbles up as a false.

But maybe we don't want that, since it wouldn't reveal which inner call failed. We could choose to ignore inner onUninstall call failuress instead. Wdyt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

Copy link
Contributor

@adamegyed adamegyed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 1 potential simplification to remove the 2 loops

Comment on lines 36 to 40
bytes32[] memory executionHooks = executionData.executionHooks.values();
uint256 executionHooksLen = executionHooks.length;
data.executionHooks = new HookConfig[](executionHooksLen);
for (uint256 i = 0; i < executionHooksLen; ++i) {
data.executionHooks[i] = HookConfig.wrap(bytes26(executionHooks[i]));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could simplify:

uint256 executionHooksLen = executionHooks.length;
data.executionHooks = new HookConfig[](executionHooksLen);
for (uint256 i = 0; i < executionHooksLen; ++i) {
    data.executionHooks[i] = HookConfig.wrap(bytes26(executionData.executionHooks.at(i)));
}

Same for the other cases where we use .values() and convert to a different type.

Not totally needed though, just an optimization.

@fangting-alchemy fangting-alchemy merged commit 29dcd83 into develop Aug 1, 2024
3 checks passed
@fangting-alchemy fangting-alchemy deleted the fangting/data branch August 1, 2024 21:48
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.

2 participants