entropyxyz / sdk

Official JavaScript SDK for Entropy blockchain.
GNU Affero General Public License v3.0
7 stars 0 forks source link

can't register same account twice #346

Closed mixmix closed 1 month ago

mixmix commented 1 month ago

users should have the ability to register the same account multiple times. currently polkadot errors with registry.alreadySubmitted

ameba23 commented 1 month ago

You are right, it should be possible to create multiple entropy accounts by submitting a register transaction from the same substrate account. I think the check which makes this not possible is left over from when we had a signature request account which defined which entropy account you were talking about. Thats not the case anymore so we can remove that check. I will make an issue in entropy-core.

ameba23 commented 1 month ago

Having looked into this a bit more, i've changed my mind about this.

When registering, we check if the substrate account which submits the register transaction is in a 'registering' state, and if it is give the alreadySubmitted error. That is, that registration is in progress and not yet completed.

https://github.com/entropyxyz/entropy-core/blob/741f81b0014b192810b9f8e8f5283606ba2341ee/pallets/registry/src/lib.rs#L249

I think it is not unreasonable to not allow you to register a second account until the first one has completed registering. This is needed because until DKG is completed we dont have a verifying key, so we use the substrate account to refer to which registration request we are talking about. The plus side of this is we avoid there being two accounts setup when the same register transaction was mistakenly submitted a second time - which could alternatively be addressed at the UX level.

I can confirm i have successfully registered two entropy accounts submitting the register transaction from the same substrate account on release/v0.1.0.

If however you somehow get stuck in the 'registering' state forever, then this is big a problem. If this happens please make an issue with steps to reproduce. There are some cases where this is hard to avoid, eg: some TSS server went offline just at the moment between the DKG protocol successfully finishing but before submitting the register confirmation to the chain. For this we have the prune_registration extrinsic: https://github.com/entropyxyz/entropy-core/blob/741f81b0014b192810b9f8e8f5283606ba2341ee/pallets/registry/src/lib.rs#L297

That is, you can explicitly ask to cancel a pending registration to get out of a 'registering' state. I'm not sure whether this is implemented yet in the SDK, but it works much the same as submitting the register extrinsic, except you don't need to give any arguments. Since you can only have one account in a 'registering' state, it knows which one you mean from the account ID you submit the extrinsic from.