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

fix libsecp256k1 compiletion on linux #413

Merged
merged 3 commits into from
Sep 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
{Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 120},
{Credo.Check.Readability.ModuleAttributeNames},
{Credo.Check.Readability.ModuleDoc, false},
{Credo.Check.Readability.AliasOrder, false},
{Credo.Check.Readability.ModuleNames},
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, false},
{Credo.Check.Readability.ParenthesesInCondition},
Expand Down
3 changes: 1 addition & 2 deletions apps/blockchain/lib/blockchain/account/storage.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ defmodule Blockchain.Account.Storage do
db
|> Trie.new(root)
|> Trie.Inspector.all_values()
|> Enum.map(fn {k, v} ->
|> Enum.into(%{}, fn {k, v} ->
{BitHelper.decode_unsigned(k), BitHelper.decode_unsigned(v)}
end)
|> Enum.into(%{})
end
end
5 changes: 1 addition & 4 deletions apps/blockchain/lib/blockchain/chain.ex
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ defmodule Blockchain.Chain do
def load_chain(chain, evm_config \\ nil) do
chain_data = read_chain!(chain)

engine =
chain_data["engine"]
|> Enum.map(&get_engine/1)
|> Enum.into(%{})
engine = Enum.into(chain_data["engine"], %{}, &get_engine/1)

accounts =
chain_data["accounts"]
Expand Down
2 changes: 1 addition & 1 deletion apps/blockchain/lib/blockchain/transaction/signature.ex
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ defmodule Blockchain.Transaction.Signature do
@spec sender(Transaction.t(), integer() | nil) :: {:ok, EVM.address()} | {:error, String.t()}
def sender(tx, chain_id \\ nil) do
# Ignore chain_id if transaction has a `v` value before EIP-155 minimum
chain_id = if not uses_chain_id?(tx.v), do: nil, else: chain_id
chain_id = if uses_chain_id?(tx.v), do: chain_id
tx_hash = transaction_hash(tx, chain_id)

with {:ok, public_key} <- recover_public(tx_hash, tx.v, tx.r, tx.s, chain_id) do
Expand Down
1 change: 0 additions & 1 deletion apps/blockchain/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ defmodule Blockchain.Mixfile do
# Type "mix help deps" for more examples and options
defp deps do
[
{:credo, "~> 0.9.1", only: [:dev, :test], runtime: false},
{:ethereumex, "~> 0.3.2"},
{:evm, in_umbrella: true},
{:ex_rlp, "~> 0.3.0"},
Expand Down
4 changes: 1 addition & 3 deletions apps/blockchain/scripts/generate_state_tests.ex
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ defmodule GenerateStateTests do
end

defp dedup_tests(tests) do
tests
|> Enum.map(fn {fork, list_of_tests} ->
Enum.into(tests, %{}, fn {fork, list_of_tests} ->
{fork, Enum.dedup(list_of_tests)}
end)
|> Enum.into(%{})
end

defp run_group_tests(directory_path) do
Expand Down
6 changes: 2 additions & 4 deletions apps/blockchain/test/blockchain/transaction_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,15 @@ defmodule Blockchain.TransactionTest do
defp organize_tests_by_fork(tests) do
tests
|> Map.take(@forks)
|> Enum.map(fn {fork, fork_tests} ->
|> Enum.into(%{}, fn {fork, fork_tests} ->
{
fork,
fork_tests
|> Enum.map(fn {key_to_test, value} ->
|> Enum.into(%{}, fn {key_to_test, value} ->
{String.to_atom(key_to_test), maybe_hex(value)}
end)
|> Enum.into(%{})
}
end)
|> Enum.into(%{})
end

describe "when handling transactions" do
Expand Down
6 changes: 3 additions & 3 deletions apps/evm/lib/evm/refunds.ex
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ defmodule EVM.Refunds do

# `SELFDESTRUCT` operations produce a refund if the address has not already been suicided.
def refund(:selfdestruct, _args, _machine_state, sub_state, exec_env) do
if exec_env.address not in sub_state.selfdestruct_list do
@selfdestruct_refund
else
if exec_env.address in sub_state.selfdestruct_list do
0
else
@selfdestruct_refund
end
end

Expand Down
5 changes: 1 addition & 4 deletions apps/evm/lib/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ defmodule EVM.Helpers do
"""
@spec invert(map()) :: map()
def invert(m) do
m
|> Enum.into([])
|> Enum.map(fn {a, b} -> {b, a} end)
|> Enum.into(%{})
Enum.into(m, %{}, fn {a, b} -> {b, a} end)
end

def bit_at(n, at), do: band(bsr(n, at), 1)
Expand Down
1 change: 0 additions & 1 deletion apps/evm/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ defmodule EVM.Mixfile do
# Type "mix help deps" for more examples and options
defp deps do
[
{:credo, "~> 0.9.1", only: [:dev, :test], runtime: false},
{:poison, "~> 3.1.0", only: [:dev, :test], runtime: false},
{:decimal, "~>1.5.0"},
{:merkle_patricia_tree, in_umbrella: true},
Expand Down
4 changes: 1 addition & 3 deletions apps/evm/test/evm/operation/block_information_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ defmodule EVM.Operation.BlockInformationTest do

def build_block_interface(headers = [most_recent_header | _]) do
block_map =
headers
|> Enum.map(fn header ->
Enum.into(headers, %{}, fn header ->
{Block.Header.hash(header), header}
end)
|> Enum.into(%{})

EVM.Interface.Mock.MockBlockInterface.new(most_recent_header, block_map)
end
Expand Down
1 change: 0 additions & 1 deletion apps/ex_wire/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ defmodule ExWire.Mixfile do

defp deps do
[
{:credo, "~> 0.9.1", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.16", only: :dev, runtime: false},
{:ex_rlp, "~> 0.3.0"},
{:blockchain, in_umbrella: true},
Expand Down
3 changes: 1 addition & 2 deletions apps/ex_wire/test/ex_wire/framing/secrets_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ defmodule ExWire.Framing.SecretsTest do
auth_2: auth_2(),
ack_2: ack_2()
}
|> Enum.map(fn {k, v} -> {k, bin_format(v)} end)
|> Enum.into(%{})
|> Enum.into(%{}, fn {k, v} -> {k, bin_format(v)} end)

public_keys = %{
ephemeral_public_key_a: public_key(eip8_creds.ephemeral_key_a),
Expand Down
3 changes: 1 addition & 2 deletions apps/exth_crypto/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ defmodule ExthCrypto.Mixfile do
# Type "mix help deps" for more examples and options
defp deps do
[
{:libsecp256k1, "~> 0.1.9"},
{:libsecp256k1, "== 0.1.4"},
{:keccakf1600, "~> 2.0.0", hex: :keccakf1600_orig},
{:credo, "~> 0.8", only: [:dev, :test], runtime: false},
{:binary, "~> 0.0.4"}
]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ defmodule MerklePatriciaTree.Trie.Verifier do
if v == "" do
{:error, "empty leaf value at #{inspect(k)}"}
else
if not Enum.member?(values, v) do
{:error, "leaf value v does not appear in values (#{inspect(v)})"}
else
if Enum.member?(values, v) do
:ok
else
{:error, "leaf value v does not appear in values (#{inspect(v)})"}
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion apps/merkle_patricia_tree/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ defmodule MerklePatriciaTree.Mixfile do
# {:myapp, in_umbrella: true}
#
# Type `mix help deps` for more examples and options
#
defp deps do
[
{:credo, "~> 0.9.1", only: [:dev, :test], runtime: false},
{:poison, "~> 3.1.0", only: [:dev, :test], runtime: false},
{:ex_rlp, "~> 0.3.0"},
{:exth_crypto, in_umbrella: true},
Expand Down
10 changes: 10 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,17 @@ fi
fancy_echo "Installing elixir dependencies and compiling."
mix local.hex --force
mix local.rebar --force

if ! command -v rebar > /dev/null; then
fancy_echo "\`rebar\`: Command not found"
fancy_echo "Please either add ~/.mix to your \$PATH environemnt varible or install it with brew: \`brew install rebar\`"
exit 1
fi

mix deps.get

cd deps/libsecp256k1 && rebar compile && cd ../..

mix compile

fancy_echo "You're all set!"
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ defmodule Exthereum.MixProject do
{:ex_doc, "~> 0.19", only: :dev, runtime: false},
{:dialyxir, "~> 0.5", only: [:dev, :test], runtime: false},
{:ethereumex, "~> 0.3.2"},
{:credo, "~> 0.9.1", only: [:dev, :test], runtime: false}
{:credo, "~> 0.10.0", only: [:dev, :test], runtime: false}
]
end
end
14 changes: 7 additions & 7 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
%{
"binary": {:hex, :binary, "0.0.4", "dd077db70c0ded3e85c132b802338e14b80694684a7e2277666bfa4004b7fa66", [:mix], [], "hexpm"},
"binary": {:hex, :binary, "0.0.5", "20d816f7274ea34f1b673b4cff2fdb9ebec9391a7a68c349070d515c66b1b2cf", [:mix], [], "hexpm"},
"bn": {:hex, :bn, "0.1.0", "59fb2172447daafe29050cc85443e433a9ee5e1f81559c0e7d56c7d6708b8e09", [:mix], [], "hexpm"},
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"},
"certifi": {:hex, :certifi, "2.3.1", "d0f424232390bf47d82da8478022301c561cf6445b5b5fb6a84d49a9e76d2639", [:rebar3], [{:parse_trans, "3.2.0", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"},
"credo": {:hex, :credo, "0.9.2", "841d316612f568beb22ba310d816353dddf31c2d94aa488ae5a27bb53760d0bf", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:poison, ">= 0.0.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
"credo": {:hex, :credo, "0.10.0", "66234a95effaf9067edb19fc5d0cd5c6b461ad841baac42467afed96c78e5e9e", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
"decimal": {:hex, :decimal, "1.5.0", "b0433a36d0e2430e3d50291b1c65f53c37d56f83665b43d79963684865beab68", [:mix], [], "hexpm"},
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
"earmark": {:hex, :earmark, "1.2.5", "4d21980d5d2862a2e13ec3c49ad9ad783ffc7ca5769cf6ff891a4553fbaae761", [:mix], [], "hexpm"},
"ethereumex": {:hex, :ethereumex, "0.3.2", "ee01a49c781c9751317b2918f799e84185203c81c8314ebebb1f1e22b754db3e", [:mix], [{:httpoison, "~> 1.0.0", [hex: :httpoison, repo: "hexpm", optional: false]}, {:poison, "~> 3.1.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
"earmark": {:hex, :earmark, "1.2.6", "b6da42b3831458d3ecc57314dff3051b080b9b2be88c2e5aa41cd642a5b044ed", [:mix], [], "hexpm"},
"ethereumex": {:hex, :ethereumex, "0.3.3", "6d5d7e6b089d907135ad22c72e63225c4e8855e54476dcb27c79e9983c01605c", [:mix], [{:httpoison, "~> 1.1.0", [hex: :httpoison, repo: "hexpm", optional: false]}, {:poison, "~> 3.1.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.19.1", "519bb9c19526ca51d326c060cb1778d4a9056b190086a8c6c115828eaccea6cf", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.7", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
"ex_rlp": {:hex, :ex_rlp, "0.3.0", "76eb293a743b17d6071693014c1a57eb0f3f71fbf560716046d62c8a14340628", [:mix], [], "hexpm"},
"hackney": {:hex, :hackney, "1.13.0", "24edc8cd2b28e1c652593833862435c80661834f6c9344e84b6a2255e7aeef03", [:rebar3], [{:certifi, "2.3.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.2", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
"httpoison": {:hex, :httpoison, "1.0.0", "1f02f827148d945d40b24f0b0a89afe40bfe037171a6cf70f2486976d86921cd", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
"httpoison": {:hex, :httpoison, "1.1.1", "96ed7ab79f78a31081bb523eefec205fd2900a02cda6dbc2300e7a1226219566", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
"idna": {:hex, :idna, "5.1.2", "e21cb58a09f0228a9e0b95eaa1217f1bcfc31a1aaa6e1fdf2f53a33f7dbd9494", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
"jason": {:hex, :jason, "1.1.1", "d3ccb840dfb06f2f90a6d335b536dd074db748b3e7f5b11ab61d239506585eb2", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
"keccakf1600": {:hex, :keccakf1600_orig, "2.0.0", "0a7217ddb3ee8220d449bbf7575ec39d4e967099f220a91e3dfca4dbaef91963", [:rebar3], [], "hexpm"},
"libsecp256k1": {:hex, :libsecp256k1, "0.1.9", "e725f31364cda7b554d56ce2bb976241303dde5ffd1ad59598513297bf1f2af6", [:make, :mix], [{:mix_erlang_tasks, "0.1.0", [hex: :mix_erlang_tasks, repo: "hexpm", optional: false]}], "hexpm"},
"libsecp256k1": {:hex, :libsecp256k1, "0.1.4", "42b7f76d8e32f85f578ccda0abfdb1afa0c5c231d1fd8aeab9cda352731a2d83", [:rebar3], [], "hexpm"},
"makeup": {:hex, :makeup, "0.5.1", "966c5c2296da272d42f1de178c1d135e432662eca795d6dc12e5e8787514edf7", [:mix], [{:nimble_parsec, "~> 0.2.2", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
"makeup_elixir": {:hex, :makeup_elixir, "0.8.0", "1204a2f5b4f181775a0e456154830524cf2207cf4f9112215c05e0b76e4eca8b", [:mix], [{:makeup, "~> 0.5.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 0.2.2", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"},
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"},
"mix_erlang_tasks": {:hex, :mix_erlang_tasks, "0.1.0", "36819fec60b80689eb1380938675af215565a89320a9e29c72c70d97512e4649", [:mix], [], "hexpm"},
"nimble_parsec": {:hex, :nimble_parsec, "0.2.2", "d526b23bdceb04c7ad15b33c57c4526bf5f50aaa70c7c141b4b4624555c68259", [:mix], [], "hexpm"},
"parse_trans": {:hex, :parse_trans, "3.2.0", "2adfa4daf80c14dc36f522cf190eb5c4ee3e28008fc6394397c16f62a26258c2", [:rebar3], [], "hexpm"},
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
Expand Down