I have a factory contract, which creates child contracts. The child contract inherits from OpenZeppelin's Ownable, so it has an owner and a transferOwnership method.
The factory contract uses CREATE2 to deploy the child contract, and is passing the owner's address as the 32 bytes salt:
bytes32 salt = keccak256(abi.encode(owner));
assembly {
proxy := create2(0, add(bytecode, 0x20), mload(bytecode), salt)
}
The issue I ran into is that when the owner calls the transferOwnerwship method, the factory contract cannot deploy another child contract for that owner. That's because CREATE2 does not allow overwriting a contract deployed with a specific salt.
The question is: is it possible to use the owner as the salt, at all? I thought about forking Ownable and deleting the transferOwnership method, yet I'd prefer to keep that if I can.
Is there some cryptographic hack that I could employ?