Refactor runtime config

pull/5713/head
Qwerty5Uiop 2 years ago
parent 4293c3af31
commit e269f90c95
  1. 98
      apps/block_scout_web/config/config.exs
  2. 24
      apps/block_scout_web/config/dev.exs
  3. 6
      apps/block_scout_web/config/prod.exs
  4. 7
      apps/ethereum_jsonrpc/config/config.exs
  5. 144
      apps/explorer/config/config.exs
  6. 49
      apps/explorer/config/dev.exs
  7. 35
      apps/explorer/config/prod.exs
  8. 14
      apps/explorer/config/test.exs
  9. 81
      apps/indexer/config/config.exs
  10. 14
      apps/indexer/config/dev.exs
  11. 14
      apps/indexer/config/prod.exs
  12. 14
      apps/indexer/config/test.exs
  13. 984
      config/runtime.exs
  14. 92
      config/runtime/dev.exs
  15. 68
      config/runtime/prod.exs
  16. 31
      config/runtime/test.exs
  17. 19
      mix.exs

@ -8,90 +8,16 @@ import Config
# General application configuration
config :block_scout_web,
namespace: BlockScoutWeb,
ecto_repos: [Explorer.Repo],
version: System.get_env("BLOCKSCOUT_VERSION"),
release_link: System.get_env("RELEASE_LINK"),
decompiled_smart_contract_token: System.get_env("DECOMPILED_SMART_CONTRACT_TOKEN"),
show_percentage: if(System.get_env("SHOW_ADDRESS_MARKETCAP_PERCENTAGE", "true") == "false", do: false, else: true),
checksum_address_hashes: if(System.get_env("CHECKSUM_ADDRESS_HASHES", "true") == "false", do: false, else: true)
config :block_scout_web, BlockScoutWeb.Chain,
network: System.get_env("NETWORK"),
subnetwork: System.get_env("SUBNETWORK"),
network_icon: System.get_env("NETWORK_ICON"),
logo: System.get_env("LOGO"),
logo_footer: System.get_env("LOGO_FOOTER"),
logo_text: System.get_env("LOGO_TEXT"),
has_emission_funds: false,
show_maintenance_alert: System.get_env("SHOW_MAINTENANCE_ALERT", "false") == "true",
enable_testnet_label: System.get_env("SHOW_TESTNET_LABEL", "false") == "true",
testnet_label_text: System.get_env("TESTNET_LABEL_TEXT", "Testnet")
ecto_repos: [Explorer.Repo]
config :block_scout_web,
link_to_other_explorers: System.get_env("LINK_TO_OTHER_EXPLORERS") == "true",
other_explorers: System.get_env("OTHER_EXPLORERS"),
other_networks: System.get_env("SUPPORTED_CHAINS"),
webapp_url: System.get_env("WEBAPP_URL"),
api_url: System.get_env("API_URL"),
apps_menu: if(System.get_env("APPS_MENU", "false") == "true", do: true, else: false),
external_apps: System.get_env("EXTERNAL_APPS"),
gas_price: System.get_env("GAS_PRICE", nil),
restricted_list: System.get_env("RESTRICTED_LIST", nil),
restricted_list_key: System.get_env("RESTRICTED_LIST_KEY", nil),
dark_forest_addresses: System.get_env("CUSTOM_CONTRACT_ADDRESSES_DARK_FOREST"),
dark_forest_addresses_v_0_5: System.get_env("CUSTOM_CONTRACT_ADDRESSES_DARK_FOREST_V_0_5"),
circles_addresses: System.get_env("CUSTOM_CONTRACT_ADDRESSES_CIRCLES"),
test_tokens_addresses: System.get_env("CUSTOM_CONTRACT_ADDRESSES_TEST_TOKEN"),
max_size_to_show_array_as_is: Integer.parse(System.get_env("MAX_SIZE_UNLESS_HIDE_ARRAY", "50")),
max_length_to_show_string_without_trimming: System.get_env("MAX_STRING_LENGTH_WITHOUT_TRIMMING", "2040"),
re_captcha_secret_key: System.get_env("RE_CAPTCHA_SECRET_KEY", nil),
re_captcha_client_key: System.get_env("RE_CAPTCHA_CLIENT_KEY", nil),
admin_panel_enabled: System.get_env("ADMIN_PANEL_ENABLED", "") == "true"
default_api_rate_limit = 50
default_api_rate_limit_str = Integer.to_string(default_api_rate_limit)
global_api_rate_limit_value =
"API_RATE_LIMIT"
|> System.get_env(default_api_rate_limit_str)
|> Integer.parse()
|> case do
{integer, ""} -> integer
_ -> default_api_rate_limit
end
api_rate_limit_by_key_value =
"API_RATE_LIMIT_BY_KEY"
|> System.get_env(default_api_rate_limit_str)
|> Integer.parse()
|> case do
{integer, ""} -> integer
_ -> default_api_rate_limit
end
api_rate_limit_by_ip_value =
"API_RATE_LIMIT_BY_IP"
|> System.get_env(default_api_rate_limit_str)
|> Integer.parse()
|> case do
{integer, ""} -> integer
_ -> default_api_rate_limit
end
config :block_scout_web, :api_rate_limit,
global_limit: global_api_rate_limit_value,
limit_by_key: api_rate_limit_by_key_value,
limit_by_ip: api_rate_limit_by_ip_value,
static_api_key: System.get_env("API_RATE_LIMIT_STATIC_API_KEY", nil),
whitelisted_ips: System.get_env("API_RATE_LIMIT_WHITELISTED_IPS", nil)
config :block_scout_web, BlockScoutWeb.Counters.BlocksIndexedCounter, enabled: true
# Configures the endpoint
config :block_scout_web, BlockScoutWeb.Endpoint,
url: [
scheme: System.get_env("BLOCKSCOUT_PROTOCOL") || "http",
host: System.get_env("BLOCKSCOUT_HOST") || "localhost",
path: System.get_env("NETWORK_PATH") || "/",
api_path: System.get_env("API_PATH") || "/"
],
@ -112,32 +38,10 @@ config :block_scout_web, BlockScoutWeb.SocialMedia,
facebook: "PoaNetwork",
instagram: "PoaNetwork"
# Configures History
price_chart_config =
if System.get_env("SHOW_PRICE_CHART", "false") != "false" do
%{market: [:price, :market_cap]}
else
%{}
end
tx_chart_config =
if System.get_env("SHOW_TXS_CHART", "true") == "true" do
%{transactions: [:transactions_per_day]}
else
%{}
end
config :block_scout_web,
chart_config: Map.merge(price_chart_config, tx_chart_config)
config :block_scout_web, BlockScoutWeb.Chain.TransactionHistoryChartController,
# days
history_size: 30
config :block_scout_web, BlockScoutWeb.Chain.Address.CoinBalance,
# days
coin_balance_history_days: System.get_env("COIN_BALANCE_HISTORY_DAYS", "10")
config :ex_cldr,
default_locale: "en",
default_backend: BlockScoutWeb.Cldr

