Skip to content

Commit

Permalink
Manually revert 22cd77f
Browse files Browse the repository at this point in the history
This rolls back the changes to use the new Optimism's system config contract and therefore keeps using the old manual config and the previous Optimism contract versions.
  • Loading branch information
gabmontes committed Dec 30, 2024
1 parent c7b03e9 commit 8ab8626
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 33 deletions.
19 changes: 10 additions & 9 deletions apps/indexer/lib/indexer/fetcher/optimism.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ defmodule Indexer.Fetcher.Optimism do
request: 1
]

import Explorer.Helper, only: [parse_integer: 1]

alias EthereumJSONRPC.Block.ByNumber
alias EthereumJSONRPC.Contract
alias Indexer.Helper
Expand Down Expand Up @@ -228,15 +230,15 @@ defmodule Indexer.Fetcher.Optimism do
end

optimism_env = Application.get_all_env(:indexer)[__MODULE__]
system_config = optimism_env[:optimism_l1_system_config]
optimism_l1_rpc = l1_rpc_url()

with {:system_config_valid, true} <- {:system_config_valid, Helper.address_correct?(system_config)},
with {:start_block_l1_undefined, false} <- {:start_block_l1_undefined, is_nil(optimism_env[:start_block_l1])},
{:reorg_monitor_started, true} <-
{:reorg_monitor_started, !is_nil(Process.whereis(Indexer.Fetcher.RollupL1ReorgMonitor))},
{:rpc_l1_undefined, false} <- {:rpc_l1_undefined, is_nil(optimism_l1_rpc)},
json_rpc_named_arguments = json_rpc_named_arguments(optimism_l1_rpc),
{optimism_portal, start_block_l1} <- read_system_config(system_config, json_rpc_named_arguments),
{optimism_portal, start_block_l1} <-
{optimism_env[:optimism_l1_portal], parse_integer(optimism_env[:start_block_l1])},
{:contract_is_valid, true} <-
{:contract_is_valid,
caller == Indexer.Fetcher.Optimism.WithdrawalEvent or Helper.address_correct?(output_oracle)},
Expand Down Expand Up @@ -269,6 +271,10 @@ defmodule Indexer.Fetcher.Optimism do
stop: false
}}
else
{:start_block_l1_undefined, true} ->
# the process shouldn't start if the start block is not defined
{:stop, :normal, %{}}

