rooch-network / rooch

VApp Container with Move Language
https://rooch.network
Apache License 2.0
128 stars 54 forks source link

[RPC]Implementing ETH-Compatible RPC Proxy for Rooch #108

Closed jolestar closed 10 months ago

jolestar commented 1 year ago

Motivation

To enable ETH ecosystem users to use Rooch conveniently, we need to implement an ETH-compatible RPC proxy on top of an existing RPC service used by Rooch. This will enable ETH clients to interact with Rooch and use the features of a compatible Ethereum wallet.

The ETH-compatible RPC proxy

A proxy service would be developed to provide an interface between the Rooch RPC and the Ethereum client. The proxy would have to support the necessary methods used in ETH protocol such as account balance retrieval, transfers, smart contract calls, and ensure ETH client requests are received.

Transform the input and output formats.

As input and output formats used by the existing RPC may differ from those used in the ETH protocol, we need to develop a mechanism to transform input and output formats making them compatible with ETH protocol.

  1. In the transaction format, we need to support the original eth transaction because the user signature is for the original transaction. If We convert it to Rooch's transaction, we can not verify it.
  2. In the address format, we need to provide a method to let the Rooch users can bind an ETH address, then provide a method to resolve the Eth address to Rooch address.

Ref:

  1. https://github.com/starcoinorg/sips/issues/22
jolestar commented 11 months ago

I define some ETH API in #174. We need to determine if we want to support Metamask and which APIs are required first. @yubing744

yubing744 commented 11 months ago

@jolestar I found the API used by the basic functions by debugging the MetaMask wallet:

Use Case APIs Used
Query balance eth_getBalance
Query current Gas price eth_gasPrice
Send transaction eth_sendRawTransaction, eth_estimateGas
Check transaction status eth_getTransactionByHash, eth_getTransactionReceipt
Query smart contract state eth_call
jolestar commented 11 months ago

Please help to mock these APIs and let MetaMask try to connect Rooch @yubing744

yubing744 commented 11 months ago

@jolestar I have mocked some APIs required by MetaMask, now we can configure the rooch server RPC address to MetaMask and initiate transactions.

image

PR: https://github.com/rooch-network/rooch/pull/201

jolestar commented 11 months ago

Great, So the next task is to support the ETH signature and define a CallData standard, how to call a Move Function in ETH transaction's CallData?

yubing744 commented 11 months ago

Great, So the next task is to support the ETH signature and define a CallData standard, how to call a Move Function in ETH transaction's CallData?

OK, I'll look into it.

jolestar commented 11 months ago

Great, So the next task is to support the ETH signature and define a CallData standard, how to call a Move Function in ETH transaction's CallData?

OK, I'll look into it.

You can split this feature into issues, and help record.

yubing744 commented 11 months ago

Great, So the next task is to support the ETH signature and define a CallData standard, how to call a Move Function in ETH transaction's CallData?

OK, I'll look into it.

You can split this feature into issues, and help record.

This task can be split into three subtasks:

  1. Support ETH signature
  2. MoveCallData encoding
  3. ETH address and Rooch address mapping
yubing744 commented 11 months ago

The ETH signature and the MoveCallData encoding has been passed, and I will do the ETH address and Rooch address mapping below.

yubing744 commented 11 months ago

My idea is to automatically complete the creation and binding of the Rooch account on the first transaction.