Merge branch 'master' into ab-make-pages-async

pull/2012/head
Ayrat Badykov 6 years ago committed by GitHub
commit df20e0af64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 5
      apps/explorer/config/config.exs
  3. 12
      apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex
  4. 28
      apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs

@ -66,6 +66,7 @@
- [#1900](https://github.com/poanetwork/blockscout/pull/1900) - SUPPORTED_CHAINS ENV var - [#1900](https://github.com/poanetwork/blockscout/pull/1900) - SUPPORTED_CHAINS ENV var
- [#1892](https://github.com/poanetwork/blockscout/pull/1892) - Remove temporary worker modules - [#1892](https://github.com/poanetwork/blockscout/pull/1892) - Remove temporary worker modules
- [#1958](https://github.com/poanetwork/blockscout/pull/1958) - Default value for release link env var - [#1958](https://github.com/poanetwork/blockscout/pull/1958) - Default value for release link env var
- [#1964](https://github.com/poanetwork/blockscout/pull/1964) - ALLOWED_EVM_VERSIONS env var
- [#1975](https://github.com/poanetwork/blockscout/pull/1975) - add log index to transaction view - [#1975](https://github.com/poanetwork/blockscout/pull/1975) - add log index to transaction view
- [#1988](https://github.com/poanetwork/blockscout/pull/1988) - Fix wrong parity tasks names in Circle CI - [#1988](https://github.com/poanetwork/blockscout/pull/1988) - Fix wrong parity tasks names in Circle CI

@ -9,7 +9,10 @@ use Mix.Config
config :explorer, config :explorer,
ecto_repos: [Explorer.Repo], ecto_repos: [Explorer.Repo],
coin: System.get_env("COIN") || "POA", coin: System.get_env("COIN") || "POA",
token_functions_reader_max_retries: 3 token_functions_reader_max_retries: 3,
allowed_evm_versions:
System.get_env("ALLOWED_EVM_VERSIONS") ||
"homestead,tangerineWhistle,spuriousDragon,byzantium,constantinople,petersburg"
config :explorer, Explorer.Counters.AverageBlockTime, enabled: true config :explorer, Explorer.Counters.AverageBlockTime, enabled: true

@ -8,7 +8,6 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do
require Logger require Logger
@new_contract_name "New.sol" @new_contract_name "New.sol"
@allowed_evm_versions ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople", "petersburg"]
@doc """ @doc """
Compiles a code in the solidity command line. Compiles a code in the solidity command line.
@ -72,13 +71,13 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do
code = Keyword.fetch!(params, :code) code = Keyword.fetch!(params, :code)
optimize = Keyword.fetch!(params, :optimize) optimize = Keyword.fetch!(params, :optimize)
optimization_runs = params |> Keyword.get(:optimization_runs, 200) |> Integer.to_string() optimization_runs = params |> Keyword.get(:optimization_runs, 200) |> Integer.to_string()
evm_version = Keyword.get(params, :evm_version, List.last(@allowed_evm_versions)) evm_version = Keyword.get(params, :evm_version, List.last(allowed_evm_versions()))
external_libs = Keyword.get(params, :external_libs, %{}) external_libs = Keyword.get(params, :external_libs, %{})
external_libs_string = Jason.encode!(external_libs) external_libs_string = Jason.encode!(external_libs)
checked_evm_version = checked_evm_version =
if evm_version in @allowed_evm_versions do if evm_version in allowed_evm_versions() do
evm_version evm_version
else else
"byzantium" "byzantium"
@ -125,7 +124,12 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do
end end
end end
def allowed_evm_versions, do: @allowed_evm_versions def allowed_evm_versions do
:explorer
|> Application.get_env(:allowed_evm_versions)
|> String.split(",")
|> Enum.map(fn version -> String.trim(version) end)
end
def get_contract_info(contracts, _) when contracts == %{}, do: {:error, :compilation} def get_contract_info(contracts, _) when contracts == %{}, do: {:error, :compilation}

@ -310,6 +310,34 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do
end end
end end
# describe "allowed_evm_versions/0" do
# test "returns allowed evm versions defined by ALLOWED_EVM_VERSIONS env var" do
# Application.put_env(:explorer, :allowed_evm_versions, "CustomEVM1,CustomEVM2,CustomEVM3")
# response = CodeCompiler.allowed_evm_versions()
# assert ["CustomEVM1", "CustomEVM2", "CustomEVM3"] = response
# end
# test "returns allowed evm versions defined by not trimmed ALLOWED_EVM_VERSIONS env var" do
# Application.put_env(:explorer, :allowed_evm_versions, "CustomEVM1, CustomEVM2, CustomEVM3")
# response = CodeCompiler.allowed_evm_versions()
# assert ["CustomEVM1", "CustomEVM2", "CustomEVM3"] = response
# end
# test "returns default_allowed_evm_versions" do
# Application.put_env(
# :explorer,
# :allowed_evm_versions,
# "homestead,tangerineWhistle,spuriousDragon,byzantium,constantinople,petersburg"
# )
# response = CodeCompiler.allowed_evm_versions()
# assert ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople", "petersburg"] = response
# end
# end
defp remove_init_data_and_whisper_data(code) do defp remove_init_data_and_whisper_data(code) do
{res, _} = {res, _} =
code code

Loading…
Cancel
Save