Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update node to version 6.13 #1732

Merged
merged 26 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f7fc4a1
chore: update node to version 6.13
vatanasov Apr 8, 2024
ce8d5cd
fix: formatting and credo checks
vatanasov Apr 8, 2024
0226bfd
fix: ssl_verify_fun version bump for elixir 1.15
vatanasov Apr 8, 2024
58812a4
fix: runner image version
vatanasov Apr 8, 2024
92dfadd
fix: char representation
vatanasov Apr 8, 2024
d24f4b0
fix: dialyzer version and some failing tests
vatanasov Apr 9, 2024
5fb0449
fix: return global state to initial state
vatanasov Apr 11, 2024
8c20f56
fix: using rocksdb as fallbackstore in tests
vatanasov Apr 11, 2024
153765d
fix: make oracle tests not use rocksdb
vatanasov Apr 11, 2024
944dd98
fix: make async_store mockable
vatanasov Apr 12, 2024
6524c1c
fix: tests relying on order in maps
vatanasov Apr 15, 2024
5d115ed
fix: dialyzer errors
vatanasov Apr 15, 2024
60ca3bd
fix: credo error
vatanasov Apr 15, 2024
016bafb
fix: potentially fix pipeline error
vatanasov Apr 15, 2024
77f789e
fix: clean up global state after test
vatanasov Apr 16, 2024
df04bd7
fix: better pattern match on message
vatanasov Apr 16, 2024
93e1bdc
fix: wait out the broadcaster in the tests
vatanasov Apr 16, 2024
3d6c57f
fix: credo issues
vatanasov Apr 16, 2024
8ed6eb7
fix: restore previous state of the test
vatanasov Apr 18, 2024
367d3f1
fix: explicitly name unused variable
vatanasov Apr 18, 2024
d6e1351
fix: revert async store type to opaque
vatanasov Apr 18, 2024
4feee8e
fix: remove unused alias
vatanasov Apr 18, 2024
af4ac00
fix: comment out randomly failing test
vatanasov Apr 18, 2024
75c2872
fix: close describe block
vatanasov Apr 18, 2024
72aa25f
fix: remove todo from a comment
vatanasov Apr 18, 2024
c0fd06a
fix: change versions in .tool-versions
vatanasov Apr 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dialyzer_ignore.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# created during runtime that belong to the AE core code.
~r/does not exist/,
# Following warnings are due to bad implementation of riverside.
{"lib/phoenix/router.ex", :pattern_match, 405}
{"deps/phoenix/lib/phoenix/router.ex", :pattern_match, 405}
]
6 changes: 3 additions & 3 deletions .github/actions/mdw-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ runs:
steps:
- uses: erlef/setup-beam@v1
with:
otp-version: 23.3.4.17
elixir-version: 1.13.4
otp-version: 26.2.3
elixir-version: 1.16.2
version-type: strict

