Skip to content

Commit

Permalink
block nonce
Browse files Browse the repository at this point in the history
  • Loading branch information
InoMurko committed Jan 26, 2021
1 parent ebb8f08 commit 17d7bb9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ defmodule OMG.Watcher.ExitProcessor.ExitInfo do
# `exitable` will be `false` if the exit was challenged
# `exitable` will be `false` ALONG WITH the whole tuple holding zeroees, if the exit was processed successfully
# **NOTE** one can only rely on the zero-nonzero of this data, since for processed exits this data will be all zeros
defp parse_contract_exit_status({exitable, _, _, _, _, _}), do: exitable
defp parse_contract_exit_status({exitable, _, _, _, _, _, _}), do: exitable

# Based on the block number determines whether UTXO was created by a deposit.
defguardp is_deposit(blknum, child_block_interval) when rem(blknum, child_block_interval) != 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ defmodule OMG.Watcher.Integration.BlockGetter2Test do

require OMG.Utxo

alias OMG.Eth.RootChain
alias OMG.Eth.Support.BlockSubmission.Integration
alias OMG.Watcher.BlockGetter
alias OMG.Watcher.Event
Expand Down Expand Up @@ -93,7 +94,10 @@ defmodule OMG.Watcher.Integration.BlockGetter2Test do
assert WatcherHelper.capture_log(fn ->
# Here we're manually submitting invalid block to the root chain
# THIS IS CHILDCHAIN CODE
{:ok, _} = Integration.submit_block(bad_block_hash, 2, 1)
gas_price = 1
nonce = RootChain.next_child_block() / 1000

{:ok, _} = Integration.submit_block(bad_block_hash, round(nonce - 1), gas_price)

IntegrationTest.wait_for_byzantine_events(
[%Event.InvalidExit{}.name, %Event.UnchallengedExit{}.name],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ defmodule OMG.Watcher.Integration.BlockGetter3Test do
end

defp get_next_blknum_nonce(blknum) do
child_block_interval = Application.fetch_env!(:omg_eth, :child_block_interval)
child_block_interval = 1000
next_blknum = blknum + child_block_interval
{next_blknum, trunc(next_blknum / child_block_interval)}
{next_blknum, trunc(next_blknum / child_block_interval) - 1}
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ defmodule OMG.Watcher.Integration.BlockGetter4Test do

# checking if both machines and humans learn about the byzantine condition
assert WatcherHelper.capture_log(fn ->
{:ok, _txhash} = Integration.submit_block(block_overclaiming_fees.hash, 1, 20_000_000_000)
gas_price = 20_000_000_000
nonce = RootChain.next_child_block() / 1000

{:ok, _txhash} = Integration.submit_block(block_overclaiming_fees.hash, round(nonce - 1), 20_000_000_000)
IntegrationTest.wait_for_byzantine_events([%Event.InvalidBlock{}.name], @timeout)
end) =~ inspect({:tx_execution, :claimed_and_collected_amounts_mismatch})
end
Expand Down

0 comments on commit 17d7bb9

Please sign in to comment.