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

Feat/guardian module #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Feat/guardian module #1

wants to merge 4 commits into from

Conversation

calvogenerico
Copy link
Collaborator

Description

Additional context

Created GuardianRecoveryValidator structure to start development
implemented proposeRecoveryKey and addRecoveryKey with tests.
@calvogenerico calvogenerico requested review from MiniRoman and aon January 9, 2025 12:23
// If the guardian exist this method stops
for (uint i = 0; i < guardians.length; i++) {
if (guardians[i].addr == newGuardian) {
return;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should revert in this case

src/validators/GuardianRecoveryValidator.sol Show resolved Hide resolved
Guardian[] storage guardians = accountGuardians[msg.sender];

// If the guardian exist this method stops
for (uint i = 0; i < guardians.length; i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please replace all uint variable types for uint256

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👌

bool isReady;
}

mapping(address account => Guardian[]) accountGuardians;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps an approach of:

struct GuardianStatus { bool proposed; bool ready }

mapping(address account => mapping (address guardian => GuardianStatus)) guardians;

Might be more gas efficient.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we do that we cannot remove all the guardians for an account or list all the guardians of an account. Not sure how bad is that.

Comment on lines +76 to +78
bool retValue = !guardians[i].isReady;
guardians[i].isReady = true;
return retValue;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should revert if the guardian is already confirmed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They do the return false things in other modules. That's why I did it in this way.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes but that's usually done when the functions are meant to be called by other contracts. In this case, we don't want the user wasting gas in case they're already guardians.

When a user tries to remove a guardian that does not exist
we revert the tx.
Using uint256 instead of uint everywhere.
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