@ -7,31 +7,7 @@ import Config
# watchers to your application. For example, we use it
# with webpack to recompile .js and .css sources.
port =
case System.get_env("PORT") && Integer.parse(System.get_env("PORT")) do
{port, _} -> port
:error -> nil
nil -> nil
end
config :block_scout_web, BlockScoutWeb.Endpoint,
secret_key_base:
System.get_env("SECRET_KEY_BASE") || "RMgI4C1HSkxsEjdhtGMfwAHfyT6CKWXOgzCboJflfSm4jeAlic52io05KB6mqzc5",
http: [
port: port || 4000
],
url: [
scheme: "http",
host: System.get_env("BLOCKSCOUT_HOST") || "localhost",
path: System.get_env("NETWORK_PATH") || "/",
api_path: System.get_env("API_PATH") || "/"
],
https: [
port: (port && port + 1) || 4001,
cipher_suite: :strong,
certfile: System.get_env("CERTFILE") || "priv/cert/selfsigned.pem",
keyfile: System.get_env("KEYFILE") || "priv/cert/selfsigned_key.pem"
],
debug_errors: true,
code_reloader: true,
check_origin: false,

@ -16,13 +16,7 @@ import Config
config :block_scout_web, BlockScoutWeb.Endpoint,
cache_static_manifest: "priv/static/cache_manifest.json",
force_ssl: false,
secret_key_base: System.get_env("SECRET_KEY_BASE"),
check_origin: System.get_env("CHECK_ORIGIN", "false") == "true" || false,
http: [port: System.get_env("PORT")],
url: [
scheme: System.get_env("BLOCKSCOUT_PROTOCOL") || "https",
port: System.get_env("PORT"),
host: System.get_env("BLOCKSCOUT_HOST") || "localhost",
path: System.get_env("NETWORK_PATH") || "/",
api_path: System.get_env("API_PATH") || "/"
]

