Closed lemunozm closed 4 weeks ago
Current implementation is done as:
pub enum DomainAddress {
Local([u8; 32]),
Evm(EVMChainId, [u8; 20]),
}
But I'm thinking of changing this into:
pub enum DomainAddress {
Centrifuge(AccountId32),
Evm(EVMChainId, H160),
}
I do not like that we expose the AccountId32
type (which, theoretically, is set at runtime), but we would gain much more type safety. It's a pain to deal with arrays. Maybe it makes sense to expose an AccountId32
because speaking about a "Centrifuge domain" inherently carries some "domain information"
EDIT: after playing with the second approach, I feel like it's harder to deal with in a lot of scenarios, so I will keep the first model.
Attention: Patch coverage is 60.34483%
with 46 lines
in your changes missing coverage. Please review.
Project coverage is 47.76%. Comparing base (
e8f1efd
) to head (764e4b2
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This PR wants to change 6e8f1a29dff0d7cf5ff74285cfffadae8a8b303f which is origin/main to 4301885b9a3b8ec36f3bda4b789daa5b115c006a
Good point! It was during the rebase...
Given the change from Local
to Centrifuge
, I should also change the as_local()
and from_local()
, I think both could be: as_account()
(or just account()
) and from_account()
.
Do you agree or do you have some preference? @wischli @cdamian
Given the change from
Local
toCentrifuge
, I should also change theas_local()
andfrom_local()
, I think both could be:as_account()
(or justaccount()
) andfrom_account()
.Do you agree or do you have some preference? @wischli @cdamian
Sounds good to me! {as, from}_centrifuge
certainly sounds wrong. If we want to be more explicit, we could also use ..account32..
or ..account_id..
.
Well, I need to think a bit more because what's returned is the 32-bit array, so the account name may not make sense in some places where the array is expected (as when we construct a message with an eth address expanded to 32 bytes). Such a dilemma!
Closed in favor of: https://github.com/centrifuge/centrifuge-chain/pull/1969
Description
Convert
traits. NotDomainAddress
know about to convert accounts.Unify DomainAddress to
[u8;32]
. See this slack threadDomainAddress
into[u8;32]
in two ways:T::DomainAddressIntoAccount::convert()
which put 20 bytes from Eth + chain + "EVM" number.DomainAddress.address()
which put 20 bytes following by 0s.This is pretty confusing because is easy to use one or the other in different places, ending with different arrays values. From this PR, the second option is removed. We always add the extra information each time we extract the array from a
DomainAddress
DomainAddress
to easy work with them safelyCentrifuge
toLocal
(or maybe I revert this)EVM
toEvm
From/Into
traits fromKeyring
toH160
and[u8;20]
and use instead an explicit method calledin_eth()
(open to name proposals). This method represents the account in the Ethereum network. Note that this differs fromKeyring::Alice.into()[0..20]
, which is used in other places where an ethereum account is stored as anAccountId
and needs to be recovered. Because this is highly confusing, I've removed theinto/from
methods to be more explicit about when the first case happens.