Skip to content

Commit

Permalink
[Rust] Update Rust version to 1.80.1
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLind committed Nov 2, 2024
1 parent 5a7a416 commit 0a86dc3
Show file tree
Hide file tree
Showing 155 changed files with 1,879 additions and 1,835 deletions.
3,123 changes: 1,555 additions & 1,568 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ homepage = "https://aptoslabs.com"
license = "Apache-2.0"
publish = false
repository = "https://github.com/aptos-labs/aptos-core"
rust-version = "1.78.0"
rust-version = "1.80.1"

[workspace.dependencies]
# Internal crate dependencies.
Expand Down Expand Up @@ -658,7 +658,7 @@ mockall = "0.11.4"
more-asserts = "0.3.0"
named-lock = "0.2.0"
native-tls = "0.2.10"
neptune = { version = "13.0.0", default_features = false }
neptune = { version = "13.0.0", default-features = false }
ntest = "0.9.3"
num = "0.4.0"
num-bigint = { version = "0.3.2", features = ["rand"] }
Expand Down Expand Up @@ -740,7 +740,7 @@ ring = { version = "0.16.20", features = ["std"] }
ripemd = "0.1.1"
rocksdb = { version = "0.22.0", features = ["lz4"] }
rsa = { version = "0.9.6" }
rstack-self = { version = "0.3.0", features = ["dw"], default_features = false }
rstack-self = { version = "0.3.0", features = ["dw"], default-features = false }
rstest = "0.15.0"
rusty-fork = "0.3.0"
rustversion = "1.0.14"
Expand Down Expand Up @@ -823,7 +823,7 @@ uint = "0.9.4"
ureq = { version = "1.5.4", features = [
"json",
"native-tls",
], default_features = false }
], default-features = false }
url = { version = "2.4.0", features = ["serde"] }
uuid = { version = "1.0.0", features = ["v4", "serde"] }
variant_count = "1.1.0"
Expand Down
4 changes: 3 additions & 1 deletion aptos-move/aptos-aggregator/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ pub trait TDelayedFieldView {
/// 1. The resource is read during the transaction execution.
/// 2. The resource is not present in write set of the VM Change Set.
/// 3. The resource has a delayed field in it that is part of delayed field change set.
///
/// We get the keys of these resources and metadata to include them in the write set
/// of the transaction output after value exchange.
fn get_reads_needing_exchange(
Expand All @@ -190,7 +191,8 @@ pub trait TDelayedFieldView {
/// 1. At least one of the resource in the group is read during the transaction execution.
/// 2. The resource group is not present in the write set of the VM Change Set.
/// 3. At least one of the resources in the group has a delayed field in it that is part.
/// of delayed field change set.
/// of delayed field change set.
///
/// We get the keys of these resource groups and metadata to include them in the write set
/// of the transaction output after value exchange. For each such resource group, this function
/// outputs:(resource key, (metadata, resource group size))
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/aptos-e2e-comparison-testing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ fn dump_and_compile_from_package_metadata(
File::create(module_path.clone()).expect("Error encountered while creating file!");
};
let source_str = unzip_metadata_str(&module.source).unwrap();
std::fs::write(&module_path.clone(), source_str).unwrap();
std::fs::write(module_path.clone(), source_str).unwrap();
}

// step 2: unzip, parse the manifest file
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/aptos-gas-profiling/src/flamegraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl ExecutionAndIOCosts {
}
}

self.lines.push(&self.path(), frame_cost);
self.lines.push(self.path(), frame_cost);
self.path.pop();
}

