Skip to content

Commit

Permalink
perf setup and cabbage
Browse files Browse the repository at this point in the history
  • Loading branch information
InoMurko committed Feb 9, 2021
1 parent 5f0c590 commit ac0cfde
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "priv/cabbage"]
path = priv/cabbage
url = git@github.com:omgnetwork/specs.git
branch = inomurko/bump_ex_plasma_03
branch = master-v2
5 changes: 3 additions & 2 deletions apps/omg/lib/omg/state/transaction/fee.ex
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ defimpl OMG.State.Transaction.Protocol, for: OMG.State.Transaction.Fee do
do: {:ok, %{}}
end

defp find_output_by_currency(outputs, currency),
do: Enum.find(outputs, {:error, :surplus_in_token_not_collected}, fn o -> o.currency == currency end)
defp find_output_by_currency(outputs, currency) do
Enum.find(outputs, {:error, :surplus_in_token_not_collected}, fn o -> o.currency == currency end)
end

defp amounts_equal?(collected, claimed) when collected == claimed, do: true
defp amounts_equal?(_, _), do: {:error, :claimed_and_collected_amounts_mismatch}
Expand Down
28 changes: 21 additions & 7 deletions priv/perf/apps/load_test/lib/child_chain/exit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ defmodule LoadTest.ChildChain.Exit do
@gas_start_exit 500_000
@gas_challenge_exit 300_000
@gas_add_exit_queue 800_000
@standard_exit_bond 14_000_000_000_000_000

@doc """
Returns the exit data of a utxo.
Expand Down Expand Up @@ -96,7 +95,7 @@ defmodule LoadTest.ChildChain.Exit do

tx = %Ethereum.Transaction{
to: contract_address_payment_exit_game(),
value: @standard_exit_bond,
value: get_start_standard_exit_size(),
gas_price: gas_price,
gas_limit: @gas_start_exit,
data: data
Expand Down Expand Up @@ -143,11 +142,7 @@ defmodule LoadTest.ChildChain.Exit do
end

defp has_exit_queue?(vault_id, token) do
data =
ABI.encode(
"hasExitQueue(uint256,address)",
[vault_id, token]
)
data = ABI.encode("hasExitQueue(uint256,address)", [vault_id, token])

{:ok, receipt_enc} =
Ethereumex.HttpClient.eth_call(%{
Expand Down Expand Up @@ -184,4 +179,23 @@ defmodule LoadTest.ChildChain.Exit do
|> Application.fetch_env!(:contract_address_payment_exit_game)
|> Encoding.to_binary()
end

defp get_start_standard_exit_size() do
data = ABI.encode("startStandardExitBondSize()", [])

{:ok, result} =
Ethereumex.HttpClient.eth_call(%{
from: Application.fetch_env!(:load_test, :contract_address_payment_exit_game),
to: Application.fetch_env!(:load_test, :contract_address_payment_exit_game),
data: Encoding.to_hex(data)
})

start_standard_exit_size =
result
|> Encoding.to_binary()
|> ABI.TypeDecoder.decode([{:uint, 128}])
|> hd()

start_standard_exit_size
end
end
3 changes: 2 additions & 1 deletion priv/perf/apps/load_test/lib/ethereum/ethereum.ex
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ defmodule LoadTest.Ethereum do
|> Ethereumex.HttpClient.eth_get_transaction_receipt()
|> case do
{:ok, receipt} when receipt != nil -> {:ok, receipt}
_ -> :repeat
_other ->
:repeat
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ defmodule LoadTest.Scenario.ManyStandardExits do
exiter.addr
|> LoadTest.ChildChain.Utxos.get_utxos()
|> Enum.map(&exit_utxo(session, &1, exiter))
|> List.last()
|> List.first()

last_tx_hash = session.assigned.tx_hash
{:ok, %{"status" => "0x1", "blockNumber" => last_exit_height}} = Ethereum.transact_sync(last_tx_hash)
Expand Down
6 changes: 3 additions & 3 deletions priv/perf/config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ config :load_test,
# fee testing setup: static fee in <root>/docker/static_feefed/file.json
fee_amount: 1,
utxo_load_test_config: %{
concurrent_sessions: 10,
utxos_to_create_per_session: 5,
transactions_per_session: 5
concurrent_sessions: 20,
utxos_to_create_per_session: 15,
transactions_per_session: 15
},
childchain_transactions_test_config: %{
concurrent_sessions: 10,
Expand Down

0 comments on commit ac0cfde

Please sign in to comment.