Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
4418: Update rust version r=Fraser999 a=Fraser999

This PR updates the pinned rust version to 1.73.0.

All fixes for new `clippy::arithmetic_side_effects` warnings were grouped into a single commit ([888c2f0](casper-network@888c2f0)), and are worth special attention for correctness.

Closes casper-network#4416.


Co-authored-by: Fraser Hutchison <[email protected]>
  • Loading branch information
casperlabs-bors-ng[bot] and Fraser999 authored Nov 16, 2023
2 parents cb968e5 + bedfd49 commit f5698a0
Show file tree
Hide file tree
Showing 88 changed files with 341 additions and 333 deletions.
46 changes: 40 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ default-members = [

exclude = ["utils/nctl/remotes/casper-client-rs"]

resolver = "2"

# Include debug symbols in the release build of `casper-engine-tests` so that `simple-transfer` will yield useful
# perf data.
[profile.release.package.casper-engine-tests]
Expand Down
2 changes: 1 addition & 1 deletion ci/casper_updater/src/regex_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ pub mod chainspec_protocol_version {
),
DependentFile::new(
"node/src/components/rpc_server/rpcs/docs.rs",
Regex::new(r#"(?m)(DOCS_EXAMPLE_PROTOCOL_VERSION: ProtocolVersion =\s*ProtocolVersion::from_parts)\((\d+,\s*\d+,\s*\d+)\)"#).unwrap(),
Regex::new(r"(?m)(DOCS_EXAMPLE_PROTOCOL_VERSION: ProtocolVersion =\s*ProtocolVersion::from_parts)\((\d+,\s*\d+,\s*\d+)\)").unwrap(),
rpcs_docs_rs_replacement,
),
DependentFile::new(
Expand Down
2 changes: 1 addition & 1 deletion execution_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ casper-types = { path = "../types", features = ["datasize", "json-schema", "test
criterion = "0.3.5"
proptest = "1.0.0"
tempfile = "3.4.0"
walrus = "0.19.0"
walrus = "0.20.2"

[features]
default = ["gens"]
Expand Down
4 changes: 2 additions & 2 deletions execution_engine/src/core/engine_state/execution_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ impl ExecutionResultBuilder {
}
Some(ExecutionResult::Success {
execution_journal, ..
}) => journal.extend(execution_journal.into_iter()),
}) => journal.extend(execution_journal),
None => return Err(ExecutionResultBuilderError::MissingSessionExecutionResult),
};

Expand All @@ -521,7 +521,7 @@ impl ExecutionResultBuilder {
}
Some(ExecutionResult::Success {
execution_journal, ..
}) => journal.extend(execution_journal.into_iter()),
}) => journal.extend(execution_journal),
None => return Err(ExecutionResultBuilderError::MissingFinalizeExecutionResult),
}

Expand Down
9 changes: 2 additions & 7 deletions execution_engine/src/core/engine_state/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
};

/// Representation of a single operation during execution.
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
#[derive(PartialEq, Eq, Debug, Clone, Copy, Default)]
pub enum Op {
/// Read value from a `Key`.
Read,
Expand All @@ -15,6 +15,7 @@ pub enum Op {
/// Add a value into a `Key`.
Add,
/// No operation.
#[default]
NoOp,
}

Expand Down Expand Up @@ -44,12 +45,6 @@ impl Display for Op {
}
}

impl Default for Op {
fn default() -> Self {
Op::NoOp
}
}

