-
Notifications
You must be signed in to change notification settings - Fork 20
feat: custom runtime functions to generate deterministic Eth address from an MSA ID #2358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportAttention: Patch coverage is
🚀 New features to boost your workflow:
|
Would you mind adding a brief explanation to the PR description about why this feature is being introduced? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a number of questions around this approach:
- What is the scope and goal of these ETH addresses? Are we expecting to use these in the bridges to send money to and from Ethereum?
- Ideas about generation
- I don't like any addresses prefixed or postfixed with zeros since those are likely the precompiles in some chain or another
- Another alternative might be to have the first or last 8 bytes for MsaID and either use it with some kind of tag to hash or use as a seed to generate the remaining 12 bytes.
- Another alternatives would be that If they behave like a smart contract then maybe it should get generated like a smart contract or at least in a similar way.
- In general, l think there might be better ways to generate these addresses that are more natural with more entropy. I think it would worth doing some research since we are going to be stuck with them for a long time.
- We should probably use something similar
trait AccountAddressMapper
|
Can any user can send tokens to these addresses at any time (as long as they know the MSA and the algorithm to determine the account)? Or will the accounts be marked in some way that prevents this from happening other than via chain code? If not, two cases to consider, neither of which may prevent a threat, but just thinking it through...
|
This would be the idea. So yes, it is possible for anyone to send tokens to any MSA, even future MSAs, (although there is no way to specifically select an MSA Id or batch transactions in such a way that ensures a specific MSA Id at this time) |
Most of this sounds fine to me. I don’t love the idea of being able to send tokens to a non existent MSA, given that they are assigned vs claimed (token accounts are “claimed” by proving you have the private key, while MSAs are assigned based on the next available number/id). I don’t think that really matters, but in ideal world that would be an obvious error that we would just reject when the txn was submitted. Not sure it is worth the work to implement or the runtime efficiency overhead, but that is the only thing that I would really change. |
OK, rethinking the implementation of this based on some conversation. We could use However, what might be even better is: Downside of using So, if we use
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, added some nits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing blocking, leave it up to you to incorporate any suggestions, otherwise GTG!
Goal
This PR adds some internal pallet functions and custom runtime to deterministically generate an Ethereum address from an MSA ID, and vice versa.
The general approach is:
CREATE2
(prefix + MSA ID + salt)
Note, although addresses generated in this manner cannot be reversed to recover the related MSA ID, they can be verified (ie, given an address and an MSA ID, we can determine whether or not the address is the result of applying the above algorithm to the MSA ID). It is not envisioned that there would ever be an on-chain requirement to recover the MSA ID from the address; if such a use case was desired for off-chain purposes, it would be relatively trivial to populate a static lookup table mapping all known or possible MSAs to their corresponding address, or vice-versa.
Closes #2353
Closes #2352
Discussion
Checklist