ewasm / go-ethereum

Official Go implementation of the Ethereum protocol
https://geth.ethereum.org
GNU Lesser General Public License v3.0
27 stars 4 forks source link

Rust-generated contract causes consensus failure #6

Closed jakelang closed 5 years ago

jakelang commented 5 years ago

Repro

  1. Open ewasm studio and submit a create transaction with valid wast code (destination empty) ewasm-studio will send a notification saying that the program terminated, and will then prompt the user to sign the TX via metamask. It will send the TX as usual and yield the receipt. Wagon will then fail to sync.

TX fields

Wei: 100000000000000000 Code: https://pastebin.com/yPQGkDPp

Message

ExitStatus: Program terminated with exit(1)

jakelang commented 5 years ago

Update: this belongs in a different repo. Thought this was an ewasm-studio bug at first but actually it is worse.

hugo-dc commented 5 years ago

I reproduced this problem following the steps described above. This transaction was produced: http://ewasm.ethereum.org/explorer/tx/0x8293c7f2e0c01ff88ac4c6364b93da11230398966ae17d67a4318d536cea686c

It is deploying a contract with empty bytecode: http://ewasm.ethereum.org/explorer/account/0x807A7C82D2800a78B2F3b180F1D85a1e77E18E82

If you convert the Data in the transaction to wast you see something like this:

(module
  (type $t0 (func (param i32 i32)))
  (type $t1 (func))
  (import "ethereum" "finish" (func $ethereum.finish (type $t0)))
  (func $main (export "main") (type $t1)
    (call $ethereum.finish
      (i32.const 0)
      (i32.const 0)))
  (memory $memory (export "memory") 100))

This is the code which causes a difference between hera en wagon. I'm not sure why this test case is not failing for wagon: https://github.com/ewasm/tests/blob/wasm-tests/src/GeneralStateTestsFiller/stEWASMTests/createFromTransactionReturnZeroBytesFiller.yml#L38-L48

hugo-dc commented 5 years ago

The test case is passing when I run it with go-ethereum+wagon, however there is something that chaught my attention: gasUsed: 0x0

$ ./evm --json statetest /home/hugo/workspace/tests/GeneralStateTests/stEWASMTests/createFromTransactionReturnZeroBytes.json 
{"output":"","gasUsed":"0x0","time":2433380}
{"stateRoot": "d14d4ecbf1dfc0d5d5d20b3e9889479a70345baa31296da6ed06ade886b6e4c2"}
[
  {
    "name": "createFromTransactionReturnZeroBytes",
    "pass": true,
    "fork": "Byzantium"
  }
]
gballet commented 5 years ago

@jakelang @hugo-dc I was able to full-synch to block 145093 which is further than 139871 (the one hugo mentions). Could you please give more details on the issue?

jakelang commented 5 years ago

@gballet i don't have much more info but here's a log from the same thing happening at block 110066.

Chain config: {ChainID: 66 Homestead: 0 DAO: <nil> DAOSupport: false EIP150: 0 EIP155: 0 EIP158: 0 Byzantium: 0 Constantinople: <nil> Engine: ethash}

Number: 110066
Hash: 0xefeb899654f9b784c2d01d6bd577a94f6012b24da15390c442560b7026d7d8fc
    &{[] 1 70260 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [] [220 142 116 30 27 212 254 26 215 116 74 224 11 233 53 153 211 171 160 138 126 0 134 122 61 56 77 236 15 65 169 131] [54 214 77 94 2 178 30 150 11 10 127 31 34 55 194 222 44 233 7 31] 70260}

Error: invalid gas used (remote: 76064 local: 70260)
##############################
gballet commented 5 years ago

@jakelang I re-synced and didn't have the issue. Could you please make sure that you have the latest version of wagon ? My last fix got merged today.

gballet commented 5 years ago

This is a block that got mined with wagon on a full sync: http://ewasm.ethereum.org/explorer/account/0x9AfA52330797885BC7f6Df7b7d87835995d0f4f1 so either I'm mining the wrong chain, or your config is somewhat wrong. Any suggestion?

gballet commented 5 years ago

@hugo-dc has identified the issue, the metering command line is wrong. I'm closing this issue, and will update the README.