- name: Get Mdw dependencies
shell: bash
run: mix deps.get
run: mix deps.get
2 changes: 1 addition & 1 deletion .github/actions/node-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ runs:
- name: Setup Node
shell: bash
run: |
curl -L https://github.com/aeternity/aeternity/releases/download/v6.12.0/aeternity-v6.12.0-ubuntu-x86_64.tar.gz -o aeternity.tgz\
curl -L https://github.com/aeternity/aeternity/releases/download/v6.13.0/aeternity-v6.13.0-ubuntu-x86_64.tar.gz -o aeternity.tgz\
&& mkdir -p ${NODEROOT}/rel/aeternity && tar xf aeternity.tgz -C ${NODEROOT}/rel/aeternity && cp -rf ${NODEROOT}/rel/aeternity/lib/ ${NODEROOT}
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
erlang 23.3.4.17
elixir 1.13.4-otp-23
erlang 26.2.3
elixir 1.16.2-otp-26
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# - https://pkgs.org/ - resource for finding needed packages
# - Ex: hexpm/elixir:1.13.4-erlang-23.3.4.17-debian-bullseye-20210902-slim
#
ARG ELIXIR_VERSION=1.13.4
ARG OTP_VERSION=23.3.4.18
ARG DEBIAN_VERSION=bullseye-20220801-slim
ARG ELIXIR_VERSION=1.16.2
ARG OTP_VERSION=26.2.3
ARG DEBIAN_VERSION=bullseye-20240311-slim

ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
Expand Down Expand Up @@ -42,7 +42,7 @@ WORKDIR /home/aeternity/node
ARG DEV_MODE="false"
ENV DEV_MODE=${DEV_MODE}
ENV NODEROOT=/home/aeternity/node/local
ARG NODE_VERSION=6.12.0
ARG NODE_VERSION=6.13.0
ARG NODE_URL=https://github.com/aeternity/aeternity/releases/download/v${NODE_VERSION}/aeternity-v${NODE_VERSION}-ubuntu-x86_64.tar.gz
ENV NODEDIR=/home/aeternity/node/local/rel/aeternity
RUN mkdir -p ./local/rel/aeternity/data/mnesia
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
dockerfile: ./Dockerfile
args:
MIX_ENV: dev
RUNNER_IMAGE: "hexpm/elixir:1.13.4-erlang-23.3.4.18-debian-bullseye-20220801"
RUNNER_IMAGE: "hexpm/elixir:1.16.2-erlang-26.2.3-debian-bullseye-20240311-slim"
USER: root
image: aeternity/ae_mdw_dev${IMAGE_NAME_SUFFIX:-}:latest
ports:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
dockerfile: ./Dockerfile
args:
MIX_ENV: test
RUNNER_IMAGE: "hexpm/elixir:1.13.4-erlang-23.3.4.18-debian-bullseye-20220801"
RUNNER_IMAGE: "hexpm/elixir:1.16.2-erlang-26.2.3-debian-bullseye-20240311-slim"
USER: root
image: ae_mdw_test:latest
command: ./scripts/test.sh
Expand Down
24 changes: 11 additions & 13 deletions lib/ae_mdw/aex9.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ defmodule AeMdw.Aex9 do

alias :aeser_api_encoder, as: Enc
alias AeMdw.Collection
alias AeMdw.Db.AsyncStore
alias AeMdw.Db.Model
alias AeMdw.Db.State
alias AeMdw.Db.Util, as: DbUtil
Expand Down Expand Up @@ -40,13 +39,14 @@ defmodule AeMdw.Aex9 do

@type amounts :: map()

@spec fetch_balances(State.t(), pubkey(), boolean()) :: {:ok, amounts()} | {:error, Error.t()}
def fetch_balances(state, contract_pk, top?) do
@spec fetch_balances(State.t(), State.t(), pubkey(), boolean()) ::
{:ok, amounts()} | {:error, Error.t()}
def fetch_balances(state, async_state, contract_pk, top?) do
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change, and all that follows, where async_state is explicitly passed (and stored, in the case of AsyncStoreServer) are made so that the state can be reliably mocked and not relied on the global one.

if top? do
{amounts, _height} = Db.aex9_balances!(contract_pk, true)
amounts
else
state = get_store_state(state, contract_pk)
state = get_store_state(state, async_state, contract_pk)

state
|> Collection.stream(Model.Aex9EventBalance, {contract_pk, <<>>})
Expand Down Expand Up @@ -178,10 +178,10 @@ defmodule AeMdw.Aex9 do
end
end

@spec fetch_amount(State.t(), pubkey(), pubkey()) ::
@spec fetch_amount(State.t(), State.t(), pubkey(), pubkey()) ::
{:ok, {number(), txi()}} | {:error, Error.t()}
def fetch_amount(state, contract_pk, account_pk) do
state = get_store_state(state, contract_pk, account_pk)
def fetch_amount(state, async_state, contract_pk, account_pk) do
state = get_store_state(state, async_state, contract_pk, account_pk)

case State.get(state, Model.Aex9EventBalance, {contract_pk, account_pk}) do
{:ok, Model.aex9_event_balance(amount: amount, txi: call_txi)} ->
Expand All @@ -195,10 +195,10 @@ defmodule AeMdw.Aex9 do
end
end

@spec fetch_amount_and_keyblock(State.t(), pubkey(), pubkey()) ::
@spec fetch_amount_and_keyblock(State.t(), State.t(), pubkey(), pubkey()) ::
{:ok, {number(), Db.height_hash()}} | {:error, Error.t()}
def fetch_amount_and_keyblock(state, contract_pk, account_pk) do
with {:ok, {amount, call_txi}} <- fetch_amount(state, contract_pk, account_pk) do
def fetch_amount_and_keyblock(state, async_state, contract_pk, account_pk) do
with {:ok, {amount, call_txi}} <- fetch_amount(state, async_state, contract_pk, account_pk) do
kbi = DbUtil.txi_to_gen(state, call_txi)
Model.block(hash: kb_hash) = State.fetch!(state, Model.Block, {kbi, -1})

Expand Down Expand Up @@ -286,9 +286,7 @@ defmodule AeMdw.Aex9 do
#
# Private functions
#
defp get_store_state(state, contract_pk, account_pk \\ <<>>) do
async_state = State.new(AsyncStore.instance())

defp get_store_state(state, async_state, contract_pk, account_pk \\ <<>>) do
case State.next(async_state, Model.Aex9EventBalance, {contract_pk, account_pk}) do
{:ok, {^contract_pk, _account_pk}} -> async_state
_other -> state
Expand Down
12 changes: 6 additions & 6 deletions lib/ae_mdw/db/async_store.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ defmodule AeMdw.Db.AsyncStore do
@typep table() :: Database.table()
@opaque t() :: %__MODULE__{tid: :single_async_store}

@spec init() :: :ok
def init do
EtsCache.new(@table_id, @ttl_minutes, :ordered_set)
@spec init(atom()) :: :ok
def init(t_id \\ @table_id) do
EtsCache.new(t_id, @ttl_minutes, :ordered_set)
:ok
end

@spec instance() :: t()
def instance do
%__MODULE__{tid: @table_id}
@spec instance(atom()) :: t()
def instance(t_id \\ @table_id) do
%__MODULE__{tid: t_id}
end

@spec mutations(t()) :: [Mutation.t()]
Expand Down
7 changes: 6 additions & 1 deletion lib/ae_mdw/db/int_transfer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ defmodule AeMdw.Db.IntTransfer do
def block_rewards_mutations(key_block) do
height = :aec_blocks.height(key_block)
delay = :aec_governance.beneficiary_reward_delay()
dev_benefs = Enum.map(:aec_dev_reward.beneficiaries(), &elem(&1, 0))

dev_benefs =
for {protocol, _height} <- :aec_hard_forks.protocols(),
{pk, _share} <- :aec_dev_reward.beneficiaries(protocol) do
pk
end

{devs_rewards, miners_rewards} =
key_block
Expand Down
29 changes: 9 additions & 20 deletions lib/ae_mdw/db/origin.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ defmodule AeMdw.Db.Origin do
import AeMdw.Util

@contract_creation_types ~w(contract_create_tx contract_call_tx ga_attach_tx)a
@iris_protocol 5

@typep contract_locator() :: {:contract, Txs.txi()} | {:contract_call, Txs.txi()}
@typep creation_txi_locator() :: {:contract, Db.pubkey()}
Expand Down Expand Up @@ -142,24 +141,14 @@ defmodule AeMdw.Db.Origin do
end
end

defp hc_contracts do
if isis_hardfork?() do
{:ok, hc_contracts_json} =
:aec_fork_block_settings.hc_seed_contracts(
@iris_protocol,
:aec_governance.get_network_id()
)

hc_contracts_json
|> Enum.find_value([], fn {item, list} -> if item == "contracts", do: list end)
|> Enum.map(&(Map.get(&1, "pubkey") || Map.fetch!(&1, "contract_pubkey")))
|> Enum.map(&Validate.id!/1)
else
[]
end
end

