Commit 2c6b1f2d authored by Grégoire Henry's avatar Grégoire Henry Committed by Julien

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

At this stage, nodes are compatible with nodes at stage 2.

After this patch, the branch `mainnet` should contain the exact same
encoding than the `master` branch.

This patch relies on the fact that the binary representation of a
singleton version list with `(Variable.list P2p_version.encoding)`
is the exact same one than the representation of the version
with `P2p_version.encoding`.
parent 8e0ebe53
......@@ -32,7 +32,6 @@ let pp_name = Format.pp_print_string
let name_encoding = Data_encoding.string
let chain_name = "TEZOS_MAINNET"
let incompatible_chain_name = "INCOMPATIBLE"
let sandboxed_chain_name = "SANDBOXED_TEZOS_MAINNET"
type t = int
......
......@@ -32,7 +32,6 @@ val pp_name: Format.formatter -> name -> unit
val name_encoding: name Data_encoding.t
val chain_name: name
val incompatible_chain_name: name
val sandboxed_chain_name: name
(** An abstract version number for the high-level distributed_db messages. *)
......
......@@ -121,33 +121,6 @@ module Connection_message = struct
version : Network_version.t ;
}
let mainnet_stage2_version_encoding =
(* minimal ugly hack for migrating from stage1 node. *)
let open Data_encoding in
conv
(fun v ->
(* 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. *)
{ Network_version.
chain_name = Distributed_db_version.incompatible_chain_name ;
distributed_db_version = Distributed_db_version.zero ;
p2p_version = P2p_version.zero }
| [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 stage1 node, we can safely
ignore the rest of the list. *)
v)
(Variable.list Network_version.encoding)
let encoding =
let open Data_encoding in
conv
......@@ -166,7 +139,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_stage2_version_encoding))
(req "version" Network_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