@ -9,10 +9,6 @@ config :ethereum_jsonrpc, EthereumJSONRPC.RequestCoordinator,
wait_per_timeout: :timer.seconds(20),
max_jitter: :timer.seconds(2)
config :ethereum_jsonrpc,
rpc_transport: if(System.get_env("ETHEREUM_JSONRPC_TRANSPORT", "http") == "http", do: :http, else: :ipc),
ipc_path: System.get_env("IPC_PATH")
# Add this configuration to add global RPC request throttling.
# throttle_rate_limit: 250,
# throttle_rolling_window_opts: [
@ -26,9 +22,6 @@ config :ethereum_jsonrpc, EthereumJSONRPC.Tracer,
adapter: SpandexDatadog.Adapter,
trace_key: :blockscout
debug_trace_transaction_timeout = System.get_env("ETHEREUM_JSONRPC_DEBUG_TRACE_TRANSACTION_TIMEOUT", "5s")
config :ethereum_jsonrpc, EthereumJSONRPC.Geth, debug_trace_transaction_timeout: debug_trace_transaction_timeout
config :logger, :ethereum_jsonrpc,
# keep synced with `config/config.exs`
format: "$dateT$time $metadata[$level] $message\n",

@ -5,67 +5,26 @@
# is restricted to this project.
import Config
disable_indexer = System.get_env("DISABLE_INDEXER")
disable_webapp = System.get_env("DISABLE_WEBAPP")
# General application configuration
config :explorer,
ecto_repos: [Explorer.Repo],
coin: System.get_env("COIN") || "POA",
coin_name: System.get_env("COIN_NAME") || System.get_env("COIN") || "POA",
token_functions_reader_max_retries: 3,
allowed_evm_versions:
System.get_env("ALLOWED_EVM_VERSIONS") ||
"homestead,tangerineWhistle,spuriousDragon,byzantium,constantinople,petersburg,istanbul,berlin,london,default",
include_uncles_in_average_block_time:
if(System.get_env("UNCLES_IN_AVERAGE_BLOCK_TIME") == "true", do: true, else: false),
healthy_blocks_period: System.get_env("HEALTHY_BLOCKS_PERIOD") || :timer.minutes(5),
realtime_events_sender:
if(disable_webapp != "true",
do: Explorer.Chain.Events.SimpleSender,
else: Explorer.Chain.Events.DBSender
)
token_functions_reader_max_retries: 3
config :explorer, Explorer.Counters.AverageBlockTime,
enabled: true,
period: :timer.minutes(10)
config :explorer, Explorer.Chain.Events.Listener,
enabled:
if(disable_webapp == "true" && disable_indexer == "true",
do: false,
else: true
)
config :explorer, Explorer.ChainSpec.GenesisData,
enabled: true,
chain_spec_path: System.get_env("CHAIN_SPEC_PATH"),
emission_format: System.get_env("EMISSION_FORMAT", "DEFAULT"),
rewards_contract_address: System.get_env("REWARDS_CONTRACT", "0xeca443e8e1ab29971a45a9c57a6a9875701698a5")
config :explorer, Explorer.ChainSpec.GenesisData, enabled: true
config :explorer, Explorer.Chain.Cache.BlockNumber,
enabled: true,
ttl_check_interval: if(disable_indexer == "true", do: :timer.seconds(1), else: false),
global_ttl: if(disable_indexer == "true", do: :timer.seconds(5))
address_sum_global_ttl =
"CACHE_ADDRESS_SUM_PERIOD"
|> System.get_env("")
|> Integer.parse()
|> case do
{integer, ""} -> :timer.seconds(integer)
_ -> :timer.minutes(60)
end
config :explorer, Explorer.Chain.Cache.BlockNumber, enabled: true
config :explorer, Explorer.Chain.Cache.AddressSum,
enabled: true,
ttl_check_interval: :timer.seconds(1),
global_ttl: address_sum_global_ttl
ttl_check_interval: :timer.seconds(1)
config :explorer, Explorer.Chain.Cache.AddressSumMinusBurnt,
enabled: true,
ttl_check_interval: :timer.seconds(1),
global_ttl: address_sum_global_ttl
ttl_check_interval: :timer.seconds(1)
cache_address_with_balances_update_interval = System.get_env("CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL")
@ -126,56 +85,12 @@ config :explorer, Explorer.Counters.BlockPriorityFeeCounter,
config :explorer, Explorer.Chain.Cache.GasUsage,
enabled: System.get_env("CACHE_ENABLE_TOTAL_GAS_USAGE_COUNTER") == "true"
config :explorer, Explorer.ExchangeRates,
enabled: System.get_env("DISABLE_EXCHANGE_RATES") != "true",
store: :ets,
coingecko_coin_id: System.get_env("EXCHANGE_RATES_COINGECKO_COIN_ID"),
coingecko_api_key: System.get_env("EXCHANGE_RATES_COINGECKO_API_KEY"),
coinmarketcap_api_key: System.get_env("EXCHANGE_RATES_COINMARKETCAP_API_KEY"),
fetch_btc_value: System.get_env("EXCHANGE_RATES_FETCH_BTC_VALUE") == "true"
exchange_rates_source =
cond do
System.get_env("EXCHANGE_RATES_SOURCE") == "coin_gecko" -> Explorer.ExchangeRates.Source.CoinGecko
System.get_env("EXCHANGE_RATES_SOURCE") == "coin_market_cap" -> Explorer.ExchangeRates.Source.CoinMarketCap
true -> Explorer.ExchangeRates.Source.CoinGecko
end
config :explorer, Explorer.ExchangeRates.Source, source: exchange_rates_source
config :explorer, Explorer.KnownTokens, enabled: System.get_env("DISABLE_KNOWN_TOKENS") != "true", store: :ets
config :explorer, Explorer.ExchangeRates, store: :ets
config :explorer, Explorer.Integrations.EctoLogger, query_time_ms_threshold: :timer.seconds(2)
config :explorer, Explorer.Market.History.Cataloger, enabled: disable_indexer != "true"
config :explorer, Explorer.Chain.Cache.MinMissingBlockNumber, enabled: System.get_env("DISABLE_WRITE_API") != "true"
txs_stats_init_lag =
System.get_env("TXS_HISTORIAN_INIT_LAG", "0")
|> Integer.parse()
|> elem(0)
|> :timer.minutes()
txs_stats_days_to_compile_at_init =
System.get_env("TXS_STATS_DAYS_TO_COMPILE_AT_INIT", "40")
|> Integer.parse()
|> elem(0)
config :explorer, Explorer.Chain.Transaction.History.Historian,
enabled: System.get_env("ENABLE_TXS_STATS", "true") != "false",
init_lag: txs_stats_init_lag,
days_to_compile_at_init: txs_stats_days_to_compile_at_init
history_fetch_interval =
case Integer.parse(System.get_env("HISTORY_FETCH_INTERVAL", "")) do
{mins, ""} -> mins
_ -> 60
end
|> :timer.minutes()
config :explorer, Explorer.History.Process, history_fetch_interval: history_fetch_interval
config :explorer, Explorer.Repo, migration_timestamps: [type: :utc_datetime_usec]
config :explorer, Explorer.Tracer,
@ -183,31 +98,8 @@ config :explorer, Explorer.Tracer,
adapter: SpandexDatadog.Adapter,
trace_key: :blockscout
if System.get_env("METADATA_CONTRACT") && System.get_env("VALIDATORS_CONTRACT") do
config :explorer, Explorer.Validator.MetadataRetriever,
metadata_contract_address: System.get_env("METADATA_CONTRACT"),
validators_contract_address: System.get_env("VALIDATORS_CONTRACT")
config :explorer, Explorer.Validator.MetadataProcessor, enabled: disable_indexer != "true"
else
config :explorer, Explorer.Validator.MetadataProcessor, enabled: false
end
config :explorer, Explorer.Chain.Block.Reward,
validators_contract_address: System.get_env("VALIDATORS_CONTRACT"),
keys_manager_contract_address: System.get_env("KEYS_MANAGER_CONTRACT")
case System.get_env("SUPPLY_MODULE") do
"rsk" ->
config :explorer, supply: Explorer.Chain.Supply.RSK
_ ->
:ok
end
config :explorer,
solc_bin_api_url: "https://solc-bin.ethereum.org",
checksum_function: System.get_env("CHECKSUM_FUNCTION") && String.to_atom(System.get_env("CHECKSUM_FUNCTION"))
solc_bin_api_url: "https://solc-bin.ethereum.org"
config :logger, :explorer,
# keep synced with `config/config.exs`
@ -222,28 +114,6 @@ config :spandex_ecto, SpandexEcto.EctoLogger,
tracer: Explorer.Tracer,
otp_app: :explorer
config :explorer, Explorer.Chain.Cache.Blocks,
ttl_check_interval: if(disable_indexer == "true", do: :timer.seconds(1), else: false),
global_ttl: if(disable_indexer == "true", do: :timer.seconds(5))
config :explorer, Explorer.Chain.Cache.Transactions,
ttl_check_interval: if(disable_indexer == "true", do: :timer.seconds(1), else: false),
global_ttl: if(disable_indexer == "true", do: :timer.seconds(5))
config :explorer, Explorer.Chain.Cache.Accounts,
ttl_check_interval: if(disable_indexer == "true", do: :timer.seconds(1), else: false),
global_ttl: if(disable_indexer == "true", do: :timer.seconds(5))
config :explorer, Explorer.Chain.Cache.Uncles,
ttl_check_interval: if(disable_indexer == "true", do: :timer.seconds(1), else: false),
global_ttl: if(disable_indexer == "true", do: :timer.seconds(5))
config :explorer, Explorer.ThirdPartyIntegrations.Sourcify,
server_url: System.get_env("SOURCIFY_SERVER_URL") || "https://sourcify.dev/server",
enabled: System.get_env("ENABLE_SOURCIFY_INTEGRATION") == "true",
chain_id: System.get_env("CHAIN_ID"),
repo_url: System.get_env("SOURCIFY_REPO_URL") || "https://repo.sourcify.dev/contracts"
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{config_env()}.exs"

