gnosisguild / zodiac-safe-app

https://gnosis-safe.io/app/share/safe-app?appUrl=https://zodiac.gnosisguild.org/&chainId=5
GNU Lesser General Public License v3.0
26 stars 28 forks source link

Create a Reality.eth template and add it to the oracle. #94

Closed asgeir-s closed 2 years ago

asgeir-s commented 2 years ago

We need to call the create template function of Reality.eth in order to get a template ID that we can use when adding the Reality Module.

It is not possible to know the template ID in advance with the current implementation of Reality.eth. This is not known until the transaction that adds the template is executed because the template ID is a number increased for each new template created. And we need to know this in advance in order to construct the transaction bundle for the Safe.

Here are some solutions I have thought of:

  1. The best thing would probably be if the Reality.eth oracle could use a hash of the template content as the id, so that we could know this in advance. - Will require changes in the Reality Module contracts, due to that, an uint256 is expected for the template ID, in addition to getting Reality.eth to add it.

  2. We can wrap the module deployment and Reality.eth template creation calls in a contract function. So that we can forward the template ID to the reality module's setUp function. Possible challenge: how will this work with deterministic deployment via the factory 🤔

  3. We could make the user execute a transaction (not through the Safe) for adding the template during the template step.

@auryn-macmillan What do you think we should do? Do you like any of the options above or can you think of another solution?

asgeir-s commented 2 years ago

@auryn-macmillan: One possible solution:

Create a singleton contract, RealityDeploymentUtil: This contract can have a function that can be called with templateContent, realityOracleAddress and newOwnerAddress. This function will:

  1. Add the template to the Reality oracle and get back the template id.
  2. Set the templateId on the RealityModule.
  3. Transfer ownership of the RealityModule.

When the RealityModule is deployed we initialize it with templateId=0 and owner=<RealityDeploymentUtilAddress> (so that the address will be deterministic). Then we call the RealityDeploymentUtil helper function (described above) in the same multicall transaction.

This way, we do not change any of the contracts that are already deployed, we just have to deploy that RealityDeploymentUtil contract, and make sure, that when this functionality is used, we must always call that helper function in the same transaction.

auryn-macmillan commented 2 years ago

@manboy-eth, yeah I think you latest proposed solution sounds like the best way to solve it, since it doesn't require any changes to already deployed contracts.