-
Notifications
You must be signed in to change notification settings - Fork 36
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
[WIP] Session Activity Factory #230
base: main
Are you sure you want to change the base?
Conversation
[WIP] Session Activity Factory
🚨 Report Summary
For more details view the full report in OpenZeppelin Code Inspector |
address private _pauser; | ||
|
||
/// @notice The address for the unpauser role on the SessionActivity contract | ||
address private _unpauser; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking for specific feedback and suggestions for effective role management for the Factory + deployed contracts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would the same pauser and unpauser be used all the time?
What happens is the pauser or unpauser account are compromised?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe have setPauserAndUnpauser() function?
for (uint256 i = 0; i < names.length; i++) { | ||
if (keccak256(abi.encodePacked(names[i])) == keccak256(abi.encodePacked(name))) { | ||
revert NameAlreadyRegistered(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something more robust may be needed here. Is Guild Wars
the same as Guildwars
or GuildWars
?
Another consideration: would we ever want to deploy a separate contract for the same game?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This construct is super gas inefficient:
- There is a for loop
- The bytes32 for keccak256(abi.encodePacked(name)) happens each loop. This is likely to result in a memory expansion for each time through the loop which will cost $$$LOTS
- keccak256(abi.encodePacked(names[i])) is also going to result in lots of memory expansion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this code to:
if (sessionActivityContracts[name] != address(0)) {
revert NameAlreadyRegistered();
}
mapping(string name => address deployedContract) public sessionActivityContracts; | ||
|
||
/// @notice Array of deployed SessionActivity contracts | ||
address[] public deployedContracts; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This declaration will result in an accessor that returns an array. If there are a lot of values, this could result in a out of gas error (yes, for a view call)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is, if we get to 100,000 (or maybe just 10,000) values. If we feel that it is unlikely to ever happen, then it is probably OK. An alternative would be to have a function to return how many contracts have been deployed, and another function to request, starting at contract N, return information for up to M contracts.
address[] public deployedContracts; | ||
|
||
/// @notice Array of deployed SessionActivity contract names | ||
string[] public names; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
No description provided.