Merge branch 'master' into split-api-and-webapp-routes

pull/2376/head
saneery 5 years ago
commit 5d2cca0884
  1. 38
      .circleci/config.yml
  2. 4
      .dialyzer-ignore
  3. 2
      .tool-versions
  4. 8
      CHANGELOG.md
  5. 4
      apps/block_scout_web/assets/css/components/_footer.scss
  6. 10
      apps/block_scout_web/assets/css/components/_network-selector.scss
  7. 4
      apps/block_scout_web/assets/webpack.config.js
  8. 28
      apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex
  9. 2
      apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex
  10. 2
      apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex
  11. 2
      apps/block_scout_web/mix.exs
  12. 10
      apps/block_scout_web/priv/gettext/default.pot
  13. 10
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  14. 10
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex
  15. 7
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transport.ex
  16. 2
      apps/ethereum_jsonrpc/mix.exs
  17. 3
      apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs
  18. 2
      apps/explorer/config/config.exs
  19. 4
      apps/explorer/lib/explorer/chain/import/runner/transactions.ex
  20. 2
      apps/explorer/mix.exs
  21. 23
      apps/explorer/priv/compile_solc.js
  22. 50
      apps/explorer/test/explorer/chain/import/runner/transactions_test.exs
  23. 20
      apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs
  24. 2
      apps/indexer/mix.exs
  25. 2
      docs/requirements.md
  26. 17
      mix.exs

@ -3,7 +3,7 @@ jobs:
build:
docker:
# Ensure .tool-versions matches
- image: circleci/elixir:1.8.1-node-browsers
- image: circleci/elixir:1.9.0-node-browsers
environment:
MIX_ENV: test
# match POSTGRES_PASSWORD for postgres image below
@ -129,7 +129,7 @@ jobs:
check_formatted:
docker:
# Ensure .tool-versions matches
- image: circleci/elixir:1.8.1
- image: circleci/elixir:1.9.0
environment:
MIX_ENV: test
@ -143,7 +143,7 @@ jobs:
credo:
docker:
# Ensure .tool-versions matches
- image: circleci/elixir:1.8.1
- image: circleci/elixir:1.9.0
environment:
MIX_ENV: test
@ -177,7 +177,7 @@ jobs:
dialyzer:
docker:
# Ensure .tool-versions matches
- image: circleci/elixir:1.8.1
- image: circleci/elixir:1.9.0
environment:
MIX_ENV: test
@ -191,9 +191,9 @@ jobs:
- restore_cache:
keys:
- v7-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}-{{ checksum "mix.lock" }}
- v7-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}-{{ checksum "mix.exs" }}
- v7-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}
- v8-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}-{{ checksum "mix.lock" }}
- v8-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}-{{ checksum "mix.exs" }}
- v8-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}
- run:
name: Unpack PLT cache
@ -213,15 +213,15 @@ jobs:
cp ~/.mix/dialyxir*.plt plts/
- save_cache:
key: v7-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}-{{ checksum "mix.lock" }}
key: v8-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}-{{ checksum "mix.lock" }}
paths:
- plts
- save_cache:
key: v7-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}-{{ checksum "mix.exs" }}
key: v8-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}-{{ checksum "mix.exs" }}
paths:
- plts
- save_cache:
key: v7-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}
key: v8-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}
paths:
- plts
@ -247,7 +247,7 @@ jobs:
gettext:
docker:
# Ensure .tool-versions matches
- image: circleci/elixir:1.8.1
- image: circleci/elixir:1.9.0
environment:
MIX_ENV: test
@ -286,7 +286,7 @@ jobs:
release:
docker:
# Ensure .tool-versions matches
- image: circleci/elixir:1.8.1
- image: circleci/elixir:1.9.0
environment:
MIX_ENV: prod
@ -298,7 +298,7 @@ jobs:
- run: mix local.hex --force
- run: mix local.rebar --force
- run: mix release --verbose --env prod
- run: MIX_ENV=prod mix release
- run:
name: Collecting artifacts
command: |
@ -312,7 +312,7 @@ jobs:
sobelow:
docker:
# Ensure .tool-versions matches
- image: circleci/elixir:1.8.1
- image: circleci/elixir:1.9.0
environment:
MIX_ENV: test
@ -336,7 +336,7 @@ jobs:
test_geth_http_websocket:
docker:
# Ensure .tool-versions matches
- image: circleci/elixir:1.8.1-node-browsers
- image: circleci/elixir:1.9.0-node-browsers
environment:
MIX_ENV: test
# match POSTGRES_PASSWORD for postgres image below
@ -390,7 +390,7 @@ jobs:
test_geth_mox:
docker:
# Ensure .tool-versions matches
- image: circleci/elixir:1.8.1-node-browsers
- image: circleci/elixir:1.9.0-node-browsers
environment:
MIX_ENV: test
# match POSTGRES_PASSWORD for postgres image below
@ -444,7 +444,7 @@ jobs:
test_parity_http_websocket:
docker:
# Ensure .tool-versions matches
- image: circleci/elixir:1.8.1-node-browsers
- image: circleci/elixir:1.9.0-node-browsers
environment:
MIX_ENV: test
# match POSTGRES_PASSWORD for postgres image below
@ -498,7 +498,7 @@ jobs:
test_parity_mox:
docker:
# Ensure .tool-versions matches
- image: circleci/elixir:1.8.1-node-browsers
- image: circleci/elixir:1.9.0-node-browsers
environment:
MIX_ENV: test
# match POSTGRES_PASSWORD for postgres image below
@ -552,7 +552,7 @@ jobs:
coveralls_merge:
docker:
# Ensure .tool-versions matches
- image: circleci/elixir:1.8.1
- image: circleci/elixir:1.9.0
environment:
MIX_ENV: test

