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

Remove fields deprecated in AvalancheGo v1.11.11 #207

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion crates/avalanche-types/src/avalanchego/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::{
io::{self, Error, ErrorKind, Write},
path::Path,
time::SystemTime,
u64,
};

use crate::{constants, coreth::genesis as coreth_genesis, key};
Expand Down
12 changes: 2 additions & 10 deletions crates/avalanche-types/src/codec/serde/ip_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ where
return Err(serde::de::Error::custom("no host found"));
};
let ip: IpAddr = host.parse().map_err(serde::de::Error::custom)?;
let port = if let Some(port) = url.port() {
port
} else {
0 // e.g., DNS
};
let port = url.port().unwrap_or(0);
Ok(SocketAddr::new(ip, port))
}
}
Expand Down Expand Up @@ -72,11 +68,7 @@ impl<'de> DeserializeAs<'de, SocketAddr> for IpPort {
return Err(serde::de::Error::custom("no host found"));
};
let ip: IpAddr = host.parse().map_err(serde::de::Error::custom)?;
let port = if let Some(port) = url.port() {
port
} else {
0 // e.g., DNS
};
let port = url.port().unwrap_or(0);
Ok(SocketAddr::new(ip, port))
}
}
Expand Down
15 changes: 0 additions & 15 deletions crates/avalanche-types/src/jsonrpc/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,6 @@ pub struct Peer {
pub last_received: DateTime<Utc>,
#[serde_as(as = "DisplayFromStr")]
pub observed_uptime: u32,
#[serde_as(as = "HashMap<_, DisplayFromStr>")]
pub observed_subnet_uptimes: HashMap<ids::Id, u32>,
pub tracked_subnets: Vec<ids::Id>,
}

Expand All @@ -660,7 +658,6 @@ impl Default for Peer {
last_sent: DateTime::<Utc>::MIN_UTC,
last_received: DateTime::<Utc>::MIN_UTC,
observed_uptime: 0,
observed_subnet_uptimes: HashMap::new(),
tracked_subnets: Vec::new(),
}
}
Expand Down Expand Up @@ -691,7 +688,6 @@ fn test_peers() {
\"lastReceived\": \"2020-06-01T15:22:57Z\",
\"benched\": [],
\"observedUptime\": \"99\",
\"observedSubnetUptimes\": {},
\"trackedSubnets\": [],
\"benched\": []
},
Expand All @@ -704,9 +700,6 @@ fn test_peers() {
\"lastReceived\": \"2020-06-01T15:22:34Z\",
\"benched\": [],
\"observedUptime\": \"75\",
\"observedSubnetUptimes\": {
\"29uVeLPJB1eQJkzRemU8g8wZDw5uJRqpab5U2mX9euieVwiEbL\": \"100\"
},
\"trackedSubnets\": [
\"29uVeLPJB1eQJkzRemU8g8wZDw5uJRqpab5U2mX9euieVwiEbL\"
],
Expand All @@ -721,13 +714,6 @@ fn test_peers() {
)
.unwrap();

let uptimes: HashMap<ids::Id, u32> = [(
ids::Id::from_str("29uVeLPJB1eQJkzRemU8g8wZDw5uJRqpab5U2mX9euieVwiEbL").unwrap(),
100,
)]
.iter()
.cloned()
.collect();
let expected = PeersResponse {
jsonrpc: "2.0".to_string(),
id: 1,
Expand Down Expand Up @@ -770,7 +756,6 @@ fn test_peers() {
.naive_utc(),
),
observed_uptime: 75,
observed_subnet_uptimes: uptimes,
tracked_subnets: vec![ids::Id::from_str(
"29uVeLPJB1eQJkzRemU8g8wZDw5uJRqpab5U2mX9euieVwiEbL",
)
Expand Down
10 changes: 5 additions & 5 deletions crates/avalanche-types/src/jsonrpc/platformvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ pub struct ApiPrimaryValidator {
#[serde_as(as = "Option<DisplayFromStr>")]
#[serde(skip_serializing_if = "Option::is_none")]
pub uptime: Option<f32>,
pub connected: bool,
pub connected: Option<bool>,

/// None for permissioned Subnet validator
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -765,7 +765,7 @@ impl Default for ApiPrimaryValidator {
potential_reward: None,
delegation_fee: None,
uptime: None,
connected: false,
connected: None,
signer: None,
delegator_count: None,
delegator_weight: None,
Expand Down Expand Up @@ -935,7 +935,7 @@ fn test_get_current_validators() {
potential_reward: Some(79984390135364555),
delegation_fee: Some(6.25),
uptime: Some(100.0),
connected: true,
connected: Some(true),
delegator_count: Some(0),
delegator_weight: Some(0),
..ApiPrimaryValidator::default()
Expand Down Expand Up @@ -966,7 +966,7 @@ fn test_get_current_validators() {
potential_reward: Some(77148186230865960),
delegation_fee: Some(6.25),
uptime: Some(100.0),
connected: true,
connected: Some(true),
delegator_count: Some(0),
delegator_weight: Some(0),
..ApiPrimaryValidator::default()
Expand Down Expand Up @@ -1029,7 +1029,7 @@ fn test_get_pending_validators() {
stake_amount: Some(200000000000),
node_id: node::Id::from_str("NodeID-5mb46qkSBj81k9g9e4VFjGGSbaaSLFRzD").unwrap(),
delegation_fee: Some(10.0),
connected: false,
connected: Some(false),
..ApiPrimaryValidator::default()
}]),
delegators: <Vec<ApiPrimaryDelegator>>::from([ApiPrimaryDelegator {
Expand Down
2 changes: 1 addition & 1 deletion crates/avalanche-types/src/key/secp256k1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ fn test_keys_address() {
log::info!("checking the key info at {}", pos);

let sk = crate::key::secp256k1::private_key::Key::from_cb58(
&ki.private_key_cb58.clone().unwrap(),
ki.private_key_cb58.clone().unwrap(),
)
.unwrap();
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion crates/avalanche-types/src/key/secp256k1/private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ pub fn load_cb58_keys(d: &[u8], permute_keys: bool) -> Result<Vec<Key>> {
let mut added = HashMap::new();
loop {
if let Some(s) = lines.next() {
if added.get(s).is_some() {
if added.contains_key(s) {
return Err(Error::Other {
message: format!("key at line {} already added before", line_cnt),
retryable: false,
Expand Down
2 changes: 1 addition & 1 deletion crates/avalanche-types/src/packer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Low-level byte-packing utilities.
pub mod ip;

use std::{cell::Cell, u16};
use std::cell::Cell;

use crate::errors::{Error, Result};
use bytes::{Buf, BufMut, Bytes, BytesMut};
Expand Down
1 change: 1 addition & 0 deletions crates/avalanche-types/src/subnet/rpc/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub trait KeyValueReaderWriterDeleter {
// Trait that specifies that something may be
// committed.
#[tonic::async_trait]
#[allow(dead_code)]
trait Commitable {
/// Writes all the operations of this database to the underlying database.
async fn commit(&mut self) -> Result<()>;
Expand Down
17 changes: 7 additions & 10 deletions tests/avalanche-e2e/src/x/simple_transfers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,26 +321,23 @@ async fn make_single_transfer(
}
};
let matched = prometheus_manager::find_all(&s.metrics, |s| {
s.metric
.contains("avalanche_X_vm_avalanche_base_txs_accepted")
s.metric.contains("avalanche_avm_txs_accepted")
&& s.labels.as_ref().unwrap().get("chain") == Some("X")
&& s.labels.as_ref().unwrap().get("tx") == Some("base")
});
log::info!("matched {:?}", matched);
let mut cur: HashMap<String, f64> = HashMap::new();
for m in matched {
cur.insert(m.metric.clone(), m.value.to_f64());
}

if *cur
.get("avalanche_X_vm_avalanche_base_txs_accepted")
.unwrap()
== 0_f64
{
if *cur.get("avalanche_avm_txs_accepted").unwrap() == 0_f64 {
return Err(Error::new(
ErrorKind::InvalidData,
format!(
"{} unexpected 'avalanche_X_vm_avalanche_base_txs_accepted' {}, expected >0",
"{} unexpected 'avalanche_avm_txs_accepted{{chain=\"X\",tx=\"base\"}}' {}, expected >0",
ep.as_str(),
*cur.get("avalanche_X_vm_avalanche_base_txs_accepted")
.unwrap(),
*cur.get("avalanche_avm_txs_accepted").unwrap(),
),
));
}
Expand Down
Loading