Skip to content

Commit

Permalink
up version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bchamagne authored and Neylix committed Jun 7, 2023
1 parent 3979972 commit 6c68963
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 34 deletions.
4 changes: 2 additions & 2 deletions lib/archethic/beacon_chain/slot.ex
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ defmodule Archethic.BeaconChain.Slot do
"""
@spec transform(binary(), t()) :: t()
def transform(
"1.0.8",
"1.1.0",
slot = %__MODULE__{transaction_attestations: attestations}
) do
if Enum.any?(attestations, fn %ReplicationAttestation{version: version} -> version == 1 end) do
Expand All @@ -645,7 +645,7 @@ defmodule Archethic.BeaconChain.Slot do
TaskSupervisor,
attestations,
fn attestation = %ReplicationAttestation{transaction_summary: summary} ->
new_summary = TransactionSummary.transform("1.0.8", summary)
new_summary = TransactionSummary.transform("1.1.0", summary)
%ReplicationAttestation{attestation | transaction_summary: new_summary}
end,
max_concurrency: System.schedulers_online() * 10
Expand Down
4 changes: 2 additions & 2 deletions lib/archethic/beacon_chain/subset.ex
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ defmodule Archethic.BeaconChain.Subset do
end

def handle_call(:get_current_slot, _from, state = %{current_slot: current_slot}) do
current_slot = Slot.transform("1.0.8", current_slot)
current_slot = Slot.transform("1.1.0", current_slot)
{:reply, current_slot, state}
end

Expand Down Expand Up @@ -353,7 +353,7 @@ defmodule Archethic.BeaconChain.Subset do
defp broadcast_beacon_slot(subset, next_time, slot) do
nodes = P2P.authorized_and_available_nodes(next_time, true)

slot = Slot.transform("1.0.8", slot)
slot = Slot.transform("1.1.0", slot)

subset
|> Election.beacon_storage_nodes(next_time, nodes)
Expand Down
19 changes: 1 addition & 18 deletions lib/archethic/beacon_chain/subset/summary_cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ defmodule Archethic.BeaconChain.Subset.SummaryCache do
:ets.insert(@table_name, {subset, slot})

{subset, slot} ->
slot = Slot.transform("1.0.8", slot)
slot = Slot.transform("1.1.0", slot)
backup_slot(slot, "")
:ets.insert(@table_name, {subset, slot})
end)
Expand All @@ -82,23 +82,6 @@ defmodule Archethic.BeaconChain.Subset.SummaryCache do
{:ok, state}
end

def code_change("1.1.0-rc1", state, _extra) do
backup_path = DateTime.utc_now() |> SummaryTimer.next_summary() |> recover_path()
backup_path_temp = backup_path <> "_temp"
File.rename(backup_path, backup_path_temp)

Enum.each(BeaconChain.list_subsets(), fn subset ->
:ets.lookup(@table_name, subset)
|> Enum.each(fn {_subset, {slot, pub_key}} ->
backup_slot(slot, pub_key)
end)
end)

File.rm(backup_path_temp)

{:ok, state}
end

def code_change(_, state, _), do: {:ok, state}

defp clean_previous_summary_cache(subset, previous_summary_time) do
Expand Down
12 changes: 12 additions & 0 deletions lib/archethic/crypto/keystore/shared_secrets/software_impl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ defmodule Archethic.Crypto.SharedSecretsKeystore.SoftwareImpl do
{:ok, %{}}
end

# we store functions in the ETS table, so we need to reload them
# every upgrade to avoid: "xxx is invalid, likely because it points to an old version of the code"
@impl true
def code_change(_, state, _extra) do
:node_shared_secrets
|> TransactionChain.list_addresses_by_type()
|> Stream.take(-2)
|> Enum.each(&load_node_shared_secrets_tx/1)

{:ok, state}
end

defp load_storage_nonce do
case DB.get_bootstrap_info("storage_nonce") do
nil ->
Expand Down
8 changes: 4 additions & 4 deletions lib/archethic/transaction_chain/transaction_summary.ex
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ defmodule Archethic.TransactionChain.TransactionSummary do
Apply a tranformation of a transaction summary based on the blockchain version
"""
@spec transform(binary(), t()) :: t()
def transform("1.0.8", tx_summary = %__MODULE__{version: 1}), do: tx_summary
def transform("1.1.0", tx_summary = %__MODULE__{version: 1}), do: tx_summary

