Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
DSharifi committed Jan 17, 2025
1 parent 0c8a8dd commit d22137d
Show file tree
Hide file tree
Showing 29 changed files with 61 additions and 52 deletions.
2 changes: 1 addition & 1 deletion rs/bitcoin/adapter/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ rust_binary(
rust_test(
name = "adapter_test",
crate = ":adapter",
data = [
compile_data = [
"test_data/first_2500_mainnet_headers.json",
"test_data/first_2500_testnet_headers.json",
],
Expand Down
2 changes: 1 addition & 1 deletion rs/bitcoin/adapter/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![warn(missing_docs)]
#![cfg_attr(not(test), warn(missing_docs))]

//! The Bitcoin adapter interacts with the Bitcoin P2P network to obtain blocks
//! and publish transactions. Moreover, it interacts with the Bitcoin system
Expand Down
4 changes: 2 additions & 2 deletions rs/boundary_node/canary_proxy/src/support/auto_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ enum Version {
H1,
H2,
}
async fn read_version<'a, A>(mut reader: A) -> IoResult<(Version, Rewind<A>)>
async fn read_version<A>(mut reader: A) -> IoResult<(Version, Rewind<A>)>
where
A: AsyncRead + Unpin,
{
Expand Down Expand Up @@ -171,7 +171,7 @@ where
if this.buf.filled() == H2_PREFACE {
*this.version = Version::H2;
}
return Poll::Ready(Ok((*this.version, this.buf.filled().to_vec())));
Poll::Ready(Ok((*this.version, this.buf.filled().to_vec())))
}
}

Expand Down
2 changes: 1 addition & 1 deletion rs/boundary_node/rate_limits/api/src/schema_versions/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub enum RequestType {

/// Implement serde parser for Action
struct ActionVisitor;
impl<'de> de::Visitor<'de> for ActionVisitor {
impl de::Visitor<'_> for ActionVisitor {
type Value = Action;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
1 change: 0 additions & 1 deletion rs/canonical_state/src/encoding/tests/compatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ fn canonical_encoding_stream_header_v19_plus() {
/// 00 # unsigned(0)
/// 03 # field_index(SubnetMetrics::update_transactions_total)
/// 19 1068 # unsigned(4200)
/// ```
/// Used http://cbor.me/ for printing the human friendly output.
#[test]
Expand Down
1 change: 0 additions & 1 deletion rs/config/src/config_sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
/// # EXAMPLE: y: "bad"
/// y: "good"
/// ```
pub const SAMPLE_CONFIG: &str = r#"
{
// ============================================
Expand Down
2 changes: 1 addition & 1 deletion rs/consensus/utils/src/pool_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<'a> PoolReader<'a> {
/// Get the range of ancestor blocks of `block` specified (inclusively) by
/// `min` and `max`. This assumes the correctness of the state of the pool.
pub fn get_range(
&'a self,
&self,
block: Block,
min: Height,
max: Height,
Expand Down
2 changes: 1 addition & 1 deletion rs/crypto/internal/crypto_lib/bls12_381/type/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ macro_rules! define_affine_and_projective_types {
const WINDOW_MASK: u8 = (1 << Self::WINDOW_BITS) - 1;

// The total number of windows in a scalar
const WINDOWS : usize = Self::SUBGROUP_BITS.div_ceil(define_affine_and_projective_types!(G1Affine, G1Projective, 48));
const WINDOWS: usize = Self::SUBGROUP_BITS.div_ceil(Self::WINDOW_BITS);

// We must select from 2^WINDOW_BITS elements in each table
// group. However one element of the table group is always the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn encrypted_chunks_should_validate(epoch: Epoch) {
/// Context: Most of this code converts the data used for the fs
/// encryption to the form needed by the zk crypto. Suggestion:
/// Put the conversion code in the library.
///
/// Combine a big endian array of group elements (first chunk is the
/// most significant) into a single group element.
fn g1_from_big_endian_chunks(terms: &[G1Affine]) -> G1Affine {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ macro_rules! declare_mul2_table_impl {

// The number of windows (of WINDOW_BITS size) required to examine every
// bit of a scalar of this curve.
const WINDOWS: usize = (<$scalar>::BITS + Self::WINDOW_BITS - 1) / Self::WINDOW_BITS;
const WINDOWS: usize = <$scalar>::BITS.div_ceil(Self::WINDOW_BITS);

pub fn for_standard_generators() -> Self {
let g = <$projective>::generator();
Expand Down
10 changes: 5 additions & 5 deletions rs/crypto/internal/crypto_service_provider/src/vault/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,31 +187,31 @@ impl NodeKeysErrors {
}

pub fn keys_in_registry_missing_locally(&self) -> bool {
self.node_signing_key_error.as_ref().map_or(false, |err| {
self.node_signing_key_error.as_ref().is_some_and(|err| {
err.external_public_key_error.is_none()
&& err.contains_local_public_or_secret_key_error()
}) || self
.committee_signing_key_error
.as_ref()
.map_or(false, |err| {
.is_some_and(|err| {
err.external_public_key_error.is_none()
&& err.contains_local_public_or_secret_key_error()
})
|| self.tls_certificate_error.as_ref().map_or(false, |err| {
|| self.tls_certificate_error.as_ref().is_some_and(|err| {
err.external_public_key_error.is_none()
&& err.contains_local_public_or_secret_key_error()
})
|| self
.dkg_dealing_encryption_key_error
.as_ref()
.map_or(false, |err| {
.is_some_and(|err| {
err.external_public_key_error.is_none()
&& err.contains_local_public_or_secret_key_error()
})
|| self
.idkg_dealing_encryption_key_error
.as_ref()
.map_or(false, |err| {
.is_some_and(|err| {
err.external_public_key_error.is_none()
&& err.contains_local_public_or_secret_key_error()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ use std::sync::Arc;
/// only during node key generation and rotation).
///
/// [1]: https://medium.com/digitalfrontiers/rust-dynamic-dispatching-deep-dive-236a5896e49b
pub struct LocalCspVault<
R: Rng + CryptoRng,
S: SecretKeyStore,
Expand Down
14 changes: 7 additions & 7 deletions rs/crypto/test_utils/canister_threshold_sigs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -821,15 +821,15 @@ pub mod node {
pub fn filter_by_receivers<'a, T: AsRef<IDkgReceivers> + 'a>(
&'a self,
idkg_receivers: T,
) -> impl Iterator<Item = &Node> + 'a {
) -> impl Iterator<Item = &'a Node> + 'a {
self.iter()
.filter(move |node| idkg_receivers.as_ref().contains(node.id))
}

pub fn filter_by_dealers<'a, T: AsRef<IDkgDealers> + 'a>(
&'a self,
idkg_dealers: T,
) -> impl Iterator<Item = &Node> + 'a {
) -> impl Iterator<Item = &'a Node> + 'a {
self.iter()
.filter(move |node| idkg_dealers.as_ref().contains(node.id))
}
Expand All @@ -838,7 +838,7 @@ pub mod node {
&'a self,
minimum_size: usize,
rng: &'a mut R,
) -> impl Iterator<Item = &Node> + 'a {
) -> impl Iterator<Item = &'a Node> + 'a {
assert!(
minimum_size <= self.len(),
"Requested a random subset with at least {} elements but there are only {} elements",
Expand All @@ -853,7 +853,7 @@ pub mod node {
&'a self,
size: usize,
rng: &'a mut R,
) -> impl Iterator<Item = &Node> + 'a {
) -> impl Iterator<Item = &'a Node> + 'a {
assert!(
size <= self.len(),
"Requested a random subset with {} elements but there are only {} elements",
Expand All @@ -867,7 +867,7 @@ pub mod node {
&'a self,
idkg_receivers: T,
rng: &mut R,
) -> &Node {
) -> &'a Node {
self.filter_by_receivers(idkg_receivers)
.choose(rng)
.expect("empty receivers")
Expand All @@ -878,7 +878,7 @@ pub mod node {
exclusion: &Node,
idkg_receivers: T,
rng: &mut R,
) -> &Node {
) -> &'a Node {
self.filter_by_receivers(idkg_receivers)
.filter(|node| *node != exclusion)
.choose(rng)
Expand All @@ -889,7 +889,7 @@ pub mod node {
&'a self,
params: &'a IDkgTranscriptParams,
rng: &mut R,
) -> &Node {
) -> &'a Node {
self.filter_by_dealers(params)
.choose(rng)
.expect("empty dealers")
Expand Down
2 changes: 1 addition & 1 deletion rs/crypto/test_utils/tls/src/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl Client {
let msg_for_server_with_eol = format!("{}\n", msg_for_server);
#[allow(clippy::disallowed_methods)]
let num_bytes_written = wr.write(msg_for_server_with_eol.as_bytes()).await.unwrap();
assert_eq!(num_bytes_written, msg_for_server_with_eol.as_bytes().len());
assert_eq!(num_bytes_written, msg_for_server_with_eol.len());

const ACK: u8 = 0x06;
let reply = rd.read_u8().await.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion rs/crypto/test_utils/tls/src/test_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl Server {
let msg_with_eol = format!("{}\n", msg_for_client);
#[allow(clippy::disallowed_methods)]
let num_bytes_written = wr.write(msg_with_eol.as_bytes()).await.unwrap();
assert_eq!(num_bytes_written, msg_with_eol.as_bytes().len());
assert_eq!(num_bytes_written, msg_with_eol.len());

const ACK: u8 = 0x06;
let reply = rd.read_u8().await.unwrap();
Expand Down
4 changes: 1 addition & 3 deletions rs/embedders/src/wasm_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ fn compile_inner(

let is_wasm64 = module
.get_export(crate::wasmtime_embedder::WASM_HEAP_MEMORY_NAME)
.map_or(false, |export| {
export.memory().map_or(false, |mem| mem.is_64())
});
.is_some_and(|export| export.memory().is_some_and(|mem| mem.is_64()));

let serialized_module = SerializedModule::new(
&module,
Expand Down
2 changes: 1 addition & 1 deletion rs/http_utils/src/file_downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ mod tests {
let mut tar = Builder::new(writer);
let mut header = tar::Header::new_gnu();
header.set_path("test.txt")?;
header.set_size("Hello, world!".as_bytes().len() as u64);
header.set_size("Hello, world!".len() as u64);
header.set_cksum();
tar.append(&header, "Hello, world!".as_bytes())?;
tar.finish()?;
Expand Down
1 change: 0 additions & 1 deletion rs/ic_os/os_tools/guestos_tool/src/prometheus_metric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::vec::Vec;
/// Types and utils for writing prometheus metrics to textfile collector
/// Unused for now:
/// const DEFAULT_TEXTFILE_COLLECTOR_DIR: &str = "/run/node_exporter/collector_textfile/";
#[allow(dead_code)]
pub enum MetricType {
Counter,
Expand Down
1 change: 0 additions & 1 deletion rs/interfaces/src/crypto/sign/canister_threshold_sig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ pub trait IDkgProtocol {
/// The threshold signing protocol is non-interactive, which means that the nodes participating
/// to the protocol only need to compute a signature share and publish it. Shares can then be
/// publicly verified by anybody and combined into a single ECDSA signature.
pub trait ThresholdEcdsaSigner {
/// Create a threshold ECDSA signature share.
///
Expand Down
17 changes: 14 additions & 3 deletions rs/memory_tracker/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,13 @@ mod random_ops {
handler.sa_flags = libc::SA_SIGINFO | libc::SA_NODEFER | libc::SA_ONSTACK;
handler.sa_sigaction = sigsegv_handler as usize;
libc::sigemptyset(&mut handler.sa_mask);
if libc::sigaction(libc::SIGSEGV, &handler, PREV_SIGSEGV.as_mut_ptr()) != 0 {
if libc::sigaction(
libc::SIGSEGV,
&handler,
#[allow(static_mut_refs)]
PREV_SIGSEGV.as_mut_ptr(),
) != 0
{
panic!(
"unable to install signal handler: {}",
io::Error::last_os_error(),
Expand All @@ -809,8 +815,12 @@ mod random_ops {
TRACKER.with(|cell| {
let previous = cell.replace(None);
unsafe {
if libc::sigaction(libc::SIGSEGV, PREV_SIGSEGV.as_ptr(), std::ptr::null_mut())
!= 0
if libc::sigaction(
libc::SIGSEGV,
#[allow(static_mut_refs)]
PREV_SIGSEGV.as_ptr(),
std::ptr::null_mut(),
) != 0
{
panic!(
"unable to unregister signal handler: {}",
Expand Down Expand Up @@ -846,6 +856,7 @@ mod random_ops {

unsafe {
if !handled {
#[allow(static_mut_refs)]
let previous = *PREV_SIGSEGV.as_ptr();
if previous.sa_flags & libc::SA_SIGINFO != 0 {
mem::transmute::<
Expand Down
2 changes: 1 addition & 1 deletion rs/orchestrator/src/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ pub(crate) fn is_time_to_rotate_in_subnet(
let now = SystemTime::now();
timestamps
.iter()
.all(|ts| now.duration_since(*ts).map_or(false, |d| d >= gamma))
.all(|ts| now.duration_since(*ts).is_ok_and(|d| d >= gamma))
}

pub(crate) fn http_config_to_endpoint(
Expand Down
7 changes: 2 additions & 5 deletions rs/p2p/consensus_manager/src/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,8 @@ where
});

for peers_sender in self.active_assembles.values() {
peers_sender.send_if_modified(|set| {
nodes_leaving_topology
.iter()
.any(|n| set.remove(*n))
});
peers_sender
.send_if_modified(|set| nodes_leaving_topology.iter().any(|n| set.remove(*n)));
}
debug_assert!(
self.slot_table.len() <= self.topology_watcher.borrow().iter().count(),
Expand Down
6 changes: 5 additions & 1 deletion rs/pocket_ic_server/tests/bitcoin_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ rpcauth=ic-btc-integration:cdf2741387f3a12438f69092f0fdad8e$62081498c98bee09a0dc
let data_dir_path = tmp_dir.path().join("data");
create_dir(data_dir_path.clone()).unwrap();

Command::new(bitcoind_path)
let mut bitcoin_d_process = Command::new(bitcoind_path)
.arg(format!("-conf={}", conf_path.display()))
.arg(format!("-datadir={}", data_dir_path.display()))
.spawn()
Expand Down Expand Up @@ -180,4 +180,8 @@ rpcauth=ic-btc-integration:cdf2741387f3a12438f69092f0fdad8e$62081498c98bee09a0dc
n += 1;
}
}

// Kill the task to avoid zombie process.
bitcoin_d_process.kill().unwrap();
bitcoin_d_process.wait().unwrap();
}
2 changes: 1 addition & 1 deletion rs/replicated_state/src/canister_state/queues.rs
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ impl CanisterQueues {
if self
.canister_queues
.get(sender)
.map_or(false, |(input_queue, _)| input_queue.len() != 0)
.is_some_and(|(input_queue, _)| input_queue.len() != 0)
{
self.input_schedule.reschedule(*sender, input_queue_type);
break;
Expand Down
2 changes: 1 addition & 1 deletion rs/rust_canisters/memory_test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ fn copy() {
let step = operation.step.unwrap_or(ELEMENT_SIZE) / ELEMENT_SIZE;
let value = operation.value.unwrap_or_else(|| rand(0, u8::MAX));
// Address can't exceed 4GiB WASM memory
let len = (operation.size as usize + ELEMENT_SIZE - 1) / ELEMENT_SIZE;
let len = (operation.size as usize).div_ceil(ELEMENT_SIZE);
assert!(2 * len <= MEMORY_LEN);
MEMORY.with(|memory| {
let mut memory_ref = memory.borrow_mut();
Expand Down
4 changes: 4 additions & 0 deletions rs/state_machine_tests/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ fn test() {
time.duration_since(SystemTime::UNIX_EPOCH).unwrap(),
Duration::from_nanos(1_620_329_630_000_000_000)
);

// Kill the task to avoid zombie process.
child.kill().unwrap();
child.wait().unwrap();
}

fn call_state_machine<T: DeserializeOwned>(
Expand Down
4 changes: 2 additions & 2 deletions rs/tla_instrumentation/local_key/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl<T: 'static> LocalKey<T> {
slot: &'a mut Option<T>,
}

impl<'a, T: 'static> Drop for Guard<'_, T> {
impl<T: 'static> Drop for Guard<'_, T> {
fn drop(&mut self) {
// This should not panic.
//
Expand Down Expand Up @@ -414,7 +414,7 @@ where
struct TransparentOption<'a, T> {
value: &'a Option<T>,
}
impl<'a, T: fmt::Debug> fmt::Debug for TransparentOption<'_, T> {
impl<T: fmt::Debug> fmt::Debug for TransparentOption<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.value.as_ref() {
Some(value) => value.fmt(f),
Expand Down
6 changes: 3 additions & 3 deletions rs/types/types/src/consensus/idkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,10 @@ impl IDkgPayload {
}

/// Return an iterator of all ids of pre-signatures for the given key in the payload.
pub fn iter_pre_signature_ids(
&self,
pub fn iter_pre_signature_ids<'a>(
&'a self,
key_id: &'a IDkgMasterPublicKeyId,
) -> impl Iterator<Item = PreSigId> {
) -> impl Iterator<Item = PreSigId> + 'a {
let available_pre_signature_ids = self
.available_pre_signatures
.iter()
Expand Down
Loading

0 comments on commit d22137d

Please sign in to comment.