Skip to content

Commit

Permalink
Rename 1.5.6 to 1.5.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Neylix committed Sep 9, 2024
1 parent b130c4e commit 561a32b
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 72 deletions.
8 changes: 4 additions & 4 deletions lib/archethic/crypto/keystore/node/software_impl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ defmodule Archethic.Crypto.NodeKeystore.SoftwareImpl do

@impl GenServer
# FIXME: use genserver message because ets table is protected
def handle_cast(:migrate_1_5_6, state) do
def handle_cast(:migrate_1_5_9, state) do
node_seed = Origin.retrieve_node_seed()
:ets.insert(@keystore_table, {:node_seed, node_seed})
:ets.delete(@keystore_table, :sign_fun)
Expand All @@ -243,9 +243,9 @@ defmodule Archethic.Crypto.NodeKeystore.SoftwareImpl do
{:noreply, state}
end

# FIXME: to remove after 1.5.6
# FIXME: to remove after 1.5.9
@doc false
def migrate_ets_table_1_5_6 do
GenServer.cast(__MODULE__, :migrate_1_5_6)
def migrate_ets_table_1_5_9 do
GenServer.cast(__MODULE__, :migrate_1_5_9)
end
end
4 changes: 2 additions & 2 deletions lib/archethic/crypto/keystore/shared_secrets/software_impl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ defmodule Archethic.Crypto.SharedSecretsKeystore.SoftwareImpl do
@impl GenServer
def code_change(_old_vsn, state, _extra), do: {:ok, state}

# FIXME: to remove after 1.5.6
# FIXME: to remove after 1.5.9
@doc false
def migrate_ets_table_1_5_6 do
def migrate_ets_table_1_5_9 do
:node_shared_secrets
|> TransactionChain.list_addresses_by_type()
|> Stream.take(-2)
Expand Down
4 changes: 2 additions & 2 deletions lib/archethic/p2p/mem_table.ex
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,9 @@ defmodule Archethic.P2P.MemTable do
end
end