@ -1,41 +1,10 @@
import Config
database = if System.get_env("DATABASE_URL"), do: nil, else: "explorer_dev"
hostname = if System.get_env("DATABASE_URL"), do: nil, else: "localhost"
database_api_url =
if System.get_env("DATABASE_READ_ONLY_API_URL"),
do: System.get_env("DATABASE_READ_ONLY_API_URL"),
else: System.get_env("DATABASE_URL")
pool_size =
if System.get_env("DATABASE_READ_ONLY_API_URL"),
do: String.to_integer(System.get_env("POOL_SIZE", "40")),
else: String.to_integer(System.get_env("POOL_SIZE", "50"))
# Configure your database
config :explorer, Explorer.Repo,
database: database,
hostname: hostname,
url: System.get_env("DATABASE_URL"),
pool_size: pool_size,
timeout: :timer.seconds(80)
database_api = if System.get_env("DATABASE_READ_ONLY_API_URL"), do: nil, else: database
hostname_api = if System.get_env("DATABASE_READ_ONLY_API_URL"), do: nil, else: hostname
pool_size_api =
if System.get_env("DATABASE_READ_ONLY_API_URL"),
do: String.to_integer(System.get_env("POOL_SIZE_API", "50")),
else: String.to_integer(System.get_env("POOL_SIZE_API", "10"))
config :explorer, Explorer.Repo, timeout: :timer.seconds(80)
# Configure API database
config :explorer, Explorer.Repo.Replica1,
database: database_api,
hostname: hostname_api,
url: database_api_url,
pool_size: pool_size_api,
timeout: :timer.seconds(80)
config :explorer, Explorer.Repo.Replica1, timeout: :timer.seconds(80)
config :explorer, Explorer.Tracer, env: "dev", disabled?: true
@ -52,17 +21,3 @@ config :logger, :token_instances,
level: :debug,
path: Path.absname("logs/dev/explorer/tokens/token_instances.log"),
metadata_filter: [fetcher: :token_instances]
variant =
if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do
"ganache"
else
System.get_env("ETHEREUM_JSONRPC_VARIANT")
|> String.split(".")
|> List.last()
|> String.downcase()
end
# Import variant specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "dev/#{variant}.exs"