impl From<&Op> for casper_types::OpKind {
fn from(op: &Op) -> Self {
match op {
Expand Down
6 changes: 2 additions & 4 deletions execution_engine/src/core/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3007,8 +3007,7 @@ where
}

// A set of keys is converted into a vector so it can be written to a host buffer
let authorization_keys =
Vec::from_iter(self.context.authorization_keys().clone().into_iter());
let authorization_keys = Vec::from_iter(self.context.authorization_keys().clone());

let total_keys: u32 = match authorization_keys.len().try_into() {
Ok(value) => value,
Expand Down Expand Up @@ -3046,8 +3045,7 @@ where
#[cfg(feature = "test-support")]
fn dump_runtime_stack_info(instance: casper_wasmi::ModuleRef, max_stack_height: u32) {
let globals = instance.globals();
let Some(current_runtime_call_stack_height) = globals.last()
else {
let Some(current_runtime_call_stack_height) = globals.last() else {
return;
};

Expand Down
7 changes: 2 additions & 5 deletions execution_engine/src/core/tracking_copy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! were applied on it.
mod byte_size;
mod ext;
pub(self) mod meter;
mod meter;
#[cfg(test)]
mod tests;

Expand Down Expand Up @@ -193,10 +193,7 @@ impl<M: Meter<Key, StoredValue>> TrackingCopyCache<M> {
pub fn insert_write(&mut self, key: Key, value: StoredValue) {
self.muts_cached.insert(key, value);

let key_set = self
.key_tag_muts_cached
.entry(key.tag())
.or_insert_with(BTreeSet::new);
let key_set = self.key_tag_muts_cached.entry(key.tag()).or_default();

key_set.insert(key);
}
Expand Down
4 changes: 2 additions & 2 deletions execution_engine/src/shared/logging/structured_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ impl<'kvs> Visitor<'kvs> for MessageProperties {
let value = value
.to_string()
.trim_matches('"')
.replace(r#"\'"#, r#"'"#)
.replace(r"\'", "'")
.replace(r#"\""#, r#"""#)
.replace(r#"\\"#, r#"\"#);
.replace(r"\\", r"\");
self.0.insert(key.to_string(), value);
Ok(())
}
Expand Down
3 changes: 1 addition & 2 deletions execution_engine/src/shared/newtypes/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ macro_rules! make_array_newtype {

impl Clone for $name {
fn clone(&self) -> $name {
let &$name(ref dat) = self;
$name(dat.clone())
*self
}
}

Expand Down
9 changes: 2 additions & 7 deletions execution_engine/src/shared/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ impl From<CLValueError> for Error {
/// Note that all arithmetic variants of [`Transform`] are commutative which means that a given
/// collection of them can be executed in any order to produce the same end result.
#[allow(clippy::large_enum_variant)]
#[derive(PartialEq, Eq, Debug, Clone, DataSize)]
#[derive(PartialEq, Eq, Debug, Clone, DataSize, Default)]
pub enum Transform {
/// An identity transformation that does not modify a value in the global state.
///
/// Created as part of a read from the global state.
#[default]
Identity,
/// Writes a new value in the global state.
Write(StoredValue),
Expand Down Expand Up @@ -333,12 +334,6 @@ impl Display for Transform {
}
}

impl Default for Transform {
fn default() -> Self {
Transform::Identity
}
}

impl From<&Transform> for casper_types::Transform {
fn from(transform: &Transform) -> Self {
match transform {
Expand Down
2 changes: 1 addition & 1 deletion execution_engine/src/storage/trie_store/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ mod tests {
let txn = env.create_read_txn().unwrap();

// Observe that nothing has been persisted to the store
for hash in vec![&leaf_1_hash, &leaf_2_hash, &node_hash].iter() {
for hash in [&leaf_1_hash, &leaf_2_hash, &node_hash].iter() {
// We need to use a type annotation here to help the compiler choose
// a suitable FromBytes instance
let maybe_trie: Option<Trie<Bytes, Bytes>> = store.get(&txn, hash).unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ where
Ok(ret)
}

fn check_keys<K, V, T, S, E>(
fn check_keys<K, V, T, S>(
correlation_id: CorrelationId,
txn: &T,
store: &S,
Expand All @@ -711,7 +711,6 @@ where
T: Readable<Handle = S::Handle>,
S: TrieStore<K, V>,
S::Error: From<T::Error>,
E: From<S::Error> + From<bytesrepr::Error>,
{
let expected = {
let mut tmp = leaves
Expand Down Expand Up @@ -774,7 +773,7 @@ where
.all(bool::not)
);

assert!(check_keys::<_, _, _, _, E>(
assert!(check_keys::<_, _, _, _>(
correlation_id,
&txn,
store,
Expand Down
2 changes: 1 addition & 1 deletion execution_engine_testing/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ num-rational = "0.4.0"
num-traits = "0.2.10"
once_cell = "1.5.2"
regex = "1.5.4"
walrus = "0.19.0"
walrus = "0.20.2"
wat = "1.0.47"

[features]
Expand Down
4 changes: 2 additions & 2 deletions execution_engine_testing/tests/src/test/regression/gh_3710.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,11 @@ mod fixture {
let rewards: Vec<&U512> = era_infos
.iter()
.flat_map(|era_info| era_info.seigniorage_allocations())
.filter_map(|seigniorage| match seigniorage {
.map(|seigniorage| match seigniorage {
SeigniorageAllocation::Validator {
validator_public_key,
amount,
} if validator_public_key == &*DEFAULT_ACCOUNT_PUBLIC_KEY => Some(amount),
} if validator_public_key == &*DEFAULT_ACCOUNT_PUBLIC_KEY => amount,
SeigniorageAllocation::Validator { .. } => panic!("Unexpected validator"),
SeigniorageAllocation::Delegator { .. } => panic!("No delegators"),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,12 @@ fn should_pass_elem_section() {
);

// wasmi assumes table size and function pointers are equal
assert!(matches!(
test_element_section(
DEFAULT_MAX_TABLE_SIZE,
Some(DEFAULT_MAX_TABLE_SIZE),
DEFAULT_MAX_TABLE_SIZE
),
None
));
assert!(test_element_section(
DEFAULT_MAX_TABLE_SIZE,
Some(DEFAULT_MAX_TABLE_SIZE),
DEFAULT_MAX_TABLE_SIZE
)
.is_none());
}

fn test_element_section(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1911,8 +1911,7 @@ fn should_handle_evictions() {
let era_validators: EraValidators = builder.get_era_validators();
let validators = era_validators
.iter()
.rev()
.next()
.next_back()
.map(|(_era_id, validators)| validators)
.expect("should have validators");
validators.keys().cloned().collect::<BTreeSet<PublicKey>>()
Expand Down Expand Up @@ -2557,7 +2556,7 @@ fn should_not_undelegate_vfta_holder_stake() {
.vesting_schedule()
.expect("should have vesting schedule");
assert!(
matches!(vesting_schedule.locked_amounts(), Some(_)),
vesting_schedule.locked_amounts().is_some(),
"{:?}",
vesting_schedule
);
Expand Down
3 changes: 1 addition & 2 deletions hashing/src/chunk_with_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ mod tests {
fn prepare_bytes(length: usize) -> Vec<u8> {
let mut rng = rand::thread_rng();

(0..length).into_iter().map(|_| rng.gen()).collect()
(0..length).map(|_| rng.gen()).collect()
}

fn random_chunk_with_proof() -> ChunkWithProof {
Expand Down Expand Up @@ -204,7 +204,6 @@ mod tests {
.unwrap();

assert!((0..number_of_chunks)
.into_iter()
.map(|chunk_index| { ChunkWithProof::new(data.as_slice(), chunk_index).unwrap() })
.all(|chunk_with_proof| chunk_with_proof.verify().is_ok()));
}
Expand Down
2 changes: 1 addition & 1 deletion hashing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ mod tests {

#[test]
fn test_hash_rfold() {
let hashes = vec![
let hashes = [
Digest([1u8; 32]),
Digest([2u8; 32]),
Digest([3u8; 32]),
Expand Down
Loading

0 comments on commit f5698a0

Please sign in to comment.