From b6859d3547ec7032eb6216c66ba2b782445fc27c Mon Sep 17 00:00:00 2001 From: POA <33550681+poa@users.noreply.github.com> Date: Fri, 15 Sep 2023 13:22:03 +0300 Subject: [PATCH] Define chain type --- apps/explorer/config/test.exs | 9 +++++++++ config/runtime.exs | 16 ++++++++-------- config/runtime/dev.exs | 32 ++++++++++++++++---------------- config/runtime/prod.exs | 32 ++++++++++++++++---------------- 4 files changed, 49 insertions(+), 40 deletions(-) diff --git a/apps/explorer/config/test.exs b/apps/explorer/config/test.exs index 728b931ac9..16e54f04eb 100644 --- a/apps/explorer/config/test.exs +++ b/apps/explorer/config/test.exs @@ -64,6 +64,15 @@ for repo <- [ pool_size: 1 end +config :explorer, Explorer.Repo.PolygonZkevm, + database: "explorer_test", + hostname: "localhost", + pool: Ecto.Adapters.SQL.Sandbox, + # Default of `5_000` was too low for `BlockFetcher` test + ownership_timeout: :timer.minutes(1), + timeout: :timer.seconds(60), + queue_target: 1000 + config :logger, :explorer, level: :warn, path: Path.absname("logs/test/explorer.log") diff --git a/config/runtime.exs b/config/runtime.exs index 4e3fee6b8d..d7061cd179 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -682,14 +682,6 @@ config :indexer, Indexer.Fetcher.PolygonEdge.WithdrawalExit, start_block_l1: System.get_env("INDEXER_POLYGON_EDGE_L1_WITHDRAWALS_START_BLOCK"), exit_helper: System.get_env("INDEXER_POLYGON_EDGE_L1_EXIT_HELPER_CONTRACT") -config :indexer, Indexer.Fetcher.Zkevm.TransactionBatch, - chunk_size: ConfigHelper.parse_integer_env_var("INDEXER_ZKEVM_BATCHES_CHUNK_SIZE", 20), - recheck_interval: ConfigHelper.parse_integer_env_var("INDEXER_ZKEVM_BATCHES_RECHECK_INTERVAL", 60) - -config :indexer, Indexer.Fetcher.Zkevm.TransactionBatch.Supervisor, - enabled: - ConfigHelper.chain_type() == "polygon_zkevm" && ConfigHelper.parse_bool_env_var("INDEXER_ZKEVM_BATCHES_ENABLED") - config :indexer, Indexer.Fetcher.RootstockData.Supervisor, disabled?: ConfigHelper.chain_type() != "rsk" || ConfigHelper.parse_bool_env_var("INDEXER_DISABLE_ROOTSTOCK_DATA_FETCHER") @@ -735,6 +727,14 @@ config :indexer, Indexer.Fetcher.Shibarium.L1.Supervisor, enabled: ConfigHelper. config :indexer, Indexer.Fetcher.Shibarium.L2.Supervisor, enabled: ConfigHelper.chain_type() == "shibarium" +config :indexer, Indexer.Fetcher.Zkevm.TransactionBatch, + chunk_size: ConfigHelper.parse_integer_env_var("INDEXER_ZKEVM_BATCHES_CHUNK_SIZE", 20), + recheck_interval: ConfigHelper.parse_integer_env_var("INDEXER_ZKEVM_BATCHES_RECHECK_INTERVAL", 60) + +config :indexer, Indexer.Fetcher.Zkevm.TransactionBatch.Supervisor, + enabled: + ConfigHelper.chain_type() == "polygon_zkevm" && ConfigHelper.parse_bool_env_var("INDEXER_ZKEVM_BATCHES_ENABLED") + Code.require_file("#{config_env()}.exs", "config/runtime") for config <- "../apps/*/config/runtime/#{config_env()}.exs" |> Path.expand(__DIR__) |> Path.wildcard() do diff --git a/config/runtime/dev.exs b/config/runtime/dev.exs index 4636eb72af..e9d66539c0 100644 --- a/config/runtime/dev.exs +++ b/config/runtime/dev.exs @@ -74,8 +74,8 @@ config :explorer, Explorer.Repo.Account, pool_size: ConfigHelper.parse_integer_env_var("ACCOUNT_POOL_SIZE", 10), queue_target: queue_target -# Configure PolygonEdge database -config :explorer, Explorer.Repo.PolygonEdge, +# Configure Beacon Chain database +config :explorer, Explorer.Repo.Beacon, database: database, hostname: hostname, url: System.get_env("DATABASE_URL"), @@ -83,8 +83,8 @@ config :explorer, Explorer.Repo.PolygonEdge, # separating repos for different CHAIN_TYPE is implemented only for the sake of keeping DB schema update relevant to the current chain type pool_size: 1 -# Configure PolygonZkevm database -config :explorer, Explorer.Repo.PolygonZkevm, +# Configures BridgedTokens database +config :explorer, Explorer.Repo.BridgedTokens, database: database, hostname: hostname, url: System.get_env("DATABASE_URL"), @@ -92,8 +92,8 @@ config :explorer, Explorer.Repo.PolygonZkevm, # separating repos for different CHAIN_TYPE is implemented only for the sake of keeping DB schema update relevant to the current chain type pool_size: 1 -# Configure Rootstock database -config :explorer, Explorer.Repo.RSK, +# Configure PolygonEdge database +config :explorer, Explorer.Repo.PolygonEdge, database: database, hostname: hostname, url: System.get_env("DATABASE_URL"), @@ -101,8 +101,8 @@ config :explorer, Explorer.Repo.RSK, # separating repos for different CHAIN_TYPE is implemented only for the sake of keeping DB schema update relevant to the current chain type pool_size: 1 -# Configure Beacon Chain database -config :explorer, Explorer.Repo.Beacon, +# Configure PolygonZkevm database +config :explorer, Explorer.Repo.PolygonZkevm, database: database, hostname: hostname, url: System.get_env("DATABASE_URL"), @@ -110,11 +110,13 @@ config :explorer, Explorer.Repo.Beacon, # separating repos for different CHAIN_TYPE is implemented only for the sake of keeping DB schema update relevant to the current chain type pool_size: 1 -# Configure Suave database -config :explorer, Explorer.Repo.Suave, +# Configure Rootstock database +config :explorer, Explorer.Repo.RSK, database: database, hostname: hostname, - url: ExplorerConfigHelper.get_suave_db_url(), + url: System.get_env("DATABASE_URL"), + # actually this repo is not started, and its pool size remains unused. + # separating repos for different CHAIN_TYPE is implemented only for the sake of keeping DB schema update relevant to the current chain type pool_size: 1 # Configure Shibarium database @@ -124,13 +126,11 @@ config :explorer, Explorer.Repo.Shibarium, url: System.get_env("DATABASE_URL"), pool_size: 1 -# Configures BridgedTokens database -config :explorer, Explorer.Repo.BridgedTokens, +# Configure Suave database +config :explorer, Explorer.Repo.Suave, database: database, hostname: hostname, - url: System.get_env("DATABASE_URL"), - # actually this repo is not started, and its pool size remains unused. - # separating repos for different CHAIN_TYPE is implemented only for the sake of keeping DB schema update relevant to the current chain type + url: ExplorerConfigHelper.get_suave_db_url(), pool_size: 1 variant = Variant.get() diff --git a/config/runtime/prod.exs b/config/runtime/prod.exs index 81c1e4ff24..42e253146b 100644 --- a/config/runtime/prod.exs +++ b/config/runtime/prod.exs @@ -51,41 +51,43 @@ config :explorer, Explorer.Repo.Account, ssl: ExplorerConfigHelper.ssl_enabled?(), queue_target: queue_target -# Configures PolygonEdge database -config :explorer, Explorer.Repo.PolygonEdge, +# Configure Beacon Chain database +config :explorer, Explorer.Repo.Beacon, url: System.get_env("DATABASE_URL"), # actually this repo is not started, and its pool size remains unused. # separating repos for different CHAIN_TYPE is implemented only for the sake of keeping DB schema update relevant to the current chain type pool_size: 1, ssl: ExplorerConfigHelper.ssl_enabled?() -# Configures PolygonZkevm database -config :explorer, Explorer.Repo.PolygonZkevm, +# Configures BridgedTokens database +config :explorer, Explorer.Repo.BridgedTokens, url: System.get_env("DATABASE_URL"), # actually this repo is not started, and its pool size remains unused. # separating repos for different CHAIN_TYPE is implemented only for the sake of keeping DB schema update relevant to the current chain type pool_size: 1, ssl: ExplorerConfigHelper.ssl_enabled?() -# Configures Rootstock database -config :explorer, Explorer.Repo.RSK, +# Configures PolygonEdge database +config :explorer, Explorer.Repo.PolygonEdge, url: System.get_env("DATABASE_URL"), # actually this repo is not started, and its pool size remains unused. # separating repos for different CHAIN_TYPE is implemented only for the sake of keeping DB schema update relevant to the current chain type pool_size: 1, ssl: ExplorerConfigHelper.ssl_enabled?() -# Configure Beacon Chain database -config :explorer, Explorer.Repo.Beacon, +# Configures PolygonZkevm database +config :explorer, Explorer.Repo.PolygonZkevm, url: System.get_env("DATABASE_URL"), # actually this repo is not started, and its pool size remains unused. # separating repos for different CHAIN_TYPE is implemented only for the sake of keeping DB schema update relevant to the current chain type pool_size: 1, ssl: ExplorerConfigHelper.ssl_enabled?() -# Configures Suave database -config :explorer, Explorer.Repo.Suave, - url: ExplorerConfigHelper.get_suave_db_url(), +# Configures Rootstock database +config :explorer, Explorer.Repo.RSK, + url: System.get_env("DATABASE_URL"), + # actually this repo is not started, and its pool size remains unused. + # separating repos for different CHAIN_TYPE is implemented only for the sake of keeping DB schema update relevant to the current chain type pool_size: 1, ssl: ExplorerConfigHelper.ssl_enabled?() @@ -95,11 +97,9 @@ config :explorer, Explorer.Repo.Shibarium, pool_size: 1, ssl: ExplorerConfigHelper.ssl_enabled?() -# Configures BridgedTokens database -config :explorer, Explorer.Repo.BridgedTokens, - url: System.get_env("DATABASE_URL"), - # actually this repo is not started, and its pool size remains unused. - # separating repos for different CHAIN_TYPE is implemented only for the sake of keeping DB schema update relevant to the current chain type +# Configures Suave database +config :explorer, Explorer.Repo.Suave, + url: ExplorerConfigHelper.get_suave_db_url(), pool_size: 1, ssl: ExplorerConfigHelper.ssl_enabled?()