@ -1,33 +1,12 @@
import Config
pool_size =
if System.get_env("DATABASE_READ_ONLY_API_URL"),
do: String.to_integer(System.get_env("POOL_SIZE", "50")),
else: String.to_integer(System.get_env("POOL_SIZE", "40"))
# Configures the database
config :explorer, Explorer.Repo,
url: System.get_env("DATABASE_URL"),
pool_size: pool_size,
ssl: String.equivalent?(System.get_env("ECTO_USE_SSL") || "true", "true"),
prepare: :unnamed,
timeout: :timer.seconds(60)
database_api_url =
if System.get_env("DATABASE_READ_ONLY_API_URL"),
do: System.get_env("DATABASE_READ_ONLY_API_URL"),
else: System.get_env("DATABASE_URL")
pool_size_api =
if System.get_env("DATABASE_READ_ONLY_API_URL"),
do: String.to_integer(System.get_env("POOL_SIZE_API", "50")),
else: String.to_integer(System.get_env("POOL_SIZE_API", "10"))
# Configures API the database
config :explorer, Explorer.Repo.Replica1,
url: database_api_url,
pool_size: pool_size_api,
ssl: String.equivalent?(System.get_env("ECTO_USE_SSL") || "true", "true"),
prepare: :unnamed,
timeout: :timer.seconds(60)
@ -49,17 +28,3 @@ config :logger, :token_instances,
path: Path.absname("logs/prod/explorer/tokens/token_instances.log"),
metadata_filter: [fetcher: :token_instances],
rotate: %{max_bytes: 52_428_800, keep: 19}
variant =
if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do
"parity"
else
System.get_env("ETHEREUM_JSONRPC_VARIANT")
|> String.split(".")
|> List.last()
|> String.downcase()
end
# Import variant specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "prod/#{variant}.exs"

