omgnetwork / plasma-contracts

Root chain contracts for Plasma
Apache License 2.0
114 stars 66 forks source link

exit queue introspection #644

Open InoMurko opened 4 years ago

InoMurko commented 4 years ago

The test adds two exit queues: 16:44:55.122 [info] ETH exit queue missing. Adding... 16:44:57.149 [info] ERC20 exit queue missing. Adding... after which I immidiately call: getNextExit(uint256,address)

data = ABI.encode("getNextExit(uint256,address)", [Itest.PlasmaFramework.vault_id(Currency.ether()), Currency.ether()])

{:ok, result} = Ethereumex.HttpClient.eth_call(%{to: Itest.PlasmaFramework.address(), data: Encoding.to_hex(data)})

case Encoding.to_binary(result) do
  "" ->
    :queue_not_added

  result ->
    next_exit_id = hd(ABI.TypeDecoder.decode(result, [{:uint, 256}]))
    next_exit_id &&& (1 <<< 160) - 1
end 

result is consistently a binary (on a clique geth node): <<8, 195, 121, 160, 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, 32, 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, 14, 81, 117, 101, 117, 101, 32, 105, 115, 32, 101, 109, 112, 116, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>>

which is decoded to 3963877391197344453575983046348115674221700746820753546331534351508065746944 and the biwtise operation turns it into: next_exit_id &&& (1 <<< 160) - 1 0

looking at the plasma contracts code... that's not what it's supposed to happen: https://github.com/omgnetwork/plasma-contracts/blob/ba662a978bf0158a1ca4e86fa707213531224193/plasma_framework/contracts/src/framework/ExitGameController.sol#L234-L237

https://github.com/omgnetwork/plasma-contracts/blob/655a792436194f43fb06d0e1f501fbff055501a9/plasma_framework/contracts/src/framework/utils/PriorityQueue.sol#L76-L79

So on ethhash node the transaction is reversed with this: require(queue.currentSize > 0, "Queue is empty");

The question is... why do contracts behave differently on different eth nodes?

boolafish commented 4 years ago

found some references:

boolafish commented 4 years ago

would adding sth like this in ethereumx help? https://github.com/ethereum/web3.js/pull/3248/files

boolafish commented 4 years ago

Seems like Geth actually fixed the issue:

~Probably check the release and update the Geth~ Okay, it is in its latest release: https://github.com/ethereum/go-ethereum/releases/tag/v1.9.15