From a735611404287633a482d1bd45e34316f4f32658 Mon Sep 17 00:00:00 2001 From: avilagaston9 Date: Thu, 10 Oct 2024 10:48:52 -0300 Subject: [PATCH 1/8] feat(explorer): add is_valid field to batches --- explorer/lib/explorer/models/batch_structs.ex | 6 +- explorer/lib/explorer/models/batches.ex | 10 ++-- explorer/lib/explorer_web/live/utils.ex | 57 ++++++++++++------- .../20241010133259_add_is_valid_field.exs | 9 +++ 4 files changed, 54 insertions(+), 28 deletions(-) create mode 100644 explorer/priv/repo/migrations/20241010133259_add_is_valid_field.exs diff --git a/explorer/lib/explorer/models/batch_structs.ex b/explorer/lib/explorer/models/batch_structs.ex index 0ba1329d1a..599c0f0d13 100644 --- a/explorer/lib/explorer/models/batch_structs.ex +++ b/explorer/lib/explorer/models/batch_structs.ex @@ -32,7 +32,8 @@ defmodule BatchDB do :proof_hashes, :fee_per_proof, :sender_address, - :max_aggregator_fee + :max_aggregator_fee, + :is_valid ] defstruct [ :merkle_root, @@ -48,6 +49,7 @@ defmodule BatchDB do :proof_hashes, :fee_per_proof, :sender_address, - :max_aggregator_fee + :max_aggregator_fee, + :is_valid ] end diff --git a/explorer/lib/explorer/models/batches.ex b/explorer/lib/explorer/models/batches.ex index 7d2b430afa..e3700b7c61 100644 --- a/explorer/lib/explorer/models/batches.ex +++ b/explorer/lib/explorer/models/batches.ex @@ -18,6 +18,7 @@ defmodule Batches do field :fee_per_proof, :integer field :sender_address, :binary field :max_aggregator_fee, :decimal + field :is_valid, :boolean timestamps() end @@ -25,8 +26,8 @@ defmodule Batches do @doc false def changeset(new_batch, updates) do new_batch - |> cast(updates, [:merkle_root, :amount_of_proofs, :is_verified, :submission_block_number, :submission_transaction_hash, :submission_timestamp, :response_block_number, :response_transaction_hash, :response_timestamp, :data_pointer, :fee_per_proof, :sender_address, :max_aggregator_fee]) - |> validate_required([:merkle_root, :amount_of_proofs, :is_verified, :submission_block_number, :submission_transaction_hash, :fee_per_proof, :sender_address]) + |> cast(updates, [:merkle_root, :amount_of_proofs, :is_verified, :submission_block_number, :submission_transaction_hash, :submission_timestamp, :response_block_number, :response_transaction_hash, :response_timestamp, :data_pointer, :fee_per_proof, :sender_address, :max_aggregator_fee, :is_valid]) + |> validate_required([:merkle_root, :amount_of_proofs, :is_verified, :submission_block_number, :submission_transaction_hash, :fee_per_proof, :sender_address, :is_valid]) |> validate_format(:merkle_root, ~r/0x[a-fA-F0-9]{64}/) |> unique_constraint(:merkle_root) |> validate_number(:amount_of_proofs, greater_than: 0) @@ -37,6 +38,7 @@ defmodule Batches do |> validate_format(:response_transaction_hash, ~r/0x[a-fA-F0-9]{64}/) |> validate_number(:max_aggregator_fee, greater_than: 0) |> validate_number(:fee_per_proof, greater_than_or_equal_to: 0) + |> validate_inclusion(:is_verified, [true, false]) end def cast_to_batches(%BatchDB{} = batch_db) do @@ -53,7 +55,8 @@ defmodule Batches do data_pointer: batch_db.data_pointer, fee_per_proof: batch_db.fee_per_proof, sender_address: batch_db.sender_address, - max_aggregator_fee: batch_db.max_aggregator_fee + max_aggregator_fee: batch_db.max_aggregator_fee, + is_valid: batch_db.is_valid } end @@ -193,5 +196,4 @@ defmodule Batches do end end end - end diff --git a/explorer/lib/explorer_web/live/utils.ex b/explorer/lib/explorer_web/live/utils.ex index d4e5a08097..f4b19c387d 100644 --- a/explorer/lib/explorer_web/live/utils.ex +++ b/explorer/lib/explorer_web/live/utils.ex @@ -264,36 +264,49 @@ defmodule Utils do end end - def extract_info_from_data_pointer(%BatchDB{} = batch) do - Logger.debug("Extracting batch's proofs info: #{batch.merkle_root}") + defp get_proof_hashes(%BatchDB{} = batch) do # only get from s3 if not already in DB - proof_hashes = - case Proofs.get_proofs_from_batch(%{merkle_root: batch.merkle_root}) do - nil -> - Logger.debug("Fetching from S3") + case Proofs.get_proofs_from_batch(%{merkle_root: batch.merkle_root}) do + nil -> + Logger.debug("Fetching from S3") - batch_content = batch.data_pointer |> Utils.fetch_batch_data_pointer() + batch_content = batch.data_pointer |> Utils.fetch_batch_data_pointer() - case batch_content do - {:ok, batch_content} -> + case batch_content do + {:ok, batch_content} -> + proof_hashes = batch_content |> Utils.calculate_proof_hashes() - {:error, reason} -> - Logger.error("Error fetching batch content: #{inspect(reason)}") - # Returning something ensures we avoid attempting to fetch the invalid data again. - [<<0>>] - end + {:ok, proof_hashes} - proof_hashes -> - # already processed and stored the S3 data - Logger.debug("Fetching from DB") - proof_hashes - end + {:error, reason} -> + Logger.error("Error fetching batch content: #{inspect(reason)}") + # Returning something ensures we avoid attempting to fetch the invalid data again. + {:error, [<<0>>]} + end + + proof_hashes -> + # already processed and stored the S3 data + Logger.debug("Fetching from DB") + {:ok, proof_hashes} + end + end + + def extract_info_from_data_pointer(%BatchDB{} = batch) do + Logger.debug("Extracting batch's proofs info: #{batch.merkle_root}") - batch - |> Map.put(:proof_hashes, proof_hashes) - |> Map.put(:amount_of_proofs, proof_hashes |> Enum.count()) + {status, proof_hashes} = get_proof_hashes(batch) + + updated_batch = + batch + |> Map.put(:proof_hashes, proof_hashes) + |> Map.put(:amount_of_proofs, Enum.count(proof_hashes)) + + case status do + :error -> Map.put(updated_batch, :is_valid, false) + _ -> updated_batch + end end def fetch_eigen_operator_metadata(url) do diff --git a/explorer/priv/repo/migrations/20241010133259_add_is_valid_field.exs b/explorer/priv/repo/migrations/20241010133259_add_is_valid_field.exs new file mode 100644 index 0000000000..f229471a92 --- /dev/null +++ b/explorer/priv/repo/migrations/20241010133259_add_is_valid_field.exs @@ -0,0 +1,9 @@ +defmodule Explorer.Repo.Migrations.AddIsValidField do + use Ecto.Migration + + def change do + alter table("batches") do + add :is_valid, :boolean + end + end +end From abf078e9da75eaaa7410055c05ff3ed35f1aa542 Mon Sep 17 00:00:00 2001 From: avilagaston9 Date: Thu, 10 Oct 2024 10:53:16 -0300 Subject: [PATCH 2/8] fix: change is_verified to is_valid --- explorer/lib/explorer/models/batches.ex | 2 +- explorer/lib/explorer_web/live/utils.ex | 32 ++++++++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/explorer/lib/explorer/models/batches.ex b/explorer/lib/explorer/models/batches.ex index e3700b7c61..afd4f41219 100644 --- a/explorer/lib/explorer/models/batches.ex +++ b/explorer/lib/explorer/models/batches.ex @@ -38,7 +38,7 @@ defmodule Batches do |> validate_format(:response_transaction_hash, ~r/0x[a-fA-F0-9]{64}/) |> validate_number(:max_aggregator_fee, greater_than: 0) |> validate_number(:fee_per_proof, greater_than_or_equal_to: 0) - |> validate_inclusion(:is_verified, [true, false]) + |> validate_inclusion(:is_valid, [true, false]) end def cast_to_batches(%BatchDB{} = batch_db) do diff --git a/explorer/lib/explorer_web/live/utils.ex b/explorer/lib/explorer_web/live/utils.ex index f4b19c387d..2af93a6ec1 100644 --- a/explorer/lib/explorer_web/live/utils.ex +++ b/explorer/lib/explorer_web/live/utils.ex @@ -264,6 +264,22 @@ defmodule Utils do end end + def extract_info_from_data_pointer(%BatchDB{} = batch) do + Logger.debug("Extracting batch's proofs info: #{batch.merkle_root}") + + {status, proof_hashes} = get_proof_hashes(batch) + + updated_batch = + batch + |> Map.put(:proof_hashes, proof_hashes) + |> Map.put(:amount_of_proofs, Enum.count(proof_hashes)) + + case status do + :error -> Map.put(updated_batch, :is_valid, false) + _ -> updated_batch + end + end + defp get_proof_hashes(%BatchDB{} = batch) do # only get from s3 if not already in DB case Proofs.get_proofs_from_batch(%{merkle_root: batch.merkle_root}) do @@ -293,22 +309,6 @@ defmodule Utils do end end - def extract_info_from_data_pointer(%BatchDB{} = batch) do - Logger.debug("Extracting batch's proofs info: #{batch.merkle_root}") - - {status, proof_hashes} = get_proof_hashes(batch) - - updated_batch = - batch - |> Map.put(:proof_hashes, proof_hashes) - |> Map.put(:amount_of_proofs, Enum.count(proof_hashes)) - - case status do - :error -> Map.put(updated_batch, :is_valid, false) - _ -> updated_batch - end - end - def fetch_eigen_operator_metadata(url) do case Finch.build(:get, url) |> Finch.request(Explorer.Finch) do {:ok, %Finch.Response{status: 200, body: body}} -> From 48c61df74e611c1b64dde4bd083fa3fea44486a4 Mon Sep 17 00:00:00 2001 From: avilagaston9 Date: Thu, 10 Oct 2024 12:01:04 -0300 Subject: [PATCH 3/8] fix: set true as a default for is_valid field --- explorer/lib/explorer/models/batches.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/explorer/lib/explorer/models/batches.ex b/explorer/lib/explorer/models/batches.ex index afd4f41219..bef38a130e 100644 --- a/explorer/lib/explorer/models/batches.ex +++ b/explorer/lib/explorer/models/batches.ex @@ -18,7 +18,7 @@ defmodule Batches do field :fee_per_proof, :integer field :sender_address, :binary field :max_aggregator_fee, :decimal - field :is_valid, :boolean + field :is_valid, :boolean, default: true timestamps() end From f6d3cea22a6bd99aba92b2db38974aa405e414f0 Mon Sep 17 00:00:00 2001 From: avilagaston9 Date: Thu, 10 Oct 2024 17:03:00 -0300 Subject: [PATCH 4/8] feat: add is valid status to frontend --- .../aligned_layer_service_manager.ex | 6 ++- explorer/lib/explorer/models/batches.ex | 2 +- .../components/core_components.ex | 41 +++++++++++++++++-- .../live/pages/batch/index.html.heex | 2 +- .../live/pages/batches/index.html.heex | 2 +- .../live/pages/operators/index.ex | 2 +- explorer/lib/explorer_web/live/utils.ex | 8 ++++ .../20241010133259_add_is_valid_field.exs | 2 +- 8 files changed, 54 insertions(+), 11 deletions(-) diff --git a/explorer/lib/explorer/contract_managers/aligned_layer_service_manager.ex b/explorer/lib/explorer/contract_managers/aligned_layer_service_manager.ex index fb31b19d50..dca61d58bd 100644 --- a/explorer/lib/explorer/contract_managers/aligned_layer_service_manager.ex +++ b/explorer/lib/explorer/contract_managers/aligned_layer_service_manager.ex @@ -136,7 +136,8 @@ defmodule AlignedLayerServiceManager do proof_hashes: nil, fee_per_proof: BatcherPaymentServiceManager.get_fee_per_proof(%{merkle_root: created_batch.batchMerkleRoot}), sender_address: Utils.string_to_bytes32(created_batch.senderAddress), - max_aggregator_fee: created_batch.maxAggregatorFee + max_aggregator_fee: created_batch.maxAggregatorFee, + is_valid: true } end @@ -166,7 +167,8 @@ defmodule AlignedLayerServiceManager do fee_per_proof: unverified_batch.fee_per_proof, proof_hashes: nil, sender_address: unverified_batch.sender_address, - max_aggregator_fee: unverified_batch.max_aggregator_fee + max_aggregator_fee: unverified_batch.max_aggregator_fee, + is_valid: true } end end diff --git a/explorer/lib/explorer/models/batches.ex b/explorer/lib/explorer/models/batches.ex index bef38a130e..f2474ef485 100644 --- a/explorer/lib/explorer/models/batches.ex +++ b/explorer/lib/explorer/models/batches.ex @@ -116,7 +116,7 @@ defmodule Batches do threshold_datetime = DateTime.utc_now() |> DateTime.add(-43200, :second) # 12 hours ago query = from(b in Batches, - where: b.is_verified == false and b.submission_timestamp > ^threshold_datetime, + where: b.is_valid == true and b.is_verified == false and b.submission_timestamp > ^threshold_datetime, select: b) Explorer.Repo.all(query) diff --git a/explorer/lib/explorer_web/components/core_components.ex b/explorer/lib/explorer_web/components/core_components.ex index 54976b84f2..02a49e5653 100644 --- a/explorer/lib/explorer_web/components/core_components.ex +++ b/explorer/lib/explorer_web/components/core_components.ex @@ -417,15 +417,15 @@ defmodule ExplorerWeb.CoreComponents do end @doc """ - Renders a dynamic badge compoent. + Renders a dynamic badge component. """ attr :class, :string, default: nil attr :status, :boolean, default: true - attr :falsy_text, :string, default: "Pending" - attr :truthy_text, :string, default: "Verified" + attr :falsy_text, :string + attr :truthy_text, :string slot :inner_block, default: nil - def dynamic_badge(assigns) do + def dynamic_badge_boolean(assigns) do ~H""" <.badge variant={ @@ -449,6 +449,39 @@ defmodule ExplorerWeb.CoreComponents do """ end + @doc """ + Renders a dynamic badge component for the batcher. + """ + attr :class, :string, default: nil + attr :status, :atom + slot :inner_block, default: nil + + def dynamic_badge_for_batcher(assigns) do + ~H""" + <.badge + variant={ + case @status do + :invalid -> "destructive" + :verified -> "accent" + :pending -> "foreground" + end + } + class={ + classes([ + @class + ]) + } + > + <%= case @status do + :invalid -> "Invalid" + :verified -> "Verified" + :pending -> "Pending" + end %> + <%= render_slot(@inner_block) %> + + """ + end + @doc """ Renders an input with label and error messages. diff --git a/explorer/lib/explorer_web/live/pages/batch/index.html.heex b/explorer/lib/explorer_web/live/pages/batch/index.html.heex index 98636fec5e..764f12219c 100644 --- a/explorer/lib/explorer_web/live/pages/batch/index.html.heex +++ b/explorer/lib/explorer_web/live/pages/batch/index.html.heex @@ -25,7 +25,7 @@

Status:

- <.dynamic_badge class="w-fit" status={@current_batch.is_verified} /> + <.dynamic_badge_for_batcher class="w-fit" status={Helpers.get_batch_status(@current_batch)} />

diff --git a/explorer/lib/explorer_web/live/pages/batches/index.html.heex b/explorer/lib/explorer_web/live/pages/batches/index.html.heex index 044e43a14e..26ce5ac2ee 100644 --- a/explorer/lib/explorer_web/live/pages/batches/index.html.heex +++ b/explorer/lib/explorer_web/live/pages/batches/index.html.heex @@ -14,7 +14,7 @@ <:col :let={batch} label="Status"> - <.dynamic_badge status={batch.is_verified} /> + <.dynamic_badge_for_batcher status={Helpers.get_batch_status(batch)} /> <:col :let={batch} label="Age"> diff --git a/explorer/lib/explorer_web/live/pages/operators/index.ex b/explorer/lib/explorer_web/live/pages/operators/index.ex index 563cfce078..dab94a92e8 100644 --- a/explorer/lib/explorer_web/live/pages/operators/index.ex +++ b/explorer/lib/explorer_web/live/pages/operators/index.ex @@ -83,7 +83,7 @@ defmodule ExplorerWeb.Operators.Index do <%= operator.total_stake |> EthConverter.wei_to_eth(2) |> Helpers.format_number() %> ETH <:col :let={operator} label="Status"> - <.dynamic_badge status={operator.is_active} truthy_text="Active" falsy_text="Inactive" /> + <.dynamic_badge_boolean status={operator.is_active} truthy_text="Active" falsy_text="Inactive" /> <% else %> diff --git a/explorer/lib/explorer_web/live/utils.ex b/explorer/lib/explorer_web/live/utils.ex index 2af93a6ec1..8d9be81edf 100644 --- a/explorer/lib/explorer_web/live/utils.ex +++ b/explorer/lib/explorer_web/live/utils.ex @@ -127,6 +127,14 @@ defmodule ExplorerWeb.Helpers do def binary_to_hex_string(binary) do Utils.binary_to_hex_string(binary) end + + def get_batch_status(batch) do + cond do + not batch.is_valid -> :invalid + batch.is_verified -> :verified + true -> :pending + end + end end # Backend utils diff --git a/explorer/priv/repo/migrations/20241010133259_add_is_valid_field.exs b/explorer/priv/repo/migrations/20241010133259_add_is_valid_field.exs index f229471a92..0864313352 100644 --- a/explorer/priv/repo/migrations/20241010133259_add_is_valid_field.exs +++ b/explorer/priv/repo/migrations/20241010133259_add_is_valid_field.exs @@ -3,7 +3,7 @@ defmodule Explorer.Repo.Migrations.AddIsValidField do def change do alter table("batches") do - add :is_valid, :boolean + add :is_valid, :boolean, default: true end end end From 6534a09b7aa09026aba7e45206a2bfb425383079 Mon Sep 17 00:00:00 2001 From: avilagaston9 Date: Sat, 12 Oct 2024 17:20:11 -0300 Subject: [PATCH 5/8] refactor: improve error handling --- explorer/lib/explorer/periodically.ex | 36 +++++++++-------------- explorer/lib/explorer_web/live/utils.ex | 38 +++++++++++++++---------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/explorer/lib/explorer/periodically.ex b/explorer/lib/explorer/periodically.ex index 423b3738e6..9731502443 100644 --- a/explorer/lib/explorer/periodically.ex +++ b/explorer/lib/explorer/periodically.ex @@ -45,6 +45,7 @@ defmodule Explorer.Periodically do run_every_n_iterations = 8 new_count = rem(count + 1, run_every_n_iterations) + if new_count == 0 do Task.start(&process_unverified_batches/0) end @@ -79,28 +80,19 @@ defmodule Explorer.Periodically do {:ok, lock} -> "Processing batch: #{batch.merkle_root}" |> Logger.debug() - {batch_changeset, proofs} = - batch - |> Utils.extract_info_from_data_pointer() - |> Batches.generate_changesets() - - Batches.insert_or_update(batch_changeset, proofs) - |> case do - {:ok, _} -> - PubSub.broadcast(Explorer.PubSub, "update_views", %{ - eth_usd: - case EthConverter.get_eth_price_usd() do - {:ok, eth_usd_price} -> eth_usd_price - {:error, _error} -> :empty - end - }) - - {:error, error} -> - Logger.error("Some error in DB operation, not broadcasting update_views: #{inspect(error)}") - - # no changes in DB - nil -> - nil + with {:ok, updated_batch} <- Utils.process_batch(batch), + {batch_changeset, proofs} <- Batches.generate_changesets(updated_batch), + {:ok, _} <- Batches.insert_or_update(batch_changeset, proofs) do + PubSub.broadcast(Explorer.PubSub, "update_views", %{ + eth_usd: + case EthConverter.get_eth_price_usd() do + {:ok, eth_usd_price} -> eth_usd_price + {:error, _error} -> :empty + end + }) + else + {:error, reason} -> + Logger.error("Error processing batch #{batch.merkle_root}. Error: #{inspect(reason)}") end "Done processing batch: #{batch.merkle_root}" |> Logger.debug() diff --git a/explorer/lib/explorer_web/live/utils.ex b/explorer/lib/explorer_web/live/utils.ex index 17bf946c2e..772fd507dc 100644 --- a/explorer/lib/explorer_web/live/utils.ex +++ b/explorer/lib/explorer_web/live/utils.ex @@ -207,7 +207,7 @@ defmodule Utils do defp check_batch_size(size, acc) do if size > @max_batch_size do - {:halt, {:error, {:http, :body_too_large}}} + {:halt, {:error, {:invalid, body_too_large}}} else {:cont, acc} end @@ -241,7 +241,7 @@ defmodule Utils do true -> Logger.error("Unknown S3 object format") - {:error, :unknown_format} + {:error, {:invalid, :unknown_format}} end {:error, reason} -> @@ -272,23 +272,33 @@ defmodule Utils do end end - def extract_info_from_data_pointer(%BatchDB{} = batch) do - Logger.debug("Extracting batch's proofs info: #{batch.merkle_root}") + def process_batch(%BatchDB{} = batch) do + case get_proof_hashes(batch) do + {:ok, proof_hashes} -> + {:ok, add_proof_hashes_to_batch(batch, proof_hashes)} - {status, proof_hashes} = get_proof_hashes(batch) + {:error, {:invalid, reason}} -> + # Returning something ensures we avoid attempting to fetch the invalid data again. + updated_batch = + batch + |> Map.put(:is_valid, false) + |> add_proof_hashes_to_batch(<<0>>) - updated_batch = - batch - |> Map.put(:proof_hashes, proof_hashes) - |> Map.put(:amount_of_proofs, Enum.count(proof_hashes)) + {:ok, updated_batch} - case status do - :error -> Map.put(updated_batch, :is_valid, false) - _ -> updated_batch + {:error, reason} -> + {:error, reason} end end + defp add_proof_hashes_to_batch(batch, proof_hashes) do + batch + |> Map.put(:proof_hashes, proof_hashes) + |> Map.put(:amount_of_proofs, Enum.count(proof_hashes)) + end + defp get_proof_hashes(%BatchDB{} = batch) do + Logger.debug("Extracting batch's proofs info: #{batch.merkle_root}") # only get from s3 if not already in DB case Proofs.get_proofs_from_batch(%{merkle_root: batch.merkle_root}) do nil -> @@ -305,9 +315,7 @@ defmodule Utils do {:ok, proof_hashes} {:error, reason} -> - Logger.error("Error fetching batch content: #{inspect(reason)}") - # Returning something ensures we avoid attempting to fetch the invalid data again. - {:error, [<<0>>]} + {:error, "Error fetching batch content: #{inspect(reason)}"} end proof_hashes -> From 35fe8864701f487eb920e42ebe45e22cb8f1c1f5 Mon Sep 17 00:00:00 2001 From: avilagaston9 Date: Sat, 12 Oct 2024 17:32:18 -0300 Subject: [PATCH 6/8] fix: error handling --- explorer/lib/explorer_web/live/utils.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/explorer/lib/explorer_web/live/utils.ex b/explorer/lib/explorer_web/live/utils.ex index 772fd507dc..68737af33d 100644 --- a/explorer/lib/explorer_web/live/utils.ex +++ b/explorer/lib/explorer_web/live/utils.ex @@ -278,6 +278,7 @@ defmodule Utils do {:ok, add_proof_hashes_to_batch(batch, proof_hashes)} {:error, {:invalid, reason}} -> + Logger.error("Invalid batch content for #{batch.merkle_root}: #{inspect(reason)}") # Returning something ensures we avoid attempting to fetch the invalid data again. updated_batch = batch @@ -315,7 +316,7 @@ defmodule Utils do {:ok, proof_hashes} {:error, reason} -> - {:error, "Error fetching batch content: #{inspect(reason)}"} + {:error, reason} end proof_hashes -> From 0fa48b87241de77f2a33e5d5d97afe0b4df8df68 Mon Sep 17 00:00:00 2001 From: avilagaston9 Date: Mon, 14 Oct 2024 10:26:59 -0300 Subject: [PATCH 7/8] fix: handle errors properly --- explorer/lib/explorer/periodically.ex | 3 +++ explorer/lib/explorer_web/live/utils.ex | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/explorer/lib/explorer/periodically.ex b/explorer/lib/explorer/periodically.ex index 9731502443..403d651403 100644 --- a/explorer/lib/explorer/periodically.ex +++ b/explorer/lib/explorer/periodically.ex @@ -93,6 +93,9 @@ defmodule Explorer.Periodically do else {:error, reason} -> Logger.error("Error processing batch #{batch.merkle_root}. Error: #{inspect(reason)}") + # no changes in DB + nil -> + nil end "Done processing batch: #{batch.merkle_root}" |> Logger.debug() diff --git a/explorer/lib/explorer_web/live/utils.ex b/explorer/lib/explorer_web/live/utils.ex index 68737af33d..270083825d 100644 --- a/explorer/lib/explorer_web/live/utils.ex +++ b/explorer/lib/explorer_web/live/utils.ex @@ -207,7 +207,7 @@ defmodule Utils do defp check_batch_size(size, acc) do if size > @max_batch_size do - {:halt, {:error, {:invalid, body_too_large}}} + {:halt, {:error, {:invalid, :body_too_large}}} else {:cont, acc} end @@ -283,7 +283,7 @@ defmodule Utils do updated_batch = batch |> Map.put(:is_valid, false) - |> add_proof_hashes_to_batch(<<0>>) + |> add_proof_hashes_to_batch([<<0>>]) {:ok, updated_batch} From 1f2841b612042bac13fdbc3b8c89b0cd2b8cc75f Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:52:20 -0300 Subject: [PATCH 8/8] chore: add comment --- .../contract_managers/aligned_layer_service_manager.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/explorer/lib/explorer/contract_managers/aligned_layer_service_manager.ex b/explorer/lib/explorer/contract_managers/aligned_layer_service_manager.ex index dca61d58bd..bc276bba4b 100644 --- a/explorer/lib/explorer/contract_managers/aligned_layer_service_manager.ex +++ b/explorer/lib/explorer/contract_managers/aligned_layer_service_manager.ex @@ -137,7 +137,7 @@ defmodule AlignedLayerServiceManager do fee_per_proof: BatcherPaymentServiceManager.get_fee_per_proof(%{merkle_root: created_batch.batchMerkleRoot}), sender_address: Utils.string_to_bytes32(created_batch.senderAddress), max_aggregator_fee: created_batch.maxAggregatorFee, - is_valid: true + is_valid: true # set to false later if a process determines it is invalid } end @@ -168,7 +168,7 @@ defmodule AlignedLayerServiceManager do proof_hashes: nil, sender_address: unverified_batch.sender_address, max_aggregator_fee: unverified_batch.max_aggregator_fee, - is_valid: true + is_valid: true # set to false later if a process determines it is invalid } end end