@ -2,6 +2,10 @@
:0: Unknown function 'Elixir.ExUnit.CaseTemplate':'__proxy__'/2
:0: Unknown type 'Elixir.Map':t/0
apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex:400: Function timestamp_to_datetime/1 has no local return
lib/block_scout_web/views/layout_view.ex:174: The call 'Elixir.Poison.Parser':'parse!'(any(),#{'keys':='atoms!'}) will never return since the success typing is (binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | []),[{atom(),_}]) -> 'false' | 'nil' | 'true' | binary() | ['false' | 'nil' | 'true' | binary() | [any()] | number() | map()] | number() | map() and the contract is (iodata(),'Elixir.Keyword':t()) -> t()
lib/explorer/repo/prometheus_logger.ex:8
lib/block_scout_web/views/layout_view.ex:175
lib/explorer/smart_contract/publisher_worker.ex:6
apps/explorer/lib/explorer/repo/prometheus_logger.ex:8: Function microseconds_time/1 has no local return
apps/explorer/lib/explorer/repo/prometheus_logger.ex:8: The call 'Elixir.System':convert_time_unit(__@1::any(),'native','microseconds') breaks the contract (integer(),time_unit() | 'native',time_unit() | 'native') -> integer()
apps/block_scout_web/lib/block_scout_web/views/layout_view.ex:175: The call 'Elixir.Poison.Parser':'parse!'(any(),#{'keys':='atoms!'}) will never return since the success typing is (binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | []),[{atom(),_}]) -> 'false' | 'nil' | 'true' | binary() | ['false' | 'nil' | 'true' | binary() | [any()] | number() | map()] | number() | map() and the contract is (iodata(),'Elixir.Keyword':t()) -> t()

@ -1,3 +1,3 @@
elixir 1.8.1
elixir 1.9
erlang 21.0.4
nodejs 10.11.0

@ -1,10 +1,15 @@
## Current
### Features
- [#2379](https://github.com/poanetwork/blockscout/pull/2379) - Disable network selector when is empty
- [#2360](https://github.com/poanetwork/blockscout/pull/2360) - add default evm version to smart contract verification
- [#2352](https://github.com/poanetwork/blockscout/pull/2352) - Fetch rewards in parallel with transactions
- [#2294](https://github.com/poanetwork/blockscout/pull/2294) - add healthy block period checking endpoint
### Fixes
- [#2378](https://github.com/poanetwork/blockscout/pull/2378) - Page performance: exclude moment.js localization files except EN, remove unused css
- [#2368](https://github.com/poanetwork/blockscout/pull/2368) - add two columns of smart contract info
- [#2375](https://github.com/poanetwork/blockscout/pull/2375) - Update created_contract_code_indexed_at on transaction import conflict
- [#2346](https://github.com/poanetwork/blockscout/pull/2346) - Avoid fetching internal transactions of blocks that still need refetching
- [#2350](https://github.com/poanetwork/blockscout/pull/2350) - fix invalid User agent headers
- [#2345](https://github.com/poanetwork/blockscout/pull/2345) - do not override existing market records
@ -27,8 +32,8 @@
- [#2302](https://github.com/poanetwork/blockscout/pull/2302) - fix names for xDai source
- [#2289](https://github.com/poanetwork/blockscout/pull/2289) - Optional websockets for dev environment
- [#2307](https://github.com/poanetwork/blockscout/pull/2307) - add GoJoy to README
- [#2293](https://github.com/poanetwork/blockscout/pull/2293) - remove request idle timeout configuration
- [#2255](https://github.com/poanetwork/blockscout/pull/2255) - bump elixir version to 1.9.0
## 2.0.1-beta
@ -115,6 +120,7 @@
### Chore
- [#2127](https://github.com/poanetwork/blockscout/pull/2127) - use previouse chromedriver version
- [#2118](https://github.com/poanetwork/blockscout/pull/2118) - show only the last decompiled contract
- [#2255](https://github.com/poanetwork/blockscout/pull/2255) - upgrade elixir version to 1.9.0
- [#2256](https://github.com/poanetwork/blockscout/pull/2256) - use the latest version of chromedriver
## 2.0.0-beta

@ -61,10 +61,6 @@ $footer-logo-width: auto !default;
}
}
.footer-info {
padding-top: 1em;
}
.footer-link {
color: $footer-link-color;

@ -287,16 +287,6 @@ $network-selector-item-icon-dimensions: 30px !default;
}
}
.network-selector-load-more-container {
flex-shrink: 1;
padding: 0 $network-selector-horizontal-padding;
.btn-network-selector-load-more {
@include btn-line($btn-network-selector-load-more-background, $btn-network-selector-load-more-color);
width: 100%;
}
}
.network-selector-item-favorite {
align-items: center;
cursor: pointer;

@ -1,6 +1,7 @@
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const { ContextReplacementPlugin } = require('webpack')
const glob = require("glob");
function transpileViewScript(file) {
@ -74,7 +75,8 @@ const appJs =
},
plugins: [
new ExtractTextPlugin('../css/app.css'),
new CopyWebpackPlugin([{ from: 'static/', to: '../' }])
new CopyWebpackPlugin([{ from: 'static/', to: '../' }]),
new ContextReplacementPlugin(/moment[\/\\]locale$/, /en/)
]
}

@ -23,12 +23,22 @@
<%= if BlockScoutWeb.AddressView.smart_contract_verified?(@address) do %>
<div class="mb-4">
<dl class="row">
<dt class="col-sm-4 col-md-2 text-muted"><%= gettext "Contract name:" %></dt>
<dd class="col-sm-8 col-md-10"><%= @address.smart_contract.name %></dd>
<dt class="col-md-2 text-muted"><%= gettext "Contract name:" %></dt>
<dd class="col-md-4"><%= @address.smart_contract.name %></dd>
<div class="d-none d-sm-block d-md-none"></br></br></div>
<div class="d-block d-sm-none"></br></br></div>
<dt class="col-md-2 text-muted"><%= gettext "Optimization enabled" %></dt>
<dd class="col-md-4"><%= format_optimization_text(@address.smart_contract.optimization) %></dd>
</dl>
<dl class="row">
<dt class="col-sm-4 col-md-2 text-muted"><%= gettext "Compiler version" %></dt>
<dd class="col-sm-8 col-md-10"><%= @address.smart_contract.compiler_version %></dd>
<dt class="col-md-2 text-muted"><%= gettext "Compiler version" %></dt>
<dd class="col-md-4"><%= @address.smart_contract.compiler_version %></dd>
<div class="d-none d-sm-block d-md-none"></br></br></div>
<div class="d-block d-sm-none"></br></br></div>
<%= if @address.smart_contract.optimization && @address.smart_contract.optimization_runs do %>
<dt class="col-md-2 text-muted"><%= gettext "Optimization runs" %></dt>
<dd class="col-md-4"><%= @address.smart_contract.optimization_runs %></dd>
<% end %>
</dl>
<%= if @address.smart_contract.evm_version do %>
<dl class="row">
@ -36,16 +46,6 @@
<dd class="col-sm-8 col-md-10"><%= @address.smart_contract.evm_version %></dd>
</dl>
<% end %>
<dl class="row">
<dt class="col-sm-4 col-md-2 text-muted"><%= gettext "Optimization enabled" %></dt>
<dd class="col-sm-8 col-md-10"><%= format_optimization_text(@address.smart_contract.optimization) %></dd>
</dl>
<%= if @address.smart_contract.optimization && @address.smart_contract.optimization_runs do %>
<dl class="row">
<dt class="col-sm-4 col-md-2 text-muted"><%= gettext "Optimization runs" %></dt>
<dd class="col-sm-8 col-md-10"><%= @address.smart_contract.optimization_runs %></dd>
</dl>
<% end %>
<%= if @address.smart_contract.constructor_arguments do %>
<dl class="row">
<dt class="col-sm-4 col-md-2 text-muted"><%= gettext "Constructor arguments" %></dt>

@ -50,7 +50,7 @@
<div class="smart-contract-form-group-inner-wrapper">
<%= label :evm_version, :evm_version, gettext("EVM Version") %>
<div class="center-column">
<%= select f, :evm_version, @evm_versions, class: "form-control border-rounded", selected: "petersburg", "aria-describedby": "evm-version-help-block" %>
<%= select f, :evm_version, @evm_versions, class: "form-control border-rounded", selected: "default", "aria-describedby": "evm-version-help-block" %>
</div>
<div class="smart-contract-form-group-tooltip">The EVM version the contract is written for. If the bytecode does not match the version, we try to verify using the latest EVM version. <a href="https://forum.poa.network/t/smart-contract-verification-evm-version-details/2318" target="_blank">EVM version details</a>.</div>
</div>

@ -86,7 +86,7 @@
</li>
<% end %>
<li class="nav-item dropdown nav-item-networks">
<a class="nav-link topnav-nav-link dropdown-toggle active-icon js-show-network-selector <%= if dropdown_nets() == [], do: "disabled" %>" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<a class="nav-link topnav-nav-link active-icon <%= if dropdown_nets() != [], do: "dropdown-toggle js-show-network-selector" %>" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="nav-link-icon">
<%= render BlockScoutWeb.IconsView, "_active_icon.html" %>
</span>

@ -15,7 +15,7 @@ defmodule BlockScoutWeb.Mixfile do
plt_add_deps: :transitive,
ignore_warnings: "../../.dialyzer-ignore"
],
elixir: "~> 1.8",
elixir: "~> 1.9",
elixirc_paths: elixirc_paths(Mix.env()),
lockfile: "../../mix.lock",
package: package(),

@ -230,7 +230,7 @@ msgid "Compiler"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:30
#: lib/block_scout_web/templates/address_contract/index.html.eex:34
msgid "Compiler version"
msgstr ""
@ -509,11 +509,13 @@ msgstr ""
#: lib/block_scout_web/templates/chain/show.html.eex:31
#: lib/block_scout_web/templates/layout/app.html.eex:53
#: lib/block_scout_web/views/address_view.ex:121
#: lib/block_scout_web/views/address_view.ex:121
msgid "Market Cap"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:129
#: lib/block_scout_web/views/transaction_view.ex:129
msgid "Max of"
msgstr ""
@ -577,7 +579,7 @@ msgid "OUT"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:40
#: lib/block_scout_web/templates/address_contract/index.html.eex:30
msgid "Optimization enabled"
msgstr ""
@ -1487,7 +1489,7 @@ msgid "Search by address, token symbol name, transaction hash, or block number"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:35
#: lib/block_scout_web/templates/address_contract/index.html.eex:45
#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:51
msgid "EVM Version"
msgstr ""
@ -1518,7 +1520,7 @@ msgid "Decompiler version"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:45
#: lib/block_scout_web/templates/address_contract/index.html.eex:39
#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:83
msgid "Optimization runs"
msgstr ""

@ -230,7 +230,7 @@ msgid "Compiler"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:30
#: lib/block_scout_web/templates/address_contract/index.html.eex:34
msgid "Compiler version"
msgstr ""
@ -509,11 +509,13 @@ msgstr ""
#: lib/block_scout_web/templates/chain/show.html.eex:31
#: lib/block_scout_web/templates/layout/app.html.eex:53
#: lib/block_scout_web/views/address_view.ex:121
#: lib/block_scout_web/views/address_view.ex:121
msgid "Market Cap"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:129
#: lib/block_scout_web/views/transaction_view.ex:129
msgid "Max of"
msgstr ""
@ -577,7 +579,7 @@ msgid "OUT"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:40
#: lib/block_scout_web/templates/address_contract/index.html.eex:30
msgid "Optimization enabled"
msgstr ""
@ -1487,7 +1489,7 @@ msgid "Search by address, token symbol name, transaction hash, or block number"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:35
#: lib/block_scout_web/templates/address_contract/index.html.eex:45
#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:51
msgid "EVM Version"
msgstr ""
@ -1518,7 +1520,7 @@ msgid "Decompiler version"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:45
#: lib/block_scout_web/templates/address_contract/index.html.eex:39
#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:83
msgid "Optimization runs"
msgstr ""

@ -209,9 +209,14 @@ defmodule EthereumJSONRPC.RollingWindow do
@doc """
Display the raw contents of all windows for a given key.
"""
@spec inspect(table :: atom, key :: term()) :: nonempty_list(non_neg_integer)
@spec inspect(table :: atom, key :: term()) :: nonempty_list(non_neg_integer) | []
def inspect(table, key) do
case :ets.lookup(table, key) do
case :ets.whereis(table) do
:undefined ->
[]
tid ->
case :ets.lookup(tid, key) do
[{_, current_window, windows}] ->
[current_window | windows]
@ -219,4 +224,5 @@ defmodule EthereumJSONRPC.RollingWindow do
[]
end
end
end
end

@ -88,10 +88,6 @@ defmodule EthereumJSONRPC.Transport do
`%{"id" => ..., "error" => reason}`. The transport can also give any `term()` for `reason` if a more specific
reason is possible.
"""
@callback json_rpc(request, options) :: {:ok, result} | {:error, reason :: term()}
@doc """
Runs a batch of Remote Procedure Call (RPC) `request`s with `options`.
## Returns
@ -99,8 +95,9 @@ defmodule EthereumJSONRPC.Transport do
* `{:ok, [response]}` unlike `json_rpc(request, options)`, the individual `t:response.t/0` are not unwrapped and it
is the callers responsibility to extract the `t:result/0` or error `reason`.
* `{:error, reason}` an error that affects *all* `t:request/0`s, such as the batch as a whole being rejected.
"""
@callback json_rpc(request, options) :: {:ok, result} | {:error, reason :: term()}
@callback json_rpc(batch_request, options) :: {:ok, batch_response} | {:error, reason :: term()}
@doc """

@ -15,7 +15,7 @@ defmodule EthereumJsonrpc.MixProject do
plt_add_apps: [:mix],
ignore_warnings: "../../.dialyzer-ignore"
],
elixir: "~> 1.8",
elixir: "~> 1.9",
elixirc_paths: elixirc_paths(Mix.env()),
lockfile: "../../mix.lock",
preferred_cli_env: [

@ -10,8 +10,11 @@ defmodule EthereumJSONRPC.RollingWindowTest do
setup do
# We set `window_length` to a large time frame so that we can sweep manually to simulate
# time passing
{:ok, pid} =
RollingWindow.start_link([table: @table, duration: :timer.minutes(120), window_count: 3], name: RollingWindow)
on_exit(fn -> Process.exit(pid, :normal) end)
:ok
end

@ -12,7 +12,7 @@ config :explorer,
token_functions_reader_max_retries: 3,
allowed_evm_versions:
System.get_env("ALLOWED_EVM_VERSIONS") ||
"homestead,tangerineWhistle,spuriousDragon,byzantium,constantinople,petersburg",
"homestead,tangerineWhistle,spuriousDragon,byzantium,constantinople,petersburg,default",
include_uncles_in_average_block_time:
if(System.get_env("UNCLES_IN_AVERAGE_BLOCK_TIME") == "false", do: false, else: true),
healthy_blocks_period: System.get_env("HEALTHY_BLOCKS_PERIOD") || :timer.minutes(5)

@ -105,6 +105,7 @@ defmodule Explorer.Chain.Import.Runner.Transactions do
old_block_hash: transaction.block_hash,
block_number: fragment("EXCLUDED.block_number"),
created_contract_address_hash: fragment("EXCLUDED.created_contract_address_hash"),
created_contract_code_indexed_at: fragment("EXCLUDED.created_contract_code_indexed_at"),
cumulative_gas_used: fragment("EXCLUDED.cumulative_gas_used"),
error: fragment("EXCLUDED.error"),
from_address_hash: fragment("EXCLUDED.from_address_hash"),
@ -128,10 +129,11 @@ defmodule Explorer.Chain.Import.Runner.Transactions do
],
where:
fragment(
"(EXCLUDED.block_hash, EXCLUDED.block_number, EXCLUDED.created_contract_address_hash, EXCLUDED.cumulative_gas_used, EXCLUDED.cumulative_gas_used, EXCLUDED.from_address_hash, EXCLUDED.gas, EXCLUDED.gas_price, EXCLUDED.gas_used, EXCLUDED.index, EXCLUDED.internal_transactions_indexed_at, EXCLUDED.input, EXCLUDED.nonce, EXCLUDED.r, EXCLUDED.s, EXCLUDED.status, EXCLUDED.to_address_hash, EXCLUDED.v, EXCLUDED.value) IS DISTINCT FROM (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"(EXCLUDED.block_hash, EXCLUDED.block_number, EXCLUDED.created_contract_address_hash, EXCLUDED.created_contract_code_indexed_at, EXCLUDED.cumulative_gas_used, EXCLUDED.cumulative_gas_used, EXCLUDED.from_address_hash, EXCLUDED.gas, EXCLUDED.gas_price, EXCLUDED.gas_used, EXCLUDED.index, EXCLUDED.internal_transactions_indexed_at, EXCLUDED.input, EXCLUDED.nonce, EXCLUDED.r, EXCLUDED.s, EXCLUDED.status, EXCLUDED.to_address_hash, EXCLUDED.v, EXCLUDED.value) IS DISTINCT FROM (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
transaction.block_hash,
transaction.block_number,
transaction.created_contract_address_hash,
transaction.created_contract_code_indexed_at,
transaction.cumulative_gas_used,
transaction.cumulative_gas_used,
transaction.from_address_hash,

@ -15,7 +15,7 @@ defmodule Explorer.Mixfile do
plt_add_apps: ~w(ex_unit mix)a,
ignore_warnings: "../../.dialyzer-ignore"
],
elixir: "~> 1.8",
elixir: "~> 1.9",
elixirc_paths: elixirc_paths(Mix.env()),
lockfile: "../../mix.lock",
package: package(),

@ -16,15 +16,7 @@ var solc = solc.setupMethods(compilerSnapshot);
var fs = require('fs');
var sourceCode = fs.readFileSync(sourceCodePath, 'utf8');
const input = {
language: 'Solidity',
sources: {
[newContractName]: {
content: sourceCode
}
},
settings: {
evmVersion: evmVersion,
var settings = {
optimizer: {
enabled: optimize == '1',
runs: optimizationRuns
@ -37,7 +29,20 @@ const input = {
'*': ['*']
}
}
}
if (evmVersion !== 'default') {
settings = Object.assign(settings, {evmVersion: evmVersion})
}
const input = {
language: 'Solidity',
sources: {
[newContractName]: {
content: sourceCode
}
},
settings: settings
}

@ -0,0 +1,50 @@
defmodule Explorer.Chain.Import.Runner.TransactionsTest do
use Explorer.DataCase
alias Ecto.Multi
alias Explorer.Chain.{Address, Transaction}
alias Explorer.Chain.Import.Runner.Transactions
describe "run/1" do
test "transaction's created_contract_code_indexed_at is modified on update" do
%Address{hash: address_hash} = insert(:address)
transaction =
insert(:transaction,
created_contract_address_hash: address_hash,
created_contract_code_indexed_at: DateTime.utc_now()
)
assert not is_nil(transaction.created_contract_code_indexed_at)
non_indexed_transaction_params = %{
from_address_hash: transaction.from_address.hash,
gas: transaction.gas,
gas_price: transaction.gas_price,
hash: transaction.hash,
input: transaction.input,
nonce: transaction.nonce,
r: transaction.r,
s: transaction.s,
to_address_hash: transaction.to_address.hash,
v: transaction.v,
value: transaction.value,
created_contract_address_hash: address_hash,
created_contract_code_indexed_at: nil
}
assert {:ok, _} = run_transactions([non_indexed_transaction_params])
assert is_nil(Repo.get(Transaction, transaction.hash).created_contract_code_indexed_at)
end
end
defp run_transactions(changes_list) when is_list(changes_list) do
Multi.new()
|> Transactions.run(changes_list, %{
timeout: :infinity,
timestamps: %{inserted_at: DateTime.utc_now(), updated_at: DateTime.utc_now()}
})
|> Repo.transaction()
end
end

@ -53,6 +53,26 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do
}} = response
end
test "compiles smart contract with default evm version", %{contract_code_info: contract_code_info} do
optimize = true
response =
CodeCompiler.run(
name: contract_code_info.name,
compiler_version: contract_code_info.version,
code: contract_code_info.source_code,
optimize: optimize,
evm_version: "default"
)
assert {:ok,
%{
"abi" => _,
"bytecode" => _,
"name" => _
}} = response
end
test "compiles code with external libraries" do
Enum.each(@compiler_tests, fn compiler_test ->
compiler_version = compiler_test["compiler_version"]

@ -10,7 +10,7 @@ defmodule Indexer.MixProject do
deps: deps(),
deps_path: "../../deps",
description: "Fetches block chain data from on-chain node for later reading with Explorer.",
elixir: "~> 1.8",
elixir: "~> 1.9",
elixirc_paths: elixirc_paths(Mix.env()),
lockfile: "../../mix.lock",
preferred_cli_env: [

@ -5,7 +5,7 @@
| Dependency | Mac | Linux |
|-------------|-----|-------|
| [Erlang/OTP 21.0.4](https://github.com/erlang/otp) | `brew install erlang` | [Erlang Install Example](https://github.com/poanetwork/blockscout-terraform/blob/33f68e816e36dc2fb055911fa0372531f0e956e7/modules/stack/libexec/init.sh#L134) |
| [Elixir 1.8.1](https://elixir-lang.org/) | :point_up: | [Elixir Install Example](https://github.com/poanetwork/blockscout-terraform/blob/33f68e816e36dc2fb055911fa0372531f0e956e7/modules/stack/libexec/init.sh#L138) |
| [Elixir 1.9.0](https://elixir-lang.org/) | :point_up: | [Elixir Install Example](https://github.com/poanetwork/blockscout-terraform/blob/33f68e816e36dc2fb055911fa0372531f0e956e7/modules/stack/libexec/init.sh#L138) |
| [Postgres 10.3](https://www.postgresql.org/) | `brew install postgresql` | [Postgres Install Example](https://github.com/poanetwork/blockscout-terraform/blob/33f68e816e36dc2fb055911fa0372531f0e956e7/modules/stack/libexec/init.sh#L187) |
| [Node.js 10.x.x](https://nodejs.org/en/) | `brew install node` | [Node.js Install Example](https://github.com/poanetwork/blockscout-terraform/blob/33f68e816e36dc2fb055911fa0372531f0e956e7/modules/stack/libexec/init.sh#L66) |
| [Automake](https://www.gnu.org/software/automake/) | `brew install automake` | [Automake Install Example](https://github.com/poanetwork/blockscout-terraform/blob/33f68e816e36dc2fb055911fa0372531f0e956e7/modules/stack/libexec/init.sh#L72) |

@ -6,6 +6,7 @@ defmodule BlockScout.Mixfile do
def project do
[
aliases: aliases(Mix.env()),
version: "2.0",
apps_path: "apps",
deps: deps(),
dialyzer: [
@ -13,7 +14,7 @@ defmodule BlockScout.Mixfile do
plt_add_apps: ~w(ex_unit mix)a,
ignore_warnings: ".dialyzer-ignore"
],
elixir: "~> 1.8",
elixir: "~> 1.9",
preferred_cli_env: [
coveralls: :test,
"coveralls.detail": :test,
@ -23,7 +24,17 @@ defmodule BlockScout.Mixfile do
dialyzer: :test
],
start_permanent: Mix.env() == :prod,
test_coverage: [tool: ExCoveralls]
test_coverage: [tool: ExCoveralls],
releases: [
blockscout: [
applications: [
block_scout_web: :permanent,
ethereum_jsonrpc: :permanent,
explorer: :permanent,
indexer: :permanent
]
]
]
]
end
@ -61,8 +72,6 @@ defmodule BlockScout.Mixfile do
# and cannot be accessed from applications inside the apps folder
defp deps do
[
# Release
{:distillery, "~> 2.0", runtime: false},
# Documentation
{:ex_doc, "~> 0.19.0", only: [:dev]},
# Code coverage

Loading…
Cancel
Save