ethereum-optimism / plugins

[Optimism] Plugins!
MIT License
12 stars 10 forks source link

l2ethers: Reporting failing deploy transaction as successful #27

Open Bobface opened 3 years ago

Bobface commented 3 years ago

When deploying a contract with l2ethers to a local optimism-integration OVM node, a failing deployment is reported as successful.

Test code excerpt:

const ideaTokenExchange = await IdeaTokenExchange.deploy()
await ideaTokenExchange.deployed()

const receipt = await ideaTokenExchange.deployTransaction.wait()
console.log('tx', await ethers.provider.getTransaction(receipt.transactionHash))
console.log('receipt', receipt)
console.log('code', await ethers.provider.getCode(ideaTokenExchange.address))
await ideaTokenExchange.getOwner()

Deploy transaction:

{
  hash: '0xfa35a0f2dd0b126aff75fa09c6c2704918bb37a4a5baa3f8e0492bb64c96ba5e',
  blockHash: '0xf7b70395fc9756f9a7fc4a319eb0c781b551d9f3cbbee3359ca6a6d1020190e2',
  blockNumber: 42,
  transactionIndex: 0,
  confirmations: 1,
  from: '0xBc5058C4F77AC924584CE63cEBB754Ea14775a70',
  gasPrice: BigNumber { _hex: '0x00', _isBigNumber: true },
  gasLimit: BigNumber { _hex: '0x89543f', _isBigNumber: true },
  to: null,
  value: BigNumber { _hex: '0x00', _isBigNumber: true },
  nonce: 41,
  data: '0x608060405234801562..........', // contract bytecode
  r: '0xda67d4a11637d9c8bb0f56cb63947de409933b7b0148e902939adad695c88334',
  s: '0x4032027920305e81fba37e633643dd86194930c8638ff2471a59c711375ff576',
  v: 876,
  creates: '0x065afE7ADe5F05E4Bd69F00Edd53DC57Ea09774d',
  chainId: 420,
  wait: [Function (anonymous)]
}

Receipt:

{
  to: null,
  from: '0xBc5058C4F77AC924584CE63cEBB754Ea14775a70',
  contractAddress: '0x065afE7ADe5F05E4Bd69F00Edd53DC57Ea09774d',
  transactionIndex: 0,
  gasUsed: BigNumber { _hex: '0x7b89b5', _isBigNumber: true },
  logsBloom: '0x00000000004000000000000000000000000000000000000000040000000000008000000000000000000000100000000000000000000000000000000000000000000000000000000000000008000000000000000010000000000000000000000400000000000000000000000000008000000000000000000000000010000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000',
  blockHash: '0xf7b70395fc9756f9a7fc4a319eb0c781b551d9f3cbbee3359ca6a6d1020190e2',
  transactionHash: '0xfa35a0f2dd0b126aff75fa09c6c2704918bb37a4a5baa3f8e0492bb64c96ba5e',
  logs: [
    {
      transactionIndex: 0,
      blockNumber: 42,
      transactionHash: '0xfa35a0f2dd0b126aff75fa09c6c2704918bb37a4a5baa3f8e0492bb64c96ba5e',
      address: '0x4200000000000000000000000000000000000006',
      topics: [Array],
      data: '0x0000000000000000000000000000000000000000000000000000000000000000',
      logIndex: 0,
      blockHash: '0xf7b70395fc9756f9a7fc4a319eb0c781b551d9f3cbbee3359ca6a6d1020190e2'
    }
  ],
  blockNumber: 42,
  confirmations: 1,
  cumulativeGasUsed: BigNumber { _hex: '0x7b89b5', _isBigNumber: true },
  status: 1, // <------------- Transaction successful
  byzantium: true
}

Checking the deployed bytecode:

0x

At the end, the await ideaTokenExchange.getOwner() call fails because there is no bytecode at that address.

Also, the deployment works when running the test with the built-in Hardhat network with l2ethers.

Output from optimism-integration:

geth_l2_1               | DEBUG[03-16|11:01:40.239] Calling Known Contract                   ID=50d5fab9 Name=OVM_SafetyChecker        Method=isBytecodeSafe
geth_l2_1               | DEBUG[03-16|11:01:40.242] Reached the end of an OVM execution      ID=50d5fab9 Return Data=0x0000000000000000000000000000000000000000000000000000000000000000 Error=nil