def transform("1.0.8", %__MODULE__{address: address}) do
def transform("1.1.0", %__MODULE__{address: address}) do
transaction =
case TransactionChain.get_transaction(address) do
{:ok, tx} ->
Expand All @@ -238,8 +238,8 @@ defmodule Archethic.TransactionChain.TransactionSummary do
def transform(_, tx_summary), do: tx_summary

@doc """
This function will be used during the summary day of 1.0.8 upgrade. This function can be deleted after the upgrade.
Migrate this function into files 1.0.8-migrate_old_tx_summaries
This function will be used during the summary day of 1.1.0 upgrade. This function can be deleted after the upgrade.
Migrate this function into files 1.1.0-migrate_old_tx_summaries
Deserialize an old version of transaction summary
"""
@spec deserialize_old(bitstring()) :: {t(), bitstring()}
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Archethic.MixProject do
def project do
[
app: :archethic,
version: "1.1.0-rc5",
version: "1.1.0",
build_path: "_build",
config_path: "config/config.exs",
deps_path: "deps",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Migration_1_0_8 do
defmodule Migration_1_1_0 do
@moduledoc false

alias Archethic.TaskSupervisor
Expand Down Expand Up @@ -46,7 +46,7 @@ defmodule Migration_1_0_8 do
replication_attestations =
Task.Supervisor.async_stream(
TaskSupervisor,
tx_summaries,
tx_summaries,
fn tx_summary ->
create_attestation(tx_summary)
end,
Expand Down Expand Up @@ -101,7 +101,7 @@ defmodule Migration_1_0_8 do
end

defp create_attestation(tx_summary) do
new_tx_summary = TransactionSummary.transform("1.0.8", tx_summary)
new_tx_summary = TransactionSummary.transform("1.1.0", tx_summary)
%ReplicationAttestation{version: 1, transaction_summary: new_tx_summary}
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{"1.1.0-rc5",
{"1.1.0",
[{"1.0.7",
[{add_module,'Elixir.Archethic.BeaconChain.NetworkCoordinates'},
{add_module,'Elixir.Archethic.BeaconChain.Subset.StatsCollector'},
Expand Down Expand Up @@ -681,8 +681,6 @@
['Elixir.Archethic.Crypto','Elixir.Archethic.DB',
'Elixir.Archethic.SharedSecrets',
'Elixir.Archethic.TransactionChain']},
{apply,{supervisor, terminate_child, ['Elixir.Archethic.Crypto.KeystoreSupervisor', 'Elixir.Archethic.Crypto.SharedSecretsKeystore.SoftwareImpl']}},
{apply,{supervisor, restart_child, ['Elixir.Archethic.Crypto.KeystoreSupervisor', 'Elixir.Archethic.Crypto.SharedSecretsKeystore.SoftwareImpl']}},
{update,'Elixir.Archethic.DB.EmbeddedImpl.ChainIndex',
{advanced,[]},
brutal_purge,soft_purge,
Expand Down Expand Up @@ -1054,7 +1052,7 @@
type => supervisor
}
]}},
{apply,{'Elixir.Mix.Tasks.Archethic.Migrate',run,["1.1.0-rc5",true]}}]}],
{apply,{'Elixir.Mix.Tasks.Archethic.Migrate',run,["1.1.0",true]}}]}],
[{"1.0.7",
[{delete_module,'Elixir.Archethic.BeaconChain.NetworkCoordinates'},
{delete_module,'Elixir.Archethic.BeaconChain.Subset.StatsCollector'},
Expand Down

0 comments on commit 6c68963

Please sign in to comment.