Commit 066c041b authored by Romain's avatar Romain Committed by Seb Mondet

Node: built-in networks have default bootstrap peers

parent 0dde0dbf
......@@ -48,12 +48,13 @@ type blockchain_network = {
sandboxed_chain_name : chain_name;
user_activated_upgrades : User_activated.upgrades;
user_activated_protocol_overrides : User_activated.protocol_overrides;
default_bootstrap_peers : string list;
}
let make_blockchain_network ~chain_name ?old_chain_name
?incompatible_chain_name ~sandboxed_chain_name
?(user_activated_upgrades = []) ?(user_activated_protocol_overrides = [])
genesis =
?(default_bootstrap_peers = []) genesis =
let of_string = Distributed_db_version.of_string in
{
genesis;
......@@ -70,6 +71,7 @@ let make_blockchain_network ~chain_name ?old_chain_name
(fun (a, b) ->
(Protocol_hash.of_b58check_exn a, Protocol_hash.of_b58check_exn b))
user_activated_protocol_overrides;
default_bootstrap_peers;
}
let blockchain_network_mainnet =
......@@ -94,6 +96,7 @@ let blockchain_network_mainnet =
~user_activated_protocol_overrides:
[ ( "PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU",
"PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS" ) ]
~default_bootstrap_peers:["boot.tzbeta.net"]
let blockchain_network_alphanet =
make_blockchain_network
......@@ -111,6 +114,7 @@ let blockchain_network_alphanet =
~old_chain_name:"TEZOS_ALPHANET_2018-11-30T15:30:56Z"
~incompatible_chain_name:"INCOMPATIBLE"
~sandboxed_chain_name:"SANDBOXED_TEZOS_MAINNET"
~default_bootstrap_peers:["boot.tzalpha.net"; "bootalpha.tzbeta.net"]
let blockchain_network_zeronet =
make_blockchain_network
......@@ -126,6 +130,7 @@ let blockchain_network_zeronet =
}
~chain_name:"TEZOS_ZERONET_2019-08-06T15:18:56Z"
~sandboxed_chain_name:"SANDBOXED_TEZOS"
~default_bootstrap_peers:["bootstrap.zeronet.fun"; "bootzero.tzbeta.net"]
let blockchain_network_babylonnet =
make_blockchain_network
......@@ -141,6 +146,8 @@ let blockchain_network_babylonnet =
}
~chain_name:"TEZOS_ALPHANET_BABYLON_2019-09-27T07:43:32Z"
~sandboxed_chain_name:"SANDBOXED_TEZOS"
~default_bootstrap_peers:
["35.246.251.120"; "34.89.154.253"; "babylonnet.kaml.fr"; "tezaria.com"]
let blockchain_network_sandbox =
make_blockchain_network
......@@ -166,21 +173,24 @@ let blockchain_network_encoding : blockchain_network Data_encoding.t =
incompatible_chain_name;
sandboxed_chain_name;
user_activated_upgrades;
user_activated_protocol_overrides } ->
user_activated_protocol_overrides;
default_bootstrap_peers } ->
( genesis,
chain_name,
old_chain_name,
incompatible_chain_name,
sandboxed_chain_name,
user_activated_upgrades,
user_activated_protocol_overrides ))
user_activated_protocol_overrides,
default_bootstrap_peers ))
(fun ( genesis,
chain_name,
old_chain_name,
incompatible_chain_name,
sandboxed_chain_name,
user_activated_upgrades,
user_activated_protocol_overrides ) ->
user_activated_protocol_overrides,
default_bootstrap_peers ) ->
{
genesis;
chain_name;
......@@ -189,18 +199,26 @@ let blockchain_network_encoding : blockchain_network Data_encoding.t =
sandboxed_chain_name;
user_activated_upgrades;
user_activated_protocol_overrides;
default_bootstrap_peers;
})
(let chain = Distributed_db_version.name_encoding in
obj7
obj8
(req "genesis" State.Chain.genesis_encoding)
(req "chain_name" chain)
(opt "old_chain_name" chain)
(opt "incompatible_chain_name" chain)
(req "sandboxed_chain_name" chain)
(req "user_activated_upgrades" User_activated.upgrades_encoding)
(req
(dft "user_activated_upgrades" User_activated.upgrades_encoding [])
(dft
"user_activated_protocol_overrides"
User_activated.protocol_overrides_encoding))
User_activated.protocol_overrides_encoding
[])
(dft
"default_bootstrap_peers"
~description:
"List of hosts to use if p2p.bootstrap_peers is unspecified."
(list string)
[]))
let sugared_blockchain_network_encoding : blockchain_network Data_encoding.t =
let open Data_encoding in
......@@ -255,7 +273,7 @@ type t = {
and p2p = {
expected_pow : float;
bootstrap_peers : string list;
bootstrap_peers : string list option;
listen_addr : string option;
discovery_addr : string option;
private_mode : bool;
......@@ -313,7 +331,7 @@ let default_p2p_limits : P2p.limits =
let default_p2p =
{
expected_pow = 26.;
bootstrap_peers = [];
bootstrap_peers = None;
listen_addr = Some ("[::]:" ^ string_of_int default_p2p_port);
discovery_addr = None;
private_mode = false;
......@@ -589,13 +607,12 @@ let p2p =
zeroes are expected in the hash."
float
default_p2p.expected_pow)
(dft
(opt
"bootstrap-peers"
~description:
"List of hosts. Tezos can connect to both IPv6 and IPv4 hosts. If \
the port is not specified, default port 9732 will be assumed."
(list string)
default_p2p.bootstrap_peers)
(list string))
(opt
"listen-addr"
~description:
......@@ -1199,8 +1216,15 @@ let check_bootstrap_peer addr =
| exn ->
Lwt.fail exn)
let bootstrap_peers config =
match config.p2p.bootstrap_peers with
| None ->
config.blockchain_network.default_bootstrap_peers
| Some peers ->
peers
let check_bootstrap_peers config =
Lwt_list.iter_p check_bootstrap_peer config.p2p.bootstrap_peers
Lwt_list.iter_p check_bootstrap_peer (bootstrap_peers config)
let fail fmt = Format.kasprintf (fun s -> prerr_endline s ; exit 1) fmt
......
......@@ -36,6 +36,7 @@ type blockchain_network = {
sandboxed_chain_name : chain_name;
user_activated_upgrades : User_activated.upgrades;
user_activated_protocol_overrides : User_activated.protocol_overrides;
default_bootstrap_peers : string list;
}
type t = {
......@@ -50,7 +51,7 @@ type t = {
and p2p = {
expected_pow : float;
bootstrap_peers : string list;
bootstrap_peers : string list option;
listen_addr : string option;
discovery_addr : string option;
private_mode : bool;
......@@ -97,7 +98,7 @@ val update :
?binary_chunks_size:int ->
?peer_table_size:int ->
?expected_pow:float ->
?bootstrap_peers:string list ->
?bootstrap_peers:string list option ->
?listen_addr:string ->
?discovery_addr:string ->
?rpc_listen_addrs:string list ->
......@@ -130,3 +131,7 @@ val resolve_bootstrap_addrs : string list -> (P2p_addr.t * int) list Lwt.t
val encoding : t Data_encoding.t
val check : t -> unit Lwt.t
(** Return [p2p.bootstrap_peers] if not [None],
[network.default_bootstrap_peers] otherwise. *)
val bootstrap_peers : t -> string list
......@@ -113,7 +113,8 @@ let init_node ?sandbox ?checkpoint ~singleprocess (config : Node_config_file.t)
| (None, Some _) ->
return_none
| _ ->
Node_config_file.resolve_bootstrap_addrs config.p2p.bootstrap_peers
Node_config_file.resolve_bootstrap_addrs
(Node_config_file.bootstrap_peers config)
>>= fun trusted_points ->
Node_identity_file.read
(config.data_dir // Node_data_version.default_identity_file_name)
......
......@@ -418,7 +418,7 @@ let read_and_patch_config_file ?(ignore_bootstrap_peers = false) args =
if no_bootstrap_peers || ignore_bootstrap_peers then (
log_info "Ignoring bootstrap peers" ;
peers )
else cfg.p2p.bootstrap_peers @ peers
else Node_config_file.bootstrap_peers cfg @ peers
in
Node_config_file.update
?data_dir
......@@ -430,7 +430,7 @@ let read_and_patch_config_file ?(ignore_bootstrap_peers = false) args =
?binary_chunks_size
?peer_table_size
?expected_pow
~bootstrap_peers
~bootstrap_peers:(Some bootstrap_peers)
?listen_addr
?discovery_addr
~rpc_listen_addrs
......
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