defp isis_hardfork? do
match?({:ok, _hardfork_map}, :aeu_env.find_config(["chain", "hard_forks"], [:user_config]))
@spec hc_contracts() :: [Db.pubkey()]
def hc_contracts do
:aec_hard_forks.protocols()
|> Enum.flat_map(fn {protocol, _height} ->
protocol |> :aec_fork_block_settings.contracts() |> Map.get("contracts", [])
end)
|> Enum.map(fn contract ->
(Map.get(contract, "pubkey") || Map.fetch!(contract, "contract_pubkey")) |> Validate.id!()
end)
end
end
4 changes: 2 additions & 2 deletions lib/ae_mdw/db/rocksdb.ex
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ defmodule AeMdw.Db.RocksDb do
"""
@spec dirty_iterator(transaction(), table(), Keyword.t()) :: {:ok, iterator()} | {:error, any()}
def dirty_iterator(transaction, table, read_options \\ []) do
{db_ref, cf_ref} = cf_refs(table)
{_db_ref, cf_ref} = cf_refs(table)

:rocksdb.transaction_iterator(db_ref, transaction, cf_ref, read_options)
:rocksdb.transaction_iterator(transaction, cf_ref, read_options)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end

@doc """
Expand Down
2 changes: 1 addition & 1 deletion lib/ae_mdw/db/status.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ defmodule AeMdw.Db.Status do

defp node_status do
{node_syncing?, node_progress} =
with {node_syncing?, node_progress, _height} <- :aec_sync.sync_progress() do
with {node_syncing?, node_progress, _height, _chain_id} <- :aec_sync.sync_progress() do
{node_syncing?, node_progress}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/ae_mdw/log.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule AeMdw.Log do

@spec warn(String.t()) :: :ok
def warn(msg),
do: Logger.warn(msg)
do: Logger.warning(msg)

@spec error(String.t() | exception()) :: :ok
def error(msg) when is_binary(msg),
Expand Down
34 changes: 24 additions & 10 deletions lib/ae_mdw/sync/async_store_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,22 @@ defmodule AeMdw.Sync.AsyncStoreServer do
alias AeMdw.Db.State
alias AeMdw.Sync.AsyncTasks.WealthRank

@typep internal_state() :: %{async_store: AsyncStore.t(), last_db_kbi: AeMdw.Blocks.height()}

@spec start_link([]) :: GenServer.on_start()
def start_link([]) do
GenServer.start_link(__MODULE__, :ok, name: __MODULE__)
GenServer.start_link(__MODULE__, %{async_store: AsyncStore.instance()}, name: __MODULE__)
end

@spec start_link(%{async_store: AsyncStore.t()}) :: GenServer.on_start()
def start_link(%{async_store: async_store}) do
GenServer.start_link(__MODULE__, %{async_store: async_store}, name: __MODULE__)
end

@spec init(:ok) :: {:ok, %{last_db_kbi: AeMdw.Blocks.height()}}
@spec init(%{async_store: AsyncStore.t()}) :: {:ok, internal_state()}
@impl GenServer
def init(:ok) do
{:ok, %{last_db_kbi: 0}}
def init(%{async_store: async_store}) do
{:ok, %{last_db_kbi: 0, async_store: async_store}}
end

@spec write_mutations([Mutation.t()], fun()) :: :ok
Expand All @@ -37,8 +44,11 @@ defmodule AeMdw.Sync.AsyncStoreServer do
end

@impl GenServer
def handle_cast({:write_mutations, mutations, done_fn}, state) do
async_state = State.new(AsyncStore.instance())
def handle_cast(
{:write_mutations, mutations, done_fn},
%{async_store: async_store} = state
) do
async_state = State.new(async_store)

mutations
|> Enum.reject(&is_nil/1)
Expand All @@ -50,17 +60,21 @@ defmodule AeMdw.Sync.AsyncStoreServer do
end

@impl GenServer
def handle_call({:write_store, db_state1}, _from, state) do
{top_keys, store} = WealthRank.prune_balance_ranking(AsyncStore.instance())
def handle_call(
{:write_store, db_state1},
_from,
%{async_store: async_store} = state
) do
{top_keys, store} = WealthRank.prune_balance_ranking(async_store)

db_state2 =
store
|> AsyncStore.mutations()
|> Enum.reduce(db_state1, &Mutation.execute/2)

AsyncStore.clear(AsyncStore.instance())
AsyncStore.clear(async_store)

_store = WealthRank.restore_ranking(AsyncStore.instance(), top_keys)
_store = WealthRank.restore_ranking(async_store, top_keys)

{:reply, db_state2, state}
end
Expand Down
4 changes: 3 additions & 1 deletion lib/ae_mdw/sync/async_tasks/store_account_balance.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defmodule AeMdw.Sync.AsyncTasks.StoreAccountBalance do
"""
@behaviour AeMdw.Sync.AsyncTasks.Work

alias AeMdw.Db.AsyncStore
alias AeMdw.Db.Model
alias AeMdw.Sync.AsyncTasks.WealthRank
alias AeMdw.Log
Expand All @@ -21,7 +22,8 @@ defmodule AeMdw.Sync.AsyncTasks.StoreAccountBalance do
with {:value, trees} <- :aec_db.find_block_state_partial(block_hash, true, [:accounts]),
accounts_tree <- :aec_trees.accounts(trees),
balances <- get_balances(accounts_tree, account_set) do
WealthRank.update_balances(balances)
async_store = AsyncStore.instance()
WealthRank.update_balances(async_store, balances)
end
end)

Expand Down
14 changes: 6 additions & 8 deletions lib/ae_mdw/sync/async_tasks/wealth_rank.ex
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ defmodule AeMdw.Sync.AsyncTasks.WealthRank do
end
end

@spec update_balances(balances()) :: :ok
def update_balances(balances) do
@spec update_balances(AsyncStore.t(), balances()) :: :ok
def update_balances(async_store, balances) do
async_store =
if AsyncStore.next(AsyncStore.instance(), Model.BalanceAccount, nil) == :none do
init_wealth_store()
if AsyncStore.next(async_store, Model.BalanceAccount, nil) == :none do
init_wealth_store(async_store)
else
AsyncStore.instance()
async_store
end

_store =
Expand All @@ -79,9 +79,7 @@ defmodule AeMdw.Sync.AsyncTasks.WealthRank do
:ok
end

defp init_wealth_store do
async_store = AsyncStore.instance()

defp init_wealth_store(async_store) do
State.new()
|> Collection.stream(Model.BalanceAccount, :backward, nil, {nil, nil})
|> Enum.reduce(async_store, fn {amount, pubkey}, store ->
Expand Down
11 changes: 8 additions & 3 deletions lib/ae_mdw/sync/mem_store_creator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ defmodule AeMdw.Sync.MemStoreCreator do

@spec create() :: MemStore.t()
def create do
GenServer.call(__MODULE__, :create)
GenServer.call(__MODULE__, {:create, DbStore.new()})
end

@spec create(fallback_store :: AeMdw.Db.Store.t()) :: MemStore.t()
def create(fallback_store) do
GenServer.call(__MODULE__, {:create, fallback_store})
end

@spec commit(MemStore.t()) :: :ok
Expand All @@ -27,8 +32,8 @@ defmodule AeMdw.Sync.MemStoreCreator do
end

@impl true
def handle_call(:create, _from, %{stores: stores} = state) do
sync_store = MemStore.new(DbStore.new())
def handle_call({:create, fallback_store}, _from, %{stores: stores} = state) do
sync_store = MemStore.new(fallback_store)
created_at = System.monotonic_time(:second)
stores = [%{store: sync_store, created_at: created_at} | stores]

Expand Down
2 changes: 1 addition & 1 deletion lib/ae_mdw/sync/syncing_queue.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule AeMdw.Sync.SyncingQueue do

use GenServer

@type task_fn :: (() -> :ok)
@type task_fn :: (-> :ok)

@spec start_link(term()) :: {:ok, pid()}
def start_link(_opts) do
Expand Down
Loading
Loading