Does this mean the contract did not pass the bytecode safety check?


Reproduce

git clone https://github.com/Ideamarket/ideamarket-contracts
cd ideamarket-contracts
git checkout cb55038
npm i
./optimism-integration/up.sh &
# Wait a moment for up.sh to boot
npx hardhat test --network ovm_local test/contracts/ovm/core/IdeaTokenExchange.test.js
smartcontracts commented 3 years ago

@Bobface can you run ./optimism-integration/pull.sh and try again? We recently made a change to our contracts that should fix this problem.

smartcontracts commented 3 years ago

And thank you again for opening issues here :-) it means a lot that you're willing to take the time

Bobface commented 3 years ago

Sure, no need to thank me :) I'm glad for every bug we can get fixed this way.

I ran docker-compose pull to get the latest images, but the bug is still happening. Here is the output of docker image ls --digests:

REPOSITORY                              TAG       DIGEST                                                                    IMAGE ID       CREATED         SIZE
ethereumoptimism/deployer               latest    sha256:2bda1e5f9d6b67fcd05d0950e9f5f9b5dda42ba3d8e6b89fe58119ec7235a712   8321f87e3158   17 hours ago    1.52GB
ethereumoptimism/batch-submitter        latest    sha256:8f6ef6f78b075be85951fb1f7666c838c4a4b39862d8c990833e4f0e8a084375   4426dcbe370d   32 hours ago    1.49GB
ethereumoptimism/data-transport-layer   latest    sha256:ef5895a30ef6c8a8a4f7b73657a8141235f2bf2630c048ee032c8da3884ed2b0   be612ac6f0ae   3 days ago      1.39GB
ethereumoptimism/deployer               <none>    sha256:1173f0b6d754783dad0a65da948d13a1937a9d889520c0af96e6529e2b25d354   2a04a9dec939   4 days ago      1.52GB
ethereumoptimism/batch-submitter        <none>    sha256:256b5bb86492051fee93978a2a6c467e70770c4c5b833b4bb8e94b35765aa468   481353b77c59   4 days ago      1.51GB
ethereumoptimism/integration-tests      latest    sha256:76a9cbecfd8850ecdc295e3d5b1f28c627ee25585d1cb29136bc7f7790265cbe   96f18e75b096   5 days ago      2.25GB
ethereumoptimism/go-ethereum            latest    sha256:7f08d062ab6aa3a5d1854cbb614237d83771e875f292f9bcdc7d2a567c40e3bc   779ab29798eb   5 days ago      869MB
ethereumoptimism/message-relayer        latest    sha256:e817a730b6857ec2ba35db7fb09fd2838239381d267b5be00b5b1204c8a02087   af40f86ed090   7 days ago      1.25GB
ethereumoptimism/hardhat                latest    sha256:225b659975ce950427e853df0044aa0c003141f8bfb8a61210f53233ee2ed394   7da463caaa32   10 days ago     1.53GB
Bobface commented 3 years ago

@smartcontracts I was able to reproduce this on the offical Kovan testnet:

Deploy Tx with Receipt Status 0x1

Deployed contract with bytecode 0x.

smartcontracts commented 3 years ago

Hmmm I would expect this to be happening on Kovan, but not on the latest images. Will give this a shot locally myself, one moment please!

smartcontracts commented 3 years ago

Okay I can reproduce this locally. I think this is very likely to be a problem with ./up.sh and not with @eth-optimism/plugins. We recently made a change that should have fixed this issue (specifically here: https://github.com/ethereum-optimism/contracts/pull/308).

smartcontracts commented 3 years ago

I managed to isolate the issue to our error parsing logic in geth: https://github.com/ethereum-optimism/go-ethereum/blob/2e468279837326ed882c9a2ea11ccebf1a17b60d/core/vm/evm.go#L380-L438

This is a known problem and we're planning to modify our contracts so that we can entirely remove this logic. I'll push on this harder so we can get a fix out ASAP.

smartcontracts commented 3 years ago

Going to leave this open until the issue is fixed in Geth.