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

Convert module role hats to mutable #1

Merged
merged 7 commits into from
May 13, 2024
Merged

Convert module role hats to mutable #1

merged 7 commits into from
May 13, 2024

Conversation

spengrah
Copy link
Member

@spengrah spengrah commented May 11, 2024

Converts ownerHat and arbitratorHat from immutable "constants" to mutable storage values.

The reason to do this is that this module is stateful, which adds friction to migrating to a new instance in order to update owner or arbitrator roles.

There are two primary benefits of immutable config on modules

  1. simple to understand when/how they can be updated, ie by an admin of the hat as long as the hat is mutable
  2. some gas savings by using immutable values instead of storage reads

We can get the benefits of (1) in a mutable scenario by constraining changes to when the hat is mutable.

@spengrah spengrah requested a review from gershido May 11, 2024 19:05
@spengrah spengrah marked this pull request as ready for review May 11, 2024 19:08
@spengrah
Copy link
Member Author

spengrah commented May 11, 2024

@gershido do we need _setup() to emit events for the owner and arbitrator hats in order to track these authorities in the ancillary subgaph?

edit: applied in 130e8a1

Copy link

@gershido gershido left a comment

Choose a reason for hiding this comment

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

In addition to the comments, the rest of the functions documentation includes still the previous names - OWNER_HAT and ARBITRATOR_HAT. Regarding emitting events in the setup, it's easier with the events but we can also parse the initialization data in the subgraph handler if necessary, so both work.


/**
* @notice Set a new arbitrator hat
* @dev Only callable by a wearer of the current arbitratorHat, and only if the target hat is mutable

Choose a reason for hiding this comment

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

Documentation fix: "ownerHat" instead of "arbitratorHat". Or is the intention here is to provide the permission to the arbitrator?

Comment on lines 363 to 382
/**
* @dev Set a new owner hat
* @param _newOwnerHat The new owner hat
*/
function _setOwnerHat(uint256 _newOwnerHat) public {
ownerHat = _newOwnerHat;

emit OwnerHatSet(_newOwnerHat);
}

/**
* @dev Set a new arbitrator hat
* @param _newArbitratorHat The new arbitrator hat
*/
function _setArbitratorHat(uint256 _newArbitratorHat) public {
arbitratorHat = _newArbitratorHat;

emit ArbitratorHatSet(_newArbitratorHat);
}

Choose a reason for hiding this comment

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

The functions visibility is accidentally public

README.md Outdated
### Humanistic Functionality

- Wearer(s) of the `ownerHat` can manually revoke an account's hat by calling `removeAccountAndBurnHat()`.
- Wearer(s) of the `arbitrator` can manually put an account in bad standing and burn their hat `setStandingForAccountAndBurnHat()`.

Choose a reason for hiding this comment

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

arbitratorHat instead of arbitrator

README.md Outdated

- Wearer(s) of the `ownerHat` can simply add account(s) to the allowlist by calling `addAccount()` or `addAccounts()`.
- Wearer(s) of the `ownerHat` can simply remove account(s) from the allowlist by calling `removeAccount()` or `removeAccounts()`.
- Wearer(s) of the `arbitrator` can simply set the standing of account(s) by calling `setStandingForAccount()` or `setStandingForAccounts()`.

Choose a reason for hiding this comment

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

arbitratorHat instead of arbitrator

README.md Outdated
@@ -4,20 +4,22 @@ A [Hats Protocol](https://github.com/hats-protocol/hats-protocol) eligibility mo

## Overview and Usage

This module sets up a simple allowlist to determine eligibility for a hat. For a given account (i.e., potential hat wearer), the allowlist stores values for that account's eligibility and standing for the hat. The wearer(s) of the `OWNER_HAT` can add or remove accounts from the allowlist. The wearer(s) of the `ARBITRATOR_HAT` can set the standing of accounts.
This module sets up a simple allowlist to determine eligibility for a hat. For a given account (i.e., potential hat wearer), the allowlist stores values for that account's eligibility and standing for the hat. The wearer(s) of the `ownerHat` can add or remove accounts from the allowlist. The wearer(s) of the `arbitrator` can set the standing of accounts.

Choose a reason for hiding this comment

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

arbitratorHat instead of arbitrator

@gershido gershido self-requested a review May 12, 2024 18:56
Copy link

@gershido gershido left a comment

Choose a reason for hiding this comment

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

lgtm

@spengrah spengrah merged commit 23604b0 into main May 13, 2024
3 checks passed
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