Skip to content

Commit

Permalink
Add timestamp in node validation election
Browse files Browse the repository at this point in the history
  • Loading branch information
Neylix authored and Wassim Mansouri committed Nov 13, 2024
1 parent 5ad163c commit 4c0b0e8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions lib/archethic.ex
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ defmodule Archethic do

responses =
%{already_locked?: already_locked?} =
do_send_transaction(tx, validation_nodes, welcome_node_key, contract_context)
do_send_transaction(tx, validation_nodes, welcome_node_key, contract_context, ref_timestamp)

maybe_start_resync(responses)

Expand Down Expand Up @@ -122,7 +122,8 @@ defmodule Archethic do
tx = %Transaction{type: tx_type},
validation_nodes,
welcome_node_key,
contract_context
contract_context,
ref_timestamp
) do
message = %StartMining{
transaction: tx,
Expand All @@ -131,7 +132,7 @@ defmodule Archethic do
network_chains_view_hash: NetworkView.get_chains_hash(),
p2p_view_hash: NetworkView.get_p2p_hash(),
contract_context: contract_context,
ref_timestamp: DateTime.utc_now()
ref_timestamp: ref_timestamp
}

Task.Supervisor.async_stream_nolink(
Expand Down
4 changes: 2 additions & 2 deletions lib/archethic/election.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ defmodule Archethic.Election do
|> Transaction.to_pending()
|> Transaction.serialize()

tx_hash =
sorting_hash =
<<serialized_tx::bitstring, DateTime.to_unix(timestamp, :millisecond)::64>>
|> Crypto.hash()

Crypto.sign_with_daily_nonce_key(tx_hash, timestamp)
Crypto.sign_with_daily_nonce_key(sorting_hash, timestamp)
end

@doc """
Expand Down
2 changes: 1 addition & 1 deletion lib/archethic/mining.ex
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ defmodule Archethic.Mining do
) do
sorting_seed = Election.validation_nodes_election_seed_sorting(tx, ref_timestamp)

node_list = P2P.authorized_and_available_nodes()
node_list = P2P.authorized_and_available_nodes(ref_timestamp)

storage_nodes = Election.chain_storage_nodes(tx_address, node_list)

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.5.12",
version: "1.5.13",
build_path: "_build",
config_path: "config/config.exs",
deps_path: "deps",
Expand Down

0 comments on commit 4c0b0e8

Please sign in to comment.