Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exit queue introspection #644

Open
InoMurko opened this issue Jun 15, 2020 · 3 comments
Open

exit queue introspection #644

InoMurko opened this issue Jun 15, 2020 · 3 comments
Assignees

Comments

@InoMurko
Copy link
Contributor

InoMurko commented Jun 15, 2020

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:

function getNextExit(uint256 vaultId, address token) external view returns (uint256) {
bytes32 key = exitQueueKey(vaultId, token);
return exitsQueues[key].getMin();
}

function getMin() external view returns (uint256) {
require(queue.currentSize > 0, "Queue is empty");
return queue.heapList[1];
}

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
Copy link
Contributor

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

@boolafish
Copy link
Contributor

boolafish commented Jun 16, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants