optimism
optimism copied to clipboard
eth_sign method produces an OVM: Unsupported RPC Method error
Describe the bug
eth_sign method produces a OVM: Unsupported RPC Method error.
To Reproduce Steps to reproduce the behavior:
- 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
- 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)
})
- See
OVM: Unsupported RPC Methoderror caused by theeth_signmethod andL2 Signature undefinedin 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
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
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(...)
...
We may re-open this in the future but for now will close as wontfix.
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.
Hmmm... I see. @elenadimitrova presumably for L2-native apps you could simply use truffle + ganache. How are people doing L1 <> L2 testing with truffle?
Won't be fixed before Bedrock. Should "just work" after Bedrock.