# FIXME: to remove after 1.5.6
# FIXME: to remove after 1.5.9
@doc false
def migrate_ets_table_1_5_6 do
def migrate_ets_table_1_5_9 do
# Inject the mining public key as nil awaiting the migration scripts to be executed
ms = [
{{:"$1", :"$2", :"$3", :"$4", :"$5", :"$6", :"$7", :"$8", :"$9", :"$10", :"$11", :"$12",
Expand Down
57 changes: 0 additions & 57 deletions priv/migration_tasks/prod/1.5.6@add_mining_bls_key.exs

This file was deleted.

57 changes: 57 additions & 0 deletions priv/migration_tasks/prod/1.5.9@add_mining_bls_key.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
defmodule Migration_1_5_9 do
@moduledoc false

alias Archethic.Crypto
alias Archethic.P2P
alias Archethic.P2P.Node

alias Archethic.TransactionChain
alias Archethic.TransactionChain.Transaction
alias Archethic.TransactionChain.TransactionData

alias Archethic.Utils

require Logger

def run() do
%Node{ip: ip, port: p2p_port, http_port: http_port, transport: transport, reward_address: reward_address, origin_public_key: origin_public_key} = P2P.get_node_info()

mining_public_key = Crypto.mining_node_public_key()
key_certificate = Crypto.get_key_certificate(origin_public_key)

genesis_address = Crypto.first_node_public_key() |> Crypto.derive_address()
{:ok, %Transaction{data: %TransactionData{code: code}}} =
TransactionChain.get_last_transaction(genesis_address, data: [:code])

tx =
Transaction.new(:node, %TransactionData{
code: code,
content:
Node.encode_transaction_content(
ip,
p2p_port,
http_port,
transport,
reward_address,
origin_public_key,
key_certificate,
mining_public_key
)
})

:ok = Archethic.send_new_transaction(tx, forward?: true)

nodes =
P2P.authorized_and_available_nodes()
|> Enum.filter(&P2P.node_connected?/1)
|> P2P.nearest_nodes()

case Utils.await_confirmation(tx.address, nodes) do
{:ok, _} ->
Logger.info("Mining node updated")

{:error, reason} ->
Logger.warning("Cannot update node transaction - #{inspect reason}")
end
end
end
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
{"1.5.6",
[{"1.5.5",
{"1.5.9",
[{"1.5.8",
[{apply,{'Elixir.Archethic.PubSub',notify_node_status,[node_down]}},
{load_module,'Elixir.Archethic.Cldr.Currency',brutal_purge,soft_purge,[]},
{load_module,'Elixir.Archethic.Cldr.Number.Transliterate',brutal_purge,
soft_purge,[]},
{load_module,'Elixir.Archethic.Contracts.Interpreter.Library.Common.List',
brutal_purge,soft_purge,[]},
{load_module,'Elixir.Archethic.Contracts.Interpreter.Library.Common.Math',
brutal_purge,soft_purge,[]},
{load_module,'Elixir.Archethic.Crypto.ID',brutal_purge,soft_purge,[]},
{load_module,'Elixir.Archethic.Crypto.NodeKeystore',brutal_purge,
soft_purge,[]},
{load_module,'Elixir.Archethic.P2P.Message.ValidateSmartContractCall',
brutal_purge,soft_purge,[]},
{load_module,'Elixir.Archethic.P2P.Message.ShardRepair',brutal_purge,
soft_purge,[]},
{load_module,'Elixir.Archethic.P2P.Node',brutal_purge,soft_purge,[]},
{load_module,'Elixir.ArchethicWeb.Explorer.LayoutView',brutal_purge,
soft_purge,[]},
{load_module,'Elixir.ArchethicWeb.Explorer.WorldMapLive',brutal_purge,
soft_purge,[]},
{load_module,'Elixir.ArchethicWeb.ExplorerRouter',brutal_purge,soft_purge,
[]},
{load_module,'Elixir.Archethic.Crypto',brutal_purge,soft_purge,
['Elixir.Archethic.Crypto.ID',
'Elixir.Archethic.Crypto.NodeKeystore']},
{update,'Elixir.Archethic.Contracts.Worker',
{advanced,[]},
brutal_purge,soft_purge,
['Elixir.Archethic.Crypto']},
{update,'Elixir.Archethic.Crypto.SharedSecretsKeystore.SoftwareImpl',
{advanced,[]},
brutal_purge,soft_purge,
Expand All @@ -29,6 +39,10 @@
{advanced,[]},
brutal_purge,soft_purge,
['Elixir.Archethic.P2P.Node']},
{update,'Elixir.Archethic.SelfRepair.Notifier',
{advanced,[]},
brutal_purge,soft_purge,
['Elixir.Archethic.Crypto']},
{load_module,'Elixir.ArchethicWeb.Explorer.NodeDetailsLive',brutal_purge,
soft_purge,
['Elixir.Archethic.Crypto']},
Expand All @@ -53,9 +67,15 @@
{advanced,[]},
brutal_purge,soft_purge,
['Elixir.Archethic.Crypto','Elixir.Archethic.P2P.Node']},
{load_module,'Elixir.ArchethicWeb.Explorer.ExplorerView',brutal_purge,
soft_purge,
['Elixir.Archethic.Crypto','Elixir.Archethic.P2P.Node']},
{load_module,'Elixir.ArchethicWeb.Explorer.SettingsLive',brutal_purge,
soft_purge,
['Elixir.Archethic.Crypto','Elixir.Archethic.P2P.Node']},
{load_module,'Elixir.Archethic.Bootstrap',brutal_purge,soft_purge,
['Elixir.Archethic.Bootstrap.TransactionHandler',
'Elixir.Archethic.Crypto','Elixir.Archethic.P2P.Node']},
{update,'Elixir.Archethic.P2P.MemTableLoader',
{advanced,[]},
brutal_purge,soft_purge,
Expand All @@ -74,23 +94,33 @@
{apply,{'Elixir.Archethic.Crypto.NodeKeystore.SoftwareImpl', migrate_ets_table_1_5_6, []}},
{apply,{'Elixir.Archethic.Crypto.SharedSecretsKeystore.SoftwareImpl', migrate_ets_table_1_5_6, []}},
{apply,{'Elixir.Archethic.PubSub',notify_node_status, [node_up]}}]}],
[{"1.5.5",
[{"1.5.8",
[{load_module,'Elixir.Archethic.Cldr.Currency',brutal_purge,soft_purge,[]},
{load_module,'Elixir.Archethic.Cldr.Number.Transliterate',brutal_purge,
soft_purge,[]},
{load_module,'Elixir.Archethic.Contracts.Interpreter.Library.Common.List',
brutal_purge,soft_purge,[]},
{load_module,'Elixir.Archethic.Contracts.Interpreter.Library.Common.Math',
brutal_purge,soft_purge,[]},
{load_module,'Elixir.Archethic.Crypto.ID',brutal_purge,soft_purge,[]},
{load_module,'Elixir.Archethic.Crypto.NodeKeystore',brutal_purge,
soft_purge,[]},
{load_module,'Elixir.Archethic.P2P.Message.ValidateSmartContractCall',
brutal_purge,soft_purge,[]},
{load_module,'Elixir.Archethic.P2P.Message.ShardRepair',brutal_purge,
soft_purge,[]},
{load_module,'Elixir.Archethic.P2P.Node',brutal_purge,soft_purge,[]},
{load_module,'Elixir.ArchethicWeb.Explorer.LayoutView',brutal_purge,
soft_purge,[]},
{load_module,'Elixir.ArchethicWeb.Explorer.WorldMapLive',brutal_purge,
soft_purge,[]},
{load_module,'Elixir.ArchethicWeb.ExplorerRouter',brutal_purge,soft_purge,
[]},
{load_module,'Elixir.Archethic.Crypto',brutal_purge,soft_purge,
['Elixir.Archethic.Crypto.ID',
'Elixir.Archethic.Crypto.NodeKeystore']},
{update,'Elixir.Archethic.Contracts.Worker',
{advanced,[]},
brutal_purge,soft_purge,
['Elixir.Archethic.Crypto']},
{update,'Elixir.Archethic.Crypto.SharedSecretsKeystore.SoftwareImpl',
{advanced,[]},
brutal_purge,soft_purge,
Expand All @@ -103,6 +133,10 @@
{advanced,[]},
brutal_purge,soft_purge,
['Elixir.Archethic.P2P.Node']},
{update,'Elixir.Archethic.SelfRepair.Notifier',
{advanced,[]},
brutal_purge,soft_purge,
['Elixir.Archethic.Crypto']},
{load_module,'Elixir.ArchethicWeb.Explorer.NodeDetailsLive',brutal_purge,
soft_purge,
['Elixir.Archethic.Crypto']},
Expand All @@ -127,9 +161,15 @@
{advanced,[]},
brutal_purge,soft_purge,
['Elixir.Archethic.Crypto','Elixir.Archethic.P2P.Node']},
{load_module,'Elixir.ArchethicWeb.Explorer.ExplorerView',brutal_purge,
soft_purge,
['Elixir.Archethic.Crypto','Elixir.Archethic.P2P.Node']},
{load_module,'Elixir.ArchethicWeb.Explorer.SettingsLive',brutal_purge,
soft_purge,
['Elixir.Archethic.Crypto','Elixir.Archethic.P2P.Node']},
{load_module,'Elixir.Archethic.Bootstrap',brutal_purge,soft_purge,
['Elixir.Archethic.Bootstrap.TransactionHandler',
'Elixir.Archethic.Crypto','Elixir.Archethic.P2P.Node']},
{update,'Elixir.Archethic.P2P.MemTableLoader',
{advanced,[]},
brutal_purge,soft_purge,
Expand Down

0 comments on commit 561a32b

Please sign in to comment.