Remove compile-time vars

pull/6954/head
Viktor Baranov 2 years ago
parent 944434363d
commit 44d9562f41
  1. 5
      .github/workflows/e2e-tests.yml
  2. 10
      .github/workflows/publish-docker-image-every-push.yml
  3. 3
      .github/workflows/publish-docker-image-release.yml
  4. 1
      CHANGELOG.md
  5. 3
      apps/block_scout_web/assets/js/lib/add_chain_to_mm.js
  6. 8
      apps/block_scout_web/assets/js/socket.js
  7. 2
      apps/block_scout_web/assets/webpack.config.js
  8. 27
      apps/block_scout_web/config/config.exs
  9. 12
      apps/block_scout_web/lib/block_scout_web/router.ex
  10. 1
      apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex
  11. 23
      apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex
  12. 21
      apps/block_scout_web/lib/block_scout_web/views/tokens/instance/overview_view.ex
  13. 6
      apps/block_scout_web/priv/gettext/default.pot
  14. 6
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  15. 30
      apps/block_scout_web/test/block_scout_web/views/api_docs_view_test.exs
  16. 6
      apps/explorer/lib/explorer/repo/config_helper.ex
  17. 25
      config/runtime.exs
  18. 3
      docker-compose/docker-compose-no-rust-services.yml
  19. 3
      docker-compose/docker-compose.yml
  20. 3
      docker-compose/envs/common-blockscout.env
  21. 3
      docker/Dockerfile
  22. 9
      docker/Makefile

@ -63,17 +63,12 @@ jobs:
build-args: |
CACHE_EXCHANGE_RATES_PERIOD=
DISABLE_READ_API=false
API_PATH=
NETWORK_PATH=
DISABLE_WEBAPP=false
DISABLE_WRITE_API=false
CACHE_ENABLE_TOTAL_GAS_USAGE_COUNTER=
WOBSERVER_ENABLED=false
ADMIN_PANEL_ENABLED=false
CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL=
DISABLE_BRIDGE_MARKET_CAP_UPDATER=false
CACHE_BRIDGE_MARKET_CAP_UPDATE_INTERVAL=
SOCKET_ROOT=
deploy_and_tests:
needs: push_to_registry

@ -59,17 +59,12 @@ jobs:
build-args: |
CACHE_EXCHANGE_RATES_PERIOD=
DISABLE_READ_API=false
API_PATH=
NETWORK_PATH=
DISABLE_WEBAPP=false
DISABLE_WRITE_API=false
CACHE_ENABLE_TOTAL_GAS_USAGE_COUNTER=
WOBSERVER_ENABLED=false
ADMIN_PANEL_ENABLED=false
CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL=
DISABLE_BRIDGE_MARKET_CAP_UPDATER=false
CACHE_BRIDGE_MARKET_CAP_UPDATE_INTERVAL=
SOCKET_ROOT=
- name: Build and push Docker image for frontend
uses: docker/build-push-action@v3
@ -82,17 +77,12 @@ jobs:
build-args: |
CACHE_EXCHANGE_RATES_PERIOD=
DISABLE_READ_API=false
API_PATH=
NETWORK_PATH=
DISABLE_WEBAPP=false
DISABLE_WRITE_API=false
CACHE_ENABLE_TOTAL_GAS_USAGE_COUNTER=
WOBSERVER_ENABLED=false
ADMIN_PANEL_ENABLED=false
CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL=
DISABLE_BRIDGE_MARKET_CAP_UPDATER=false
CACHE_BRIDGE_MARKET_CAP_UPDATE_INTERVAL=
SOCKET_ROOT=
SESSION_COOKIE_DOMAIN=${{ secrets.FRONTEND_MAIN }}
tests:
needs: push_to_registry

