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

Update ModuleManager.sol #792

Closed
wants to merge 1 commit into from
Closed

Conversation

mytudan
Copy link

@mytudan mytudan commented Jul 16, 2024

Based on the setupModules and enableModule methods in the ModuleManager, we can ascertain that SENTINEL_MODULES points to the head node. The linked list can be represented as follows: SENTINEL_MODULES --> newModule --> ModuleA --> ModuleB --> ModuleC --> address(0x01).

Given this, isn't there redundancy in the getModulesPaginated method? For example, the check next != SENTINEL_MODULES seems redundant because next can never be SENTINEL_MODULES as it points to the head node. Moreover, the first line of the getModulesPaginated method already ensures that start != SENTINEL_MODULES.

Based on the setupModules and enableModule methods in the ModuleManager, we can ascertain that SENTINEL_MODULES points to the head node. The linked list can be represented as follows: SENTINEL_MODULES --> newModule --> ModuleA --> ModuleB --> ModuleC --> address(0x01).

Given this, isn't there redundancy in the getModulesPaginated method? For example, the check next != SENTINEL_MODULES seems redundant because next can never be SENTINEL_MODULES as it points to the head node. Moreover, the first line of the getModulesPaginated method already ensures that start != SENTINEL_MODULES.
Copy link

github-actions bot commented Jul 16, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@mytudan
Copy link
Author

mytudan commented Jul 16, 2024

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Jul 16, 2024
@mytudan mytudan closed this Jul 16, 2024
@remedcu
Copy link
Member

remedcu commented Jul 16, 2024

The linked list can be represented as follows: SENTINEL_MODULES --> newModule --> ModuleA --> ModuleB --> ModuleC --> address(0x01).

The SENTINEL_MODULES is address(0x1): https://github.com/safe-global/safe-smart-account/pull/792/files#diff-82762908b9416ddadffb149ee4d25f328078fc27f938d454d8a207aad1ec3839L59

the check next != SENTINEL_MODULES seems redundant because next can never be SENTINEL_MODULES as it points to the head node

So, the next (as it moves forward within the while loop) can become SENTINEL_MODULES eventually if the pageSize is greater than the remaining module list from the start.

You can see the tests failing here: https://github.com/safe-global/safe-smart-account/actions/runs/9949739616/job/27494234482?pr=792

Also, to check further with your implementation locally, you can run the test as mentioned in the README: https://github.com/safe-global/safe-smart-account/tree/main?tab=readme-ov-file#testing

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2024
@nlordell
Copy link
Collaborator

I think the proposed changes won't work. In particular, the empty module set is a linked list that looks like: SENTINEL -> SENTINEL. This means that, without the condition in the while loop, it will iterate forever.

@mytudan mytudan deleted the patch-1 branch July 16, 2024 07:57
@mytudan mytudan restored the patch-1 branch July 19, 2024 08:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants