Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: separate peer seeds to common.network #3635

Merged
merged 2 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,29 @@ name: CI

env:
CARGO_HTTP_MULTIPLEXING: false
PROTOC: protoc
toolchain: nightly-2021-09-18

jobs:
clippy:
name: clippy
runs-on: ubuntu-18.04
steps:
- name: ubuntu dependencies
run: |
sudo apt-get update && \
sudo apt-get -y install \
libssl-dev \
openssl \
libsqlite3-dev \
pkg-config \
git \
cmake \
zip \
libc++-dev \
libc++abi-dev \
libprotobuf-dev \
protobuf-compiler
- name: checkout
uses: actions/checkout@v2
- name: toolchain
Expand All @@ -40,10 +56,10 @@ jobs:
command: fmt
args: --all -- --check
- name: Clippy check
uses: actions-rs/clippy-check@v1
uses: actions-rs/cargo@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
command: clippy
args: --all-targets -- -D warnings
test:
name: test
runs-on: ubuntu-18.04
Expand All @@ -59,7 +75,6 @@ jobs:
target
key: ${{ runner.os }}-${{ runner.cpu-model }}-${{ env.toolchain }}-${{ hashFiles('**/Cargo.lock') }}
- name: ubuntu dependencies
if: startsWith(matrix.os,'ubuntu')
run: |
sudo apt-get update && \
sudo apt-get -y install \
Expand Down
11 changes: 4 additions & 7 deletions applications/tari_app_utilities/src/initialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ pub fn init_configuration(
log::info!(target: LOG_TARGET, "{} ({})", application_type, consts::APP_VERSION);

// Populate the configuration struct
let mut global_config = GlobalConfig::convert_from(application_type, cfg.clone())
.map_err(|err| ExitCodes::ConfigError(err.to_string()))?;
let mut global_config = GlobalConfig::convert_from(application_type, cfg.clone(), bootstrap.network.clone())?;

if let Some(str) = bootstrap.network.clone() {
log::info!(target: LOG_TARGET, "Network selection requested");
Expand All @@ -54,11 +53,9 @@ pub fn init_configuration(
global_config.wallet_peer_db_path = global_config.data_dir.join("wallet_peer_db");
global_config.console_wallet_peer_db_path = global_config.data_dir.join("console_wallet_peer_db");
},
Err(_) => {
log::warn!(
target: LOG_TARGET,
"Network selection was invalid, continuing with default network."
);
Err(e) => {
log::error!(target: LOG_TARGET, "Network selection was invalid, exiting.");
return Err(e.into());
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_stratum_transcoder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ fn initialize() -> Result<GlobalConfig, StratumTranscoderProxyError> {
#[cfg(not(feature = "envlog"))]
bootstrap.initialize_logging()?;

let cfg = GlobalConfig::convert_from(application_type, cfg)?;
let cfg = GlobalConfig::convert_from(application_type, cfg, bootstrap.network)?;
Ok(cfg)
}
87 changes: 50 additions & 37 deletions common/config/presets/common.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,6 @@
# weatherwax - the Tari testnet
network = "weatherwax"

# When first logging onto the Tari network, you need to find a few peers to bootstrap the process. In the absence of
# any servers, this is a little more challenging than usual. Our best strategy is just to try and connect to the peers
# you knew about last time you ran the software. But what about when you run the software for the first time? That's
# where this allowlist comes in. It's a list of known Tari nodes that are likely to be around for a long time and that
# new nodes can use to introduce themselves to the network.
# peer_seeds = ["public_key1::address1", "public_key2::address2",... ]
peer_seeds = [
# weatherwax
"98bc76afc1c35ad4651bdc9ef57bbe0655a2ea3cd86c0e19b5fd5890546eb040::/onion3/33izgtjkrlxhxybj6luqowkpiy2wvte43osejnbqyieqtdfhovzghxad:18141", #jozi
"9a26e910288213d649b26f9a7a7ee51fe2b2a67ff7d42334523463bf4be94312::/onion3/56kq54ylttnbl5ikotqex3oqvtzlxdpn7zlx4v56rvzf4kq7eezlclid:18141", #london
"6afd5b3c7772ad7d4bb26e0c19668fe04f2d68f99de9e132bee50a6c1846946d::/onion3/may4ajbmcn4dlnzf6fanvqlklxzqiw6qwu6ywqwkjc3bb354rc2i5wid:18141", #ncal
"8e7beec9becdc44fe6015a00d97a77fa3dbafe65127dcc988df6326bd9fd040d::/onion3/3pise36l4imoopsbjic5rtw67adx7rms6w5pgjmccpdwiqx66j7oqcqd:18141", #nvir
"80bb590d943a46e63ae79af5dc2c7d35a3dcd7922c182b28f619dc4cfc366f44::/onion3/oaxwahri7r3h5qjlcdbveyjmg4jsttausik66bicmhixft73nmvecdad:18141", #oregon
"981cc8cd1e4fe2f99ea1bd3e0ab1e7821ca0bfab336a4967cfec053fee86254c::/onion3/7hxpnxrxycdfevirddau7ybofwedaamjrg2ijm57k2kevh5q46ixamid:18141", #seoul
"f2ce179fb733725961a5f7e1e45dacdd443dd43ba6237438d6abe344fb717058::/onion3/nvgdmjf4wucgatz7vemzvi2u4sw5o4gyzwuikagpepoj4w7mkii47zid:18141", #stockholm
"909c0160f4d8e815aba5c2bbccfcceb448877e7b38759fb160f3e9494484d515::/onion3/qw5uxv533sqdn2qoncfyqo35dgecy4rt4x27rexi2her6q6pcpxbm4qd:18141", #sydney
# igor
"8e7eb81e512f3d6347bf9b1ca9cd67d2c8e29f2836fc5bd608206505cc72af34::/onion3/l4wouomx42nezhzexjdzfh7pcou5l7df24ggmwgekuih7tkv2rsaokqd:18141",
"00b35047a341401bcd336b2a3d564280a72f6dc72ec4c739d30c502acce4e803::/onion3/ojhxd7z6ga7qrvjlr3px66u7eiwasmffnuklscbh5o7g6wrbysj45vid:18141",
"40a9d8573745072534bce7d0ecafe882b1c79570375a69841c08a98dee9ecb5f::/onion3/io37fylc2pupg4cte4siqlsmuszkeythgjsxs2i3prm6jyz2dtophaad:18141",
"126c7ee64f71aca36398b977dd31fbbe9f9dad615df96473fb655bef5709c540::/onion3/6ilmgndocop7ybgmcvivbdsetzr5ggj4hhsivievoa2dx2b43wqlrlid:18141",
]

# DNS seeds
# The DNS records in these hostnames should provide TXT records as per https://github.com/tari-project/tari/pull/2319
# Enter a domain name for the TXT records: seeds.tari.com
dns_seeds =["seeds.weatherwax.tari.com"]
# The name server used to resolve DNS seeds format: {socket address}/{tls sni dns name} (Default: cloudflare)
# dns_seeds_name_server = "1.1.1.1:853/cloudfare-dns.com"
# Servers addresses, majority of them have to agree.
# autoupdate_dns_hosts = [#server1, #server2, ...]
# Set to true to only accept DNS records that pass DNSSEC validation (Default: true)
dns_seeds_use_dnssec = false

# Tari is a 100% peer-to-peer network, so there are no servers to hold messages for you while you're offline.
# Instead, we rely on our peers to hold messages for us while we're offline. This settings sets maximum size of the
# message cache that for holding our peers' messages, in MB.
Expand Down Expand Up @@ -92,13 +58,60 @@ dedup_cache_capacity = 25000
# sessions.
rpc_max_simultaneous_sessions = 10000

[common.weatherwax]
# When first logging onto the Tari network, you need to find a few peers to bootstrap the process. In the absence of
# any servers, this is a little more challenging than usual. Our best strategy is just to try and connect to the peers
# you knew about last time you ran the software. But what about when you run the software for the first time? That's
# where this allowlist comes in. It's a list of known Tari nodes that are likely to be around for a long time and that
# new nodes can use to introduce themselves to the network.
# peer_seeds = ["public_key1::address1", "public_key2::address2",... ]
peer_seeds = [
# weatherwax
"98bc76afc1c35ad4651bdc9ef57bbe0655a2ea3cd86c0e19b5fd5890546eb040::/onion3/33izgtjkrlxhxybj6luqowkpiy2wvte43osejnbqyieqtdfhovzghxad:18141", #jozi
"9a26e910288213d649b26f9a7a7ee51fe2b2a67ff7d42334523463bf4be94312::/onion3/56kq54ylttnbl5ikotqex3oqvtzlxdpn7zlx4v56rvzf4kq7eezlclid:18141", #london
"6afd5b3c7772ad7d4bb26e0c19668fe04f2d68f99de9e132bee50a6c1846946d::/onion3/may4ajbmcn4dlnzf6fanvqlklxzqiw6qwu6ywqwkjc3bb354rc2i5wid:18141", #ncal
"8e7beec9becdc44fe6015a00d97a77fa3dbafe65127dcc988df6326bd9fd040d::/onion3/3pise36l4imoopsbjic5rtw67adx7rms6w5pgjmccpdwiqx66j7oqcqd:18141", #nvir
"80bb590d943a46e63ae79af5dc2c7d35a3dcd7922c182b28f619dc4cfc366f44::/onion3/oaxwahri7r3h5qjlcdbveyjmg4jsttausik66bicmhixft73nmvecdad:18141", #oregon
"981cc8cd1e4fe2f99ea1bd3e0ab1e7821ca0bfab336a4967cfec053fee86254c::/onion3/7hxpnxrxycdfevirddau7ybofwedaamjrg2ijm57k2kevh5q46ixamid:18141", #seoul
"f2ce179fb733725961a5f7e1e45dacdd443dd43ba6237438d6abe344fb717058::/onion3/nvgdmjf4wucgatz7vemzvi2u4sw5o4gyzwuikagpepoj4w7mkii47zid:18141", #stockholm
"909c0160f4d8e815aba5c2bbccfcceb448877e7b38759fb160f3e9494484d515::/onion3/qw5uxv533sqdn2qoncfyqo35dgecy4rt4x27rexi2her6q6pcpxbm4qd:18141", #sydney
]

# DNS seeds
# The DNS records in these hostnames should provide TXT records as per https://github.com/tari-project/tari/pull/2319
# Enter a domain name for the TXT records:
dns_seeds =["seeds.weatherwax.tari.com"]
# The name server used to resolve DNS seeds format: {socket address}/{tls sni dns name} (Default: cloudflare)
# dns_seeds_name_server = "1.1.1.1:853/cloudfare-dns.com"
# Servers addresses, majority of them have to agree.
# autoupdate_dns_hosts = [#server1, #server2, ...]
# Set to true to only accept DNS records that pass DNSSEC validation (Default: true)
dns_seeds_use_dnssec = false

# Auto Update
#
# This interval in seconds to check for software updates. Setting this to 0 disables checking.
# auto_update.check_interval = 300
# Customize the hosts that are used to check for updates. These hosts must contain update information in DNS TXT records.
# auto_update.dns_hosts = ["updates.taripulse.com"]
# "auto_update.dns_hosts" = ["updates.weatherwax.taripulse.com"]
# Customize the location of the update SHA hashes and maintainer-signed signature.
# auto_update.hashes_url = "https://<address>/hashes.txt"
# auto_update.hashes_sig_url = "https://<address>/hashes.txt.sig"
# "auto_update.hashes_url" = "https://<address>/hashes.txt"
# "auto_update.hashes_sig_url" = "https://<address>/hashes.txt.sig"

[common.igor]
peer_seeds = [
# igor
"8e7eb81e512f3d6347bf9b1ca9cd67d2c8e29f2836fc5bd608206505cc72af34::/onion3/l4wouomx42nezhzexjdzfh7pcou5l7df24ggmwgekuih7tkv2rsaokqd:18141",
"00b35047a341401bcd336b2a3d564280a72f6dc72ec4c739d30c502acce4e803::/onion3/ojhxd7z6ga7qrvjlr3px66u7eiwasmffnuklscbh5o7g6wrbysj45vid:18141",
"40a9d8573745072534bce7d0ecafe882b1c79570375a69841c08a98dee9ecb5f::/onion3/io37fylc2pupg4cte4siqlsmuszkeythgjsxs2i3prm6jyz2dtophaad:18141",
"126c7ee64f71aca36398b977dd31fbbe9f9dad615df96473fb655bef5709c540::/onion3/6ilmgndocop7ybgmcvivbdsetzr5ggj4hhsivievoa2dx2b43wqlrlid:18141",
]

dns_seeds =["seeds.igor.tari.com"]
# dns_seeds_name_server = "1.1.1.1:853/cloudfare-dns.com"
dns_seeds_use_dnssec = false

# auto_update.check_interval = 300
# "auto_update.dns_hosts" = ["updates.igor.taripulse.com"]
# "auto_update.hashes_url" = "https://<address>/hashes.txt"
# "auto_update.hashes_sig_url" = "https://<address>/hashes.txt.sig"
1 change: 0 additions & 1 deletion common/config/presets/merge_mining_proxy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ monerod_password = ""
# or not. If merge mining starts before the base node has achieved initial sync, those Tari mined blocks will not be
# accepted. (Default value = true; will wait for base node initial sync).
#wait_for_initial_sync_at_startup = true

80 changes: 45 additions & 35 deletions common/src/configuration/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,27 +145,37 @@ pub struct GlobalConfig {
}

impl GlobalConfig {
pub fn convert_from(application: ApplicationType, mut cfg: Config) -> Result<Self, ConfigurationError> {
pub fn convert_from(
application: ApplicationType,
mut cfg: Config,
network: Option<String>,
) -> Result<Self, ConfigurationError> {
// Add in settings from the environment (with a prefix of TARI_NODE)
// Eg.. `TARI_NODE_DEBUG=1 ./target/app` would set the `debug` key
let env = Environment::with_prefix("tari").separator("__");
cfg.merge(env)
.map_err(|e| ConfigurationError::new("environment variable", &e.to_string()))?;
let network = one_of::<Network>(&cfg, &[
&format!("{}.network", application.as_config_str()),
"common.network",
// TODO: Remove this once some time has passed and folks have upgraded their configs
"base_node.network",
])?;

convert_node_config(application, network, cfg)

// network override from command line
let network = match network {
Some(s) => Network::from_str(&s)?,
None => {
// otherwise specified from config
one_of::<Network>(&cfg, &[
"common.network",
&format!("{}.network", application.as_config_str()),
])?
},
};

convert_node_config(application, cfg, network)
}
}

fn convert_node_config(
application: ApplicationType,
network: Network,
cfg: Config,
network: Network,
) -> Result<GlobalConfig, ConfigurationError> {
let net_str = network.as_str();

Expand Down Expand Up @@ -353,38 +363,35 @@ fn convert_node_config(
.map(|addr| socket_or_multi(&addr).map_err(|e| ConfigurationError::new(key, &e.to_string())))??;

// Peer and DNS seeds
let key = "common.peer_seeds";
let key = config_string("common", net_str, "peer_seeds");
// Peer seeds can be an array or a comma separated list (e.g. in an ENVVAR)
let peer_seeds = match cfg.get_array(key) {
let peer_seeds = match cfg.get_array(&key) {
Ok(seeds) => seeds.into_iter().map(|v| v.into_str().unwrap()).collect(),
Err(..) => optional(cfg.get_str(key))?
Err(..) => optional(cfg.get_str(&key))?
.map(|s| s.split(',').map(|v| v.trim().to_string()).collect())
.unwrap_or_default(),
};

// TODO: dns resolver presets e.g. "cloudflare", "quad9", "custom" (maybe just in toml) and
// add support for multiple addresses
let key = "common.dns_seeds_name_server";
let key = config_string("common", net_str, "dns_seeds_name_server");
let dns_seeds_name_server = cfg
.get_str(key)
.map_err(|e| ConfigurationError::new(key, &e.to_string()))
.get_str(&key)
.map_err(|e| ConfigurationError::new(&key, &e.to_string()))
.and_then(|s| {
s.parse::<DnsNameServer>()
.map_err(|e| ConfigurationError::new(key, &e.to_string()))
.map_err(|e| ConfigurationError::new(&key, &e.to_string()))
})?;

let key = config_string("base_node", net_str, "bypass_range_proof_verification");
let base_node_bypass_range_proof_verification = cfg.get_bool(&key).unwrap_or(false);

let key = "common.dns_seeds_use_dnssec";
let key = config_string("common", net_str, "dns_seeds_use_dnssec");
let dns_seeds_use_dnssec = cfg
.get_bool(key)
.map_err(|e| ConfigurationError::new(key, &e.to_string()))?;
.get_bool(&key)
.map_err(|e| ConfigurationError::new(&key, &e.to_string()))?;

let key = "common.dns_seeds";
let dns_seeds = match cfg.get_array(key) {
let key = config_string("common", net_str, "dns_seeds");
let dns_seeds = match cfg.get_array(&key) {
Ok(seeds) => seeds.into_iter().map(|v| v.into_str().unwrap()).collect(),
Err(..) => optional(cfg.get_str(key))?
Err(..) => optional(cfg.get_str(&key))?
.map(|s| {
s.split(',')
.map(|v| v.trim().to_string())
Expand All @@ -394,6 +401,9 @@ fn convert_node_config(
.unwrap_or_default(),
};

let key = config_string("base_node", net_str, "bypass_range_proof_verification");
let base_node_bypass_range_proof_verification = cfg.get_bool(&key).unwrap_or(false);

// Peer DB path
let peer_db_path = data_dir.join("peer_db");
let wallet_peer_db_path = data_dir.join("wallet_peer_db");
Expand Down Expand Up @@ -668,29 +678,29 @@ fn convert_node_config(
let validate_tip_timeout_sec = optional(cfg.get_int(key))?.unwrap_or(0) as u64;

// Auto update
let key = "common.auto_update.check_interval";
let autoupdate_check_interval = optional(cfg.get_int(key))?.and_then(|secs| {
let key = config_string("common", net_str, "auto_update.check_interval");
let autoupdate_check_interval = optional(cfg.get_int(&key))?.and_then(|secs| {
if secs > 0 {
Some(Duration::from_secs(secs as u64))
} else {
None
}
});

let key = "common.auto_update.dns_hosts";
let key = config_string("common", net_str, "auto_update.dns_hosts");
let autoupdate_dns_hosts = cfg
.get_array(key)
.get_array(&key)
.and_then(|arr| arr.into_iter().map(|s| s.into_str()).collect::<Result<Vec<_>, _>>())
.or_else(|_| {
cfg.get_str(key)
cfg.get_str(&key)
.map(|s| s.split(',').map(ToString::to_string).collect())
})?;

let key = "common.auto_update.hashes_url";
let autoupdate_hashes_url = cfg.get_str(key)?;
let key = config_string("common", net_str, "auto_update.hashes_url");
let autoupdate_hashes_url = cfg.get_str(&key)?;

let key = "common.auto_update.hashes_sig_url";
let autoupdate_hashes_sig_url = cfg.get_str(key)?;
let key = config_string("common", net_str, "auto_update.hashes_sig_url");
let autoupdate_hashes_sig_url = cfg.get_str(&key)?;

let key = "mining_node.mining_pool_address";
let mining_pool_address = cfg.get_str(key).unwrap_or_else(|_| "".to_string());
Expand Down
Loading