Skip to content
This repository has been archived by the owner on Jul 11, 2019. It is now read-only.

Consider indexing contractName for the ImplementationChanged event of ImplementationDirectory #199

Open
facuspagnuolo opened this issue Jul 4, 2018 · 0 comments
Labels
kind:discussion To discuss on a task before implementing it kind:enhancement An upgrade or a new feature that improves the system
Milestone

Comments

@facuspagnuolo
Copy link
Contributor

We've been discussing with @frangio the idea of indexing the contractName field of the ImplementationChanged event for the ImplementationDirectory contract (see #193 (comment))

Following Fran's suggestion, the idea would be to index the contractName field and provide a way for clients to retrieve the corresponding hash for a contractName in order to filter events by the indexed field. Then, we have two alternatives:

  1. Emitting a new event to register the hash of a contractName, we should do this only once per contractName. E.g.: event ContractName(string index hash, string contractName)

  2. Adding a public method to retrieve the hash of a contractName.

If we go with 1., to make sure we emit this event only once per contract name, given a contractName could be unset, we should store whether we have emitted said event for a contractName or not. For example, adding a new mapping like mapping (string => bool) contractNameEmitted. And, every time we set a new implementation we should check that field, and update it and emit the event when needed.

If we go with 2., we will need to store this information. For example, adding a new mapping like mapping (string => bytes32) contractNameHashes to store the hash for every contractName. And, every time we set a new implementation we should update the mapping when needed.

Summing things up, both solutions are more or less the same, instead of storing a boolean + emitting a new event, we are storing a hash. Both mean a little gas cost increment that everyone will have to pay every time a new implementation is registered. Please correct me if I'm wrong.

Analyzing both alternatives, I think I'd go with 2..

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind:discussion To discuss on a task before implementing it kind:enhancement An upgrade or a new feature that improves the system
Projects
None yet
Development

No branches or pull requests

1 participant