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: [spearbit-72] cache dependencies.length earlier #40

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/account/PluginManagerInternals.sol
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,11 @@ abstract contract PluginManagerInternals is IPluginManager, AccountStorageV1 {
}

// Check that the dependencies match the manifest.
if (dependencies.length != manifest.dependencyInterfaceIds.length) {
uint256 length = dependencies.length;
if (length != manifest.dependencyInterfaceIds.length) {
revert InvalidDependenciesProvided();
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: can we get rid of the empty line here to indicate that the following for loop is a continued usage of length and logic on dependencies?

uint256 length = dependencies.length;
for (uint256 i = 0; i < length;) {
// Check the dependency interface id over the address of the dependency.
(address dependencyAddr,) = dependencies[i].unpack();
Expand Down
23 changes: 12 additions & 11 deletions src/plugins/session/permissions/SessionKeyPermissionsPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,18 @@ contract SessionKeyPermissionsPlugin is ISessionKeyPermissionsPlugin, SessionKey

uint256 callsLength = calls.length;
// Only return validation success when there is at least one call
bool validationSuccess = calls.length > 0;
for (uint256 i = 0; i < callsLength;) {
Call memory call = calls[i];
nativeTokenSpend += call.value;
validationSuccess = validationSuccess
&& _checkCallPermissions(
sessionKeyData.contractAccessControlType, keyId, call.target, call.value, call.data
);

unchecked {
++i;
bool validationSuccess = callsLength > 0;
{
ContractAccessControlType accessControlType = sessionKeyData.contractAccessControlType;
for (uint256 i = 0; i < callsLength;) {
Call memory call = calls[i];
nativeTokenSpend += call.value;
validationSuccess = validationSuccess
&& _checkCallPermissions(accessControlType, keyId, call.target, call.value, call.data);

unchecked {
++i;
}
}
}

Expand Down