optimism icon indicating copy to clipboard operation
optimism copied to clipboard

eth_sign method produces an OVM: Unsupported RPC Method error

Open stephancill opened this issue 4 years ago • 5 comments

Describe the bug eth_sign method produces a OVM: Unsupported RPC Method error.

To Reproduce Steps to reproduce the behavior:

  1. Run optimism via docker
git clone https://github.com/ethereum-optimism/optimism.git
cd optimism
yarn install
yarn build
cd ops
docker-compose build
docker-compose up
  1. Try to sign message on L2, demonstrated in the following hardhat script:
const { ethers } = require("hardhat")

async function main() {
  const l1Provider = new ethers.providers.JsonRpcProvider("http://localhost:9545")
  const l2Provider = new ethers.providers.JsonRpcProvider("http://localhost:8545")

  const l1Signer = l1Provider.getSigner(0)
  const l2Signer = l2Provider.getSigner(0)

  let l1Sig, l2Sig
  try {
    l1Sig = await l1Signer.signMessage("hello")
    l2Sig = await l2Signer.signMessage("hello")
  } catch (error) {
    console.error(error)
  }

  console.log("L1 Signature", l1Sig)
  console.log("L2 Signature", l2Sig)
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error)
    process.exit(1)
  })
  1. See OVM: Unsupported RPC Method error caused by the eth_sign method and L2 Signature undefined in output.

Expected behavior Expected script output:

L1 Signature 0xf16ea9a3478698f695fd1401bfe27e9e4a7e8e3da94aa72b021125e31fa899cc573c48ea3fe1d4ab61a9db10c19032026e3ed2dbccba5a178235ac27f94504311c
L2 Signature 0xf16ea9a3478698f695fd1401bfe27e9e4a7e8e3da94aa72b021125e31fa899cc573c48ea3fe1d4ab61a9db10c19032026e3ed2dbccba5a178235ac27f94504311c

System Specs:

  • OS: Windows 10, Docker v20.10.5
  • Package Version (or commit hash): Commit 886a1507e35c1d797c68ab8284941baed8f48999

Additional context I believe this was resolved with the OptimismProvider, which seems to be deprecated

stephancill avatar Jul 06 '21 13:07 stephancill

The problem is here:

  const l1Signer = l1Provider.getSigner(0)

You must connect a ethers.Wallet to the provider instead of using a remote signer. Using eth_sendTransaction is not supported

tynes avatar Jul 07 '21 19:07 tynes

For security reasons, we right now do not support eth_sendTransaction or eth_sign. As @tynes stated, the way to interact with the node is to create an ethers.Wallet as follows:

const wallet = new ethers.Wallet(privatekey, l2Provider)
await wallet.signMessage(...)
...

smartcontracts avatar Jul 08 '21 16:07 smartcontracts

We may re-open this in the future but for now will close as wontfix.

smartcontracts avatar Jul 08 '21 16:07 smartcontracts

I am having a similar problem when testing using truffle which works differently to how hardhat uses ethers to sign transactions, i.e. I cannot use ethers.Wallet approach easily. Currently when new-ing up a contract with truffle I get OVM: Unsupported RPC Method. Reopening as it needs further investigation to enable truffle/web3 support.

elenadimitrova avatar Oct 21 '21 09:10 elenadimitrova

Hmmm... I see. @elenadimitrova presumably for L2-native apps you could simply use truffle + ganache. How are people doing L1 <> L2 testing with truffle?

smartcontracts avatar Oct 26 '21 23:10 smartcontracts

Won't be fixed before Bedrock. Should "just work" after Bedrock.

smartcontracts avatar Oct 25 '22 19:10 smartcontracts