Skip to content

Conversation

Mr-Leshiy
Copy link
Contributor

No description provided.

@Mr-Leshiy Mr-Leshiy marked this pull request as draft April 1, 2022 12:44
@Mr-Leshiy Mr-Leshiy force-pushed the ca-accounts-mapping branch from 0050f5e to c803f5b Compare April 4, 2022 08:25
@Mr-Leshiy Mr-Leshiy marked this pull request as ready for review April 4, 2022 09:19
@Mr-Leshiy Mr-Leshiy force-pushed the ca-accounts-mapping branch from 1adea71 to 4ab495b Compare April 4, 2022 14:15
Copy link
Contributor

@zeegomo zeegomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AccountState thing looks a bit like a state machine to me (not mapped, mapped, contract account, ...), maybe we make it more explicit?

jor_to_evm: Hamt<DefaultHasher, JorAddress, EvmAddress>,
}

fn transfrom_evm_to_jor(evm_id: &EvmAddress) -> JorAddress {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be well documented


// should update and move account evm account state
let old_jor_id = transfrom_evm_to_jor(&evm_id);
accounts = accounts.evm_move_state(jor_id, &old_jor_id)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we allow to map contract accounts to an arbitrary Jormungandr account?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally no, we only allow to map to that jormungandr account which user owns, signature validation comes in the another place.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but that is currently allowed. I would have expected the implementation to progress in the opposite order not to leave exploitable gaps, but that's not too important in the end, just do not forget to add a ticket for that if it does not exist yet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we have already tickets for that :)

@Mr-Leshiy
Copy link
Contributor Author

Mr-Leshiy commented Apr 12, 2022

@zeegomo

The AccountState thing looks a bit like a state machine to me (not mapped, mapped, contract account, ...), maybe we make it more explicit?

Yes, good point, but need to think how it is better to do it.

@Mr-Leshiy Mr-Leshiy requested a review from zeegomo April 13, 2022 11:21
Comment on lines 46 to 47
/// This allows to map any `EvmAddress` to the `JorAddress` before explicit execution of the `EvmMapping` transaction.
/// Intention - is to have possibility to map EVM Contarct accounts with the Jormungandr accounts.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusing though, contract accounts should never be part of a EvmMapping transaction AFAIK, right?

Copy link
Contributor Author

@Mr-Leshiy Mr-Leshiy Apr 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, contract account should not be a part of the EvmMapping certificate, will try to paraphrase it. I meant that with the usage of this function we can link contract account with the jormungandr.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contract account should be a part of the EvmMapping certificate

How can this happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, mistaken 😓

contract account should NOT be a part of the EvmMapping certificate

@Mr-Leshiy Mr-Leshiy force-pushed the ca-accounts-mapping branch from 2d6f3d2 to e0c0075 Compare April 14, 2022 10:00
@Mr-Leshiy Mr-Leshiy requested a review from zeegomo April 14, 2022 12:19
Comment on lines +45 to +46
/// This allows to map any `EvmAddress` to the `JorAddress` before explicit execution of the `EvmMapping` transaction.
/// Intention - is to have possibility to link an EVM Contarct account with a Jormungandr account.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those are two slightly different use cases.

  1. standard account not yet mapped, but that could be mapped in the future
  2. contract account that can't possibly be mapped

///
/// Algorithm description:
/// 1. Get `evm_address` bytes representation -> evm_address_bytes
/// 2. Append b"evm" bytes prefix to the evm_address_bytes -> bytes_data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: append a prefix = prepend

/// Algorithm description:
/// 1. Get `evm_address` bytes representation -> evm_address_bytes
/// 2. Append b"evm" bytes prefix to the evm_address_bytes -> bytes_data
/// 3. Calculate hash (pub struct Hash(crypto::Blake2b256) hash) from the bytes_data -> hash_bytes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: don't need a reference to the specific Rust impl here, just mentioning blake2b256 is enough

Copy link
Contributor

@zeegomo zeegomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not master all of the details here, but let's proceed with what we have agreed on

@Mr-Leshiy Mr-Leshiy merged commit f202722 into master May 13, 2022
@Mr-Leshiy Mr-Leshiy deleted the ca-accounts-mapping branch May 13, 2022 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants