Skip to content
This repository was archived by the owner on Sep 1, 2023. It is now read-only.

Commit 8e84a2a

Browse files
committed
*: Bump to v0.0.400
Signed-off-by: Dan Sover <[email protected]>
1 parent dfa8bf2 commit 8e84a2a

File tree

14 files changed

+259
-335
lines changed

14 files changed

+259
-335
lines changed

Cargo.toml

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "avalanche-types"
3-
version = "0.0.397" # https://crates.io/crates/avalanche-types
3+
version = "0.0.400" # https://crates.io/crates/avalanche-types
44
edition = "2021"
5-
rust-version = "1.69" # use "rustup override set stable" to overwrite current toolchain
5+
rust-version = "1.70" # use "rustup override set stable" to overwrite current toolchain
66
publish = true
77
description = "Avalanche primitive types in Rust"
88
license = "BSD-3-Clause"
@@ -20,9 +20,10 @@ cert-manager = "0.0.10" # https://github.com/gyuho/cert-manager
2020
chrono = "0.4.24"
2121
cmp-manager = "0.0.1"
2222
ecdsa = { version = "0.16.7", features = ["rfc6979", "verifying"] } # https://github.com/RustCrypto/elliptic-curves/tree/master/k256
23-
ethers-core = { version = "=2.0.6", features = ["eip712"] } # https://github.com/gakonst/ethers-rs/releases
23+
ethers-core = { version = "=2.0.7", features = ["eip712"] } # https://github.com/gakonst/ethers-rs/releases
2424
hex = "0.4.3"
2525
hmac = "0.12.1"
26+
hyper = { version = "0.14.26"}
2627
k256 = { version = "0.13.1", features = ["ecdsa"] } # https://github.com/RustCrypto/elliptic-curves/tree/master/k256
2728
lazy_static = "1.4.0"
2829
log = "0.4.17"
@@ -31,14 +32,15 @@ primitive-types = { version = "0.12.1", features = ["impl-serde"] } # https://cr
3132
rand = "0.8.5"
3233
ring = "0.16.20"
3334
ripemd = "0.1.3"
34-
rust-embed = "6.6.1" # https://github.com/pyrossh/rust-embed
35-
serde = { version = "1.0.163", features = ["derive"] } # https://github.com/serde-rs/serde/releases
35+
rust-embed = "6.8.1" # https://github.com/pyrossh/rust-embed
36+
serde = { version = "1.0.166", features = ["derive"] } # https://github.com/serde-rs/serde/releases
3637
serde_json = "1.0.96" # https://github.com/serde-rs/json/releases
3738
serde_with = { version = "3.0.0", features = ["hex"] }
3839
serde_yaml = "0.9.21" # https://github.com/dtolnay/serde-yaml/releases
3940
sha2 = "0.10.6"
4041
sha3 = "0.10.8" # https://github.com/RustCrypto/hashes
4142
spki = "0.7.2" # https://github.com/RustCrypto/formats/tree/master/spki
43+
strum = "0.24.1"
4244
thiserror = "1.0.40"
4345
url = "2.3.1" # for "codec::serde::ip_port", "utils"
4446
zerocopy = "0.6.1"
@@ -48,7 +50,7 @@ zeroize = "1.6.0" # for "BLS
4850
secp256k1 = { version = "0.27.0", features = ["global-context", "rand-std", "recovery"], optional = true } # https://crates.io/crates/secp256k1
4951

5052
# [OPTIONAL] for "kms_aws"
51-
aws-manager = { version = "0.28.26", features = ["kms"], optional = true } # https://github.com/gyuho/aws-manager/tags
53+
aws-manager = { version = "0.28.67", features = ["kms"], optional = true } # https://github.com/gyuho/aws-manager/tags
5254
aws-sdk-kms = { version = "0.28.0", optional = true } # https://crates.io/crates/aws-sdk-kms/versions
5355

5456
# [OPTIONAL] for "message"
@@ -60,20 +62,19 @@ rand_core = { version = "0.6.4", features = ["std"], optional = true }
6062

6163
# [OPTIONAL] for "evm", "jsonrpc_client"
6264
reqwest = { version = "0.11.18", optional = true } # https://github.com/seanmonstar/reqwest/releases
63-
tokio = { version = "1.28.1", features = ["full"], optional = true } # https://github.com/tokio-rs/tokio/releases
65+
tokio = { version = "1.29.1", features = ["full"], optional = true } # https://github.com/tokio-rs/tokio/releases
6466

6567
# [OPTIONAL] for "evm"
6668
rlp = { version = "0.5.2", default-features = false, features = ["std"], optional = true }
6769

6870
# [OPTIONAL] for "wallet_evm"
69-
ethers = { version = "=2.0.6", features = ["eip712"], optional = true } # https://github.com/gakonst/ethers-rs/releases
70-
ethers-providers = { version = "=2.0.6", optional = true } # https://github.com/gakonst/ethers-rs/releases
71-
ethers-signers = { version = "=2.0.6", optional = true } # https://github.com/gakonst/ethers-rs/releases
71+
ethers = { version = "=2.0.7", features = ["eip712"], optional = true } # https://github.com/gakonst/ethers-rs/releases
72+
ethers-providers = { version = "=2.0.7", optional = true } # https://github.com/gakonst/ethers-rs/releases
73+
ethers-signers = { version = "=2.0.7", optional = true } # https://github.com/gakonst/ethers-rs/releases
7274

7375
# [OPTIONAL] for "subnet"
7476
futures = { version = "0.3.28", optional = true }
7577
http = { version = "0.2.9", optional = true }
76-
hyper = { version = "0.14.26", optional = true }
7778
jsonrpc-core = { version = "18.0.0", optional = true }
7879
jsonrpc-http-server = { version = "18.0.0", optional = true }
7980
num-derive = { version = "0.3.3", optional = true }
@@ -94,8 +95,8 @@ base64 = { version = "0.21.2", optional = true } # https://github.com/marshallpi
9495
num-bigint = { version = "0.4.3", optional = true }
9596

9697
[build-dependencies]
97-
protoc-gen-prost = "0.2.2"
98-
protoc-gen-tonic = "0.2.2"
98+
protoc-gen-prost = "0.2.3"
99+
protoc-gen-tonic = "0.3.0"
99100

100101
[dev-dependencies]
101102
env_logger = "0.10.0"
@@ -154,7 +155,6 @@ message = [
154155
subnet = [
155156
"futures",
156157
"http",
157-
"hyper",
158158
"jsonrpc-core",
159159
"num-derive",
160160
"num-traits",

src/avalanchego/aliases.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//! Chain alias functionality for the avalanchego node.
2+
use std::collections::HashMap;
3+
4+
/// A map from blockchainIDs to custom aliases
5+
/// ref. <https://docs.avax.network/nodes/maintain/avalanchego-config-flags#--chain-aliases-file-string>.
6+
pub type Aliases = HashMap<String, Vec<String>>;
7+
8+
#[test]
9+
fn test_aliases_json() {
10+
let json = r#"{"q2aTwKuyzgs8pynF7UXBZCU7DejbZbZ6EUyHr3JQzYgwNPUPi": ["DFK"]}"#;
11+
let aliases: Aliases = serde_json::from_str(json).unwrap();
12+
assert_eq!(
13+
aliases
14+
.get("q2aTwKuyzgs8pynF7UXBZCU7DejbZbZ6EUyHr3JQzYgwNPUPi")
15+
.unwrap(),
16+
&vec!["DFK".to_string()]
17+
)
18+
}

src/avalanchego/config.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub struct Config {
8484
pub public_ip: Option<String>,
8585

8686
#[serde(skip_serializing_if = "Option::is_none")]
87-
pub staking_enabled: Option<bool>,
87+
pub sybil_protection_enabled: Option<bool>,
8888
/// Staking port.
8989
#[serde(default)]
9090
pub staking_port: u32,
@@ -208,7 +208,7 @@ pub struct Config {
208208
pub snow_mixed_query_num_push_vdr: Option<u64>,
209209

210210
#[serde(skip_serializing_if = "Option::is_none")]
211-
pub consensus_gossip_frequency: Option<i64>,
211+
pub consensus_accepted_frontier_gossip_frequency: Option<i64>,
212212
/// ref. <https://github.com/ava-labs/avalanchego/pull/1322>
213213
#[serde(skip_serializing_if = "Option::is_none")]
214214
pub consensus_app_concurrency: Option<i64>,
@@ -247,6 +247,9 @@ pub const DEFAULT_CONFIG_FILE_PATH: &str = "/data/avalanche-configs/config.json"
247247
/// Default "genesis" path on the remote linux machines.
248248
/// MUST BE a valid path in remote host machine.
249249
pub const DEFAULT_GENESIS_PATH: &str = "/data/avalanche-configs/genesis.json";
250+
/// Default "chain aliases" path on the remote linux machine.
251+
/// MUST BE a valid path in remote host machine.
252+
pub const DEFAULT_CHAIN_ALIASES_PATH: &str = "/data/avalanche-configs/chains/aliases.json";
250253

251254
pub const DEFAULT_DB_TYPE: &str = "leveldb";
252255
/// Default "db-dir" directory path for remote linux machines.
@@ -277,7 +280,7 @@ pub const DEFAULT_HTTP_PORT: u32 = 9650;
277280
pub const DEFAULT_HTTP_HOST: &str = "0.0.0.0";
278281
pub const DEFAULT_HTTP_TLS_ENABLED: bool = false;
279282

280-
pub const DEFAULT_STAKING_ENABLED: bool = true;
283+
pub const DEFAULT_SYBIL_PROTECTION_ENABLED: bool = true;
281284
/// Default staking port.
282285
/// NOTE: keep default value in sync with "avalanchego/config/flags.go".
283286
pub const DEFAULT_STAKING_PORT: u32 = 9651;
@@ -374,7 +377,7 @@ impl Config {
374377
http_tls_cert_file: None,
375378
public_ip: None,
376379

377-
staking_enabled: Some(DEFAULT_STAKING_ENABLED),
380+
sybil_protection_enabled: Some(DEFAULT_SYBIL_PROTECTION_ENABLED),
378381
staking_port: DEFAULT_STAKING_PORT,
379382
staking_tls_key_file: Some(String::from(DEFAULT_STAKING_TLS_KEY_FILE)),
380383
staking_tls_cert_file: Some(String::from(DEFAULT_STAKING_TLS_CERT_FILE)),
@@ -436,7 +439,7 @@ impl Config {
436439

437440
snow_mixed_query_num_push_vdr: Some(10),
438441

439-
consensus_gossip_frequency: Some(10000000000), // 10-second
442+
consensus_accepted_frontier_gossip_frequency: Some(10000000000), // 10-second
440443
consensus_app_concurrency: Some(2),
441444

442445
consensus_on_accept_gossip_validator_size: Some(0),
@@ -632,10 +635,10 @@ impl Config {
632635
}
633636

634637
// staking
635-
if self.staking_enabled.is_some() && !self.staking_enabled.unwrap() {
638+
if self.sybil_protection_enabled.is_some() && !self.sybil_protection_enabled.unwrap() {
636639
return Err(Error::new(
637640
ErrorKind::InvalidInput,
638-
"'staking-enabled' must be true",
641+
"'sybil_protection_enabled' must be true",
639642
));
640643
}
641644
if self.staking_tls_cert_file.is_none() {

src/avalanchego/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
pub mod aliases;
12
pub mod config;
23
pub mod genesis;

src/jsonrpc/client/admin.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use reqwest::{header::CONTENT_TYPE, ClientBuilder};
55
use crate::{
66
errors::{Error, Result},
77
jsonrpc::admin::{ChainAliasParams, ChainAliasRequest, ChainAliasResponse},
8+
jsonrpc::client::url,
89
utils,
910
};
1011

@@ -22,11 +23,7 @@ pub async fn alias_chain(
2223
}
2324
})?;
2425

25-
let url = match (scheme, port) {
26-
(Some(scheme), Some(port)) => format!("{scheme}://{host}:{port}/ext/admin"),
27-
(Some(scheme), _) => format!("{scheme}://{host}/ext/admin"),
28-
_ => format!("http://{host}/ext/admin"),
29-
};
26+
let url = url::try_create_url(url::Path::Admin, scheme.as_deref(), host.as_str(), port)?;
3027
log::info!("getting network name for {url}");
3128

3229
let data = ChainAliasRequest {
@@ -54,7 +51,7 @@ pub async fn alias_chain(
5451
})?;
5552

5653
let resp = req_cli_builder
57-
.post(&url)
54+
.post(url.to_string())
5855
.header(CONTENT_TYPE, "application/json")
5956
.body(d)
6057
.send()

src/jsonrpc/client/health.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,27 @@ use std::{sync::Arc, time::Duration};
22

33
use crate::{
44
errors::{Error, Result},
5+
jsonrpc::client::url,
56
jsonrpc::health,
7+
utils::urls::extract_scheme_host_port_path_chain_alias,
68
};
79
use reqwest::ClientBuilder;
810

911
/// "If a single piece of data must be accessible from more than one task
1012
/// concurrently, then it must be shared using synchronization primitives such as Arc."
1113
/// ref. <https://tokio.rs/tokio/tutorial/spawning>
1214
pub async fn check(http_rpc: Arc<String>, liveness: bool) -> Result<health::Response> {
13-
let url_path = {
14-
if liveness {
15-
"ext/health/liveness"
16-
} else {
17-
"ext/health"
18-
}
19-
};
15+
let (scheme, host, port, _, _) =
16+
extract_scheme_host_port_path_chain_alias(&http_rpc).map_err(|e| Error::Other {
17+
message: format!("failed extract_scheme_host_port_path_chain_alias '{}'", e),
18+
retryable: false,
19+
})?;
20+
21+
let mut url = url::try_create_url(url::Path::Health, scheme.as_deref(), host.as_str(), port)?;
22+
if liveness {
23+
url = url::try_create_url(url::Path::Liveness, scheme.as_deref(), host.as_str(), port)?;
24+
}
25+
log::info!("getting network name for {url}");
2026

2127
let req_cli_builder = ClientBuilder::new()
2228
.user_agent(env!("CARGO_PKG_NAME"))
@@ -32,7 +38,7 @@ pub async fn check(http_rpc: Arc<String>, liveness: bool) -> Result<health::Resp
3238
}
3339
})?;
3440
let resp = req_cli_builder
35-
.get(format!("{}/{}", http_rpc, url_path).as_str())
41+
.get(url.to_string())
3642
.send()
3743
.await
3844
.map_err(|e|

0 commit comments

Comments
 (0)