@ -56,15 +56,12 @@ jobs:
build-args: |
CACHE_EXCHANGE_RATES_PERIOD=
DISABLE_READ_API=false
API_PATH=/
NETWORK_PATH=/
DISABLE_WEBAPP=false
DISABLE_WRITE_API=false
CACHE_ENABLE_TOTAL_GAS_USAGE_COUNTER=
WOBSERVER_ENABLED=false
ADMIN_PANEL_ENABLED=
CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL=
SOCKET_ROOT=
merge-master-after-release:
name: Merge 'master' to specific branch after release

@ -25,6 +25,7 @@
### Chore
- [#6954](https://github.com/blockscout/blockscout/pull/6954) - Move some compile time vars to runtime
- [#6952](https://github.com/blockscout/blockscout/pull/6952) - Manage BlockReward fetcher params
- [#6929](https://github.com/blockscout/blockscout/pull/6929) - Extend `INDEXER_MEMORY_LIMIT` env parsing
- [#6902](https://github.com/blockscout/blockscout/pull/6902) - Increase verification timeout to 120 seconds for microservice verification

@ -15,8 +15,9 @@ export async function addChainToMM ({ btn }) {
const jsonRPCObj = document.getElementById('js-json-rpc')
// @ts-ignore
const jsonRPC = jsonRPCObj && jsonRPCObj.value
const pathObj = document.getElementById('network-path')
// @ts-ignore
const path = process.env.NETWORK_PATH || '/'
const path = (pathObj && pathObj.value) || '/'
const blockscoutURL = location.protocol + '//' + location.host + path
if (chainIDFromWallet !== chainIDFromInstance) {

@ -1,8 +1,12 @@
import { Socket } from 'phoenix'
import { locale } from './locale'
// @ts-ignore
let websocketRootUrl = process.env.SOCKET_ROOT
const networkParhObj = document.getElementById('network-path')
let websocketRootUrl
if (networkParhObj) {
// @ts-ignore
websocketRootUrl = networkParhObj.value
}
if (!websocketRootUrl) {
websocketRootUrl = ''
}

@ -166,8 +166,6 @@ const appJs =
),
new ContextReplacementPlugin(/moment[\/\\]locale$/, /en/),
new webpack.DefinePlugin({
'process.env.SOCKET_ROOT': JSON.stringify(process.env.SOCKET_ROOT),
'process.env.NETWORK_PATH': JSON.stringify(process.env.NETWORK_PATH),
'process.env.MIXPANEL_TOKEN': JSON.stringify(process.env.MIXPANEL_TOKEN),
'process.env.MIXPANEL_URL': JSON.stringify(process.env.MIXPANEL_URL),
'process.env.AMPLITUDE_API_KEY': JSON.stringify(process.env.AMPLITUDE_API_KEY),

@ -5,24 +5,6 @@
# is restricted to this project.
import Config
network_path =
"NETWORK_PATH"
|> System.get_env("/")
|> (&(if String.ends_with?(&1, "/") do
String.trim_trailing(&1, "/")
else
&1
end)).()
api_path =
"API_PATH"
|> System.get_env("/")
|> (&(if String.ends_with?(&1, "/") do
String.trim_trailing(&1, "/")
else
&1
end)).()
# General application configuration
config :block_scout_web,
namespace: BlockScoutWeb,
@ -36,15 +18,6 @@ config :block_scout_web, BlockScoutWeb.Counters.BlocksIndexedCounter, enabled: t
config :block_scout_web, BlockScoutWeb.Counters.InternalTransactionsIndexedCounter, enabled: true
# Configures the endpoint
config :block_scout_web, BlockScoutWeb.Endpoint,
url: [
path: network_path,
api_path: api_path
],
render_errors: [view: BlockScoutWeb.ErrorView, accepts: ~w(html json)],
pubsub_server: BlockScoutWeb.PubSub
config :block_scout_web, BlockScoutWeb.Tracer,
service: :block_scout_web,
adapter: SpandexDatadog.Adapter,

@ -59,23 +59,11 @@ defmodule BlockScoutWeb.Router do
get("/eth-rpc-api-docs", APIDocsController, :eth_rpc)
end
url_params = Application.compile_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url]
api_path = url_params[:api_path]
path = url_params[:path]
if path != api_path do
scope to_string(api_path) <> "/verify_smart_contract" do
pipe_through(:api)
post("/contract_verifications", BlockScoutWeb.AddressContractVerificationController, :create)
end
else
scope "/verify_smart_contract" do
pipe_through(:api)
post("/contract_verifications", BlockScoutWeb.AddressContractVerificationController, :create)
end
end
if Application.compile_env(:block_scout_web, WebRouter)[:enabled] do
forward("/", BlockScoutWeb.WebRouter)

@ -64,6 +64,7 @@
<input id="js-chain-id" class="d-none" value="<%= Application.get_env(:block_scout_web, :chain_id) %>" />
<input id="js-json-rpc" class="d-none" value="<%= Application.get_env(:block_scout_web, :json_rpc) %>" />
<input id="re-captcha-client-key" class="d-none" value="<%= Application.get_env(:block_scout_web, :re_captcha_client_key) %>" />
<input id="network-path" class="d-none" value="<%= Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url][:path] %>" />
<!-- -->
<% show_maintenance_alert = Application.get_env(:block_scout_web, BlockScoutWeb.Chain)[:show_maintenance_alert] %>
<%= if show_maintenance_alert do %>

@ -49,16 +49,11 @@ defmodule BlockScoutWeb.APIDocsView do
end
end
def blockscout_url(set_path, is_api) when set_path == true do
def blockscout_url(set_path) when set_path == true do
url_params = Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url]
host = url_params[:host]
path =
if is_api do
url_params[:api_path]
else
url_params[:path]
end
path = url_params[:path]
scheme = Keyword.get(url_params, :scheme, "http")
@ -71,20 +66,14 @@ defmodule BlockScoutWeb.APIDocsView do
end
def api_url do
is_api = true
set_path = true
set_path
|> blockscout_url(is_api)
true
|> blockscout_url()
|> Path.join("api")
end
def eth_rpc_api_url do
is_api = true
set_path = true
set_path
|> blockscout_url(is_api)
true
|> blockscout_url()
|> Path.join("api/eth-rpc")
end
end

@ -6,7 +6,7 @@ defmodule BlockScoutWeb.Tokens.Instance.OverviewView do
alias Explorer.Chain.{Address, SmartContract, Token}
alias Explorer.SmartContract.Helper
import BlockScoutWeb.APIDocsView, only: [blockscout_url: 1, blockscout_url: 2]
import BlockScoutWeb.APIDocsView, only: [blockscout_url: 1]
import BlockScoutWeb.NFTHelpers, only: [external_url: 1]
@tabs ["token-transfers", "metadata"]
@ -92,24 +92,7 @@ defmodule BlockScoutWeb.Tokens.Instance.OverviewView do
def qr_code(conn, token_id, hash) do
token_instance_path = token_instance_path(conn, :show, to_string(hash), to_string(token_id))
url_params = Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url]
api_path = url_params[:api_path]
path = url_params[:path]
url_prefix =
if String.length(path) > 0 && path != "/" do
set_path = false
blockscout_url(set_path)
else
if String.length(api_path) > 0 && api_path != "/" do
is_api = true
set_path = true
blockscout_url(set_path, is_api)
else
set_path = false
blockscout_url(set_path)
end
end
url_prefix = blockscout_url(false)
url = Path.join(url_prefix, token_instance_path)

@ -81,7 +81,7 @@ msgstr ""
msgid ") may be added for each contract. Click the Add Library button to add an additional one."
msgstr ""
#: lib/block_scout_web/templates/layout/app.html.eex:84
#: lib/block_scout_web/templates/layout/app.html.eex:85
#, elixir-autogen, elixir-format
msgid "- We're indexing this chain right now. Some of the counts may be inaccurate."
msgstr ""
@ -1672,7 +1672,7 @@ msgstr ""
#: lib/block_scout_web/templates/tokens/instance/metadata/index.html.eex:18
#: lib/block_scout_web/templates/tokens/instance/overview/_tabs.html.eex:10
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:128
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:111
#, elixir-autogen, elixir-format
msgid "Metadata"
msgstr ""
@ -2736,7 +2736,7 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:4
#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:7
#: lib/block_scout_web/views/address_view.ex:373
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:127
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:110
#: lib/block_scout_web/views/tokens/overview_view.ex:39
#: lib/block_scout_web/views/transaction_view.ex:527
#, elixir-autogen, elixir-format

@ -81,7 +81,7 @@ msgstr ""
msgid ") may be added for each contract. Click the Add Library button to add an additional one."
msgstr ""
#: lib/block_scout_web/templates/layout/app.html.eex:84
#: lib/block_scout_web/templates/layout/app.html.eex:85
#, elixir-autogen, elixir-format
msgid "- We're indexing this chain right now. Some of the counts may be inaccurate."
msgstr ""
@ -1672,7 +1672,7 @@ msgstr ""
#: lib/block_scout_web/templates/tokens/instance/metadata/index.html.eex:18
#: lib/block_scout_web/templates/tokens/instance/overview/_tabs.html.eex:10
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:128
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:111
#, elixir-autogen, elixir-format
msgid "Metadata"
msgstr ""
@ -2736,7 +2736,7 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:4
#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:7
#: lib/block_scout_web/views/address_view.ex:373
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:127
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:110
#: lib/block_scout_web/views/tokens/overview_view.ex:39
#: lib/block_scout_web/views/transaction_view.ex:527
#, elixir-autogen, elixir-format

@ -14,7 +14,7 @@ defmodule BlockScoutWeb.ApiDocsViewTest do
test "adds slash before path" do
Application.put_env(:block_scout_web, BlockScoutWeb.Endpoint,
url: [scheme: "https", host: "blockscout.com", port: 9999, api_path: "/chain/dog"]
url: [scheme: "https", host: "blockscout.com", port: 9999, path: "/chain/dog"]
)
assert APIDocsView.api_url() == "https://blockscout.com/chain/dog/api"
@ -22,7 +22,7 @@ defmodule BlockScoutWeb.ApiDocsViewTest do
test "does not add slash to empty path" do
Application.put_env(:block_scout_web, BlockScoutWeb.Endpoint,
url: [scheme: "https", host: "blockscout.com", port: 9999, api_path: ""]
url: [scheme: "https", host: "blockscout.com", port: 9999, path: ""]
)
assert APIDocsView.api_url() == "https://blockscout.com/api"
@ -38,7 +38,7 @@ defmodule BlockScoutWeb.ApiDocsViewTest do
end
end
describe "blockscout_url/2" do
describe "blockscout_url/1" do
setup do
original = Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)
@ -49,35 +49,19 @@ defmodule BlockScoutWeb.ApiDocsViewTest do
test "set_path = true returns url with path" do
Application.put_env(:block_scout_web, BlockScoutWeb.Endpoint,
url: [scheme: "https", host: "blockscout.com", api_path: "/eth/mainnet", path: "/eth/mainnet"]
url: [scheme: "https", host: "blockscout.com", path: "/eth/mainnet"]
)
assert APIDocsView.blockscout_url(true, true) == "https://blockscout.com/eth/mainnet"
assert APIDocsView.blockscout_url(true) == "https://blockscout.com/eth/mainnet"
end
test "set_path = false returns url w/out path" do
Application.put_env(:block_scout_web, BlockScoutWeb.Endpoint,
url: [scheme: "https", host: "blockscout.com", api_path: "/eth/mainnet", path: "/eth/mainnet"]
url: [scheme: "https", host: "blockscout.com", path: "/eth/mainnet"]
)
assert APIDocsView.blockscout_url(false) == "https://blockscout.com"
end
test "set_path = true is_api returns url with api_path" do
Application.put_env(:block_scout_web, BlockScoutWeb.Endpoint,
url: [scheme: "https", host: "blockscout.com", api_path: "/eth/mainnet", path: "/"]
)
assert APIDocsView.blockscout_url(true, true) == "https://blockscout.com/eth/mainnet"
end
test "set_path = true is_api returns url with path" do
Application.put_env(:block_scout_web, BlockScoutWeb.Endpoint,
url: [scheme: "https", host: "blockscout.com", api_path: "/eth/mainnet", path: "/eth/mainnet2"]
)
assert APIDocsView.blockscout_url(true, false) == "https://blockscout.com/eth/mainnet2"
end
end
describe "eth_rpc_api_url/1" do
@ -91,7 +75,7 @@ defmodule BlockScoutWeb.ApiDocsViewTest do
test "adds slash before path" do
Application.put_env(:block_scout_web, BlockScoutWeb.Endpoint,
url: [scheme: "https", host: "blockscout.com", port: 9999, api_path: "/chain/dog"]
url: [scheme: "https", host: "blockscout.com", port: 9999, path: "/chain/dog"]
)
assert APIDocsView.eth_rpc_api_url() == "https://blockscout.com/chain/dog/api/eth-rpc"

@ -64,12 +64,6 @@ defmodule Explorer.Repo.ConfigHelper do
path_from_env(path)
end
def api_path do
path = System.get_env("API_PATH", "/")
path_from_env(path)
end
defp path_from_env(path_env_var) do
if String.ends_with?(path_env_var, "/") do
path_env_var

@ -31,16 +31,33 @@ indexer_empty_blocks_sanitizer_batch_size =
config :indexer, Indexer.Fetcher.EmptyBlocksSanitizer, batch_size: indexer_empty_blocks_sanitizer_batch_size
######################
### BlockScout Web ###
######################
network_path =
"NETWORK_PATH"
|> System.get_env("/")
|> (&(if String.ends_with?(&1, "/") do
String.trim_trailing(&1, "/")
else
&1
end)).()
# Configures the endpoint
config :block_scout_web, BlockScoutWeb.Endpoint,
url: [
path: network_path
],
render_errors: [view: BlockScoutWeb.ErrorView, accepts: ~w(html json)],
pubsub_server: BlockScoutWeb.PubSub
config :block_scout_web, :footer,
chat_link: System.get_env("FOOTER_CHAT_LINK", "https://discord.gg/blockscout"),
forum_link: System.get_env("FOOTER_FORUM_LINK", "https://forum.poa.network/c/blockscout"),
github_link: System.get_env("FOOTER_GITHUB_LINK", "https://github.com/blockscout/blockscout"),
enable_forum_link: System.get_env("FOOTER_ENABLE_FORUM_LINK", "false") == "true"
######################
### BlockScout Web ###
######################
# Configures Ueberauth's Auth0 auth provider
config :ueberauth, Ueberauth.Strategy.Auth0.OAuth,
domain: System.get_env("ACCOUNT_AUTH0_DOMAIN"),

@ -23,13 +23,10 @@ services:
args:
CACHE_EXCHANGE_RATES_PERIOD: ""
DISABLE_READ_API: "false"
API_PATH: "/"
NETWORK_PATH: "/"
DISABLE_WEBAPP: "false"
DISABLE_WRITE_API: "false"
CACHE_ENABLE_TOTAL_GAS_USAGE_COUNTER: ""
CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL: ""
SOCKET_ROOT: "/"
WOBSERVER_ENABLED: "false"
ADMIN_PANEL_ENABLED: ""
restart: always

@ -24,13 +24,10 @@ services:
args:
CACHE_EXCHANGE_RATES_PERIOD: ""
DISABLE_READ_API: "false"
API_PATH: "/"
NETWORK_PATH: "/"
DISABLE_WEBAPP: "false"
DISABLE_WRITE_API: "false"
CACHE_ENABLE_TOTAL_GAS_USAGE_COUNTER: ""
CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL: ""
SOCKET_ROOT: "/"
WOBSERVER_ENABLED: "false"
ADMIN_PANEL_ENABLED: ""
restart: always

@ -12,8 +12,6 @@ ETHEREUM_JSONRPC_TRANSPORT=http
ETHEREUM_JSONRPC_DISABLE_ARCHIVE_BALANCES=false
IPC_PATH=
NETWORK_PATH=/
API_PATH=/
SOCKET_ROOT=/
BLOCKSCOUT_HOST=
BLOCKSCOUT_PROTOCOL=
# SECRET_KEY_BASE=
@ -69,7 +67,6 @@ CACHE_MARKET_HISTORY_PERIOD=21600
CACHE_ADDRESS_TRANSACTIONS_COUNTER_PERIOD=1800
CACHE_ADDRESS_TOKENS_USD_SUM_PERIOD=1800
CACHE_ADDRESS_TOKEN_TRANSFERS_COUNTER_PERIOD=1800
CACHE_BRIDGE_MARKET_CAP_UPDATE_INTERVAL=1800
CACHE_TOKEN_EXCHANGE_RATE_PERIOD=1800
TOKEN_METADATA_UPDATE_INTERVAL=172800
ALLOWED_EVM_VERSIONS=homestead,tangerineWhistle,spuriousDragon,byzantium,constantinople,petersburg,istanbul,berlin,london,default

@ -25,15 +25,12 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ARG CACHE_EXCHANGE_RATES_PERIOD
ARG DISABLE_READ_API
ARG API_PATH
ARG NETWORK_PATH
ARG DISABLE_WEBAPP
ARG DISABLE_WRITE_API
ARG CACHE_ENABLE_TOTAL_GAS_USAGE_COUNTER
ARG WOBSERVER_ENABLED
ARG ADMIN_PANEL_ENABLED
ARG CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL
ARG SOCKET_ROOT
ARG SESSION_COOKIE_DOMAIN
ARG MIXPANEL_TOKEN
ARG MIXPANEL_URL

@ -211,12 +211,6 @@ endif
ifdef DECOMPILED_SMART_CONTRACT_TOKEN
BLOCKSCOUT_CONTAINER_PARAMS += -e 'DECOMPILED_SMART_CONTRACT_TOKEN=$(DECOMPILED_SMART_CONTRACT_TOKEN)'
endif
ifdef SOCKET_ROOT
BLOCKSCOUT_CONTAINER_PARAMS += -e 'SOCKET_ROOT=$(SOCKET_ROOT)'
endif
ifdef API_PATH
BLOCKSCOUT_CONTAINER_PARAMS += -e 'API_PATH=$(API_PATH)'
endif
ifdef CHECKSUM_ADDRESS_HASHES
BLOCKSCOUT_CONTAINER_PARAMS += -e 'CHECKSUM_ADDRESS_HASHES=$(CHECKSUM_ADDRESS_HASHES)'
endif
@ -271,9 +265,6 @@ endif
ifdef WOBSERVER_ENABLED
BLOCKSCOUT_CONTAINER_PARAMS += -e 'WOBSERVER_ENABLED=$(WOBSERVER_ENABLED)'
endif
ifdef CACHE_BRIDGE_MARKET_CAP_UPDATE_INTERVAL
BLOCKSCOUT_CONTAINER_PARAMS += -e 'CACHE_BRIDGE_MARKET_CAP_UPDATE_INTERVAL=$(CACHE_BRIDGE_MARKET_CAP_UPDATE_INTERVAL)'
endif
ifdef RESTRICTED_LIST
BLOCKSCOUT_CONTAINER_PARAMS += -e 'RESTRICTED_LIST=$(RESTRICTED_LIST)'
endif

Loading…
Cancel
Save