Skip to content

Commit

Permalink
eip comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
InoMurko committed Feb 4, 2021
1 parent c16b189 commit 5568e4b
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 4 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ jobs:
environment:
PERF_IMAGE_NAME: "omisego/perf:latest"
STATIX_TAG: "env:perf_circleci"
CHILD_CHAIN_URL: http://127.0.0.1:9656/v1
steps:
- checkout
- run:
Expand Down
4 changes: 3 additions & 1 deletion priv/perf/apps/load_test/lib/child_chain/deposit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ defmodule LoadTest.ChildChain.Deposit do
{:ok, %{"logs" => logs}} = Ethereumex.HttpClient.eth_get_transaction_receipt(tx_hash)

%{"topics" => [_topic, _addr, blknum | _]} =
Enum.find(logs, fn %{"address" => address} -> address == vault_address end)
Enum.find(logs, fn %{"address" => address} ->
LoadTest.EIP55.encode!(address) == LoadTest.EIP55.encode!(vault_address)
end)

{:ok, {Encoding.to_int(blknum), eth_blknum, tx_hash}}
end
Expand Down
2 changes: 1 addition & 1 deletion priv/perf/apps/load_test/lib/child_chain/exit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ defmodule LoadTest.ChildChain.Exit do
sender_data = Crypto.hash(from)

contract = contract_address_payment_exit_game()
signature = "challengeStandardExit((uint160,bytes,bytes,uint16,bytes,bytes32))"
signature = "challengeStandardExit((uint168,bytes,bytes,uint16,bytes,bytes32))"
args = [{exit_id, exiting_tx, challenge_tx, input_index, challenge_tx_sig, sender_data}]

{:ok, transaction_hash} = Ethereum.contract_transact(from, contract, signature, args, opts)
Expand Down
63 changes: 63 additions & 0 deletions priv/perf/apps/load_test/lib/eip55.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2019-2020 OMG Network Pte Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

defmodule LoadTest.EIP55 do
@moduledoc """
Implements EIP 55
"""

@spec encode!(String.t() | binary()) :: String.t()
def encode!("0x" <> address) when byte_size(address) == 40 do
address = String.downcase(address)

hash =
address
|> ExKeccak.hash_256()
|> elem(1)
|> Base.encode16(case: :lower)
|> String.graphemes()

encoded =
address
|> String.graphemes()
|> Enum.zip(hash)
|> Enum.map_join(fn
{"0", _} -> "0"
{"1", _} -> "1"
{"2", _} -> "2"
{"3", _} -> "3"
{"4", _} -> "4"
{"5", _} -> "5"
{"6", _} -> "6"
{"7", _} -> "7"
{"8", _} -> "8"
{"9", _} -> "9"
{c, "8"} -> String.upcase(c)
{c, "9"} -> String.upcase(c)
{c, "a"} -> String.upcase(c)
{c, "b"} -> String.upcase(c)
{c, "c"} -> String.upcase(c)
{c, "d"} -> String.upcase(c)
{c, "e"} -> String.upcase(c)
{c, "f"} -> String.upcase(c)
{c, _} -> c
end)

"0x" <> encoded
end

def encode!(address) when byte_size(address) == 20 do
encode!("0x" <> Base.encode16(address, case: :lower))
end
end
2 changes: 1 addition & 1 deletion priv/perf/apps/load_test/lib/watcher_info/transaction.ex
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ defmodule LoadTest.WatcherInfo.Transaction do
%{"messages" => %{"code" => "operation:service_unavailable"}} = error ->
{:error, error}

%{"txhash" => _} ->
%{"tx_hash" => _} ->
{:ok, decoded_response}
end
end
Expand Down
2 changes: 1 addition & 1 deletion priv/perf/config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ config :ethereumex,
url: "http://localhost:8545"

config :load_test,
child_chain_url: "http://localhost:9656",
child_chain_url: System.get_env("CHILD_CHAIN_URL", "http://localhost:9656"),
watcher_security_url: "http://localhost:7434",
watcher_info_url: "http://localhost:7534",
faucet_deposit_amount: trunc(:math.pow(10, 18) * 10),
Expand Down

0 comments on commit 5568e4b

Please sign in to comment.