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

[WIP] Session Activity Factory #230

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

Conversation

pano-skylakis
Copy link
Contributor

No description provided.

Copy link

openzeppelin-code bot commented Jun 14, 2024

[WIP] Session Activity Factory

Generated at commit: dfbd0002f67b152b48cdf7adcbb2224ea62c21a6

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
2
1
0
11
29
43
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

Comment on lines +40 to +43
address private _pauser;

/// @notice The address for the unpauser role on the SessionActivity contract
address private _unpauser;
Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe have setPauserAndUnpauser() function?

Comment on lines 69 to 73
for (uint256 i = 0; i < names.length; i++) {
if (keccak256(abi.encodePacked(names[i])) == keccak256(abi.encodePacked(name))) {
revert NameAlreadyRegistered();
}
}
Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor

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();
}

@cajames cajames requested a review from drinkcoffee June 17, 2024 01:01
mapping(string name => address deployedContract) public sessionActivityContracts;

/// @notice Array of deployed SessionActivity contracts
address[] public deployedContracts;
Copy link
Contributor

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)

Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

see above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants