Commit a1362049 authored by Romain's avatar Romain Committed by Seb Mondet

Node: parameterize chain name

parent b52389f6
......@@ -40,6 +40,9 @@ let with_node f =
let node_config : Node.config =
{
genesis;
chain_name = Distributed_db_version.of_string "TEZOS_DOCGEN";
sandboxed_chain_name =
Distributed_db_version.of_string "SANDBOXED_TEZOS_DOCGEN";
patch_context = None;
store_root = dir / "store";
context_root = dir / "context";
......
......@@ -158,6 +158,8 @@ let init_node ?sandbox ?checkpoint ~singleprocess (config : Node_config_file.t)
let node_config : Node.config =
{
genesis;
chain_name = config.blockchain_network.chain_name;
sandboxed_chain_name = config.blockchain_network.sandboxed_chain_name;
patch_context;
store_root = Node_data_version.store_dir config.data_dir;
context_root = Node_data_version.context_dir config.data_dir;
......
......@@ -39,10 +39,6 @@ let name_encoding =
~description:"A name for the distributed DB protocol"
string
let chain_name = "TEZOS"
let sandboxed_chain_name = "SANDBOXED_TEZOS"
type t = int
let pp = Format.pp_print_int
......
......@@ -34,10 +34,6 @@ val pp_name : Format.formatter -> name -> unit
val name_encoding : name Data_encoding.t
val chain_name : name
val sandboxed_chain_name : name
(** An abstract version number for the high-level [Distributed_db] messages. *)
type t = private int
......
......@@ -42,7 +42,7 @@ let msg_config : message P2p_connect_handler.message_config =
unwrap = (function Ping -> Some ());
max_length = None;
} ];
chain_name = Distributed_db_version.sandboxed_chain_name;
chain_name = Distributed_db_version.of_string "SANDBOXED_TEZOS";
distributed_db_versions = [Distributed_db_version.zero];
}
......
......@@ -44,7 +44,8 @@ let id0 =
let version =
{
Network_version.chain_name = Distributed_db_version.sandboxed_chain_name;
Network_version.chain_name =
Distributed_db_version.of_string "SANDBOXED_TEZOS";
distributed_db_version = Distributed_db_version.zero;
p2p_version = P2p_version.zero;
}
......
......@@ -1086,11 +1086,9 @@ let watch_operation {operation_input; _} =
Lwt_watcher.create_stream operation_input
module Raw = struct
let encoding = P2p_message.encoding Message.cfg.encoding
let encoding = P2p_message.encoding Message.encoding
let chain_name = Message.cfg.chain_name
let distributed_db_versions = Message.cfg.distributed_db_versions
let distributed_db_versions = Message.distributed_db_versions
end
module Make
......
......@@ -222,7 +222,5 @@ val commit_protocol :
module Raw : sig
val encoding : Message.t P2p_message.t Data_encoding.t
val chain_name : Distributed_db_version.name
val distributed_db_versions : Distributed_db_version.t list
end
......@@ -316,12 +316,10 @@ let encoding =
(fun ((block, ofs), (path, ops)) ->
Operations_for_block (block, ofs, ops, path)) ]
let cfg : _ P2p.message_config =
{
encoding;
chain_name = Distributed_db_version.chain_name;
distributed_db_versions = [Distributed_db_version.zero];
}
let distributed_db_versions = [Distributed_db_version.zero]
let cfg chain_name : _ P2p.message_config =
{encoding; chain_name; distributed_db_versions}
let raw_encoding = P2p_message.encoding encoding
......
......@@ -47,7 +47,11 @@ type t =
| Operations_for_block of
Block_hash.t * int * Operation.t list * Operation_list_list_hash.path
val cfg : t P2p.message_config
val encoding : t P2p_message.encoding list
val distributed_db_versions : Distributed_db_version.t list
val cfg : Distributed_db_version.name -> t P2p.message_config
val pp_json : Format.formatter -> t -> unit
......
......@@ -120,27 +120,19 @@ let init_connection_metadata opt =
private_node = c.P2p.private_mode;
}
let init_p2p ?(sandboxed = false) p2p_params =
let init_p2p chain_name p2p_params =
let message_cfg = Distributed_db_message.cfg chain_name in
match p2p_params with
| None ->
let c_meta = init_connection_metadata None in
Initialization_event.lwt_emit `P2p_layer_disabled
>>= fun () ->
return
(P2p.faked_network Distributed_db_message.cfg peer_metadata_cfg c_meta)
return (P2p.faked_network message_cfg peer_metadata_cfg c_meta)
| Some (config, limits) ->
let c_meta = init_connection_metadata (Some config) in
let conn_metadata_cfg = connection_metadata_cfg c_meta in
Initialization_event.lwt_emit `Bootstrapping
>>= fun () ->
let message_cfg =
if sandboxed then
{
Distributed_db_message.cfg with
chain_name = Distributed_db_version.sandboxed_chain_name;
}
else Distributed_db_message.cfg
in
P2p.create
~config
~limits
......@@ -153,6 +145,8 @@ let init_p2p ?(sandboxed = false) p2p_params =
type config = {
genesis : State.Chain.genesis;
chain_name : Distributed_db_version.name;
sandboxed_chain_name : Distributed_db_version.name;
store_root : string;
context_root : string;
protocol_root : string;
......@@ -318,6 +312,8 @@ let check_and_fix_storage_consistency state =
let create ?(sandboxed = false) ?sandbox_parameters ~singleprocess
{ genesis;
chain_name;
sandboxed_chain_name;
store_root;
context_root;
protocol_root;
......@@ -332,7 +328,7 @@ let create ?(sandboxed = false) ?sandbox_parameters ~singleprocess
| None ->
(true, true)
in
init_p2p ~sandboxed p2p_params
init_p2p (if sandboxed then sandboxed_chain_name else chain_name) p2p_params
>>=? fun p2p ->
(let open Block_validator_process in
if singleprocess then
......
......@@ -29,6 +29,8 @@ type t
type config = {
genesis : State.Chain.genesis;
chain_name : Distributed_db_version.name;
sandboxed_chain_name : Distributed_db_version.name;
store_root : string;
context_root : string;
protocol_root : string;
......
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