Expand Down
2 changes: 1 addition & 1 deletion aptos-move/aptos-sdk-builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct Options {
/// * Rust crates may contain a version number, e.g. "test:1.2.0".
/// * In Java, this is expected to be a package name, e.g. "com.test" to create Java files in `com/test`.
/// * In Go, this is expected to be of the format "go_module/path/go_package_name",
/// and `aptos_types` is assumed to be in "go_module/path/aptos_types".
/// and `aptos_types` is assumed to be in "go_module/path/aptos_types".
#[clap(long)]
module_name: Option<String>,

Expand Down
1 change: 1 addition & 0 deletions aptos-move/aptos-sdk-builder/src/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub fn output(out: &mut dyn Write, abis: &[EntryABI], local_types: bool) -> Resu
writeln!(emitter.out, "#![allow(clippy::too_many_arguments)]")?;
writeln!(emitter.out, "#![allow(clippy::arc_with_non_send_sync)]")?;
writeln!(emitter.out, "#![allow(clippy::get_first)]")?;
writeln!(emitter.out, "#![allow(clippy::doc_lazy_continuation)]")?;

emitter.output_script_call_enum_with_imports(abis)?;

Expand Down
1 change: 1 addition & 0 deletions aptos-move/aptos-vm-types/src/change_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ impl VMChangeSet {
/// serialized changes. The conversion fails if:
/// - deltas are not materialized.
/// - resource group writes are not (combined &) converted to resource writes.
///
/// In addition, the caller can include changes to published modules.
pub fn try_combine_into_storage_change_set(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ impl<'s, S: StateView> ModuleBytesStorage for StateViewAdapter<'s, S> {
/// A (not thread-safe) implementation of code storage on top of a state view. It is never built
/// directly by clients - only via [AsAptosCodeStorage] trait. Can be used to resolve both modules
/// and cached scripts.
#[allow(clippy::duplicated_attributes)]
#[derive(Delegate)]
#[delegate(
WithRuntimeEnvironment,
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/aptos-vm-types/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub trait TResourceGroupView {
/// Needed for backwards compatibility with the additional safety mechanism for resource
/// groups, where the violation of the following invariant causes transaction failure:
/// - if a resource is modified or deleted it must already exist within a group,
/// and if it is created, it must not previously exist.
/// and if it is created, it must not previously exist.
///
/// For normal resources, this is asserted, but for resource groups the behavior (that
/// we maintain) is for the transaction to fail with INVARIANT_VIOLATION_ERROR.
Expand Down
3 changes: 2 additions & 1 deletion aptos-move/aptos-vm/src/aptos_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2851,7 +2851,8 @@ impl VMValidator for AptosVM {
/// transaction
/// 2. The script to be executed is under given specific configuration.
/// 3. Invokes `Account.prologue`, which checks properties such as the transaction has the
/// right sequence number and the sender has enough balance to pay for the gas.
/// right sequence number and the sender has enough balance to pay for the gas.
///
/// TBD:
/// 1. Transaction arguments matches the main function's type signature.
/// We don't check this item for now and would execute the check at execution time.
Expand Down
1 change: 1 addition & 0 deletions aptos-move/aptos-vm/src/move_vm_ext/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ impl<'r, 'l> SessionExt<'r, 'l> {
/// * Remove resource group data from the deltas
/// * Attempt to read the existing resource group data or create a new empty container
/// * Apply the deltas to the resource group data
///
/// The process for translating Move deltas of resource groups to resources is
/// * Add -- insert element in container
/// * If entry exists, Unreachable
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/aptos-vm/src/transaction_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ pub(crate) fn run_script_prologue(
/// 1. The multisig tx exists
/// 2. It has received enough approvals to meet the signature threshold of the multisig account
/// 3. If only the payload hash was stored on chain, the provided payload in execution should
/// match that hash.
/// match that hash.
pub(crate) fn run_multisig_prologue(
session: &mut SessionExt,
module_storage: &impl AptosModuleStorage,
Expand Down
5 changes: 3 additions & 2 deletions aptos-move/block-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ in E is either currently being executed or (its last incarnation) has completed.
Each thread repeats the following (loop in 'executor.rs'):
- Check done: if V and E are empty and no other thread is performing a task,
then return.
then return.
- Find next task: Perform the task with the smallest transaction index tx in V
and E:
and E:
1. Execution task: Execute the next incarnation of tx. If a value marked as
ESTIMATE is read, abort execution and add tx back to E. Otherwise:
(a) If there is a write to a memory location to which the previous finished
Expand All @@ -91,6 +91,7 @@ and E:
currently in E or being executed and add them to V.
(c) Create an execution task for transaction tx with an incremented
incarnation number, and add it to E.
When a transaction tx_k reads an ESTIMATE marker written by tx_j (with j < k),
we say that tx_k encounters a dependency (we treat tx_k as tx_j's dependency
because its read depends on a value that tx_j is estimated to write).
Expand Down
10 changes: 5 additions & 5 deletions aptos-move/block-executor/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -864,9 +864,9 @@ impl Scheduler {

/// Grab an index to try and validate next (by fetch-and-incrementing validation_idx).
/// - If the index is out of bounds, return None (and invoke a check of whether
/// all txns can be committed).
/// all txns can be committed).
/// - If the transaction is ready for validation (EXECUTED state), return the version
/// to the caller.
/// to the caller.
/// - Otherwise, return None.
fn try_validate_next_version(
&self,
Expand Down Expand Up @@ -904,10 +904,10 @@ impl Scheduler {

/// Grab an index to try and execute next (by fetch-and-incrementing execution_idx).
/// - If the index is out of bounds, return None (and invoke a check of whether
/// all txns can be committed).
/// all txns can be committed).
/// - If the transaction is ready for execution (Ready state), attempt
/// to create the next incarnation (should happen exactly once), and if successful,
/// return the version to the caller for the corresponding ExecutionTask.
/// to create the next incarnation (should happen exactly once), and if successful,
/// return the version to the caller for the corresponding ExecutionTask.
/// - Otherwise, return None.
fn try_execute_next_version(&self) -> Option<(TxnIndex, Incarnation, ExecutionTaskType)> {
let idx_to_execute = self.execution_idx.fetch_add(1, Ordering::SeqCst);
Expand Down
4 changes: 2 additions & 2 deletions aptos-move/e2e-move-tests/src/tests/string_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ fn string_args_good() {
"hello".as_bytes(),
],
];
let u64_vec_max = vec![std::u64::MAX, std::u64::MAX, std::u64::MAX];
let u64_vec_max = vec![u64::MAX, u64::MAX, u64::MAX];
let u64_long = vec![0xABCDEFu64; 100];
let i = 0u64;
let j = 0u64;
Expand Down Expand Up @@ -625,7 +625,7 @@ fn string_args_generic_instantiation() {
],
];
let u8_vec = vec![0xFFu8; 100];
let u64_vec = vec![std::u64::MAX, std::u64::MAX, std::u64::MAX];
let u64_vec = vec![u64::MAX, u64::MAX, u64::MAX];
let val1 = long_addr;
let val2 = "hi there! hello".as_bytes();
let i = 0u64;
Expand Down
4 changes: 2 additions & 2 deletions aptos-move/e2e-testsuite/src/tests/verify_txn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,12 +493,12 @@ fn verify_chain_id() {
#[test]
fn verify_max_sequence_number() {
let mut executor = FakeExecutor::from_head_genesis();
let sender = executor.create_raw_account_data(900_000, std::u64::MAX);
let sender = executor.create_raw_account_data(900_000, u64::MAX);
executor.add_account_data(&sender);
let private_key = &sender.account().privkey;
let txn = transaction_test_helpers::get_test_signed_transaction(
*sender.address(),
std::u64::MAX, /* sequence_number */
u64::MAX, /* sequence_number */
private_key,
private_key.public_key(),
None, /* script */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#![allow(clippy::too_many_arguments)]
#![allow(clippy::arc_with_non_send_sync)]
#![allow(clippy::get_first)]
#![allow(clippy::doc_lazy_continuation)]
use aptos_types::{
account_address::AccountAddress,
transaction::{EntryFunction, TransactionPayload},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#![allow(clippy::too_many_arguments)]
#![allow(clippy::arc_with_non_send_sync)]
#![allow(clippy::get_first)]
#![allow(clippy::doc_lazy_continuation)]
use aptos_types::{
account_address::AccountAddress,
transaction::{EntryFunction, TransactionPayload},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#![allow(clippy::too_many_arguments)]
#![allow(clippy::arc_with_non_send_sync)]
#![allow(clippy::get_first)]
#![allow(clippy::doc_lazy_continuation)]
use aptos_types::{
account_address::AccountAddress,
transaction::{EntryFunction, TransactionPayload},
Expand Down
6 changes: 1 addition & 5 deletions aptos-move/framework/src/built_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,7 @@ impl BuiltPackage {

// If enabled generate docs.
if options.with_docs {
let docgen = if let Some(opts) = options.docgen_options.clone() {
opts
} else {
DocgenOptions::default()
};
let docgen = options.docgen_options.clone().unwrap_or_default();
let dep_paths = package
.deps_compiled_units
.iter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub(crate) const COMPRESSED_POINT_NUM_BYTES: usize = 32;
/// employed in curve25519 is:
/// 1. Strauss, when n <= 190, see <https://www.jstor.org/stable/2310929>
/// 2. Pippinger, when n > 190, which roughly requires O(n / log_2 n) scalar multiplications
///
/// For simplicity, we estimate the complexity as O(n / log_2 n)
pub fn multi_scalar_mul_gas(
size: usize,
Expand Down
1 change: 1 addition & 0 deletions aptos-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ pub fn start(
start_and_report_ports(config, log_file, create_global_rayon_pool, None, None)
}

#[allow(unexpected_cfgs)]
/// Start an Aptos node
pub fn start_and_report_ports(
config: NodeConfig,
Expand Down
1 change: 1 addition & 0 deletions config/src/config/consensus_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ impl ConfigSanitizer for ConsensusConfig {
}
}

#[allow(unexpected_cfgs)]
/// Returns true iff consensus-only-perf-test is enabled
fn is_consensus_only_perf_test_enabled() -> bool {
cfg_if! {
Expand Down
4 changes: 2 additions & 2 deletions config/src/config/override_node_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ mod test {
config.full_node_networks.push(Default::default());

let diff_yaml = override_config.get_yaml().unwrap();
let default_node_config = serde_yaml::to_value(&NetworkConfig::default()).unwrap();
let default_node_config = serde_yaml::to_value(NetworkConfig::default()).unwrap();
let mut expected_yaml: serde_yaml::Value = serde_yaml::Value::Null;
expected_yaml["full_node_networks"] =
serde_yaml::Value::Sequence(vec![default_node_config.clone(), default_node_config]);
Expand All @@ -238,7 +238,7 @@ mod test {

// Note, the diff will include the entire vector, not just the non-equal elements
let diff_yaml = override_config.get_yaml().unwrap();
let default_node_config = serde_yaml::to_value(&NetworkConfig::default()).unwrap();
let default_node_config = serde_yaml::to_value(NetworkConfig::default()).unwrap();
let mut expected_yaml: serde_yaml::Value = serde_yaml::Value::Null;
expected_yaml["full_node_networks"] =
serde_yaml::Value::Sequence(vec![default_node_config.clone(), default_node_config]);
Expand Down
6 changes: 1 addition & 5 deletions config/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@ fn get_random_port() -> u16 {

fn try_bind(port: Option<u16>) -> ::std::io::Result<u16> {
// Use the provided port or 0 to request a random available port from the OS
let port = if let Some(provided_port) = port {
provided_port
} else {
0
};
let port = port.unwrap_or_default();
let listener = TcpListener::bind(("localhost", port))?;
let addr = listener.local_addr()?;

Expand Down
4 changes: 2 additions & 2 deletions consensus/consensus-types/src/block_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl BlockData {
}

pub fn new_genesis(timestamp_usecs: u64, quorum_cert: QuorumCert) -> Self {
assume!(quorum_cert.certified_block().epoch() < u64::max_value()); // unlikely to be false in this universe
assume!(quorum_cert.certified_block().epoch() < u64::MAX); // unlikely to be false in this universe
Self {
epoch: quorum_cert.certified_block().epoch() + 1,
round: 0,
Expand All @@ -262,7 +262,7 @@ impl BlockData {
) -> Self {
// We want all the NIL blocks to agree on the timestamps even though they're generated
// independently by different validators, hence we're using the timestamp of a parent + 1.
assume!(quorum_cert.certified_block().timestamp_usecs() < u64::max_value()); // unlikely to be false in this universe
assume!(quorum_cert.certified_block().timestamp_usecs() < u64::MAX); // unlikely to be false in this universe
let timestamp_usecs = quorum_cert.certified_block().timestamp_usecs();

Self {
Expand Down
1 change: 0 additions & 1 deletion consensus/consensus-types/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use std::{
collections::HashSet,
fmt::{self, Write},
sync::Arc,
u64,
};
use tokio::sync::oneshot;

Expand Down
4 changes: 2 additions & 2 deletions consensus/src/block_storage/sync_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ impl BlockStore {
/// It works as follows:
/// 1. request the gap blocks from the peer (from highest_ledger_info to highest_ordered_cert)
/// 2. We persist the gap blocks to storage before start sync to ensure we could restart if we
/// crash in the middle of the sync.
/// crash in the middle of the sync.
/// 3. We prune the old tree and replace with a new tree built with the 3-chain.
async fn sync_to_highest_quorum_cert(
&self,
Expand Down Expand Up @@ -312,7 +312,7 @@ impl BlockStore {
+ 1;

// although unlikely, we might wrap num_blocks around on a 32-bit machine
assert!(num_blocks < std::usize::MAX as u64);
assert!(num_blocks < usize::MAX as u64);

BLOCKS_FETCHED_FROM_NETWORK_WHILE_FAST_FORWARD_SYNC.inc_by(num_blocks);
let mut blocks = retriever
Expand Down
5 changes: 3 additions & 2 deletions consensus/src/liveness/proposal_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ impl PipelineBackpressureConfig {
/// round.
/// ProposalGenerator is the one choosing the branch to extend:
/// - round is given by the caller (typically determined by RoundState).
///
/// The transactions for the proposed block are delivered by PayloadClient.
///
/// PayloadClient should be aware of the pending transactions in the branch that it is extending,
Expand Down Expand Up @@ -341,10 +342,10 @@ impl ProposalGenerator {
/// Errors returned by the PayloadClient implementation are propagated to the caller.
/// The logic for choosing the branch to extend is as follows:
/// 1. The function gets the highest head of a one-chain from block tree.
/// The new proposal must extend hqc to ensure optimistic responsiveness.
/// The new proposal must extend hqc to ensure optimistic responsiveness.
/// 2. The round is provided by the caller.
/// 3. In case a given round is not greater than the calculated parent, return an OldRound
/// error.
/// error.
pub async fn generate_proposal(
&self,
round: Round,
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/liveness/round_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl ExponentialTimeInterval {
"max_exponent for RoundStateTimeInterval should be <32"
);
assert!(
exponent_base.powf(max_exponent as f64).ceil() < f64::from(std::u32::MAX),
exponent_base.powf(max_exponent as f64).ceil() < f64::from(u32::MAX),
"Maximum interval multiplier should be less then u32::Max"
);
ExponentialTimeInterval {
Expand Down
Loading

0 comments on commit 0a86dc3

Please sign in to comment.