diff --git a/Dockerfile b/Dockerfile index c428e19c1..7e04f2185 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ # ARG ELIXIR_VERSION=1.17.3 ARG OTP_VERSION=26.2.5.3 -ARG NODE_VERSION=7.3.0-rc5 +ARG NODE_VERSION=7.3.0-rc7 ARG NODE_IMAGE=aeternity/aeternity:v${NODE_VERSION} ARG UBUNTU_VERSION=focal-20240918 @@ -114,8 +114,8 @@ RUN mix release FROM ${RUNNER_IMAGE} RUN apt-get update -y && apt-get install -y git curl libstdc++6 openssl libncurses5 locales libncurses5 libsodium-dev libgmp10 libsnappy-dev libgflags2.2 \ - && ldconfig \ - && apt-get clean && rm -f /var/lib/apt/lists/*_* + && ldconfig \ + && apt-get clean && rm -f /var/lib/apt/lists/*_* # Set the locale RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen diff --git a/lib/ae_mdw/db/hardfork_presets.ex b/lib/ae_mdw/db/hardfork_presets.ex index d76d81eaa..d5a6554b5 100644 --- a/lib/ae_mdw/db/hardfork_presets.ex +++ b/lib/ae_mdw/db/hardfork_presets.ex @@ -48,6 +48,7 @@ defmodule AeMdw.Db.HardforkPresets do defp accounts(:roma), do: :aec_fork_block_settings.genesis_accounts() defp accounts(:minerva), do: :aec_fork_block_settings.minerva_accounts() defp accounts(:fortuna), do: :aec_fork_block_settings.fortuna_accounts() + defp accounts(:lima) do contract_account = Node.lima_contracts() @@ -59,6 +60,7 @@ defmodule AeMdw.Db.HardforkPresets do Node.lima_accounts() ++ Node.lima_extra_accounts() end + defp accounts(:iris), do: %{} defp accounts(:ceres), do: %{} diff --git a/lib/ae_mdw/node.ex b/lib/ae_mdw/node.ex index 1d2bb6fb5..5dc2fbbfe 100644 --- a/lib/ae_mdw/node.ex +++ b/lib/ae_mdw/node.ex @@ -443,13 +443,13 @@ defmodule AeMdw.Node do defmemop token_supply_delta() do :aec_hard_forks.protocols() - |> Map.keys() - |> Enum.sort() - |> Enum.map(fn proto -> - proto_vsn = :aec_hard_forks.protocol_vsn_name(proto) - {HardforkPresets.hardfork_height(proto_vsn), HardforkPresets.mint_sum(proto_vsn)} - end) - |> Map.new() + |> Map.keys() + |> Enum.sort() + |> Enum.map(fn proto -> + proto_vsn = :aec_hard_forks.protocol_vsn_name(proto) + {HardforkPresets.hardfork_height(proto_vsn), HardforkPresets.mint_sum(proto_vsn)} + end) + |> Map.new() end defmemop tx_ids_positions() do diff --git a/lib/ae_mdw/transfers.ex b/lib/ae_mdw/transfers.ex index 0f2797ab6..d1ad12b58 100644 --- a/lib/ae_mdw/transfers.ex +++ b/lib/ae_mdw/transfers.ex @@ -23,7 +23,7 @@ defmodule AeMdw.Transfers do @typep pagination :: Collection.direction_limit() @typep range :: {:gen, Range.t()} | {:txi, Range.t()} | nil - @hardforks_accounts ~w(accounts_genesis accounts_minerva accounts_fortuna accounts_lima) + @hardforks_accounts ~w(accounts_roma accounts_minerva accounts_fortuna accounts_lima) @kinds ~w(fee_lock_name fee_refund_name fee_spend_name reward_block reward_dev reward_oracle) ++ @hardforks_accounts diff --git a/lib/ae_mdw_web/websocket/broadcaster.ex b/lib/ae_mdw_web/websocket/broadcaster.ex index 87d733031..164f0a8f2 100644 --- a/lib/ae_mdw_web/websocket/broadcaster.ex +++ b/lib/ae_mdw_web/websocket/broadcaster.ex @@ -125,12 +125,23 @@ defmodule AeMdwWeb.Websocket.Broadcaster do type = :aec_headers.type(header) channel = Map.fetch!(@block_subs, type) - with {:ok, block} <- serialize_block(header, type, source, version) do - block - |> Map.merge(counters) - |> encode_message(channel, source) - |> broadcast(channel, source, version) + case serialize_block(header, type, source, version) do + {:ok, block} -> + block + |> Map.merge(counters) + |> encode_message(channel, source) + |> broadcast(channel, source, version) + + {:error, reason} -> + require Logger + Logger.warning("[broadcaster] serialize_block failed: #{inspect(reason)}") + {:error, reason} end + rescue + e -> + require Logger + Logger.warning("[broadcaster] do_broadcast_block exception: #{inspect(e)}") + {:error, e} end defp serialize_block(header, :key, :mdw, version) when version in [:v2, :v3] do diff --git a/priv/migrations/20251024092223_add_roma_account_balances_to_total_supply.ex b/priv/migrations/20251024092223_add_roma_account_balances_to_total_supply.ex index d850be318..1a7373b16 100644 --- a/priv/migrations/20251024092223_add_roma_account_balances_to_total_supply.ex +++ b/priv/migrations/20251024092223_add_roma_account_balances_to_total_supply.ex @@ -1,4 +1,8 @@ defmodule AeMdw.Migrations.AddRomaAccountBalancesToTotalSupply do + @moduledoc """ + Adds Roma hardfork account balances to total supply for all heights. + """ + alias AeMdw.Db.HardforkPresets alias AeMdw.Db.Model alias AeMdw.Db.RocksDbCF @@ -13,11 +17,12 @@ defmodule AeMdw.Migrations.AddRomaAccountBalancesToTotalSupply do Model.TotalStat |> RocksDbCF.stream() |> Enum.map(fn Model.total_stat(index: height, total_supply: old_total_supply) -> - new_total_supply = old_total_supply + HardforkPresets.mint_sum(:roma) - WriteMutation.new( - Model.TotalStat, - Model.total_stat(index: height, total_supply: new_total_supply) - ) + new_total_supply = old_total_supply + HardforkPresets.mint_sum(:roma) + + WriteMutation.new( + Model.TotalStat, + Model.total_stat(index: height, total_supply: new_total_supply) + ) end) _state = State.commit_db(state, mutations) diff --git a/test/ae_mdw/db/hardfork_presets_test.exs b/test/ae_mdw/db/hardfork_presets_test.exs index 0860760ae..b149e0470 100644 --- a/test/ae_mdw/db/hardfork_presets_test.exs +++ b/test/ae_mdw/db/hardfork_presets_test.exs @@ -23,9 +23,9 @@ defmodule AeMdw.Db.HardforkPresetsTest do State.new() |> Collection.stream( Model.KindIntTransferTx, - {"accounts_genesis", nil, nil, nil} + {"accounts_roma", nil, nil, nil} ) - |> Stream.take_while(&match?({"accounts_genesis", _bi, _target, _txi}, &1)) + |> Stream.take_while(&match?({"accounts_roma", _bi, _target, _txi}, &1)) |> Enum.count() assert 325 == @@ -79,9 +79,9 @@ defmodule AeMdw.Db.HardforkPresetsTest do State.new() |> Collection.stream( Model.KindIntTransferTx, - {"accounts_genesis", nil, nil, nil} + {"accounts_roma", nil, nil, nil} ) - |> Stream.take_while(&match?({"accounts_genesis", _bi, _target, _txi}, &1)) + |> Stream.take_while(&match?({"accounts_roma", _bi, _target, _txi}, &1)) |> Enum.count() assert 3 == diff --git a/test/ae_mdw_web/controllers/transfer_controller_test.exs b/test/ae_mdw_web/controllers/transfer_controller_test.exs index 85b767aaa..8ca898d8e 100644 --- a/test/ae_mdw_web/controllers/transfer_controller_test.exs +++ b/test/ae_mdw_web/controllers/transfer_controller_test.exs @@ -20,7 +20,7 @@ defmodule AeMdwWeb.TransferControllerTest do assert Enum.count(response["data"]) == 100 assert Enum.all?(response["data"], fn %{"kind" => kind, "height" => height} -> - kind == "accounts_genesis" and height == 0 + kind == "accounts_roma" and height == 0 end) conn_next = get(conn, response["next"]) @@ -29,7 +29,7 @@ defmodule AeMdwWeb.TransferControllerTest do assert Enum.count(response_next["data"]) == 100 assert Enum.all?(response_next["data"], fn %{"kind" => kind, "height" => height} -> - kind == "accounts_genesis" and height == 0 + kind == "accounts_roma" and height == 0 end) end