clearmatics / mobius

Trustless Tumbling for Transaction Privacy
GNU Lesser General Public License v3.0
86 stars 23 forks source link

Destroy contract after use #49

Closed stevenroose closed 6 years ago

stevenroose commented 6 years ago

The mixer contracts are short-lived and one-time-use contracts and thus there will be plenty of them deployed contiuously.

For that reason, I think it's a good idea to destroy the mixer contracts after use. The data in it is no longer useful after all withdrawals.

HarryR commented 6 years ago

Hi steven

The Mixer.sol contract will create rings based on the token and deposit amount, when all withdraws have been made from that ring the storage used by it is deleted: https://github.com/clearmatics/mobius/blob/master/contracts/Mixer.sol#L223 - this saves a transaction per ring which would otherwise be necessary to create the contract, at the expense of an extra 32 bytes for the ring id per transaction.

Is it more efficient or costs less to have a contract created for every ring, or can you provide an example of a use case where there's compelling need for it?

stevenroose commented 6 years ago

My apologies, I was not aware that there were multiple rings inside one Mixer contract. You are correct, deleting the Ring data is enough.

Maybe the event names MixerDead are a bit ambiguous, becaues the Mixer contract never dies, but the rings do.

HarryR commented 6 years ago

Yup the MixerDead event sounds weird, is there even any need for the on-destroy event if there's one event per withdraw. Maybe RingWithdraw event name would be better named.