@ -53,17 +53,3 @@ config :explorer, Explorer.ExchangeRates.Source.TransactionAndLog,
config :explorer,
realtime_events_sender: Explorer.Chain.Events.SimpleSender
variant =
if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do
"parity"
else
System.get_env("ETHEREUM_JSONRPC_VARIANT")
|> String.split(".")
|> List.last()
|> String.downcase()
end
# Import variant specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "test/#{variant}.exs"

@ -2,87 +2,8 @@
# and its dependencies with the aid of the Config module.
import Config
block_transformers = %{
"clique" => Indexer.Transform.Blocks.Clique,
"base" => Indexer.Transform.Blocks.Base
}
# Compile time environment variable access requires recompilation.
configured_transformer = System.get_env("BLOCK_TRANSFORMER") || "base"
block_transformer =
case Map.get(block_transformers, configured_transformer) do
nil ->
raise """
No such block transformer: #{configured_transformer}.
Valid values are:
#{Enum.join(Map.keys(block_transformers), "\n")}
Please update environment variable BLOCK_TRANSFORMER accordingly.
"""
transformer ->
transformer
end
config :indexer,
block_transformer: block_transformer,
ecto_repos: [Explorer.Repo],
metadata_updater_seconds_interval:
String.to_integer(System.get_env("TOKEN_METADATA_UPDATE_INTERVAL") || "#{2 * 24 * 60 * 60}"),
first_block: System.get_env("FIRST_BLOCK") || "",
last_block: System.get_env("LAST_BLOCK") || "",
trace_first_block: System.get_env("TRACE_FIRST_BLOCK") || "",
trace_last_block: System.get_env("TRACE_LAST_BLOCK") || "",
fetch_rewards_way: System.get_env("FETCH_REWARDS_WAY", "trace_block")
config :indexer, Indexer.Fetcher.PendingTransaction.Supervisor,
disabled?:
System.get_env("ETHEREUM_JSONRPC_VARIANT") == "besu" ||
System.get_env("INDEXER_DISABLE_PENDING_TRANSACTIONS_FETCHER", "false") == "true"
token_balance_on_demand_fetcher_threshold_minutes = System.get_env("TOKEN_BALANCE_ON_DEMAND_FETCHER_THRESHOLD_MINUTES")
token_balance_on_demand_fetcher_threshold =
case token_balance_on_demand_fetcher_threshold_minutes &&
Integer.parse(token_balance_on_demand_fetcher_threshold_minutes) do
{integer, ""} -> integer
_ -> 60
end
config :indexer, Indexer.Fetcher.TokenBalanceOnDemand, threshold: token_balance_on_demand_fetcher_threshold
coin_balance_on_demand_fetcher_threshold_minutes = System.get_env("COIN_BALANCE_ON_DEMAND_FETCHER_THRESHOLD_MINUTES")
coin_balance_on_demand_fetcher_threshold =
case coin_balance_on_demand_fetcher_threshold_minutes &&
Integer.parse(coin_balance_on_demand_fetcher_threshold_minutes) do
{integer, ""} -> integer
_ -> 60
end
config :indexer, Indexer.Fetcher.CoinBalanceOnDemand, threshold: coin_balance_on_demand_fetcher_threshold
# config :indexer, Indexer.Fetcher.ReplacedTransaction.Supervisor, disabled?: true
config :indexer, Indexer.Fetcher.BlockReward.Supervisor,
disabled?: System.get_env("INDEXER_DISABLE_BLOCK_REWARD_FETCHER", "false") == "true"
config :indexer, Indexer.Fetcher.InternalTransaction.Supervisor,
disabled?: System.get_env("INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER", "false") == "true"
config :indexer, Indexer.Fetcher.CoinBalance.Supervisor,
disabled?: System.get_env("INDEXER_DISABLE_ADDRESS_COIN_BALANCE_FETCHER", "false") == "true"
config :indexer, Indexer.Fetcher.TokenUpdater.Supervisor,
disabled?: System.get_env("INDEXER_DISABLE_CATALOGED_TOKEN_UPDATER_FETCHER", "false") == "true"
config :indexer, Indexer.Fetcher.EmptyBlocksSanitizer.Supervisor,
disabled?: System.get_env("INDEXER_DISABLE_EMPTY_BLOCK_SANITIZER", "false") == "true"
config :indexer, Indexer.Supervisor, enabled: System.get_env("DISABLE_INDEXER") != "true"
config :indexer, Indexer.Block.Realtime.Supervisor, enabled: System.get_env("DISABLE_REALTIME_INDEXER") != "true"
ecto_repos: [Explorer.Repo]
config :indexer, Indexer.Tracer,
service: :indexer,

@ -35,17 +35,3 @@ config :logger, :block_import_timings,
level: :debug,
path: Path.absname("logs/dev/indexer/block_import_timings.log"),
metadata_filter: [fetcher: :block_import_timings]
variant =
if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do
"ganache"
else
System.get_env("ETHEREUM_JSONRPC_VARIANT")
|> String.split(".")
|> List.last()
|> String.downcase()
end
# Import variant specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "dev/#{variant}.exs"

@ -42,17 +42,3 @@ config :logger, :block_import_timings,
path: Path.absname("logs/prod/indexer/block_import_timings.log"),
metadata_filter: [fetcher: :block_import_timings],
rotate: %{max_bytes: 52_428_800, keep: 19}
variant =
if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do
"parity"
else
System.get_env("ETHEREUM_JSONRPC_VARIANT")
|> String.split(".")
|> List.last()
|> String.downcase()
end
# Import variant specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "prod/#{variant}.exs"

@ -20,17 +20,3 @@ config :logger, :addresses_without_code,
level: :debug,
path: Path.absname("logs/test/indexer/addresses_without_code.log"),
metadata_filter: [fetcher: :addresses_without_code]
variant =
if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do
"parity"
else
System.get_env("ETHEREUM_JSONRPC_VARIANT")
|> String.split(".")
|> List.last()
|> String.downcase()
end
# Import variant specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "test/#{variant}.exs"

File diff suppressed because it is too large Load Diff

@ -0,0 +1,92 @@
import Config
######################
### BlockScout Web ###
######################
port =
case System.get_env("PORT") && Integer.parse(System.get_env("PORT")) do
{port, _} -> port
:error -> nil
nil -> nil
end
config :block_scout_web, BlockScoutWeb.Endpoint,
secret_key_base:
System.get_env("SECRET_KEY_BASE") || "RMgI4C1HSkxsEjdhtGMfwAHfyT6CKWXOgzCboJflfSm4jeAlic52io05KB6mqzc5",
http: [
port: port || 4000
],
url: [
scheme: "http",
host: System.get_env("BLOCKSCOUT_HOST") || "localhost",
path: System.get_env("NETWORK_PATH") || "/",
api_path: System.get_env("API_PATH") || "/"
],
https: [
port: (port && port + 1) || 4001,
cipher_suite: :strong,
certfile: System.get_env("CERTFILE") || "priv/cert/selfsigned.pem",
keyfile: System.get_env("KEYFILE") || "priv/cert/selfsigned_key.pem"
]
########################
### Ethereum JSONRPC ###
########################
################
### Explorer ###
################
database = if System.get_env("DATABASE_URL"), do: nil, else: "explorer_dev"
hostname = if System.get_env("DATABASE_URL"), do: nil, else: "localhost"
database_api_url =
if System.get_env("DATABASE_READ_ONLY_API_URL"),
do: System.get_env("DATABASE_READ_ONLY_API_URL"),
else: System.get_env("DATABASE_URL")
pool_size =
if System.get_env("DATABASE_READ_ONLY_API_URL"),
do: String.to_integer(System.get_env("POOL_SIZE", "40")),
else: String.to_integer(System.get_env("POOL_SIZE", "50"))
# Configure your database
config :explorer, Explorer.Repo,
database: database,
hostname: hostname,
url: System.get_env("DATABASE_URL"),
pool_size: pool_size
database_api = if System.get_env("DATABASE_READ_ONLY_API_URL"), do: nil, else: database
hostname_api = if System.get_env("DATABASE_READ_ONLY_API_URL"), do: nil, else: hostname
pool_size_api =
if System.get_env("DATABASE_READ_ONLY_API_URL"),
do: String.to_integer(System.get_env("POOL_SIZE_API", "50")),
else: String.to_integer(System.get_env("POOL_SIZE_API", "10"))
# Configure API database
config :explorer, Explorer.Repo.Replica1,
database: database_api,
hostname: hostname_api,
url: database_api_url,
pool_size: pool_size_api
variant =
if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do
"ganache"
else
System.get_env("ETHEREUM_JSONRPC_VARIANT")
|> String.split(".")
|> List.last()
|> String.downcase()
end
Code.require_file("#{variant}.exs", "apps/explorer/config/dev")
###############
### Indexer ###
###############
Code.require_file("#{variant}.exs", "apps/indexer/config/dev")

@ -0,0 +1,68 @@
import Config
######################
### BlockScout Web ###
######################
config :block_scout_web, BlockScoutWeb.Endpoint,
secret_key_base: System.get_env("SECRET_KEY_BASE"),
check_origin: System.get_env("CHECK_ORIGIN", "false") == "true" || false,
http: [port: System.get_env("PORT")],
url: [
scheme: System.get_env("BLOCKSCOUT_PROTOCOL") || "https",
port: System.get_env("PORT"),
host: System.get_env("BLOCKSCOUT_HOST") || "localhost"
]
########################
### Ethereum JSONRPC ###
########################
################
### Explorer ###
################
pool_size =
if System.get_env("DATABASE_READ_ONLY_API_URL"),
do: String.to_integer(System.get_env("POOL_SIZE", "50")),
else: String.to_integer(System.get_env("POOL_SIZE", "40"))
# Configures the database
config :explorer, Explorer.Repo,
url: System.get_env("DATABASE_URL"),
pool_size: pool_size,
ssl: String.equivalent?(System.get_env("ECTO_USE_SSL") || "true", "true")
database_api_url =
if System.get_env("DATABASE_READ_ONLY_API_URL"),
do: System.get_env("DATABASE_READ_ONLY_API_URL"),
else: System.get_env("DATABASE_URL")
pool_size_api =
if System.get_env("DATABASE_READ_ONLY_API_URL"),
do: String.to_integer(System.get_env("POOL_SIZE_API", "50")),
else: String.to_integer(System.get_env("POOL_SIZE_API", "10"))
# Configures API the database
config :explorer, Explorer.Repo.Replica1,
url: database_api_url,
pool_size: pool_size_api,
ssl: String.equivalent?(System.get_env("ECTO_USE_SSL") || "true", "true")
variant =
if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do
"parity"
else
System.get_env("ETHEREUM_JSONRPC_VARIANT")
|> String.split(".")
|> List.last()
|> String.downcase()
end
Code.require_file("#{variant}.exs", "apps/explorer/config/prod")
###############
### Indexer ###
###############
Code.require_file("#{variant}.exs", "apps/indexer/config/prod")

@ -0,0 +1,31 @@
import Config
######################
### BlockScout Web ###
######################
########################
### Ethereum JSONRPC ###
########################
################
### Explorer ###
################
variant =
if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do
"parity"
else
System.get_env("ETHEREUM_JSONRPC_VARIANT")
|> String.split(".")
|> List.last()
|> String.downcase()
end
Code.require_file("#{variant}.exs", "apps/explorer/config/test")
###############
### Indexer ###
###############
Code.require_file("#{variant}.exs", "apps/indexer/config/test")

@ -24,7 +24,8 @@ defmodule BlockScout.Mixfile do
ethereum_jsonrpc: :permanent,
explorer: :permanent,
indexer: :permanent
]
],
steps: [:assemble, &copy_prod_runtime_config/1]
]
]
]
@ -32,6 +33,22 @@ defmodule BlockScout.Mixfile do
## Private Functions
defp copy_prod_runtime_config(%Mix.Release{path: path} = release) do
File.mkdir_p!(Path.join([path, "config", "runtime"]))
File.cp!(Path.join(["config", "runtime", "prod.exs"]), Path.join([path, "config", "runtime", "prod.exs"]))
File.mkdir_p!(Path.join([path, "apps", "explorer", "config", "prod"]))
File.cp_r!(
Path.join(["apps", "explorer", "config", "prod"]),
Path.join([path, "apps", "explorer", "config", "prod"])
)
File.mkdir_p!(Path.join([path, "apps", "indexer", "config", "prod"]))
File.cp_r!(Path.join(["apps", "indexer", "config", "prod"]), Path.join([path, "apps", "indexer", "config", "prod"]))
release
end
defp dialyzer() do
[
plt_add_deps: :transitive,

Loading…
Cancel
Save