rabbitholegg / quest-protocol

Quests Protocol is a protocol to distribute token rewards for completing on-chain tasks.
GNU General Public License v3.0
89 stars 23 forks source link

move to solady ownable on the factory #207

Closed waynehoover closed 1 year ago

waynehoover commented 1 year ago

closes https://github.com/rabbitholegg/quest-protocol/issues/166

main branch:

❯ forge inspect QuestFactory storage-layout --pretty Name Type Slot Offset Bytes
_initialized uint8 0 0 1
_initializing bool 0 1 1
__gap uint256[50] 1 0 1600
_owner address 51 0 20
__gap uint256[49] 52 0 1568
__gap uint256[50] 101 0 1600
_roles mapping(bytes32 => .) 151 0 32
__gap uint256[49] 152 0 1568
claimSignerAddress address 201 0 20
protocolFeeRecipient address 202 0 20
erc20QuestAddress address 203 0 20
erc1155QuestAddress address 204 0 20
quests mapping(string => struct IQuestFactory.Quest) 205 0 32
rabbitHoleReceiptContract address 206 0 20
rabbitHoleTicketsContract address 207 0 20
rewardAllowlist mapping(address => bool) 208 0 32
questFee uint16 209 0 2
mintFee uint256 210 0 32
defaultMintFeeRecipient address 211 0 20
locked uint256 212 0 32
defaultReferralFeeRecipient address 213 0 20
nftQuestFee uint256 214 0 32
questNFTAddress address 215 0 20
ownerCollections mapping(address => address[]) 216 0 32
nftQuestFeeList mapping(address => struct IQuestFactory.NftQuestFees) 217 0 32
referralFee uint16 218 0 2
sablierV2LockupLinearAddress address 218 2 20
mintFeeRecipientList mapping(address => address) 219 0 32

solady_ownable_on_factory branch

❯ forge inspect QuestFactory storage-layout --pretty Name Type Slot Offset Bytes
_initialized uint8 0 0 1
_initializing bool 0 1 1
__gap uint256[50] 1 0 1600
_owner address 51 0 20
__gap1 uint256[49] 52 0 1568
__gap2 uint256[50] 101 0 1600
_roles mapping(bytes32 => struct LegacyStorage.RoleData) 151 0 32
__gap3 uint256[49] 152 0 1568
claimSignerAddress address 201 0 20
protocolFeeRecipient address 202 0 20
erc20QuestAddress address 203 0 20
erc1155QuestAddress address 204 0 20
quests mapping(string => struct IQuestFactory.Quest) 205 0 32
rabbitHoleReceiptContract address 206 0 20
rabbitHoleTicketsContract address 207 0 20
rewardAllowlist mapping(address => bool) 208 0 32
questFee uint16 209 0 2
mintFee uint256 210 0 32
defaultMintFeeRecipient address 211 0 20
locked uint256 212 0 32
defaultReferralFeeRecipient address 213 0 20
nftQuestFee uint256 214 0 32
questNFTAddress address 215 0 20
ownerCollections mapping(address => address[]) 216 0 32
nftQuestFeeList mapping(address => struct IQuestFactory.NftQuestFees) 217 0 32
referralFee uint16 218 0 2
sablierV2LockupLinearAddress address 218 2 20
mintFeeRecipientList mapping(address => address) 219 0 32
waynehoover commented 1 year ago

@Quazia Yes, that's right. This is how solady did storage to be compatible with upgradable contracts.

/// @dev The owner slot is given by: not(_OWNER_SLOT_NOT). /// It is intentionally chosen to be a high value /// to avoid collision with lower slots. https://github.com/Vectorized/solady/blob/main/src/auth/Ownable.sol#L60-L64

Role slots are also a high value: https://github.com/Vectorized/solady/blob/main/src/auth/OwnableRoles.sol#L28-L34