Skip to content
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

Feature owen eth rooch address mapping #348

Merged

Conversation

yubing744
Copy link
Collaborator

@yubing744 yubing744 commented Jun 25, 2023

Successful debugging of calling the Move contract through MetaMask:

  1. crates/rooch-framework/sources/address_mapping.move
    When the Rooch address cannot be found according to ETH, use blake2b256(eth_address) to automatically generate the Rooch address
  2. Three interfaces that Mock MetaMask depends on: eth_getTransactionReceipt, eth_getTransactionByHash and eth_getBlockByHash
  3. Adjust the eth_getTransactionCount interface to return the real transaction number of the current account as the nonce
image image


let transaction = resp.map(|_transaction_view: TransactionView| -> Transaction {
Transaction {
hash: H256::from_str("0x7fd17d4a368fccdba4291ab121e48c96329b7dc3d027a373643fb23c20a19a3f").unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

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

We can use the real tx hash

Copy link
Contributor

Choose a reason for hiding this comment

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

The transaction_view's raw is the original eth tx. We can improve this function result in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, but here's a question, is it possible to view transactions created through the Rooch API.

Comment on lines +55 to +56
let hash = blake2b256(&maddress.raw_address);
option::some(moveos_std::bcd::to_address(hash))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think creating a new address in the resolve function is not a good idea because we can not ensure that the address mapping exists via the resolve function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

An available Rooch address must be returned here, otherwise MetaMask wallet users will prompt an error when they initiate a transaction for the first time: the multiaddress sender({}) mapping record is not exists.

The idea here is to temporarily use the ETH address to obtain the Rooch address through Hash, and after the transaction is executed, complete the creation of the Rooch account and the mapping of the address in post_execute.

The reason why the ETH public key is not used as the Rooch address as previously discussed is because the ETH public key cannot be obtained in the resolve contract method. If the resolve signature is reconstructed later, it should be changed to use the ETH public key as the Rooch address. Rooch address. But I feel that this solution is not universal enough. When we need to support a new L1 public chain, we need to adapt here.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can make this TBD. We can generate the address in the rust code. The rust code can get the ETH signature.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@jolestar jolestar left a comment

Choose a reason for hiding this comment

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

Merge this PR first, make the eth address TBD

@jolestar jolestar merged commit 0483b79 into rooch-network:main Jun 25, 2023
wubuku added a commit to wubuku/rooch that referenced this pull request Jun 26, 2023
* commit '4b1455160a92181c304e87395cf94328aa611a7b':
  [Testing] moveos_stdlib::account_storage (rooch-network#355)
  add release workflow (rooch-network#343)
  [cli] return a string for init command. (rooch-network#347)
  Feature owen eth rooch address mapping (rooch-network#348)
  Fix the issue of illegal invocation of private_generics in the module without throwing an error. (rooch-network#345)
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.

2 participants