{:reorg_monitor_started, false} ->
Logger.error(
"Cannot start this process as reorg monitor in Indexer.Fetcher.RollupL1ReorgMonitor is not started."
Expand All @@ -280,10 +286,6 @@ defmodule Indexer.Fetcher.Optimism do
Logger.error("L1 RPC URL is not defined.")
{:stop, :normal, %{}}

{:system_config_valid, false} ->
Logger.error("SystemConfig contract address is invalid or undefined.")
{:stop, :normal, %{}}

{:contract_is_valid, false} ->
Logger.error("#{contract_name} contract address is invalid or not defined.")
{:stop, :normal, %{}}
Expand Down Expand Up @@ -377,7 +379,6 @@ defmodule Indexer.Fetcher.Optimism do
"""
@spec requires_l1_reorg_monitor?() :: boolean()
def requires_l1_reorg_monitor? do
optimism_config = Application.get_all_env(:indexer)[__MODULE__]
not is_nil(optimism_config[:optimism_l1_system_config])
false
end
end
15 changes: 10 additions & 5 deletions apps/indexer/lib/indexer/fetcher/optimism/deposit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ defmodule Indexer.Fetcher.Optimism.Deposit do

env = Application.get_all_env(:indexer)[__MODULE__]
optimism_env = Application.get_all_env(:indexer)[Optimism]
system_config = optimism_env[:optimism_l1_system_config]
optimism_portal = optimism_env[:optimism_l1_portal]
optimism_l1_rpc = optimism_env[:optimism_l1_rpc]

with {:system_config_valid, true} <- {:system_config_valid, Helper.address_correct?(system_config)},
with {:start_block_l1_undefined, false} <- {:start_block_l1_undefined, is_nil(optimism_env[:start_block_l1])},
{:optimism_portal_valid, true} <- {:optimism_portal_valid, Helper.address_correct?(optimism_portal)},
{:rpc_l1_undefined, false} <- {:rpc_l1_undefined, is_nil(optimism_l1_rpc)},
json_rpc_named_arguments = Optimism.json_rpc_named_arguments(optimism_l1_rpc),
{optimism_portal, start_block_l1} <- Optimism.read_system_config(system_config, json_rpc_named_arguments),
start_block_l1 <- parse_integer(optimism_env[:start_block_l1]),
true <- start_block_l1 > 0,
{last_l1_block_number, last_l1_transaction_hash} <- get_last_l1_item(),
{:ok, last_l1_transaction} <-
Expand Down Expand Up @@ -104,6 +105,10 @@ defmodule Indexer.Fetcher.Optimism.Deposit do
transaction_type: env[:transaction_type]
}}
else
{:start_block_l1_undefined, true} ->
# the process shouldn't start if the start block is not defined
{:stop, :normal, state}

{:start_block_l1_valid, false} ->
Logger.error("Invalid L1 Start Block value. Please, check the value and op_deposits table.")
{:stop, :normal, state}
Expand All @@ -112,8 +117,8 @@ defmodule Indexer.Fetcher.Optimism.Deposit do
Logger.error("L1 RPC URL is not defined.")
{:stop, :normal, state}

{:system_config_valid, false} ->
Logger.error("SystemConfig contract address is invalid or undefined.")
{:optimism_portal_valid, false} ->
Logger.error("OptimismPortal contract address is invalid or undefined.")
{:stop, :normal, state}

{:error, error_data} ->
Expand Down
9 changes: 4 additions & 5 deletions apps/indexer/lib/indexer/fetcher/optimism/dispute_game.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@ defmodule Indexer.Fetcher.Optimism.DisputeGame do
Logger.metadata(fetcher: @fetcher_name)

env = Application.get_all_env(:indexer)[Optimism]
system_config = env[:optimism_l1_system_config]
optimism_portal = env[:optimism_l1_portal]
rpc = env[:optimism_l1_rpc]

with {:system_config_valid, true} <- {:system_config_valid, IndexerHelper.address_correct?(system_config)},
with {:optimism_portal_valid, true} <- {:optimism_portal_valid, IndexerHelper.address_correct?(optimism_portal)},
{:rpc_l1_undefined, false} <- {:rpc_l1_undefined, is_nil(rpc)},
json_rpc_named_arguments = IndexerHelper.json_rpc_named_arguments(rpc),
{optimism_portal, _} <- Optimism.read_system_config(system_config, json_rpc_named_arguments),
dispute_game_factory = get_dispute_game_factory_address(optimism_portal, json_rpc_named_arguments),
{:dispute_game_factory_available, true} <- {:dispute_game_factory_available, !is_nil(dispute_game_factory)},
game_count = get_game_count(dispute_game_factory, json_rpc_named_arguments),
Expand All @@ -85,8 +84,8 @@ defmodule Indexer.Fetcher.Optimism.DisputeGame do
Logger.error("L1 RPC URL is not defined.")
{:stop, :normal, %{}}

{:system_config_valid, false} ->
Logger.error("SystemConfig contract address is invalid or undefined.")
{:optimism_portal_valid, false} ->
Logger.error("OptimismPortal contract address is invalid or undefined.")
{:stop, :normal, %{}}

{:dispute_game_factory_available, false} ->
Expand Down
17 changes: 6 additions & 11 deletions apps/indexer/lib/indexer/fetcher/optimism/transaction_batch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,18 @@ defmodule Indexer.Fetcher.Optimism.TransactionBatch do
env = Application.get_all_env(:indexer)[__MODULE__]

optimism_env = Application.get_all_env(:indexer)[Indexer.Fetcher.Optimism]
system_config = optimism_env[:optimism_l1_system_config]
optimism_l1_rpc = l1_rpc_url()

with {:system_config_valid, true} <-
{:system_config_valid, Helper.address_correct?(system_config)},
with {:start_block_l1_undefined, false} <- {:start_block_l1_undefined, is_nil(optimism_env[:start_block_l1])},
{:genesis_block_l2_invalid, false} <-
{:genesis_block_l2_invalid, is_nil(env[:genesis_block_l2]) or env[:genesis_block_l2] < 0},
{:reorg_monitor_started, true} <-
{:reorg_monitor_started, !is_nil(Process.whereis(RollupL1ReorgMonitor))},
{:rpc_l1_undefined, false} <- {:rpc_l1_undefined, is_nil(optimism_l1_rpc)},
json_rpc_named_arguments = Optimism.json_rpc_named_arguments(optimism_l1_rpc),
{:system_config_read, {start_block_l1, batch_inbox, batch_submitter}} <-
{:system_config_read, read_system_config(system_config, json_rpc_named_arguments)},
{start_block_l1, batch_inbox, batch_submitter} <-
{String.downcase(env[:batch_inbox]), String.downcase(env[:batch_submitter]),
parse_integer(optimism_env[:start_block_l1])},
{:batch_inbox_valid, true} <- {:batch_inbox_valid, Helper.address_correct?(batch_inbox)},
{:batch_submitter_valid, true} <-
{:batch_submitter_valid, Helper.address_correct?(batch_submitter)},
Expand Down Expand Up @@ -133,8 +132,8 @@ defmodule Indexer.Fetcher.Optimism.TransactionBatch do
json_rpc_named_arguments_l2: json_rpc_named_arguments_l2
}}
else
{:system_config_valid, false} ->
Logger.error("SystemConfig contract address is invalid or undefined.")
{:start_block_l1_undefined, true} ->
# the process shouldn't start if the start block is not defined
{:stop, :normal, state}

{:genesis_block_l2_invalid, true} ->
Expand Down Expand Up @@ -181,10 +180,6 @@ defmodule Indexer.Fetcher.Optimism.TransactionBatch do

{:stop, :normal, state}

{:system_config_read, nil} ->
Logger.error("Cannot read SystemConfig contract.")
{:stop, :normal, state}

_ ->
Logger.error("Batch Start Block is invalid or zero.")
{:stop, :normal, state}
Expand Down
5 changes: 4 additions & 1 deletion config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,8 @@ config :indexer, Indexer.Fetcher.Optimism.WithdrawalEvent.Supervisor, enabled: C

config :indexer, Indexer.Fetcher.Optimism,
optimism_l1_rpc: System.get_env("INDEXER_OPTIMISM_L1_RPC"),
optimism_l1_system_config: System.get_env("INDEXER_OPTIMISM_L1_SYSTEM_CONFIG_CONTRACT")
optimism_l1_portal: System.get_env("INDEXER_OPTIMISM_L1_PORTAL_CONTRACT"),
start_block_l1: System.get_env("INDEXER_OPTIMISM_L1_START_BLOCK")

config :indexer, Indexer.Fetcher.Optimism.Deposit,
batch_size: System.get_env("INDEXER_OPTIMISM_L1_DEPOSITS_BATCH_SIZE"),
Expand All @@ -890,6 +891,8 @@ config :indexer, Indexer.Fetcher.Optimism.Withdrawal,
System.get_env("INDEXER_OPTIMISM_L2_MESSAGE_PASSER_CONTRACT", "0x4200000000000000000000000000000000000016")

config :indexer, Indexer.Fetcher.Optimism.TransactionBatch,
batch_inbox: System.get_env("INDEXER_OPTIMISM_L1_BATCH_INBOX"),
batch_submitter: System.get_env("INDEXER_OPTIMISM_L1_BATCH_SUBMITTER"),
blocks_chunk_size: System.get_env("INDEXER_OPTIMISM_L1_BATCH_BLOCKS_CHUNK_SIZE", "4"),
eip4844_blobs_api_url: System.get_env("INDEXER_OPTIMISM_L1_BATCH_BLOCKSCOUT_BLOBS_API_URL", ""),
celestia_blobs_api_url: System.get_env("INDEXER_OPTIMISM_L1_BATCH_CELESTIA_BLOBS_API_URL", ""),
Expand Down
7 changes: 5 additions & 2 deletions docker-compose/envs/common-blockscout.env
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,17 @@ INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER=false
# INDEXER_INTERNAL_TRANSACTIONS_FETCH_ORDER=
# INDEXER_SYSTEM_MEMORY_PERCENTAGE=
# WITHDRAWALS_FIRST_BLOCK=
INDEXER_OPTIMISM_L1_RPC=https://rpc2.sepolia.org
# INDEXER_OPTIMISM_L1_SYSTEM_CONFIG_CONTRACT= # FIXME
INDEXER_OPTIMISM_L1_RPC=https://sepolia.drpc.org
INDEXER_OPTIMISM_L1_BATCH_BLOCKS_CHUNK_SIZE=4
INDEXER_OPTIMISM_L2_BATCH_GENESIS_BLOCK_NUMBER=0
INDEXER_OPTIMISM_L1_OUTPUT_ORACLE_CONTRACT=0x032d1e1dd960A4B027a9a35FF8B2b672E333Bc27
INDEXER_OPTIMISM_L2_WITHDRAWALS_START_BLOCK=1
INDEXER_OPTIMISM_L2_MESSAGE_PASSER_CONTRACT=0x4200000000000000000000000000000000000007
INDEXER_OPTIMISM_L1_DEPOSITS_BATCH_SIZE=500
INDEXER_OPTIMISM_L1_PORTAL_CONTRACT=0xB6f9579980aE46f61217A99145645341E49E2516
INDEXER_OPTIMISM_L1_START_BLOCK=5302698
INDEXER_OPTIMISM_L1_BATCH_INBOX=0xFF00000000000000000000000000000000743111
INDEXER_OPTIMISM_L1_BATCH_SUBMITTER=0x0632215e32658508fC985BB80f22eE71377F7aAE
# INDEXER_OPTIMISM_L1_DEPOSITS_TRANSACTION_TYPE=
# INDEXER_SCROLL_L1_RPC=
# INDEXER_SCROLL_L1_MESSENGER_CONTRACT=
Expand Down
2 changes: 2 additions & 0 deletions docker-compose/envs/common-stats.env
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ STATS__JAEGER__AGENT_ENDPOINT=localhost:6831

STATS__TRACING__ENABLED=true
STATS__TRACING__FORMAT=default

STATS__BLOCKSCOUT_API_URL=http://host.docker.internal

0 comments on commit 8ab8626

Please sign in to comment.