Skip to content

Commit

Permalink
Merge pull request blockscout#9563 from blockscout/va-polygon-zkevm-t…
Browse files Browse the repository at this point in the history
…imestamp-fix

Fix timestamp handler for unfinalized zkEVM batches
  • Loading branch information
vbaranov authored Mar 10, 2024
2 parents c914e71 + dbf9f31 commit 4fd62a7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
### Fixes

- [#9572](https://github.com/blockscout/blockscout/pull/9572) - Fix Shibarium L1 fetcher
- [#9563](https://github.com/blockscout/blockscout/pull/9563) - Fix timestamp handler for unfinalized zkEVM batches
- [#9514](https://github.com/blockscout/blockscout/pull/9514) - Fix missing `0x` prefix for `blockNumber`, `logIndex`, `transactionIndex` and remove `transactionLogIndex` in `eth_getLogs` response.
- [#9512](https://github.com/blockscout/blockscout/pull/9512) - Docker-compose 2.24.6 compatibility
- [#9262](https://github.com/blockscout/blockscout/pull/9262) - Fix withdrawal status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ defmodule Explorer.Chain.PolygonZkevm.TransactionBatch do
alias Explorer.Chain.Hash
alias Explorer.Chain.PolygonZkevm.{BatchTransaction, LifecycleTransaction}

@optional_attrs ~w(sequence_id verify_id)a
@optional_attrs ~w(timestamp sequence_id verify_id)a

@required_attrs ~w(number timestamp l2_transactions_count global_exit_root acc_input_hash state_root)a
@required_attrs ~w(number l2_transactions_count global_exit_root acc_input_hash state_root)a

@primary_key false
typed_schema "polygon_zkevm_transaction_batches" do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Explorer.Repo.PolygonZkevm.Migrations.MakeTimestampOptional do
use Ecto.Migration

def change do
alter table("polygon_zkevm_transaction_batches") do
modify(:timestamp, :"timestamp without time zone", null: true)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,14 @@ defmodule Indexer.Fetcher.PolygonZkevm.TransactionBatch do
{batches, l2_txs, l1_txs, next_id, hash_to_id} =
_acc ->
number = quantity_to_integer(Map.get(res.result, "number"))
{:ok, timestamp} = DateTime.from_unix(quantity_to_integer(Map.get(res.result, "timestamp")))

# the timestamp is undefined for unfinalized batches
timestamp =
case DateTime.from_unix(quantity_to_integer(Map.get(res.result, "timestamp", 0xFFFFFFFFFFFFFFFF))) do
{:ok, ts} -> ts
_ -> nil
end

l2_transaction_hashes = Map.get(res.result, "transactions")
global_exit_root = Map.get(res.result, "globalExitRoot")
acc_input_hash = Map.get(res.result, "accInputHash")
Expand Down

0 comments on commit 4fd62a7

Please sign in to comment.