Commit 8e0ebe53 authored by Grégoire Henry's avatar Grégoire Henry Committed by Julien

(Mainnet only) P2p: compatibility with old node (stage 2)

At this stage, nodes are compatible with node at stages 1 and 3.
parent 2f340bf5
Pipeline #52529914 passed with stages
in 7 minutes and 15 seconds
......@@ -32,7 +32,6 @@ let pp_name = Format.pp_print_string
let name_encoding = Data_encoding.string
let chain_name = "TEZOS_MAINNET"
let old_chain_name = "TEZOS_BETANET_2018-06-30T16:07:32Z"
let incompatible_chain_name = "INCOMPATIBLE"
let sandboxed_chain_name = "SANDBOXED_TEZOS_MAINNET"
......
......@@ -32,7 +32,6 @@ val pp_name: Format.formatter -> name -> unit
val name_encoding: name Data_encoding.t
val chain_name: name
val old_chain_name: name
val incompatible_chain_name: name
val sandboxed_chain_name: name
......
......@@ -121,43 +121,29 @@ module Connection_message = struct
version : Network_version.t ;
}
let mainnet_stage1_version_encoding =
(* minimal ugly hack for migrating from original mainnet.
Original node will send a singleton list containing:
[{ chain_name = "TEZOS_BETANET_2018-06-30T16:07:32Z" ;
distributed_db_version = 0 ;
p2p_version = 0 }]
Symetrically, original mainnet node will only accept us if we
send them a list containing this version. Their
version-selection algorithm will always select this one. *)
let mainnet_stage2_version_encoding =
(* minimal ugly hack for migrating from stage1 node. *)
let open Data_encoding in
conv
(fun v ->
[ v ;
(* always send the original announce. New nodes will ignore it,
and old node will select it whatever is the first version
in this list. *)
{ Network_version.
chain_name = Distributed_db_version.old_chain_name ;
distributed_db_version = Distributed_db_version.zero ;
p2p_version = P2p_version.zero } ;
])
(* Only announce the singleton, we don't want to speak to original
node anymore. *)
[ v ])
(function
| [] ->
(* Unexpected value, let the version-selection algorithm
reject the connection by returning a dummy value. *)
{ chain_name = Distributed_db_version.incompatible_chain_name ;
{ Network_version.
chain_name = Distributed_db_version.incompatible_chain_name ;
distributed_db_version = Distributed_db_version.zero ;
p2p_version = P2p_version.zero }
| [ v ] when v.chain_name = Distributed_db_version.old_chain_name ->
(* Incoming connection from a original mainnet node,
we replace the `chain_name` by the new one. *)
{ v with chain_name = Distributed_db_version.chain_name }
| [v] ->
(* This is a announce by a stage2 node or an original node.
Original node will be later kicked by the
version-selection algorithm. *)
v
| v :: _ ->
(* This is a announce by a upgraded node, we can safely
(* This is a announce by a stage1 node, we can safely
ignore the rest of the list. *)
v)
(Variable.list Network_version.encoding)
......@@ -180,7 +166,7 @@ module Connection_message = struct
(req "pubkey" Crypto_box.public_key_encoding)
(req "proof_of_work_stamp" Crypto_box.nonce_encoding)
(req "message_nonce" Crypto_box.nonce_encoding)
(req "version" mainnet_stage1_version_encoding))
(req "version" mainnet_stage2_version_encoding))
let write ~canceler fd message =
let encoded_message_len =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment