From d377d2af093db58a15d8aa609e8bb3adb2e6c05c Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Fri, 23 Aug 2024 14:31:26 -0500 Subject: [PATCH] chore: update rust to 1.80.1 (#19087) --- .cargo/{config => config.toml} | 5 + .github/workflows/external.yml | 3 +- .github/workflows/rust.yml | 3 +- Cargo.lock | 291 +++++++++--------- Cargo.toml | 18 +- consensus/config/Cargo.toml | 3 + consensus/core/Cargo.toml | 3 + consensus/core/src/authority_service.rs | 8 +- consensus/core/src/block_verifier.rs | 1 + consensus/core/src/commit_observer.rs | 8 +- consensus/core/src/commit_syncer.rs | 2 +- consensus/core/src/dag_state.rs | 4 +- consensus/core/src/leader_scoring.rs | 2 +- consensus/core/src/leader_scoring_strategy.rs | 1 + consensus/core/src/network/network_tests.rs | 12 +- consensus/core/src/stake_aggregator.rs | 1 + consensus/core/src/storage/mem_store.rs | 2 + consensus/core/src/storage/mod.rs | 1 + consensus/core/src/subscriber.rs | 6 +- consensus/core/src/synchronizer.rs | 4 +- consensus/core/src/test_dag_parser.rs | 2 +- consensus/core/src/transaction.rs | 1 + crates/mysten-metrics/Cargo.toml | 3 + crates/mysten-util-mem/src/malloc_size.rs | 65 ---- crates/mysten-util-mem/tests/derive.rs | 21 -- crates/sui-archival/src/lib.rs | 1 + crates/sui-aws-orchestrator/src/settings.rs | 1 - crates/sui-benchmark/Cargo.toml | 3 + .../src/embedded_reconfig_observer.rs | 1 + crates/sui-bridge-cli/src/lib.rs | 2 +- crates/sui-bridge/src/types.rs | 2 +- crates/sui-config/Cargo.toml | 3 + crates/sui-config/src/node.rs | 1 - crates/sui-config/src/p2p.rs | 1 + crates/sui-core/Cargo.toml | 3 + crates/sui-core/src/authority.rs | 5 +- .../authority/authority_per_epoch_store.rs | 18 +- .../src/authority/authority_store_pruner.rs | 4 + .../src/authority/authority_store_tables.rs | 5 +- .../shared_object_congestion_tracker.rs | 4 +- .../src/authority/test_authority_builder.rs | 5 +- crates/sui-core/src/authority_aggregator.rs | 1 + .../checkpoints/checkpoint_executor/mod.rs | 2 +- crates/sui-core/src/consensus_adapter.rs | 4 +- crates/sui-core/src/rest_index.rs | 4 +- crates/sui-core/src/transaction_manager.rs | 5 +- .../unit_tests/authority_aggregator_tests.rs | 2 +- .../src/unit_tests/execution_driver_tests.rs | 2 +- crates/sui-e2e-tests/Cargo.toml | 5 +- .../tests/dynamic_committee_tests.rs | 3 +- crates/sui-faucet/src/faucet/simple_faucet.rs | 5 +- crates/sui-framework-tests/Cargo.toml | 3 + crates/sui-framework/src/lib.rs | 4 +- crates/sui-genesis-builder/Cargo.toml | 3 + crates/sui-genesis-builder/src/lib.rs | 8 +- crates/sui-graphql-e2e-tests/Cargo.toml | 3 + crates/sui-graphql-rpc/src/server/version.rs | 1 + crates/sui-graphql-rpc/src/types/event.rs | 14 - .../sui-graphql-rpc/src/types/move_object.rs | 1 + crates/sui-graphql-rpc/src/types/object.rs | 5 +- crates/sui-graphql-rpc/src/types/owner.rs | 1 + .../src/types/transaction_block/tx_lookups.rs | 4 +- crates/sui-indexer/src/store/mod.rs | 7 +- .../sui-indexer/src/store/pg_indexer_store.rs | 1 + crates/sui-json-rpc-tests/Cargo.toml | 3 + .../sui-json-rpc-types/src/sui_transaction.rs | 2 +- crates/sui-json/src/lib.rs | 2 +- crates/sui-keys/src/keypair_file.rs | 1 + crates/sui-macros/Cargo.toml | 3 + crates/sui-macros/src/lib.rs | 4 +- crates/sui-move/src/unit_test.rs | 29 +- crates/sui-network/src/state_sync/server.rs | 2 +- crates/sui-node/Cargo.toml | 3 + crates/sui-node/src/admin.rs | 4 +- crates/sui-open-rpc-macros/src/lib.rs | 15 - crates/sui-open-rpc/Cargo.toml | 3 + crates/sui-open-rpc/src/examples.rs | 5 - crates/sui-package-resolver/src/lib.rs | 5 +- crates/sui-proc-macros/Cargo.toml | 3 + crates/sui-protocol-config/Cargo.toml | 3 + crates/sui-proxy/src/consumer.rs | 7 +- crates/sui-replay/src/lib.rs | 5 +- crates/sui-rest-api/src/reader.rs | 1 + crates/sui-rest-api/src/response.rs | 4 +- crates/sui-rosetta/src/construction.rs | 2 +- crates/sui-rosetta/tests/gas_budget_tests.rs | 1 + .../src/payload/query_transactions.rs | 2 +- .../sui-rpc-loadgen/src/payload/validation.rs | 2 +- crates/sui-sdk/src/lib.rs | 4 +- crates/sui-simulator/Cargo.toml | 3 + crates/sui-simulator/src/lib.rs | 2 +- crates/sui-snapshot/src/lib.rs | 1 + crates/sui-storage/Cargo.toml | 3 + .../sui-storage/src/http_key_value_store.rs | 9 +- crates/sui-swarm-config/Cargo.toml | 3 + crates/sui-swarm/Cargo.toml | 3 + crates/sui-swarm/src/memory/container.rs | 2 +- crates/sui-tool/src/commands.rs | 54 ---- crates/sui-tool/src/lib.rs | 37 --- .../sui-transactional-test-runner/Cargo.toml | 3 + .../src/simulator_persisted_store.rs | 16 +- crates/sui-types/Cargo.toml | 3 + crates/sui-types/src/crypto.rs | 4 +- crates/sui-types/src/execution.rs | 19 +- .../sui-types/src/full_checkpoint_content.rs | 4 +- crates/sui-types/src/messages_grpc.rs | 1 + crates/sui-types/tests/serde_tests.rs | 2 +- crates/sui/Cargo.toml | 3 + crates/sui/src/client_commands.rs | 1 + crates/sui/src/client_ptb/lexer.rs | 12 +- crates/sui/tests/cli_tests.rs | 6 +- crates/suiop-cli/src/command.rs | 6 +- crates/telemetry-subscribers/src/lib.rs | 2 +- .../src/span_latency_prom.rs | 1 + crates/test-cluster/Cargo.toml | 3 + crates/transaction-fuzzer/Cargo.toml | 3 + .../src/programmable_transaction_gen.rs | 2 +- crates/typed-store-derive/src/lib.rs | 2 +- crates/typed-store/src/lib.rs | 11 +- crates/typed-store/src/rocks/mod.rs | 8 +- crates/typed-store/tests/macro_tests.rs | 16 +- deny.toml | 56 +--- docker/deterministic-canary/Dockerfile | 2 +- docker/sui-bridge-indexer/Dockerfile | 2 +- docker/sui-graphql-rpc/Dockerfile | 2 +- docker/sui-indexer-tidb/Dockerfile | 2 +- docker/sui-indexer/Dockerfile | 2 +- docker/sui-node/Dockerfile | 2 +- docker/sui-services/Dockerfile | 2 +- docker/sui-source-service/Dockerfile | 2 +- docker/sui-tools/Dockerfile | 2 +- external-crates/move/Cargo.toml | 2 +- .../move-binary-format/src/file_format.rs | 14 +- .../src/file_format_common.rs | 2 +- .../src/proptest_types/functions.rs | 14 +- .../src/proptest_types/types.rs | 3 - .../move-binary-format/src/serializer.rs | 8 +- .../src/unit_tests/number_tests.rs | 4 +- .../src/control_flow_v5.rs | 2 +- .../src/script_signature.rs | 1 + .../move-command-line-common/src/files.rs | 4 +- .../crates/move-compiler/src/cfgir/cfg.rs | 1 + .../move-compiler/src/naming/translate.rs | 6 +- .../src/to_bytecode/canonicalize_handles.rs | 6 +- .../src/typing/deprecation_warnings.rs | 1 + .../crates/move-compiler/src/typing/expand.rs | 10 +- .../src/unit_test/plan_builder.rs | 2 +- .../move/crates/move-core-types/src/state.rs | 2 +- .../move/crates/move-core-types/src/u256.rs | 1 - .../crates/move-ir-to-bytecode/src/context.rs | 2 +- .../move/crates/move-model/src/ty.rs | 28 +- .../src/access_path.rs | 1 + .../src/inconsistency_check.rs | 1 + .../src/packed_types_analysis.rs | 1 + .../crates/move-stdlib-natives/src/debug.rs | 2 +- .../crates/move-vm-runtime/src/tracing.rs | 1 - .../move-vm-test-utils/src/gas_schedule.rs | 5 +- .../move-vm-types/src/values/values_impl.rs | 30 +- .../test-generation/src/abstract_state.rs | 4 +- .../test-generation/src/borrow_graph.rs | 2 +- .../test-generation/src/bytecode_generator.rs | 18 +- .../test-generation/src/control_flow_graph.rs | 12 +- .../move/crates/test-generation/src/lib.rs | 4 +- .../tests/generic_instructions.rs | 2 +- .../src/control_flow_v5.rs | 2 +- .../src/script_signature.rs | 1 + .../v0/crates/move-vm-runtime/src/tracing.rs | 1 - .../src/control_flow_v5.rs | 2 +- .../src/script_signature.rs | 1 + .../v1/crates/move-vm-runtime/src/tracing.rs | 1 - .../src/control_flow_v5.rs | 2 +- .../src/script_signature.rs | 1 + .../v2/crates/move-vm-runtime/src/tracing.rs | 1 - narwhal/config/src/lib.rs | 6 +- narwhal/node/src/benchmark_client.rs | 1 + narwhal/node/src/main.rs | 2 +- narwhal/primary/src/consensus/metrics.rs | 6 +- narwhal/primary/src/synchronizer.rs | 5 +- narwhal/primary/tests/randomized_tests.rs | 2 +- narwhal/storage/src/certificate_store.rs | 90 +++--- narwhal/test-utils/src/cluster.rs | 1 + narwhal/types/src/primary.rs | 1 + narwhal/worker/Cargo.toml | 3 + narwhal/worker/src/handlers.rs | 2 + rust-toolchain.toml | 2 +- sui-execution/latest/sui-adapter/Cargo.toml | 3 + .../sui-move-natives/src/crypto/group_ops.rs | 4 +- .../sui-verifier/src/entry_points_verifier.rs | 4 +- sui-execution/v0/sui-adapter/Cargo.toml | 3 + sui-execution/v0/sui-verifier/Cargo.toml | 3 + .../sui-verifier/src/entry_points_verifier.rs | 2 +- sui-execution/v1/sui-adapter/Cargo.toml | 3 + .../sui-verifier/src/entry_points_verifier.rs | 2 +- sui-execution/v2/sui-adapter/Cargo.toml | 3 + .../sui-move-natives/src/crypto/group_ops.rs | 4 +- .../sui-verifier/src/entry_points_verifier.rs | 2 +- 196 files changed, 620 insertions(+), 793 deletions(-) rename .cargo/{config => config.toml} (86%) diff --git a/.cargo/config b/.cargo/config.toml similarity index 86% rename from .cargo/config rename to .cargo/config.toml index b6879bf01e5f0..47c98de4efc2a 100644 --- a/.cargo/config +++ b/.cargo/config.toml @@ -7,6 +7,7 @@ xclippy = [ "clippy", "--all-targets", "--all-features", "--", "-Wclippy::all", "-Wclippy::disallowed_methods", + "-Aclippy::unnecessary_get_then_check", ] xlint = "run --package x --bin x -- lint" xtest = "run --package x --bin x -- external-crates-tests" @@ -22,6 +23,9 @@ move-clippy = [ "-Aclippy::upper_case_acronyms", "-Aclippy::type_complexity", "-Aclippy::new_without_default", + "-Aclippy::question_mark", + "-Aclippy::unnecessary_get_then_check", + "-Aclippy::needless_borrows_for_generic_args", ] mysql-clippy = [ @@ -38,6 +42,7 @@ mysql-clippy = [ "-Aclippy::upper_case_acronyms", "-Aclippy::type_complexity", "-Aclippy::new_without_default", + "-Aclippy::unnecessary_get_then_check", ] [build] diff --git a/.github/workflows/external.yml b/.github/workflows/external.yml index 2ded81bc787b3..40faac1020070 100644 --- a/.github/workflows/external.yml +++ b/.github/workflows/external.yml @@ -127,4 +127,5 @@ jobs: runs-on: [ubuntu-latest] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1 - - uses: mystenlabs/cargo-deny-action@main + - uses: taiki-e/install-action@cargo-deny + - run: cargo deny check diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 68ff61c03e218..b549b5639e485 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -375,7 +375,8 @@ jobs: runs-on: [ ubuntu-latest ] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1 - - uses: mystenlabs/cargo-deny-action@main + - uses: taiki-e/install-action@cargo-deny + - run: cargo deny check sui-excution-cut: name: cutting a new execution layer diff --git a/Cargo.lock b/Cargo.lock index ff1e2aa0376b5..e3d83e379f77a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -100,18 +100,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - -[[package]] -name = "aho-corasick" -version = "1.0.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -257,15 +248,6 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "anstream" version = "0.6.13" @@ -316,9 +298,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" dependencies = [ "backtrace", ] @@ -1064,12 +1046,13 @@ checksum = "62af46d040ba9df09edc6528dae9d8e49f5f3e82f55b7d2ec31a733c38dbc49d" [[package]] name = "atomicwrites" -version = "0.3.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb8f2cd6962fa53c0e2a9d3f97eaa7dbd1e3cbbeeb4745403515b42ae07b3ff6" +checksum = "fc7b2dbe9169059af0f821e811180fddc971fc210c776c133c7819ccd6e478db" dependencies = [ + "rustix 0.38.28", "tempfile", - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -1865,9 +1848,9 @@ dependencies = [ [[package]] name = "bimap" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc0455254eb5c6964c4545d8bac815e1a1be4f3afe0ae695ea539c12d728d44b" +checksum = "230c5f1ca6a325a32553f8640d31ac9b49f2411e901e427570154868b46da4f7" [[package]] name = "bin-version" @@ -2172,13 +2155,12 @@ dependencies = [ [[package]] name = "bstr" -version = "1.1.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45ea9b00a7b3f2988e9a65ad3917e62123c38dba709b666506207be96d1790b" +checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" dependencies = [ "memchr", - "once_cell", - "regex-automata 0.1.10", + "regex-automata 0.4.7", "serde", ] @@ -2301,9 +2283,9 @@ checksum = "3a4f925191b4367301851c6d99b09890311d74b0d43f274c0b34c86d308a3663" [[package]] name = "camino" -version = "1.1.2" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77df041dc383319cc661b428b6961a005db4d6808d5e12536931b1ca9556055" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" dependencies = [ "serde", ] @@ -2325,7 +2307,7 @@ checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" dependencies = [ "camino", "cargo-platform", - "semver 1.0.16", + "semver 1.0.23", "serde", "serde_json", ] @@ -2338,7 +2320,7 @@ checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" dependencies = [ "camino", "cargo-platform", - "semver 1.0.16", + "semver 1.0.23", "serde", "serde_json", "thiserror", @@ -2352,7 +2334,7 @@ checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", - "semver 1.0.16", + "semver 1.0.23", "serde", "serde_json", "thiserror", @@ -2400,9 +2382,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.13.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a327683d7499ecc47369531a679fe38acdd300e09bf8c852d08b1e10558622bd" +checksum = "345c78335be0624ed29012dc10c49102196c6882c12dde65d9f35b02da2aada8" dependencies = [ "smallvec", "target-lexicon", @@ -2663,17 +2645,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "colored-diff" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "410208eb08c3f3ad44b95b51c4fc0d5993cbcc9dd39cfadb4214b9115a97dcb5" -dependencies = [ - "ansi_term", - "dissimilar", - "itertools 0.10.5", -] - [[package]] name = "combine" version = "4.6.6" @@ -3647,26 +3618,26 @@ dependencies = [ [[package]] name = "determinator" -version = "0.10.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c644b91adb5bcc66d3533607b6d3ee5c1c2d858d2d95e41dd6aae673e29e0509" +checksum = "bf14b901cdfba3f731d01c4c184100e85f586a272d38874824175b845dbaeaf9" dependencies = [ "camino", "globset", "guppy", "guppy-workspace-hack", "once_cell", - "petgraph 0.6.2", + "petgraph 0.6.5", "rayon", "serde", - "toml 0.5.10", + "toml 0.5.11", ] [[package]] name = "diesel" -version = "2.1.4" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62c6fcf842f17f8c78ecf7c81d75c5ce84436b41ee07e03f490fbb5f5a8731d8" +checksum = "65e13bab2796f412722112327f3e575601a3e9cdcbe426f0d30dbf43f3f5dc71" dependencies = [ "bitflags 2.4.1", "byteorder", @@ -3695,11 +3666,12 @@ dependencies = [ [[package]] name = "diesel_derives" -version = "2.1.2" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef8337737574f55a468005a83499da720f20c65586241ffea339db9ecdfd2b44" +checksum = "e7f2c3de51e2ba6bf2a648285696137aaf0f5f487bcbea93972fe8a364e131a4" dependencies = [ "diesel_table_macro_syntax", + "dsl_auto_type", "proc-macro2 1.0.78", "quote 1.0.35", "syn 2.0.48", @@ -3707,9 +3679,9 @@ dependencies = [ [[package]] name = "diesel_migrations" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6036b3f0120c5961381b570ee20a02432d7e2d27ea60de9578799cf9156914ac" +checksum = "8a73ce704bad4231f001bff3314d91dce4aba0770cee8b233991859abc15c1f6" dependencies = [ "diesel", "migrations_internals", @@ -3718,9 +3690,9 @@ dependencies = [ [[package]] name = "diesel_table_macro_syntax" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5" +checksum = "209c735641a413bc68c4923a9d6ad4bcb3ca306b794edaa7eb0b3228a99ffb25" dependencies = [ "syn 2.0.48", ] @@ -3922,6 +3894,20 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +[[package]] +name = "dsl_auto_type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5d9abe6314103864cc2d8901b7ae224e0ab1a103a0a416661b4097b0779b607" +dependencies = [ + "darling 0.20.3", + "either", + "heck 0.5.0", + "proc-macro2 1.0.78", + "quote 1.0.35", + "syn 2.0.48", +] + [[package]] name = "dunce" version = "1.0.4" @@ -4441,7 +4427,7 @@ dependencies = [ "chrono", "ethers-core", "reqwest 0.11.20", - "semver 1.0.16", + "semver 1.0.23", "serde", "serde_json", "thiserror", @@ -4551,7 +4537,7 @@ dependencies = [ "path-slash", "rayon", "regex", - "semver 1.0.16", + "semver 1.0.23", "serde", "serde_json", "solang-parser", @@ -4734,7 +4720,7 @@ dependencies = [ "fastcrypto", "ff 0.13.0", "im", - "itertools 0.12.0", + "itertools 0.12.1", "lazy_static", "neptune", "num-bigint 0.4.4", @@ -5224,15 +5210,15 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.10" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" dependencies = [ - "aho-corasick 0.7.20", + "aho-corasick", "bstr", - "fnv", "log", - "regex", + "regex-automata 0.4.7", + "regex-syntax 0.8.2", ] [[package]] @@ -5291,31 +5277,32 @@ dependencies = [ [[package]] name = "guppy" -version = "0.15.2" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f822a2716041492e071691606474f5a7e4fa7c2acbfd7da7b29884fb448291c7" +checksum = "3bff2f6a9d515cf6453282af93363f93bdf570792a6f4f619756e46696d773fa" dependencies = [ + "ahash 0.8.11", "camino", - "cargo_metadata 0.15.4", + "cargo_metadata 0.18.1", "cfg-if", "debug-ignore", "fixedbitset 0.4.2", "guppy-summaries", "guppy-workspace-hack", - "indexmap 1.9.3", - "itertools 0.10.5", + "indexmap 2.2.6", + "itertools 0.13.0", "nested", "once_cell", "pathdiff", - "petgraph 0.6.2", + "petgraph 0.6.5", "rayon", - "semver 1.0.16", + "semver 1.0.23", "serde", "serde_json", "smallvec", "static_assertions", "target-spec", - "toml 0.5.10", + "toml 0.5.11", ] [[package]] @@ -5328,9 +5315,9 @@ dependencies = [ "cfg-if", "diffus", "guppy-workspace-hack", - "semver 1.0.16", + "semver 1.0.23", "serde", - "toml 0.5.10", + "toml 0.5.11", ] [[package]] @@ -5379,10 +5366,11 @@ dependencies = [ [[package]] name = "hakari" -version = "0.13.1" +version = "0.17.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2c76369039f6ac178748e96def487662aebbeb26d43070d01a0eadd53964994" +checksum = "12bd2b14c094d2793daf279eb7624f4525e26f555fbc1647613756cf83f44755" dependencies = [ + "ahash 0.8.11", "atomicwrites", "bimap", "camino", @@ -5393,15 +5381,15 @@ dependencies = [ "guppy-workspace-hack", "include_dir", "indenter", - "itertools 0.10.5", + "itertools 0.12.1", "owo-colors 3.5.0", "pathdiff", "rayon", "serde", "tabular", "target-spec", - "toml 0.5.10", - "toml_edit 0.15.0", + "toml 0.5.11", + "toml_edit 0.17.1", "twox-hash", ] @@ -6174,9 +6162,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" dependencies = [ "either", ] @@ -6479,7 +6467,7 @@ dependencies = [ "ena", "itertools 0.11.0", "lalrpop-util", - "petgraph 0.6.2", + "petgraph 0.6.5", "regex", "regex-syntax 0.8.2", "string_cache", @@ -6924,19 +6912,19 @@ dependencies = [ [[package]] name = "migrations_internals" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f23f71580015254b020e856feac3df5878c2c7a8812297edd6c0a485ac9dada" +checksum = "fd01039851e82f8799046eabbb354056283fb265c8ec0996af940f4e85a380ff" dependencies = [ "serde", - "toml 0.7.4", + "toml 0.8.16", ] [[package]] name = "migrations_macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cce3325ac70e67bbab5bd837a31cae01f1a6db64e0e744a33cb03a543469ef08" +checksum = "ffb161cc72176cb37aa47f1fc520d3ef02263d67d661f44f05d05a079e1237fd" dependencies = [ "migrations_internals", "proc-macro2 1.0.78", @@ -7481,7 +7469,7 @@ dependencies = [ "serde_yaml 0.8.26", "sha2 0.9.9", "tempfile", - "toml 0.5.10", + "toml 0.5.11", "toml_edit 0.14.4", "treeline", "vfs", @@ -7515,7 +7503,7 @@ dependencies = [ "once_cell", "serde", "simplelog", - "toml 0.5.10", + "toml 0.5.11", ] [[package]] @@ -7822,7 +7810,7 @@ dependencies = [ "socket2 0.4.9", "tap", "tokio-util 0.7.10 (git+https://github.com/mystenmark/tokio-madsim-fork.git?rev=e47aafebf98e9c1734a8848a1876d5946c44bdd1)", - "toml 0.5.10", + "toml 0.5.11", "tracing", "tracing-subscriber", ] @@ -8417,7 +8405,7 @@ dependencies = [ [[package]] name = "nexlint" version = "0.1.0" -source = "git+https://github.com/nextest-rs/nexlint.git?rev=94da5c787636dad779c340affa65219134d127f5#94da5c787636dad779c340affa65219134d127f5" +source = "git+https://github.com/nextest-rs/nexlint.git?rev=7ce56bd591242a57660ed05f14ca2483c37d895b#7ce56bd591242a57660ed05f14ca2483c37d895b" dependencies = [ "camino", "debug-ignore", @@ -8432,17 +8420,17 @@ dependencies = [ [[package]] name = "nexlint-lints" version = "0.1.0" -source = "git+https://github.com/nextest-rs/nexlint.git?rev=94da5c787636dad779c340affa65219134d127f5#94da5c787636dad779c340affa65219134d127f5" +source = "git+https://github.com/nextest-rs/nexlint.git?rev=7ce56bd591242a57660ed05f14ca2483c37d895b#7ce56bd591242a57660ed05f14ca2483c37d895b" dependencies = [ "anyhow", "camino", - "colored-diff", + "diffy", "globset", "guppy", "nexlint", "regex", "serde", - "toml 0.5.10", + "toml 0.5.11", ] [[package]] @@ -8469,9 +8457,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.24.3" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" dependencies = [ "bitflags 1.3.2", "cfg-if", @@ -8494,6 +8482,15 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nom8" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" +dependencies = [ + "memchr", +] + [[package]] name = "nonempty" version = "0.9.0" @@ -9091,7 +9088,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39b0deead1528fd0e5947a8546a9642a9777c25f6e1e26f34c97b204bbb465bd" dependencies = [ "heck 0.4.1", - "itertools 0.12.0", + "itertools 0.12.1", "proc-macro2 1.0.78", "proc-macro2-diagnostics", "quote 1.0.35", @@ -9530,12 +9527,12 @@ dependencies = [ [[package]] name = "petgraph" -version = "0.6.2" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5014253a1331579ce62aa67443b4a658c5e7dd03d4bc6d302b94474888143" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset 0.4.2", - "indexmap 1.9.3", + "indexmap 2.2.6", ] [[package]] @@ -9745,16 +9742,16 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "pprof" -version = "0.11.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e20150f965e0e4c925982b9356da71c84bcd56cb66ef4e894825837cbcf6613e" +checksum = "ef5c97c51bd34c7e742402e216abdeb44d415fbe6ae41d56b114723e953711cb" dependencies = [ "backtrace", "cfg-if", "findshlibs", "libc", "log", - "nix 0.24.3", + "nix 0.26.4", "once_cell", "parking_lot 0.12.1", "smallvec", @@ -9892,7 +9889,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" dependencies = [ "thiserror", - "toml 0.5.10", + "toml 0.5.11", ] [[package]] @@ -10079,7 +10076,7 @@ dependencies = [ "log", "multimap", "once_cell", - "petgraph 0.6.2", + "petgraph 0.6.5", "prettyplease", "prost 0.13.1", "prost-types 0.13.1", @@ -10540,7 +10537,7 @@ version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ - "aho-corasick 1.0.2", + "aho-corasick", "memchr", "regex-automata 0.4.7", "regex-syntax 0.8.2", @@ -10561,7 +10558,7 @@ version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ - "aho-corasick 1.0.2", + "aho-corasick", "memchr", "regex-syntax 0.8.2", ] @@ -11103,7 +11100,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.16", + "semver 1.0.23", ] [[package]] @@ -11540,9 +11537,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.16" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" dependencies = [ "serde", ] @@ -11576,9 +11573,9 @@ checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4" [[package]] name = "serde" -version = "1.0.202" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" +checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" dependencies = [ "serde_derive", ] @@ -11615,9 +11612,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.202" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" +checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" dependencies = [ "proc-macro2 1.0.78", "quote 1.0.35", @@ -15225,7 +15222,7 @@ dependencies = [ "rand 0.8.5", "regex", "reqwest 0.12.5", - "semver 1.0.16", + "semver 1.0.23", "serde", "serde_json", "serde_yaml 0.8.26", @@ -15272,7 +15269,7 @@ dependencies = [ "hex", "once_cell", "reqwest 0.11.20", - "semver 1.0.16", + "semver 1.0.23", "serde", "serde_json", "sha2 0.10.8", @@ -15283,9 +15280,9 @@ dependencies = [ [[package]] name = "symbolic-common" -version = "10.2.1" +version = "12.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b55cdc318ede251d0957f07afe5fed912119b8c1bc5a7804151826db999e737" +checksum = "26212dc7aeb75abb4cc84320a50dd482977089402f7b4043b454d6d79d8536e7" dependencies = [ "debugid", "memmap2", @@ -15295,9 +15292,9 @@ dependencies = [ [[package]] name = "symbolic-demangle" -version = "10.2.1" +version = "12.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79be897be8a483a81fff6a3a4e195b4ac838ef73ca42d348b3f722da9902e489" +checksum = "76f1b0155f588568b2df0d693b30aeedb59360b647b85fc3c23942e81e8cc97a" dependencies = [ "cpp_demangle", "rustc-demangle", @@ -15435,20 +15432,21 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.5" +version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "target-spec" -version = "1.3.1" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb0303f2cecb4171c439135b28c33fe9da7b9fd7816fe674761834da70c9778" +checksum = "419ccf3482090c626619fa2574290aaa00b696f9ab73af08fbf48260565431bf" dependencies = [ "cfg-expr", "guppy-workspace-hack", "serde", "target-lexicon", + "unicode-ident", ] [[package]] @@ -15948,9 +15946,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.10" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ "indexmap 1.9.3", "serde", @@ -16010,13 +16008,13 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.15.0" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1541ba70885967e662f69d31ab3aeca7b1aaecfcd58679590b893e9239c3646" +checksum = "a34cc558345efd7e88b9eda9626df2138b80bb46a7606f695e751c892bc7dac6" dependencies = [ - "combine", "indexmap 1.9.3", "itertools 0.10.5", + "nom8", "toml_datetime 0.5.1", ] @@ -16622,9 +16620,9 @@ checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-linebreak" @@ -16902,19 +16900,20 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", @@ -16939,9 +16938,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote 1.0.35", "wasm-bindgen-macro-support", @@ -16949,9 +16948,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2 1.0.78", "quote 1.0.35", @@ -16962,9 +16961,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "wasm-streams" diff --git a/Cargo.toml b/Cargo.toml index a32f2f842e4cf..22fa1a7415e6d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -237,6 +237,9 @@ overflow-checks = true # opt-level 1 gives >5x speedup for simulator tests without slowing down build times very much. opt-level = 1 +[workspace.lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(msim)', 'cfg(fail_points)'] } + # Dependencies that should be kept in sync through the whole workspace [workspace.dependencies] anyhow = "1.0.71" @@ -345,7 +348,6 @@ hashbrown = "0.12" hdrhistogram = "7.5.1" hex = "0.4.3" hex-literal = "0.3.4" -highlight = "all" http = "1" http-body = "1" humantime = "2.1.0" @@ -384,8 +386,8 @@ more-asserts = "0.3.1" msim = { git = "https://github.com/MystenLabs/mysten-sim.git", rev = "b320996d8dfb99b273fe31c0222c659332283c99", package = "msim" } msim-macros = { git = "https://github.com/MystenLabs/mysten-sim.git", rev = "b320996d8dfb99b273fe31c0222c659332283c99", package = "msim-macros" } multiaddr = "0.17.0" -nexlint = { git = "https://github.com/nextest-rs/nexlint.git", rev = "94da5c787636dad779c340affa65219134d127f5" } -nexlint-lints = { git = "https://github.com/nextest-rs/nexlint.git", rev = "94da5c787636dad779c340affa65219134d127f5" } +nexlint = { git = "https://github.com/nextest-rs/nexlint.git", rev = "7ce56bd591242a57660ed05f14ca2483c37d895b" } +nexlint-lints = { git = "https://github.com/nextest-rs/nexlint.git", rev = "7ce56bd591242a57660ed05f14ca2483c37d895b" } nonempty = "0.9.0" notify = "6.1.1" ntest = "0.9.0" @@ -398,12 +400,12 @@ ouroboros = "0.17" parking_lot = "0.12.1" parquet = "52" pkcs8 = { version = "0.9.0", features = ["std"] } -pprof = { version = "0.11.0", features = ["cpp", "frame-pointer"] } +pprof = { version = "0.13.0", features = ["cpp", "frame-pointer"] } pretty_assertions = "1.3.0" prettytable-rs = "0.10.0" proc-macro2 = "1.0.47" prometheus = "0.13.3" -prometheus-http-query = { version = "0.8", default_features = false, features = [ +prometheus-http-query = { version = "0.8", default-features = false, features = [ "rustls-tls", ] } prometheus-parse = { git = "https://github.com/asonnino/prometheus-parser.git", rev = "75334db" } @@ -418,7 +420,7 @@ rand = "0.8.5" rayon = "1.5.3" rcgen = "0.13" regex = "1.7.1" -reqwest = { version = "0.12", default_features = false, features = [ +reqwest = { version = "0.12", default-features = false, features = [ "http2", "json", "rustls-tls", @@ -426,10 +428,10 @@ reqwest = { version = "0.12", default_features = false, features = [ roaring = "0.10.6" ron = "0.8.0" rstest = "0.16.0" -rusoto_core = { version = "0.48.0", default_features = false, features = [ +rusoto_core = { version = "0.48.0", default-features = false, features = [ "rustls", ] } -rusoto_kms = { version = "0.48.0", default_features = false, features = [ +rusoto_kms = { version = "0.48.0", default-features = false, features = [ "rustls", ] } russh = "0.38.0" diff --git a/consensus/config/Cargo.toml b/consensus/config/Cargo.toml index aeb3978f12301..48697e2f7e91b 100644 --- a/consensus/config/Cargo.toml +++ b/consensus/config/Cargo.toml @@ -6,6 +6,9 @@ authors = ["Mysten Labs "] edition = "2021" publish = false +[lints] +workspace = true + [dependencies] fastcrypto.workspace = true mysten-network.workspace = true diff --git a/consensus/core/Cargo.toml b/consensus/core/Cargo.toml index 067901f002a16..2cb277834c9b2 100644 --- a/consensus/core/Cargo.toml +++ b/consensus/core/Cargo.toml @@ -6,6 +6,9 @@ authors = ["Mysten Labs "] edition = "2021" publish = false +[lints] +workspace = true + [dependencies] anemo.workspace = true anemo-tower.workspace = true diff --git a/consensus/core/src/authority_service.rs b/consensus/core/src/authority_service.rs index c1c38f9dfbfb6..94fa311e01a6b 100644 --- a/consensus/core/src/authority_service.rs +++ b/consensus/core/src/authority_service.rs @@ -133,7 +133,7 @@ impl NetworkService for AuthorityService { .metrics .node_metrics .rejected_future_blocks - .with_label_values(&[&peer_hostname]) + .with_label_values(&[peer_hostname]) .inc(); debug!( "Block {:?} timestamp ({} > {}) is too far in the future, rejected.", @@ -157,7 +157,7 @@ impl NetworkService for AuthorityService { .metrics .node_metrics .block_timestamp_drift_wait_ms - .with_label_values(&[peer_hostname, &"handle_send_block"]) + .with_label_values(&[peer_hostname, "handle_send_block"]) .inc_by(forward_time_drift.as_millis() as u64); debug!( "Block {:?} timestamp ({} > {}) is in the future, waiting for {}ms", @@ -192,7 +192,7 @@ impl NetworkService for AuthorityService { .metrics .node_metrics .rejected_blocks - .with_label_values(&[&"commit_lagging"]) + .with_label_values(&["commit_lagging"]) .inc(); debug!( "Block {:?} is rejected because last commit index is lagging quorum commit index too much ({} < {})", @@ -213,7 +213,7 @@ impl NetworkService for AuthorityService { .metrics .node_metrics .verified_blocks - .with_label_values(&[&peer_hostname]) + .with_label_values(&[peer_hostname]) .inc(); let missing_ancestors = self diff --git a/consensus/core/src/block_verifier.rs b/consensus/core/src/block_verifier.rs index 4d68f476455fe..2e876e9130f0b 100644 --- a/consensus/core/src/block_verifier.rs +++ b/consensus/core/src/block_verifier.rs @@ -206,6 +206,7 @@ impl BlockVerifier for SignedBlockVerifier { } } +#[allow(unused)] pub(crate) struct NoopBlockVerifier; impl BlockVerifier for NoopBlockVerifier { diff --git a/consensus/core/src/commit_observer.rs b/consensus/core/src/commit_observer.rs index f5c996687c029..a25113de387fb 100644 --- a/consensus/core/src/commit_observer.rs +++ b/consensus/core/src/commit_observer.rs @@ -23,14 +23,16 @@ use crate::{ /// Role of CommitObserver /// - Called by core when try_commit() returns newly committed leaders. /// - The newly committed leaders are sent to commit observer and then commit observer -/// gets subdags for each leader via the commit interpreter (linearizer) +/// gets subdags for each leader via the commit interpreter (linearizer) /// - The committed subdags are sent as consensus output via an unbounded tokio channel. +/// /// No back pressure mechanism is needed as backpressure is handled as input into /// consenus. +/// /// - Commit metadata including index is persisted in store, before the CommittedSubDag -/// is sent to the consumer. +/// is sent to the consumer. /// - When CommitObserver is initialized a last processed commit index can be used -/// to ensure any missing commits are re-sent. +/// to ensure any missing commits are re-sent. pub(crate) struct CommitObserver { context: Arc, /// Component to deterministically collect subdags for committed leaders. diff --git a/consensus/core/src/commit_syncer.rs b/consensus/core/src/commit_syncer.rs index 3594548eaa95e..f4ecf4fa2f951 100644 --- a/consensus/core/src/commit_syncer.rs +++ b/consensus/core/src/commit_syncer.rs @@ -567,7 +567,7 @@ impl CommitSyncer { .metrics .node_metrics .block_timestamp_drift_wait_ms - .with_label_values(&[peer_hostname, &"commit_syncer"]) + .with_label_values(&[peer_hostname, "commit_syncer"]) .inc_by(forward_drift); let forward_drift = Duration::from_millis(forward_drift); if forward_drift >= inner.context.parameters.max_forward_time_drift { diff --git a/consensus/core/src/dag_state.rs b/consensus/core/src/dag_state.rs index 5ebac04a585a1..aa7f3ca718f28 100644 --- a/consensus/core/src/dag_state.rs +++ b/consensus/core/src/dag_state.rs @@ -307,7 +307,7 @@ impl DagState { .metrics .node_metrics .dag_state_store_read_count - .with_label_values(&[&"get_blocks"]) + .with_label_values(&["get_blocks"]) .inc(); for ((index, _), result) in missing.into_iter().zip(store_results.into_iter()) { @@ -556,7 +556,7 @@ impl DagState { .metrics .node_metrics .dag_state_store_read_count - .with_label_values(&[&"contains_blocks"]) + .with_label_values(&["contains_blocks"]) .inc(); for ((index, _), result) in missing.into_iter().zip(store_results.into_iter()) { diff --git a/consensus/core/src/leader_scoring.rs b/consensus/core/src/leader_scoring.rs index eaafbcc439e00..380003debd37d 100644 --- a/consensus/core/src/leader_scoring.rs +++ b/consensus/core/src/leader_scoring.rs @@ -41,7 +41,7 @@ pub(crate) struct ReputationScoreCalculator<'a> { impl<'a> ReputationScoreCalculator<'a> { pub(crate) fn new( context: Arc, - unscored_subdags: &Vec, + unscored_subdags: &[CommittedSubDag], scoring_strategy: &'a dyn ScoringStrategy, ) -> Self { let num_authorities = context.committee.size(); diff --git a/consensus/core/src/leader_scoring_strategy.rs b/consensus/core/src/leader_scoring_strategy.rs index b635f5f474cd0..640e3667cd71c 100644 --- a/consensus/core/src/leader_scoring_strategy.rs +++ b/consensus/core/src/leader_scoring_strategy.rs @@ -10,6 +10,7 @@ use crate::{ stake_aggregator::{QuorumThreshold, StakeAggregator}, }; +#[allow(unused)] pub(crate) trait ScoringStrategy: Send + Sync { fn calculate_scores_for_leader(&self, subdag: &UnscoredSubdag, leader_slot: Slot) -> Vec; diff --git a/consensus/core/src/network/network_tests.rs b/consensus/core/src/network/network_tests.rs index d8113befb6b3a..cef1ff8530c54 100644 --- a/consensus/core/src/network/network_tests.rs +++ b/consensus/core/src/network/network_tests.rs @@ -31,7 +31,11 @@ trait ManagerBuilder { struct AnemoManagerBuilder {} impl ManagerBuilder for AnemoManagerBuilder { - fn build(&self, context: Arc, network_keypair: NetworkKeyPair) -> AnemoManager { + fn build( + &self, + context: Arc, + network_keypair: NetworkKeyPair, + ) -> impl NetworkManager> { AnemoManager::new(context, network_keypair) } } @@ -39,7 +43,11 @@ impl ManagerBuilder for AnemoManagerBuilder { struct TonicManagerBuilder {} impl ManagerBuilder for TonicManagerBuilder { - fn build(&self, context: Arc, network_keypair: NetworkKeyPair) -> TonicManager { + fn build( + &self, + context: Arc, + network_keypair: NetworkKeyPair, + ) -> impl NetworkManager> { TonicManager::new(context, network_keypair) } } diff --git a/consensus/core/src/stake_aggregator.rs b/consensus/core/src/stake_aggregator.rs index 7e907dee1fcb8..11501319e64e9 100644 --- a/consensus/core/src/stake_aggregator.rs +++ b/consensus/core/src/stake_aggregator.rs @@ -11,6 +11,7 @@ pub(crate) trait CommitteeThreshold { pub(crate) struct QuorumThreshold; +#[allow(unused)] pub(crate) struct ValidityThreshold; impl CommitteeThreshold for QuorumThreshold { diff --git a/consensus/core/src/storage/mem_store.rs b/consensus/core/src/storage/mem_store.rs index 2a88fc5bd71ad..ad23cd3652cee 100644 --- a/consensus/core/src/storage/mem_store.rs +++ b/consensus/core/src/storage/mem_store.rs @@ -20,10 +20,12 @@ use crate::{ }; /// In-memory storage for testing. +#[allow(unused)] pub(crate) struct MemStore { inner: RwLock, } +#[allow(unused)] struct Inner { blocks: BTreeMap<(Round, AuthorityIndex, BlockDigest), VerifiedBlock>, digests_by_authorities: BTreeSet<(AuthorityIndex, Round, BlockDigest)>, diff --git a/consensus/core/src/storage/mod.rs b/consensus/core/src/storage/mod.rs index 5c524be30318e..38258c87e8420 100644 --- a/consensus/core/src/storage/mod.rs +++ b/consensus/core/src/storage/mod.rs @@ -17,6 +17,7 @@ use crate::{ }; /// A common interface for consensus storage. +#[allow(unused)] pub(crate) trait Store: Send + Sync { /// Writes blocks, consensus commits and other data to store atomically. fn write(&self, write_batch: WriteBatch) -> ConsensusResult<()>; diff --git a/consensus/core/src/subscriber.rs b/consensus/core/src/subscriber.rs index bce04247c7a1d..7b350debf313c 100644 --- a/consensus/core/src/subscriber.rs +++ b/consensus/core/src/subscriber.rs @@ -152,7 +152,7 @@ impl Subscriber { .metrics .node_metrics .subscriber_connection_attempts - .with_label_values(&[&peer_hostname, "success"]) + .with_label_values(&[peer_hostname, "success"]) .inc(); blocks } @@ -162,7 +162,7 @@ impl Subscriber { .metrics .node_metrics .subscriber_connection_attempts - .with_label_values(&[&peer_hostname, "failure"]) + .with_label_values(&[peer_hostname, "failure"]) .inc(); continue 'subscription; } @@ -184,7 +184,7 @@ impl Subscriber { .metrics .node_metrics .subscribed_blocks - .with_label_values(&[&peer_hostname]) + .with_label_values(&[peer_hostname]) .inc(); let result = authority_service .handle_send_block(peer, block.clone()) diff --git a/consensus/core/src/synchronizer.rs b/consensus/core/src/synchronizer.rs index e3bc24c2e2b07..09193b7d06742 100644 --- a/consensus/core/src/synchronizer.rs +++ b/consensus/core/src/synchronizer.rs @@ -537,13 +537,13 @@ impl Synchronizer usize; } -/// Like `MallocSizeOf`, but only measures if the value hasn't already been -/// measured. For use with types like `Rc` and `Arc` when appropriate (e.g. -/// when there is no "primary" reference). -pub trait MallocConditionalSizeOf { - /// Measure the heap usage of all heap-allocated descendant structures, but - /// not the space taken up by the value itself, and only if that heap usage - /// hasn't already been measured. - fn conditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize; -} - -/// `MallocConditionalSizeOf` combined with `MallocShallowSizeOf`. -pub trait MallocConditionalShallowSizeOf { - /// `conditional_size_of` combined with `shallow_size_of`. - fn conditional_shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize; -} - impl<'a, T: ?Sized> MallocSizeOf for &'a T { fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { // Zero makes sense for a non-owning reference. @@ -510,11 +492,6 @@ where // impl !MallocSizeOf for Arc { } // impl !MallocShallowSizeOf for Arc { } -#[cfg(feature = "std")] -fn arc_ptr(s: &Arc) -> *const T { - &(**s) as *const T -} - #[cfg(feature = "std")] impl MallocUnconditionalSizeOf for Arc { fn unconditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { @@ -522,28 +499,6 @@ impl MallocUnconditionalSizeOf for Arc { } } -#[cfg(feature = "std")] -impl MallocConditionalShallowSizeOf for Arc { - fn conditional_shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - if ops.have_seen_ptr(arc_ptr(self)) { - 0 - } else { - self.unconditional_shallow_size_of(ops) - } - } -} - -#[cfg(feature = "std")] -impl MallocConditionalSizeOf for Arc { - fn conditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - if ops.have_seen_ptr(arc_ptr(self)) { - 0 - } else { - self.unconditional_size_of(ops) - } - } -} - /// If a mutex is stored directly as a member of a data type that is being measured, /// it is the unique owner of its contents and deserves to be measured. /// @@ -724,26 +679,6 @@ where } } -#[cfg(feature = "lru")] -impl MallocSizeOf for lru::LruCache -where - K: MallocSizeOf + rstd::cmp::Eq + rstd::hash::Hash, - V: MallocSizeOf, - S: rstd::hash::BuildHasher, -{ - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - let mut n = 0; - if let (Some(k), Some(v)) = (K::constant_size(), V::constant_size()) { - n += self.len() * (k + v) - } else { - n = self - .iter() - .fold(n, |acc, (k, v)| acc + k.size_of(ops) + v.size_of(ops)) - } - n - } -} - malloc_size_of_is_0!( [u8; 1], [u8; 2], [u8; 3], [u8; 4], [u8; 5], [u8; 6], [u8; 7], [u8; 8], [u8; 9], [u8; 10], [u8; 11], [u8; 12], [u8; 13], [u8; 14], [u8; 15], [u8; 16], [u8; 17], [u8; 18], [u8; 19], diff --git a/crates/mysten-util-mem/tests/derive.rs b/crates/mysten-util-mem/tests/derive.rs index 0beeb6fb11c47..ed4b0196b1978 100644 --- a/crates/mysten-util-mem/tests/derive.rs +++ b/crates/mysten-util-mem/tests/derive.rs @@ -55,27 +55,6 @@ fn derive_ignore() { assert!(t.malloc_size_of() < 3000); } -#[test] -#[cfg(all(feature = "lru", feature = "hashbrown"))] -fn derive_morecomplex() { - #[derive(MallocSizeOf)] - struct Trivia { - hm: hashbrown::HashMap>, - cache: lru::LruCache>, - } - - let mut t = Trivia { - hm: hashbrown::HashMap::new(), - cache: lru::LruCache::unbounded(), - }; - - t.hm.insert(1, vec![0u8; 2048]); - t.cache.put(1, vec![0u8; 2048]); - t.cache.put(2, vec![0u8; 4096]); - - assert!(t.malloc_size_of() > 8000); -} - #[test] fn derive_tuple() { #[derive(MallocSizeOf)] diff --git a/crates/sui-archival/src/lib.rs b/crates/sui-archival/src/lib.rs index 1dbcd632c254d..bdc5b6b3ab18a 100644 --- a/crates/sui-archival/src/lib.rs +++ b/crates/sui-archival/src/lib.rs @@ -61,6 +61,7 @@ use tracing::{error, info}; /// - epoch_1/ /// - 101000.chk /// - ... +/// /// Blob File Disk Format ///┌──────────────────────────────┐ ///│ magic <4 byte> │ diff --git a/crates/sui-aws-orchestrator/src/settings.rs b/crates/sui-aws-orchestrator/src/settings.rs index 8eaca609aa3a8..be4b17d3ca10e 100644 --- a/crates/sui-aws-orchestrator/src/settings.rs +++ b/crates/sui-aws-orchestrator/src/settings.rs @@ -121,7 +121,6 @@ impl Settings { .path_segments() .expect("Url should already be checked when loading settings") .collect::>()[1] - .to_string() .split('.') .next() .unwrap() diff --git a/crates/sui-benchmark/Cargo.toml b/crates/sui-benchmark/Cargo.toml index 54a9362e4675b..daad4d2158c51 100644 --- a/crates/sui-benchmark/Cargo.toml +++ b/crates/sui-benchmark/Cargo.toml @@ -6,6 +6,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] async-trait.workspace = true anyhow = { workspace = true, features = ["backtrace"] } diff --git a/crates/sui-benchmark/src/embedded_reconfig_observer.rs b/crates/sui-benchmark/src/embedded_reconfig_observer.rs index 9976491327bfd..42df82d81ce3b 100644 --- a/crates/sui-benchmark/src/embedded_reconfig_observer.rs +++ b/crates/sui-benchmark/src/embedded_reconfig_observer.rs @@ -23,6 +23,7 @@ use tracing::{error, info, trace}; /// and we happen to have a big committee rotation, it may /// fail to get quorum on the latest committee info from /// demissioned validators and then stop working. +/// /// Background: this is a temporary solution for stress before /// we see fullnode reconfiguration stabilizes. #[derive(Clone, Default)] diff --git a/crates/sui-bridge-cli/src/lib.rs b/crates/sui-bridge-cli/src/lib.rs index 3cafe745d4c9b..eacd3ca431f2c 100644 --- a/crates/sui-bridge-cli/src/lib.rs +++ b/crates/sui-bridge-cli/src/lib.rs @@ -313,7 +313,7 @@ pub fn make_action(chain_id: BridgeChainId, cmd: &GovernanceClientCommands) -> B } } -fn encode_call_data(function_selector: &str, params: &Vec) -> Vec { +fn encode_call_data(function_selector: &str, params: &[String]) -> Vec { let left = function_selector .find('(') .expect("Invalid function selector, no left parentheses"); diff --git a/crates/sui-bridge/src/types.rs b/crates/sui-bridge/src/types.rs index e722a79c65eea..4fb157254a5a4 100644 --- a/crates/sui-bridge/src/types.rs +++ b/crates/sui-bridge/src/types.rs @@ -354,7 +354,7 @@ impl BridgeAction { // Digest of BridgeAction (with Keccak256 hasher) pub fn digest(&self) -> BridgeActionDigest { let mut hasher = Keccak256::default(); - hasher.update(&self.to_bytes()); + hasher.update(self.to_bytes()); BridgeActionDigest::new(hasher.finalize().into()) } diff --git a/crates/sui-config/Cargo.toml b/crates/sui-config/Cargo.toml index 87f5ab16a33ad..9704c09230224 100644 --- a/crates/sui-config/Cargo.toml +++ b/crates/sui-config/Cargo.toml @@ -6,6 +6,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] anemo.workspace = true anyhow = { workspace = true, features = ["backtrace"] } diff --git a/crates/sui-config/src/node.rs b/crates/sui-config/src/node.rs index ff87d1c8cc506..9637ffe4e2be8 100644 --- a/crates/sui-config/src/node.rs +++ b/crates/sui-config/src/node.rs @@ -19,7 +19,6 @@ use std::num::NonZeroUsize; use std::path::{Path, PathBuf}; use std::sync::Arc; use std::time::Duration; -use std::usize; use sui_keys::keypair_file::{read_authority_keypair_from_file, read_keypair_from_file}; use sui_types::base_types::{ObjectID, SuiAddress}; use sui_types::committee::EpochId; diff --git a/crates/sui-config/src/p2p.rs b/crates/sui-config/src/p2p.rs index 4be9e93ddde90..7b7b4ba59198d 100644 --- a/crates/sui-config/src/p2p.rs +++ b/crates/sui-config/src/p2p.rs @@ -267,6 +267,7 @@ impl StateSyncConfig { /// * If the node marks itself as Private, only nodes that have it in /// their `allowlisted_peers` or `seed_peers` will try to connect to it. /// * If not set, defaults to Public. +/// /// AccessType is useful when a network of nodes want to stay private. To achieve this, /// mark every node in this network as `Private` and allowlist/seed them to each other. #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] diff --git a/crates/sui-core/Cargo.toml b/crates/sui-core/Cargo.toml index a2103140851db..2c596b502a54b 100644 --- a/crates/sui-core/Cargo.toml +++ b/crates/sui-core/Cargo.toml @@ -6,6 +6,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] anyhow = { workspace = true, features = ["backtrace"] } arc-swap.workspace = true diff --git a/crates/sui-core/src/authority.rs b/crates/sui-core/src/authority.rs index 409a9f67f8de4..c94076206a994 100644 --- a/crates/sui-core/src/authority.rs +++ b/crates/sui-core/src/authority.rs @@ -3651,12 +3651,12 @@ impl AuthorityState { .rev() .skip_while(|d| cursor.is_some() && Some(*d) != cursor) .skip(usize::from(cursor.is_some())); - return Ok(iter.take(limit.unwrap_or(usize::max_value())).collect()); + return Ok(iter.take(limit.unwrap_or(usize::MAX)).collect()); } else { let iter = iter .skip_while(|d| cursor.is_some() && Some(*d) != cursor) .skip(usize::from(cursor.is_some())); - return Ok(iter.take(limit.unwrap_or(usize::max_value())).collect()); + return Ok(iter.take(limit.unwrap_or(usize::MAX)).collect()); } } self.get_indexes()? @@ -5469,7 +5469,6 @@ impl NodeStateDump { Ok(path) } - #[cfg(not(release))] pub fn read_from_file(path: &PathBuf) -> Result { let file = File::open(path)?; serde_json::from_reader(file).map_err(|e| anyhow::anyhow!(e)) diff --git a/crates/sui-core/src/authority/authority_per_epoch_store.rs b/crates/sui-core/src/authority/authority_per_epoch_store.rs index 367e77965d1d7..9e922112eff57 100644 --- a/crates/sui-core/src/authority/authority_per_epoch_store.rs +++ b/crates/sui-core/src/authority/authority_per_epoch_store.rs @@ -125,8 +125,8 @@ pub(crate) type EncG = bls12381::G2Element; // CertLockGuard and CertTxGuard are functionally identical right now, but we retain a distinction // anyway. If we need to support distributed object storage, having this distinction will be // useful, as we will most likely have to re-implement a retry / write-ahead-log at that point. -pub struct CertLockGuard(MutexGuard); -pub struct CertTxGuard(CertLockGuard); +pub struct CertLockGuard(#[allow(unused)] MutexGuard); +pub struct CertTxGuard(#[allow(unused)] CertLockGuard); impl CertTxGuard { pub fn release(self) {} @@ -370,15 +370,15 @@ pub struct AuthorityEpochTables { /// The tables below manage shared object locks / versions. There are three ways they can be /// updated: /// 1. (validators only): Upon receiving a certified transaction from consensus, the authority - /// assigns the next version to each shared object of the transaction. The next versions of - /// the shared objects are updated as well. + /// assigns the next version to each shared object of the transaction. The next versions of + /// the shared objects are updated as well. /// 2. (validators only): Upon receiving a new consensus commit, the authority assigns the - /// next version of the randomness state object to an expected future transaction to be - /// generated after the next random value is available. The next version of the randomness - /// state object is updated as well. + /// next version of the randomness state object to an expected future transaction to be + /// generated after the next random value is available. The next version of the randomness + /// state object is updated as well. /// 3. (fullnodes + validators): Upon receiving a certified effect from state sync, or - /// transaction orchestrator fast execution path, the node assigns the shared object - /// versions from the transaction effect. Next object versions are not updated. + /// transaction orchestrator fast execution path, the node assigns the shared object + /// versions from the transaction effect. Next object versions are not updated. /// /// REQUIRED: all authorities must assign the same shared object versions for each transaction. assigned_shared_object_versions: DBMap>, diff --git a/crates/sui-core/src/authority/authority_store_pruner.rs b/crates/sui-core/src/authority/authority_store_pruner.rs index aca327f15f5a2..17f34f5755f89 100644 --- a/crates/sui-core/src/authority/authority_store_pruner.rs +++ b/crates/sui-core/src/authority/authority_store_pruner.rs @@ -1152,6 +1152,8 @@ mod pprof_tests { } #[tokio::test] + // un-ignore once https://github.com/tikv/pprof-rs/issues/250 is fixed + #[ignore] async fn ensure_no_tombstone_fragmentation_in_stack_frame_with_ignore_tombstones( ) -> Result<(), anyhow::Error> { // This test writes a bunch of objects to objects table, invokes pruning on it and @@ -1188,6 +1190,8 @@ mod pprof_tests { } #[tokio::test] + // un-ignore once https://github.com/tikv/pprof-rs/issues/250 is fixed + #[ignore] async fn ensure_no_tombstone_fragmentation_in_stack_frame_after_flush( ) -> Result<(), anyhow::Error> { // This test writes a bunch of objects to objects table, invokes pruning on it and diff --git a/crates/sui-core/src/authority/authority_store_tables.rs b/crates/sui-core/src/authority/authority_store_tables.rs index d61187a3050d3..db8394b2de2d5 100644 --- a/crates/sui-core/src/authority/authority_store_tables.rs +++ b/crates/sui-core/src/authority/authority_store_tables.rs @@ -71,9 +71,10 @@ pub struct AuthorityPerpetualTables { /// A map between the transaction digest of a certificate to the effects of its execution. /// We store effects into this table in two different cases: /// 1. When a transaction is synced through state_sync, we store the effects here. These effects - /// are known to be final in the network, but may not have been executed locally yet. + /// are known to be final in the network, but may not have been executed locally yet. /// 2. When the transaction is executed locally on this node, we store the effects here. This means that - /// it's possible to store the same effects twice (once for the synced transaction, and once for the executed). + /// it's possible to store the same effects twice (once for the synced transaction, and once for the executed). + /// /// It's also possible for the effects to be reverted if the transaction didn't make it into the epoch. #[default_options_override_fn = "effects_table_default_config"] pub(crate) effects: DBMap, diff --git a/crates/sui-core/src/authority/shared_object_congestion_tracker.rs b/crates/sui-core/src/authority/shared_object_congestion_tracker.rs index 4732afe4b7399..041e523594074 100644 --- a/crates/sui-core/src/authority/shared_object_congestion_tracker.rs +++ b/crates/sui-core/src/authority/shared_object_congestion_tracker.rs @@ -78,9 +78,7 @@ impl SharedObjectCongestionTracker { previously_deferred_tx_digests: &HashMap, commit_round: Round, ) -> Option<(DeferralKey, Vec)> { - let Some(tx_cost) = self.get_tx_cost(cert) else { - return None; - }; + let tx_cost = self.get_tx_cost(cert)?; let shared_input_objects: Vec<_> = cert.shared_input_objects().collect(); if shared_input_objects.is_empty() { diff --git a/crates/sui-core/src/authority/test_authority_builder.rs b/crates/sui-core/src/authority/test_authority_builder.rs index a1fc9c40020c8..6ba9dd32d4801 100644 --- a/crates/sui-core/src/authority/test_authority_builder.rs +++ b/crates/sui-core/src/authority/test_authority_builder.rs @@ -227,10 +227,7 @@ impl<'a> TestAuthorityBuilder<'a> { epoch_flags, ) .unwrap(); - let expensive_safety_checks = match self.expensive_safety_checks { - None => ExpensiveSafetyCheckConfig::default(), - Some(config) => config, - }; + let expensive_safety_checks = self.expensive_safety_checks.unwrap_or_default(); let cache_traits = build_execution_cache(&epoch_start_configuration, ®istry, &authority_store); diff --git a/crates/sui-core/src/authority_aggregator.rs b/crates/sui-core/src/authority_aggregator.rs index 65955171bcbec..8365a2064fb3b 100644 --- a/crates/sui-core/src/authority_aggregator.rs +++ b/crates/sui-core/src/authority_aggregator.rs @@ -277,6 +277,7 @@ pub enum AggregatorProcessCertificateError { } pub fn group_errors(errors: Vec<(SuiError, Vec, StakeUnit)>) -> GroupedErrors { + #[allow(clippy::mutable_key_type)] let mut grouped_errors = HashMap::new(); for (error, names, stake) in errors { let entry = grouped_errors.entry(error).or_insert((0, vec![])); diff --git a/crates/sui-core/src/checkpoints/checkpoint_executor/mod.rs b/crates/sui-core/src/checkpoints/checkpoint_executor/mod.rs index b1872a9f21723..fd0a9c90a34d8 100644 --- a/crates/sui-core/src/checkpoints/checkpoint_executor/mod.rs +++ b/crates/sui-core/src/checkpoints/checkpoint_executor/mod.rs @@ -94,7 +94,7 @@ pub struct CheckpointTimeoutConfig { // the function is still very cheap to call so this is okay. thread_local! { static SCHEDULING_TIMEOUT: once_cell::sync::OnceCell = - once_cell::sync::OnceCell::new(); + const { once_cell::sync::OnceCell::new() }; } #[cfg(msim)] diff --git a/crates/sui-core/src/consensus_adapter.rs b/crates/sui-core/src/consensus_adapter.rs index 8b33d8031fac7..f67388061656c 100644 --- a/crates/sui-core/src/consensus_adapter.rs +++ b/crates/sui-core/src/consensus_adapter.rs @@ -1029,12 +1029,12 @@ impl<'a> InflightDropGuard<'a> { adapter .metrics .sequencing_certificate_inflight - .with_label_values(&[&tx_type]) + .with_label_values(&[tx_type]) .inc(); adapter .metrics .sequencing_certificate_attempt - .with_label_values(&[&tx_type]) + .with_label_values(&[tx_type]) .inc(); Self { adapter, diff --git a/crates/sui-core/src/rest_index.rs b/crates/sui-core/src/rest_index.rs index e999cfe2abc2e..ade98f8ada4dd 100644 --- a/crates/sui-core/src/rest_index.rs +++ b/crates/sui-core/src/rest_index.rs @@ -114,9 +114,9 @@ struct IndexStoreTables { /// /// A few uses for this singleton: /// - determining if the DB has been initialized (as some tables will still be empty post - /// initializatio) + /// initialization) /// - version of the DB. Everytime a new table or schema is changed the version number needs to - /// be incremented. + /// be incremented. meta: DBMap<(), MetadataInfo>, /// An index of extra metadata for Transactions. diff --git a/crates/sui-core/src/transaction_manager.rs b/crates/sui-core/src/transaction_manager.rs index 5accb919a8680..d7796b69edbc2 100644 --- a/crates/sui-core/src/transaction_manager.rs +++ b/crates/sui-core/src/transaction_manager.rs @@ -62,6 +62,7 @@ pub struct TransactionManager { #[derive(Clone, Debug)] pub struct PendingCertificateStats { // The time this certificate enters transaction manager. + #[allow(unused)] pub enqueue_time: Instant, // The time this certificate becomes ready for execution. pub ready_time: Option, @@ -966,9 +967,7 @@ impl TransactionQueue { /// After removing the digest, first() will return the new oldest entry /// in the queue (which may be unchanged). fn remove(&mut self, digest: &TransactionDigest) -> Option { - let Some(when) = self.digests.remove(digest) else { - return None; - }; + let when = self.digests.remove(digest)?; // This loop removes all previously inserted entries that no longer // correspond to live entries in self.digests. When the loop terminates, diff --git a/crates/sui-core/src/unit_tests/authority_aggregator_tests.rs b/crates/sui-core/src/unit_tests/authority_aggregator_tests.rs index cef3075a2e93f..cc3ffa82fb08e 100644 --- a/crates/sui-core/src/unit_tests/authority_aggregator_tests.rs +++ b/crates/sui-core/src/unit_tests/authority_aggregator_tests.rs @@ -693,7 +693,7 @@ fn get_genesis_agg( .build_custom_clients(clients) } -fn get_agg_at_epoch( +fn get_agg_at_epoch( authorities: BTreeMap, clients: BTreeMap, epoch: EpochId, diff --git a/crates/sui-core/src/unit_tests/execution_driver_tests.rs b/crates/sui-core/src/unit_tests/execution_driver_tests.rs index e9a5f381dceeb..a138886c4f6a7 100644 --- a/crates/sui-core/src/unit_tests/execution_driver_tests.rs +++ b/crates/sui-core/src/unit_tests/execution_driver_tests.rs @@ -46,7 +46,7 @@ use tokio::time::{sleep, timeout}; #[allow(dead_code)] async fn wait_for_certs( stream: &mut UnboundedReceiver, - certs: &Vec, + certs: &[VerifiedCertificate], ) { if certs.is_empty() { if timeout(Duration::from_secs(30), stream.recv()) diff --git a/crates/sui-e2e-tests/Cargo.toml b/crates/sui-e2e-tests/Cargo.toml index 4d7e294f06c75..970458f3a9e94 100644 --- a/crates/sui-e2e-tests/Cargo.toml +++ b/crates/sui-e2e-tests/Cargo.toml @@ -6,6 +6,9 @@ publish = false edition = "2021" version.workspace = true +[lints] +workspace = true + [dependencies] [dev-dependencies] @@ -67,4 +70,4 @@ passkey-client.workspace = true passkey-authenticator.workspace = true coset.workspace = true url.workspace = true -p256.workspace = true \ No newline at end of file +p256.workspace = true diff --git a/crates/sui-e2e-tests/tests/dynamic_committee_tests.rs b/crates/sui-e2e-tests/tests/dynamic_committee_tests.rs index 3d0b374dfefa8..454328bace837 100644 --- a/crates/sui-e2e-tests/tests/dynamic_committee_tests.rs +++ b/crates/sui-e2e-tests/tests/dynamic_committee_tests.rs @@ -57,6 +57,7 @@ trait StatePredicate { runner: &StressTestRunner, effects: &TransactionEffects, ); + #[allow(unused)] async fn post_epoch_post_condition( &mut self, runner: &StressTestRunner, @@ -351,7 +352,7 @@ async fn fuzz_dynamic_committee() { let num_operations = 10; // Add more actions here as we create them - let actions = vec![Box::new(add_stake::RequestAddStakeGen)]; + let actions = [Box::new(add_stake::RequestAddStakeGen)]; let mut runner = StressTestRunner::new().await; diff --git a/crates/sui-faucet/src/faucet/simple_faucet.rs b/crates/sui-faucet/src/faucet/simple_faucet.rs index 0bdbb8641d764..00133d92dcd03 100644 --- a/crates/sui-faucet/src/faucet/simple_faucet.rs +++ b/crates/sui-faucet/src/faucet/simple_faucet.rs @@ -328,6 +328,7 @@ impl SimpleFaucet { /// Check if the gas coin is still valid. A valid gas coin /// 1. Exists presently /// 2. is a gas coin + /// /// If the coin is valid, return Ok(Some(GasCoin)) /// If the coin invalid, return Ok(None) /// If the fullnode returns an unexpected error, returns Err(e) @@ -1303,7 +1304,7 @@ mod tests { .await .unwrap(); - let amounts = &vec![coin_amount]; + let amounts = &[coin_amount]; // Create a vector containing five randomly generated addresses let target_addresses: Vec = (0..5) @@ -1384,7 +1385,7 @@ mod tests { .await .unwrap(); - let amounts = &vec![1; 1]; + let amounts = &[1; 1]; // Create a vector containing five randomly generated addresses let target_addresses: Vec = (0..5) .map(|_| SuiAddress::random_for_testing_only()) diff --git a/crates/sui-framework-tests/Cargo.toml b/crates/sui-framework-tests/Cargo.toml index ad593b3634716..2093974fa826f 100644 --- a/crates/sui-framework-tests/Cargo.toml +++ b/crates/sui-framework-tests/Cargo.toml @@ -7,6 +7,9 @@ description = "Runs Move tests for sui-framework" license = "Apache-2.0" publish = false +[lints] +workspace = true + [[test]] name = "move_tests" harness = false diff --git a/crates/sui-framework/src/lib.rs b/crates/sui-framework/src/lib.rs index dfc8679cd2fc6..f51f746585acb 100644 --- a/crates/sui-framework/src/lib.rs +++ b/crates/sui-framework/src/lib.rs @@ -256,9 +256,7 @@ pub async fn compare_system_package( let mut new_normalized = new_pkg.normalize(binary_config).ok()?; for (name, cur_module) in cur_normalized { - let Some(new_module) = new_normalized.remove(&name) else { - return None; - }; + let new_module = new_normalized.remove(&name)?; if let Err(e) = compatibility.check(&cur_module, &new_module) { error!("Compatibility check failed, for new version of {id}::{name}: {e:?}"); diff --git a/crates/sui-genesis-builder/Cargo.toml b/crates/sui-genesis-builder/Cargo.toml index 32e62bf08712b..c439f28b4caf7 100644 --- a/crates/sui-genesis-builder/Cargo.toml +++ b/crates/sui-genesis-builder/Cargo.toml @@ -6,6 +6,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] anyhow.workspace = true bcs.workspace = true diff --git a/crates/sui-genesis-builder/src/lib.rs b/crates/sui-genesis-builder/src/lib.rs index fbab297181074..b0925b19951f3 100644 --- a/crates/sui-genesis-builder/src/lib.rs +++ b/crates/sui-genesis-builder/src/lib.rs @@ -693,11 +693,11 @@ fn create_genesis_context( ) -> TxContext { let mut hasher = DefaultHash::default(); hasher.update(b"sui-genesis"); - hasher.update(&bcs::to_bytes(genesis_chain_parameters).unwrap()); - hasher.update(&bcs::to_bytes(genesis_validators).unwrap()); - hasher.update(&bcs::to_bytes(token_distribution_schedule).unwrap()); + hasher.update(bcs::to_bytes(genesis_chain_parameters).unwrap()); + hasher.update(bcs::to_bytes(genesis_validators).unwrap()); + hasher.update(bcs::to_bytes(token_distribution_schedule).unwrap()); for system_package in system_packages { - hasher.update(&bcs::to_bytes(system_package.bytes()).unwrap()); + hasher.update(bcs::to_bytes(system_package.bytes()).unwrap()); } let hash = hasher.finalize(); diff --git a/crates/sui-graphql-e2e-tests/Cargo.toml b/crates/sui-graphql-e2e-tests/Cargo.toml index fb8642a2a404e..1bc925321f16e 100644 --- a/crates/sui-graphql-e2e-tests/Cargo.toml +++ b/crates/sui-graphql-e2e-tests/Cargo.toml @@ -7,6 +7,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dev-dependencies] datatest-stable.workspace = true sui-graphql-rpc.workspace = true diff --git a/crates/sui-graphql-rpc/src/server/version.rs b/crates/sui-graphql-rpc/src/server/version.rs index 0dcb46a5ba891..b73bc9b9d215d 100644 --- a/crates/sui-graphql-rpc/src/server/version.rs +++ b/crates/sui-graphql-rpc/src/server/version.rs @@ -17,6 +17,7 @@ use crate::{ pub(crate) static VERSION_HEADER: HeaderName = HeaderName::from_static("x-sui-rpc-version"); +#[allow(unused)] pub(crate) struct SuiRpcVersion(Vec, Vec>); const NAMED_VERSIONS: [&str; 3] = ["beta", "legacy", "stable"]; diff --git a/crates/sui-graphql-rpc/src/types/event.rs b/crates/sui-graphql-rpc/src/types/event.rs index e2555bb0214eb..cb558c2fba6c3 100644 --- a/crates/sui-graphql-rpc/src/types/event.rs +++ b/crates/sui-graphql-rpc/src/types/event.rs @@ -259,9 +259,6 @@ impl Event { checkpoint_sequence_number: stored_tx.checkpoint_sequence_number, #[cfg(feature = "postgres-feature")] senders: vec![Some(native_event.sender.to_vec())], - #[cfg(feature = "mysql-feature")] - #[cfg(not(feature = "postgres-feature"))] - senders: serde_json::to_value(vec![native_event.sender.to_vec()]).unwrap(), package: native_event.package_id.to_vec(), module: native_event.transaction_module.to_string(), event_type: native_event @@ -290,17 +287,6 @@ impl Event { { stored.senders.first() } - #[cfg(feature = "mysql-feature")] - #[cfg(not(feature = "postgres-feature"))] - { - stored - .senders - .as_array() - .ok_or_else(|| { - Error::Internal("Failed to parse event senders as array".to_string()) - })? - .first() - } }) else { return Err(Error::Internal("No senders found for event".to_string())); }; diff --git a/crates/sui-graphql-rpc/src/types/move_object.rs b/crates/sui-graphql-rpc/src/types/move_object.rs index c5cf724604089..cabe71c92bf60 100644 --- a/crates/sui-graphql-rpc/src/types/move_object.rs +++ b/crates/sui-graphql-rpc/src/types/move_object.rs @@ -50,6 +50,7 @@ pub(crate) enum MoveObjectDowncastError { /// This interface is implemented by types that represent a Move object on-chain (A Move value whose /// type has `key`). +#[allow(clippy::duplicated_attributes)] #[derive(Interface)] #[graphql( name = "IMoveObject", diff --git a/crates/sui-graphql-rpc/src/types/object.rs b/crates/sui-graphql-rpc/src/types/object.rs index 5cb49d63ff03c..eebe0b86447ed 100644 --- a/crates/sui-graphql-rpc/src/types/object.rs +++ b/crates/sui-graphql-rpc/src/types/object.rs @@ -221,6 +221,7 @@ pub(crate) struct HistoricalObjectCursor { /// Interface implemented by on-chain values that are addressable by an ID (also referred to as its /// address). This includes Move objects and packages. +#[allow(clippy::duplicated_attributes)] #[derive(Interface)] #[graphql( name = "IObject", @@ -579,9 +580,7 @@ impl ObjectImpl<'_> { pub(crate) async fn owner(&self, ctx: &Context<'_>) -> Option { use NativeOwner as O; - let Some(native) = self.0.native_impl() else { - return None; - }; + let native = self.0.native_impl()?; match native.owner { O::AddressOwner(address) => { diff --git a/crates/sui-graphql-rpc/src/types/owner.rs b/crates/sui-graphql-rpc/src/types/owner.rs index 3986a39f6ad23..8d790fdc2d699 100644 --- a/crates/sui-graphql-rpc/src/types/owner.rs +++ b/crates/sui-graphql-rpc/src/types/owner.rs @@ -56,6 +56,7 @@ pub(crate) struct OwnerImpl { /// are identified by an address which can represent either the public key of an account or another /// object. The same address can only refer to an account or an object, never both, but it is not /// possible to know which up-front. +#[allow(clippy::duplicated_attributes)] #[derive(Interface)] #[graphql( name = "IOwner", diff --git a/crates/sui-graphql-rpc/src/types/transaction_block/tx_lookups.rs b/crates/sui-graphql-rpc/src/types/transaction_block/tx_lookups.rs index e3d551976d5d4..8077f4b4d5da4 100644 --- a/crates/sui-graphql-rpc/src/types/transaction_block/tx_lookups.rs +++ b/crates/sui-graphql-rpc/src/types/transaction_block/tx_lookups.rs @@ -293,9 +293,7 @@ pub(crate) fn subqueries(filter: &TransactionBlockFilter, tx_bounds: TxBounds) - subqueries.push(("tx_digests", select_ids(txs, tx_bounds))); } - let Some((_, mut subquery)) = subqueries.pop() else { - return None; - }; + let (_, mut subquery) = subqueries.pop()?; if !subqueries.is_empty() { subquery = query!("SELECT tx_sequence_number FROM ({}) AS initial", subquery); diff --git a/crates/sui-indexer/src/store/mod.rs b/crates/sui-indexer/src/store/mod.rs index 920cc5817499c..f520f6afa1414 100644 --- a/crates/sui-indexer/src/store/mod.rs +++ b/crates/sui-indexer/src/store/mod.rs @@ -11,7 +11,7 @@ pub mod pg_partition_manager; pub mod diesel_macro { thread_local! { - pub static CALLED_FROM_BLOCKING_POOL: std::cell::RefCell = std::cell::RefCell::new(false); + pub static CALLED_FROM_BLOCKING_POOL: std::cell::RefCell = const { std::cell::RefCell::new(false) }; } #[macro_export] @@ -292,10 +292,11 @@ pub mod diesel_macro { /// Check that we are in a context conducive to making blocking calls. /// This is done by either: /// - Checking that we are not inside a tokio runtime context + /// /// Or: /// - If we are inside a tokio runtime context, ensure that the call went through - /// `IndexerReader::spawn_blocking` which properly moves the blocking call to a blocking thread - /// pool. + /// `IndexerReader::spawn_blocking` which properly moves the blocking call to a blocking thread + /// pool. #[macro_export] macro_rules! blocking_call_is_ok_or_panic { () => {{ diff --git a/crates/sui-indexer/src/store/pg_indexer_store.rs b/crates/sui-indexer/src/store/pg_indexer_store.rs index 7a2ac3cdb8854..23080f3f1fcaa 100644 --- a/crates/sui-indexer/src/store/pg_indexer_store.rs +++ b/crates/sui-indexer/src/store/pg_indexer_store.rs @@ -135,6 +135,7 @@ SET object_version = EXCLUDED.object_version, pub struct PgIndexerStoreConfig { pub parallel_chunk_size: usize, pub parallel_objects_chunk_size: usize, + #[allow(unused)] pub epochs_to_keep: Option, } diff --git a/crates/sui-json-rpc-tests/Cargo.toml b/crates/sui-json-rpc-tests/Cargo.toml index af78d3ccc56df..0f688d4b455e0 100644 --- a/crates/sui-json-rpc-tests/Cargo.toml +++ b/crates/sui-json-rpc-tests/Cargo.toml @@ -6,6 +6,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] [dev-dependencies] diff --git a/crates/sui-json-rpc-types/src/sui_transaction.rs b/crates/sui-json-rpc-types/src/sui_transaction.rs index dcd685349ec2a..8936d54831102 100644 --- a/crates/sui-json-rpc-types/src/sui_transaction.rs +++ b/crates/sui-json-rpc-types/src/sui_transaction.rs @@ -1803,7 +1803,7 @@ impl SuiProgrammableTransactionBlock { } fn resolve_input_type( - inputs: &Vec, + inputs: &[CallArg], commands: &[Command], module_cache: &impl GetModule, ) -> Vec> { diff --git a/crates/sui-json/src/lib.rs b/crates/sui-json/src/lib.rs index 6c367c0d6ba15..4782ed9e57116 100644 --- a/crates/sui-json/src/lib.rs +++ b/crates/sui-json/src/lib.rs @@ -703,7 +703,7 @@ fn resolve_object_vec_arg(idx: usize, arg: &SuiJsonValue) -> Result>( /// - Base64 encoded `privkey` for Raw key /// - Bech32 encoded private key prefixed with `suiprivkey` /// - Hex encoded `privkey` for Raw key +/// /// If `require_secp256k1` is true, it will return an error if the key is not Secp256k1. pub fn read_key(path: &PathBuf, require_secp256k1: bool) -> Result { if !path.exists() { diff --git a/crates/sui-macros/Cargo.toml b/crates/sui-macros/Cargo.toml index c7e99bd255f69..cb274a3af898c 100644 --- a/crates/sui-macros/Cargo.toml +++ b/crates/sui-macros/Cargo.toml @@ -6,6 +6,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] sui-proc-macros.workspace = true once_cell.workspace = true diff --git a/crates/sui-macros/src/lib.rs b/crates/sui-macros/src/lib.rs index 6e3cd85ca19be..a036a3dbfcfb0 100644 --- a/crates/sui-macros/src/lib.rs +++ b/crates/sui-macros/src/lib.rs @@ -528,7 +528,7 @@ mod test { assert_eq!(Foo::new(1, 2).b, 2); assert_eq!(new_foo(1).a, 1); - let v = vec![Foo::new(1, 2), Foo::new(3, 2)]; + let v = [Foo::new(1, 2), Foo::new(3, 2)]; assert_eq!(v[0].a, 1); assert_eq!(v[1].b, 2); @@ -720,7 +720,7 @@ mod test { assert_eq!(Foo::new(1, 2).b, 2); assert_eq!(new_foo(1).a, 1); - let v = vec![Foo::new(1, 2), Foo::new(3, 2)]; + let v = [Foo::new(1, 2), Foo::new(3, 2)]; assert_eq!(v[0].a, 1); assert_eq!(v[1].b, 2); diff --git a/crates/sui-move/src/unit_test.rs b/crates/sui-move/src/unit_test.rs index 3bb4da1f2da0f..78ae1e5260a52 100644 --- a/crates/sui-move/src/unit_test.rs +++ b/crates/sui-move/src/unit_test.rs @@ -20,13 +20,8 @@ use sui_move_natives::test_scenario::InMemoryTestStore; use sui_move_natives::{object_runtime::ObjectRuntime, NativesCostTable}; use sui_protocol_config::ProtocolConfig; use sui_types::{ - base_types::{ObjectID, SequenceNumber}, - error::SuiResult, - gas_model::tables::initial_cost_schedule_for_unit_tests, - in_memory_storage::InMemoryStorage, + gas_model::tables::initial_cost_schedule_for_unit_tests, in_memory_storage::InMemoryStorage, metrics::LimitsMetrics, - object::Object, - storage::ChildObjectResolver, }; // Move unit tests will halt after executing this many steps. This is a protection to avoid divergence @@ -63,28 +58,6 @@ impl Test { } } -struct DummyChildObjectStore {} - -impl ChildObjectResolver for DummyChildObjectStore { - fn read_child_object( - &self, - _parent: &ObjectID, - _child: &ObjectID, - _child_version_upper_bound: SequenceNumber, - ) -> SuiResult> { - Ok(None) - } - fn get_object_received_at_version( - &self, - _owner: &ObjectID, - _receiving_object_id: &ObjectID, - _receive_object_at_version: SequenceNumber, - _epoch_id: sui_types::committee::EpochId, - ) -> SuiResult> { - Ok(None) - } -} - static TEST_STORE_INNER: Lazy> = Lazy::new(|| RwLock::new(InMemoryStorage::default())); diff --git a/crates/sui-network/src/state_sync/server.rs b/crates/sui-network/src/state_sync/server.rs index f7e24b5a5202f..4e6b32cff059e 100644 --- a/crates/sui-network/src/state_sync/server.rs +++ b/crates/sui-network/src/state_sync/server.rs @@ -221,7 +221,7 @@ where } })?; - struct SemaphoreExtension(OwnedSemaphorePermit); + struct SemaphoreExtension(#[allow(unused)] OwnedSemaphorePermit); inner.call(req).await.map(move |mut response| { // Insert permit as extension so it's not dropped until the response is sent. response diff --git a/crates/sui-node/Cargo.toml b/crates/sui-node/Cargo.toml index 9411c6f9e3f9c..1e3449067aaf3 100644 --- a/crates/sui-node/Cargo.toml +++ b/crates/sui-node/Cargo.toml @@ -6,6 +6,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] anemo.workspace = true anemo-tower.workspace = true diff --git a/crates/sui-node/src/admin.rs b/crates/sui-node/src/admin.rs index 228707cebd2b4..3c867e2f994a0 100644 --- a/crates/sui-node/src/admin.rs +++ b/crates/sui-node/src/admin.rs @@ -241,12 +241,12 @@ async fn capabilities(State(state): State>) -> (StatusCode, String // Only one of v1 or v2 will be populated at a time let capabilities = epoch_store.get_capabilities_v1(); let mut output = String::new(); - for capability in &capabilities { + for capability in capabilities.unwrap_or_default() { output.push_str(&format!("{:?}\n", capability)); } let capabilities = epoch_store.get_capabilities_v2(); - for capability in &capabilities { + for capability in capabilities.unwrap_or_default() { output.push_str(&format!("{:?}\n", capability)); } diff --git a/crates/sui-open-rpc-macros/src/lib.rs b/crates/sui-open-rpc-macros/src/lib.rs index 6fa99cc211998..ccf58a392286a 100644 --- a/crates/sui-open-rpc-macros/src/lib.rs +++ b/crates/sui-open-rpc-macros/src/lib.rs @@ -121,10 +121,6 @@ pub fn open_rpc(attr: TokenStream, item: TokenStream) -> TokenStream { trait OptionalQuote { fn to_quote(&self) -> TokenStream2; - - fn unwrap_quote(&self, quote: F) -> TokenStream2 - where - F: FnOnce(LitStr) -> TokenStream2; } impl OptionalQuote for Option { @@ -135,17 +131,6 @@ impl OptionalQuote for Option { quote!(None) } } - - fn unwrap_quote(&self, quote: F) -> TokenStream2 - where - F: FnOnce(LitStr) -> TokenStream2, - { - if let Some(lit_str) = self { - quote(lit_str.clone()) - } else { - quote!() - } - } } struct RpcDefinition { diff --git a/crates/sui-open-rpc/Cargo.toml b/crates/sui-open-rpc/Cargo.toml index 3bbe0f53ab5d7..e6000fe18d0e2 100644 --- a/crates/sui-open-rpc/Cargo.toml +++ b/crates/sui-open-rpc/Cargo.toml @@ -6,6 +6,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] schemars.workspace = true serde.workspace = true diff --git a/crates/sui-open-rpc/src/examples.rs b/crates/sui-open-rpc/src/examples.rs index ed8c038571073..9c2f8d8ba6805 100644 --- a/crates/sui-open-rpc/src/examples.rs +++ b/crates/sui-open-rpc/src/examples.rs @@ -69,11 +69,6 @@ struct Examples { examples: Vec, } -#[derive(serde::Serialize)] -struct Value { - value: String, -} - impl Examples { fn new(name: &str, examples: Vec) -> Self { Self { diff --git a/crates/sui-package-resolver/src/lib.rs b/crates/sui-package-resolver/src/lib.rs index 17f1118e591d1..a6c1f3d3c0043 100644 --- a/crates/sui-package-resolver/src/lib.rs +++ b/crates/sui-package-resolver/src/lib.rs @@ -132,6 +132,7 @@ pub enum ErrorConstants { /// * A numeric value (u8, u16, u32, u64, u128, u256); or /// * A boolean value; or /// * An address value + /// /// Otherwise, the `Raw` bytes of the error constant are returned. Rendered { /// The name of the error constant. @@ -1547,7 +1548,7 @@ impl<'l> ResolutionContext<'l> { O::Datatype(key, params) => { // SAFETY: `add_signature` ensures `datatypes` has an element with this key. - let def = &self.datatypes[&key]; + let def = &self.datatypes[key]; let param_layouts = params .iter() @@ -1639,7 +1640,7 @@ impl<'l> ResolutionContext<'l> { O::Datatype(key, params) => { // SAFETY: `add_signature` ensures `datatypes` has an element with this key. - let defining_id = &self.datatypes[&key].defining_id; + let defining_id = &self.datatypes[key].defining_id; for param in params { self.relocate_signature(param)?; } diff --git a/crates/sui-proc-macros/Cargo.toml b/crates/sui-proc-macros/Cargo.toml index 0ccf1b0d77060..cb3bf09505604 100644 --- a/crates/sui-proc-macros/Cargo.toml +++ b/crates/sui-proc-macros/Cargo.toml @@ -6,6 +6,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [lib] proc-macro = true diff --git a/crates/sui-protocol-config/Cargo.toml b/crates/sui-protocol-config/Cargo.toml index edcea7bd5ba8b..f8a8dfec81551 100644 --- a/crates/sui-protocol-config/Cargo.toml +++ b/crates/sui-protocol-config/Cargo.toml @@ -6,6 +6,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] serde.workspace = true tracing.workspace = true diff --git a/crates/sui-proxy/src/consumer.rs b/crates/sui-proxy/src/consumer.rs index 7135c5eaa670b..c4b3af8ad9770 100644 --- a/crates/sui-proxy/src/consumer.rs +++ b/crates/sui-proxy/src/consumer.rs @@ -242,7 +242,7 @@ async fn check_response( async fn convert( mfs: Vec, ) -> Result, (StatusCode, &'static str)> { - let result = match tokio::task::spawn_blocking(|| { + let result = tokio::task::spawn_blocking(|| { let timer = CONSUMER_OPERATION_DURATION .with_label_values(&["convert_to_remote_write_task"]) .start_timer(); @@ -250,8 +250,9 @@ async fn convert( timer.observe_duration(); result.into_iter() }) - .await - { + .await; + + let result = match result { Ok(v) => v, Err(err) => { error!("unable to convert to remote_write; {err}"); diff --git a/crates/sui-replay/src/lib.rs b/crates/sui-replay/src/lib.rs index 4d139661dd794..26a27cf828767 100644 --- a/crates/sui-replay/src/lib.rs +++ b/crates/sui-replay/src/lib.rs @@ -586,9 +586,8 @@ pub(crate) fn chain_from_chain_id(chain: &str) -> Chain { fn parse_configs_versions( configs_and_versions: Option>, ) -> Option> { - let Some(configs_and_versions) = configs_and_versions else { - return None; - }; + let configs_and_versions = configs_and_versions?; + assert!(configs_and_versions.len() % 2 == 0, "Invalid number of arguments for configs and version -- you must supply a version for each config"); Some( configs_and_versions diff --git a/crates/sui-rest-api/src/reader.rs b/crates/sui-rest-api/src/reader.rs index dd07ba57ae88f..30b2f8c2271b7 100644 --- a/crates/sui-rest-api/src/reader.rs +++ b/crates/sui-rest-api/src/reader.rs @@ -260,6 +260,7 @@ impl Iterator for CheckpointTransactionsIter { pub struct CursorInfo { pub checkpoint: CheckpointSequenceNumber, pub timestamp_ms: u64, + #[allow(unused)] pub index: u64, // None if there are no more transactions in the store diff --git a/crates/sui-rest-api/src/response.rs b/crates/sui-rest-api/src/response.rs index 3d2bda9df3a5f..cc30c9935cd1c 100644 --- a/crates/sui-rest-api/src/response.rs +++ b/crates/sui-rest-api/src/response.rs @@ -102,9 +102,9 @@ impl axum::response::IntoResponse for BcsRejection { "Expected request with `Content-Type: application/bcs`", ) .into_response(), - BcsRejection::DeserializationError(_) => ( + BcsRejection::DeserializationError(e) => ( StatusCode::UNPROCESSABLE_ENTITY, - "Failed to deserialize the BCS body into the target type", + format!("Failed to deserialize the BCS body into the target type: {e}"), ) .into_response(), BcsRejection::BytesRejection(bytes_rejection) => bytes_rejection.into_response(), diff --git a/crates/sui-rosetta/src/construction.rs b/crates/sui-rosetta/src/construction.rs index 45eaaef6abe57..d67c37ce34a94 100644 --- a/crates/sui-rosetta/src/construction.rs +++ b/crates/sui-rosetta/src/construction.rs @@ -74,7 +74,7 @@ pub async fn payloads( let intent_msg_bytes = bcs::to_bytes(&intent_msg)?; let mut hasher = DefaultHash::default(); - hasher.update(&bcs::to_bytes(&intent_msg).expect("Message serialization should not fail")); + hasher.update(bcs::to_bytes(&intent_msg).expect("Message serialization should not fail")); let digest = hasher.finalize().digest; Ok(ConstructionPayloadsResponse { diff --git a/crates/sui-rosetta/tests/gas_budget_tests.rs b/crates/sui-rosetta/tests/gas_budget_tests.rs index ead522c111354..f5666298bdd58 100644 --- a/crates/sui-rosetta/tests/gas_budget_tests.rs +++ b/crates/sui-rosetta/tests/gas_budget_tests.rs @@ -28,6 +28,7 @@ mod rosetta_client; #[derive(Deserialize, Debug)] #[serde(untagged)] enum TransactionIdentifierResponseResult { + #[allow(unused)] Success(TransactionIdentifierResponse), Error(RosettaSubmitGasError), } diff --git a/crates/sui-rpc-loadgen/src/payload/query_transactions.rs b/crates/sui-rpc-loadgen/src/payload/query_transactions.rs index b4abb519fee19..5482372cdd812 100644 --- a/crates/sui-rpc-loadgen/src/payload/query_transactions.rs +++ b/crates/sui-rpc-loadgen/src/payload/query_transactions.rs @@ -82,7 +82,7 @@ impl<'a> ProcessPayload<'a, &'a QueryTransactionBlocks> for RpcCommandProcessor } }; - results = join_all(clients.iter().enumerate().map(|(_i, client)| { + results = join_all(clients.iter().map(|client| { let with_query = query.clone(); async move { query_transaction_blocks(client, with_query, cursor, None) diff --git a/crates/sui-rpc-loadgen/src/payload/validation.rs b/crates/sui-rpc-loadgen/src/payload/validation.rs index 00656da736ed7..8204692c73ab1 100644 --- a/crates/sui-rpc-loadgen/src/payload/validation.rs +++ b/crates/sui-rpc-loadgen/src/payload/validation.rs @@ -16,7 +16,7 @@ use tracing::log::warn; const LOADGEN_QUERY_MAX_RESULT_LIMIT: usize = 25; -pub(crate) fn cross_validate_entities(entities: &Vec>, entity_name: &str) +pub(crate) fn cross_validate_entities(entities: &[Vec], entity_name: &str) where U: PartialEq + Debug, { diff --git a/crates/sui-sdk/src/lib.rs b/crates/sui-sdk/src/lib.rs index 945a0e0ba5c86..9200d8451e5fc 100644 --- a/crates/sui-sdk/src/lib.rs +++ b/crates/sui-sdk/src/lib.rs @@ -14,9 +14,9 @@ //! * [EventApi] - provides event related functions functions to //! * [GovernanceApi] - provides functionality related to staking //! * [QuorumDriverApi] - provides functionality to execute a transaction -//! block and submit it to the fullnode(s) +//! block and submit it to the fullnode(s) //! * [ReadApi] - provides functions for retrieving data about different -//! objects and transactions +//! objects and transactions //! * TransactionBuilder - provides functions for building transactions //! //! # Usage diff --git a/crates/sui-simulator/Cargo.toml b/crates/sui-simulator/Cargo.toml index 5d2f864250cc3..4d12c46ef42a4 100644 --- a/crates/sui-simulator/Cargo.toml +++ b/crates/sui-simulator/Cargo.toml @@ -6,6 +6,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] move-package.workspace = true diff --git a/crates/sui-simulator/src/lib.rs b/crates/sui-simulator/src/lib.rs index 086d2f1282184..91fa6b5937d26 100644 --- a/crates/sui-simulator/src/lib.rs +++ b/crates/sui-simulator/src/lib.rs @@ -110,7 +110,7 @@ pub mod configs { } thread_local! { - static NODE_COUNT: AtomicUsize = AtomicUsize::new(0); + static NODE_COUNT: AtomicUsize = const { AtomicUsize::new(0) }; } pub struct NodeLeakDetector(()); diff --git a/crates/sui-snapshot/src/lib.rs b/crates/sui-snapshot/src/lib.rs index a19a090770d5c..ac083f021efe1 100644 --- a/crates/sui-snapshot/src/lib.rs +++ b/crates/sui-snapshot/src/lib.rs @@ -72,6 +72,7 @@ use tokio::time::Instant; /// - epoch_1/ /// - 1_1.obj /// - ... +/// /// Object File Disk Format ///┌──────────────────────────────┐ ///│ magic(0x00B7EC75) <4 byte> │ diff --git a/crates/sui-storage/Cargo.toml b/crates/sui-storage/Cargo.toml index e34973c342c0b..ff541a7b7e962 100644 --- a/crates/sui-storage/Cargo.toml +++ b/crates/sui-storage/Cargo.toml @@ -6,6 +6,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] integer-encoding.workspace = true async-trait.workspace = true diff --git a/crates/sui-storage/src/http_key_value_store.rs b/crates/sui-storage/src/http_key_value_store.rs index 9232bdfb1bc50..461a441cd2a02 100644 --- a/crates/sui-storage/src/http_key_value_store.rs +++ b/crates/sui-storage/src/http_key_value_store.rs @@ -148,12 +148,7 @@ impl HttpKVStore { async fn multi_fetch(&self, uris: Vec) -> Vec>> { let uris_vec = uris.to_vec(); - let fetches = stream::iter( - uris_vec - .into_iter() - .enumerate() - .map(|(_i, url)| self.fetch(url)), - ); + let fetches = stream::iter(uris_vec.into_iter().map(|url| self.fetch(url))); fetches.buffered(uris.len()).collect::>().await } @@ -221,7 +216,7 @@ fn multi_split_slice<'a, T>(slice: &'a [T], lengths: &'a [usize]) -> Vec<&'a [T] .collect() } -fn deser_check_digest( +fn deser_check_digest( digest: &D, bytes: &Bytes, get_expected_digest: impl FnOnce(&T) -> D, diff --git a/crates/sui-swarm-config/Cargo.toml b/crates/sui-swarm-config/Cargo.toml index 8c6561469549f..12a367ccbd6c4 100644 --- a/crates/sui-swarm-config/Cargo.toml +++ b/crates/sui-swarm-config/Cargo.toml @@ -6,6 +6,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] anemo.workspace = true anyhow.workspace = true diff --git a/crates/sui-swarm/Cargo.toml b/crates/sui-swarm/Cargo.toml index b67f22a309465..51caeadf3b797 100644 --- a/crates/sui-swarm/Cargo.toml +++ b/crates/sui-swarm/Cargo.toml @@ -6,6 +6,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] anyhow.workspace = true rand.workspace = true diff --git a/crates/sui-swarm/src/memory/container.rs b/crates/sui-swarm/src/memory/container.rs index edbb5e4b4f146..b763fc7893cbc 100644 --- a/crates/sui-swarm/src/memory/container.rs +++ b/crates/sui-swarm/src/memory/container.rs @@ -69,7 +69,7 @@ impl Container { RuntimeType::MultiThreaded => { thread_local! { static SPAN: std::cell::RefCell> = - std::cell::RefCell::new(None); + const { std::cell::RefCell::new(None) }; } let mut builder = tokio::runtime::Builder::new_multi_thread(); let span = span.clone(); diff --git a/crates/sui-tool/src/commands.rs b/crates/sui-tool/src/commands.rs index 5c352104c8aaa..d4a6eb83facfc 100644 --- a/crates/sui-tool/src/commands.rs +++ b/crates/sui-tool/src/commands.rs @@ -22,7 +22,6 @@ use telemetry_subscribers::TracingHandle; use sui_types::{ base_types::*, crypto::AuthorityPublicKeyBytes, messages_grpc::TransactionInfoRequest, - object::Owner, }; use clap::*; @@ -419,59 +418,6 @@ pub enum ToolCommand { }, } -trait OptionDebug { - fn opt_debug(&self, def_str: &str) -> String; -} -trait OptionDisplay { - fn opt_display(&self, def_str: &str) -> String; -} - -impl OptionDebug for Option -where - T: std::fmt::Debug, -{ - fn opt_debug(&self, def_str: &str) -> String { - match self { - None => def_str.to_string(), - Some(t) => format!("{:?}", t), - } - } -} - -impl OptionDisplay for Option -where - T: std::fmt::Display, -{ - fn opt_display(&self, def_str: &str) -> String { - match self { - None => def_str.to_string(), - Some(t) => format!("{}", t), - } - } -} - -struct OwnerOutput(Owner); - -// grep/awk-friendly output for Owner -impl std::fmt::Display for OwnerOutput { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match &self.0 { - Owner::AddressOwner(address) => { - write!(f, "address({})", address) - } - Owner::ObjectOwner(address) => { - write!(f, "object({})", address) - } - Owner::Immutable => { - write!(f, "immutable") - } - Owner::Shared { .. } => { - write!(f, "shared") - } - } - } -} - async fn check_locked_object( sui_client: &Arc, committee: Arc>, diff --git a/crates/sui-tool/src/lib.rs b/crates/sui-tool/src/lib.rs index b4290dc48b510..a49ac1b5e9498 100644 --- a/crates/sui-tool/src/lib.rs +++ b/crates/sui-tool/src/lib.rs @@ -127,9 +127,6 @@ pub struct ObjectData { trait OptionDebug { fn opt_debug(&self, def_str: &str) -> String; } -trait OptionDisplay { - fn opt_display(&self, def_str: &str) -> String; -} impl OptionDebug for Option where @@ -143,40 +140,6 @@ where } } -impl OptionDisplay for Option -where - T: std::fmt::Display, -{ - fn opt_display(&self, def_str: &str) -> String { - match self { - None => def_str.to_string(), - Some(t) => format!("{}", t), - } - } -} - -struct OwnerOutput(Owner); - -// grep/awk-friendly output for Owner -impl std::fmt::Display for OwnerOutput { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match &self.0 { - Owner::AddressOwner(address) => { - write!(f, "address({})", address) - } - Owner::ObjectOwner(address) => { - write!(f, "object({})", address) - } - Owner::Immutable => { - write!(f, "immutable") - } - Owner::Shared { .. } => { - write!(f, "shared") - } - } - } -} - #[allow(clippy::type_complexity)] pub struct GroupedObjectOutput { pub grouped_results: BTreeMap< diff --git a/crates/sui-transactional-test-runner/Cargo.toml b/crates/sui-transactional-test-runner/Cargo.toml index 46fd3ab10242f..d602aea50457a 100644 --- a/crates/sui-transactional-test-runner/Cargo.toml +++ b/crates/sui-transactional-test-runner/Cargo.toml @@ -7,6 +7,9 @@ description = "Move framework for Sui platform" license = "Apache-2.0" publish = false +[lints] +workspace = true + [dependencies] anyhow.workspace = true bcs.workspace = true diff --git a/crates/sui-transactional-test-runner/src/simulator_persisted_store.rs b/crates/sui-transactional-test-runner/src/simulator_persisted_store.rs index 2c2e9de3c7b90..64606fa58dc0d 100644 --- a/crates/sui-transactional-test-runner/src/simulator_persisted_store.rs +++ b/crates/sui-transactional-test-runner/src/simulator_persisted_store.rs @@ -313,16 +313,12 @@ impl SimulatorStore for PersistedStore { fn insert_committee(&mut self, committee: Committee) { let epoch = committee.epoch as usize; - let mut committees = if let Some(c) = self + let mut committees = self .read_write .epoch_to_committee .get(&()) .expect("Fatal: DB read failed") - { - c - } else { - vec![] - }; + .unwrap_or_default(); if committees.get(epoch).is_some() { return; @@ -397,16 +393,12 @@ impl SimulatorStore for PersistedStore { .live_objects .insert(&object_id, &version) .expect("Fatal: DB write failed"); - let mut q = if let Some(x) = self + let mut q = self .read_write .objects .get(&object_id) .expect("Fatal: DB read failed") - { - x - } else { - BTreeMap::new() - }; + .unwrap_or_default(); q.insert(version, object); self.read_write .objects diff --git a/crates/sui-types/Cargo.toml b/crates/sui-types/Cargo.toml index 90c35908f1b0a..9943fc5465d25 100644 --- a/crates/sui-types/Cargo.toml +++ b/crates/sui-types/Cargo.toml @@ -6,6 +6,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] async-trait.workspace = true anemo.workspace = true diff --git a/crates/sui-types/src/crypto.rs b/crates/sui-types/src/crypto.rs index 16c83f6fa2493..792906ce4f05e 100644 --- a/crates/sui-types/src/crypto.rs +++ b/crates/sui-types/src/crypto.rs @@ -730,7 +730,7 @@ impl Signature { // itself that computes the BCS hash of the Rust type prefix and `struct TransactionData`. // (See `fn digest` in `impl Message for SenderSignedData`). let mut hasher = DefaultHash::default(); - hasher.update(&bcs::to_bytes(&value).expect("Message serialization should not fail")); + hasher.update(bcs::to_bytes(&value).expect("Message serialization should not fail")); Signer::sign(secret, &hasher.finalize().digest) } @@ -999,7 +999,7 @@ impl SuiSignature for S { T: Serialize, { let mut hasher = DefaultHash::default(); - hasher.update(&bcs::to_bytes(&value).expect("Message serialization should not fail")); + hasher.update(bcs::to_bytes(&value).expect("Message serialization should not fail")); let digest = hasher.finalize().digest; let (sig, pk) = &self.get_verification_inputs()?; diff --git a/crates/sui-types/src/execution.rs b/crates/sui-types/src/execution.rs index c4bcf7ba293b8..53dbcfbd74797 100644 --- a/crates/sui-types/src/execution.rs +++ b/crates/sui-types/src/execution.rs @@ -175,18 +175,21 @@ impl ExecutionResultsV2 { /// gas smashing). Because this list is not gated by protocol version, there are a few important /// criteria for adding a digest to this list: /// 1. The certificate must be causing all validators to either panic or hang forever deterministically. -/// 2. If we ever ship a fix to make it no longer panic or hang when executing such transaction, -/// we must make sure the transaction is already in this list. Otherwise nodes running the newer version -/// without these transactions in the list will generate forked result. +/// 2. If we ever ship a fix to make it no longer panic or hang when executing such transaction, we +/// must make sure the transaction is already in this list. Otherwise nodes running the newer +/// version without these transactions in the list will generate forked result. +/// /// Below is a scenario of when we need to use this list: /// 1. We detect that a specific transaction is causing all validators to either panic or hang forever deterministically. /// 2. We push a CertificateDenyConfig to deny such transaction to all validators asap. -/// 3. To make sure that all fullnodes are able to sync to the latest version, we need to add the transaction digest -/// to this list as well asap, and ship this binary to all fullnodes, so that they can sync past this transaction. +/// 3. To make sure that all fullnodes are able to sync to the latest version, we need to add the +/// transaction digest to this list as well asap, and ship this binary to all fullnodes, so that +/// they can sync past this transaction. /// 4. We then can start fixing the issue, and ship the fix to all nodes. -/// 5. Unfortunately, we can't remove the transaction digest from this list, because if we do so, any future -/// node that sync from genesis will fork on this transaction. We may be able to remove it once -/// we have stable snapshots and the binary has a minimum supported protocol version past the epoch. +/// 5. Unfortunately, we can't remove the transaction digest from this list, because if we do so, +/// any future node that sync from genesis will fork on this transaction. We may be able to +/// remove it once we have stable snapshots and the binary has a minimum supported protocol +/// version past the epoch. pub fn get_denied_certificates() -> &'static HashSet { static DENIED_CERTIFICATES: Lazy> = Lazy::new(|| HashSet::from([])); Lazy::force(&DENIED_CERTIFICATES) diff --git a/crates/sui-types/src/full_checkpoint_content.rs b/crates/sui-types/src/full_checkpoint_content.rs index 4d0cb95217bbc..2c8eef47f237e 100644 --- a/crates/sui-types/src/full_checkpoint_content.rs +++ b/crates/sui-types/src/full_checkpoint_content.rs @@ -177,7 +177,7 @@ impl CheckpointTransaction { ObjectIn::NotExist, ObjectOut::PackageWrite((version, _)), IDOperation::Created, - ) => Some(((id, &version), None)), + ) => Some(((id, version), None)), // Unwrapped Objects (ObjectIn::NotExist, ObjectOut::ObjectWrite(_), IDOperation::None) => { @@ -241,7 +241,7 @@ impl CheckpointTransaction { ObjectIn::NotExist, ObjectOut::PackageWrite((version, _)), IDOperation::Created, - ) => Some((id, &version)), + ) => Some((id, version)), _ => None, } diff --git a/crates/sui-types/src/messages_grpc.rs b/crates/sui-types/src/messages_grpc.rs index f29707cca75b7..ffe8001980e68 100644 --- a/crates/sui-types/src/messages_grpc.rs +++ b/crates/sui-types/src/messages_grpc.rs @@ -233,6 +233,7 @@ impl From for HandleCertificateResponseV2 { /// If `wait_for_effects` is true, it is guaranteed that: /// - Number of responses will be equal to the number of input transactions. /// - The order of the responses matches the order of the input transactions. +/// /// Otherwise, `responses` will be empty. #[derive(Clone, Debug, Serialize, Deserialize)] pub struct HandleSoftBundleCertificatesResponseV3 { diff --git a/crates/sui-types/tests/serde_tests.rs b/crates/sui-types/tests/serde_tests.rs index cd7056857b06b..2343c90b91329 100644 --- a/crates/sui-types/tests/serde_tests.rs +++ b/crates/sui-types/tests/serde_tests.rs @@ -18,7 +18,7 @@ fn test_struct_tag_serde() { struct TestStructTag(#[serde_as(as = "SuiStructTag")] StructTag); // serialize to json should not trim the leading 0 - let Value::String(json) = serde_json::to_value(&TestStructTag(tag.clone())).unwrap() else { + let Value::String(json) = serde_json::to_value(TestStructTag(tag.clone())).unwrap() else { panic!() }; assert_eq!(json, "0x07f89cdffd8968affa0b47bef91adc5314e19509080470c45bfd434cd83a766b::suifrens::SuiFren<0x07f89cdffd8968affa0b47bef91adc5314e19509080470c45bfd434cd83a766b::capy::Capy>"); diff --git a/crates/sui/Cargo.toml b/crates/sui/Cargo.toml index 9c06cb2893505..50afe8ab31472 100644 --- a/crates/sui/Cargo.toml +++ b/crates/sui/Cargo.toml @@ -6,6 +6,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] anemo.workspace = true anyhow.workspace = true diff --git a/crates/sui/src/client_commands.rs b/crates/sui/src/client_commands.rs index 58d6a75f60d96..aec1751251eb1 100644 --- a/crates/sui/src/client_commands.rs +++ b/crates/sui/src/client_commands.rs @@ -2715,6 +2715,7 @@ pub async fn execute_dry_run( /// Call a dry run with the transaction data to estimate the gas budget. /// The estimated gas budget is computed as following: /// * the maximum between A and B, where: +/// /// A = computation cost + GAS_SAFE_OVERHEAD * reference gas price /// B = computation cost + storage cost - storage rebate + GAS_SAFE_OVERHEAD * reference gas price /// overhead diff --git a/crates/sui/src/client_ptb/lexer.rs b/crates/sui/src/client_ptb/lexer.rs index 749e8f724ada6..2338683ffadad 100644 --- a/crates/sui/src/client_ptb/lexer.rs +++ b/crates/sui/src/client_ptb/lexer.rs @@ -17,9 +17,7 @@ pub struct Lexer<'l, I: Iterator> { impl<'l, I: Iterator> Lexer<'l, I> { pub fn new(mut tokens: I) -> Option { - let Some(buf) = tokens.next() else { - return None; - }; + let buf = tokens.next()?; Some(Self { buf, @@ -63,9 +61,7 @@ impl<'l, I: Iterator> Lexer<'l, I> { fn eat_prefix(&mut self, patt: &str) -> Option> { let start = self.offset; - let Some(rest) = self.buf.strip_prefix(patt) else { - return None; - }; + let rest = self.buf.strip_prefix(patt)?; let len = self.buf.len() - rest.len(); let value = &self.buf[..len]; @@ -120,9 +116,7 @@ impl<'l, I: Iterator> Lexer<'l, I> { /// Look at the next character in the current shell token without consuming it, if it exists. fn peek(&self) -> Option> { let start = self.offset; - let Some((ix, _)) = self.next_char_boundary() else { - return None; - }; + let (ix, _) = self.next_char_boundary()?; let value = &self.buf[..ix]; let span = Span { diff --git a/crates/sui/tests/cli_tests.rs b/crates/sui/tests/cli_tests.rs index 00c2f5034172e..7d0c374dce9df 100644 --- a/crates/sui/tests/cli_tests.rs +++ b/crates/sui/tests/cli_tests.rs @@ -691,7 +691,7 @@ async fn test_move_call_args_linter_command() -> Result<(), anyhow::Error> { // Try a transfer // This should fail due to mismatch of object being sent - let args = vec![ + let args = [ SuiJsonValue::new(json!(obj))?, SuiJsonValue::new(json!(address2))?, ]; @@ -712,7 +712,7 @@ async fn test_move_call_args_linter_command() -> Result<(), anyhow::Error> { // Try a transfer with explicitly set gas price. // It should fail due to that gas price is below RGP. - let args = vec![ + let args = [ SuiJsonValue::new(json!(created_obj))?, SuiJsonValue::new(json!(address2))?, ]; @@ -740,7 +740,7 @@ async fn test_move_call_args_linter_command() -> Result<(), anyhow::Error> { // assert!(err_string.contains(&format!("Expected argument of type {package_addr}::object_basics::Object, but found type {framework_addr}::coin::Coin<{framework_addr}::sui::SUI>"))); // Try a proper transfer - let args = vec![ + let args = [ SuiJsonValue::new(json!(created_obj))?, SuiJsonValue::new(json!(address2))?, ]; diff --git a/crates/suiop-cli/src/command.rs b/crates/suiop-cli/src/command.rs index c14c39cb3e4f2..8247dbb9938f1 100644 --- a/crates/suiop-cli/src/command.rs +++ b/crates/suiop-cli/src/command.rs @@ -38,11 +38,7 @@ impl Default for CommandOptions { pub fn run_cmd(cmd_in: Vec<&str>, options: Option) -> Result { debug!("attempting to run {}", cmd_in.join(" ")); - let opts = if let Some(opts) = options { - opts - } else { - CommandOptions::default() - }; + let opts = options.unwrap_or_default(); let mut cmd = Command::new(cmd_in[0]); // add extra args diff --git a/crates/telemetry-subscribers/src/lib.rs b/crates/telemetry-subscribers/src/lib.rs index ac032093bb193..7221034ad9273 100644 --- a/crates/telemetry-subscribers/src/lib.rs +++ b/crates/telemetry-subscribers/src/lib.rs @@ -500,7 +500,7 @@ impl SamplingFilter { fn clamp(sample_rate: f64) -> f64 { // clamp sample rate to between 0.0001 and 1.0 - sample_rate.max(0.0001).min(1.0) + sample_rate.clamp(0.0001, 1.0) } fn update_sampling_rate(&self, sample_rate: f64) { diff --git a/crates/telemetry-subscribers/src/span_latency_prom.rs b/crates/telemetry-subscribers/src/span_latency_prom.rs index a42783d84684b..476bf30151980 100644 --- a/crates/telemetry-subscribers/src/span_latency_prom.rs +++ b/crates/telemetry-subscribers/src/span_latency_prom.rs @@ -10,6 +10,7 @@ //! - tracing-timing does not output to Prometheus, and extracting data from its histograms takes extra CPU //! - tracing-timing records latencies using HDRHistogram, which is great, but uses extra memory when one //! is already using Prometheus +//! //! Thus this is a much smaller and more focused module. //! //! ## Making spans visible diff --git a/crates/test-cluster/Cargo.toml b/crates/test-cluster/Cargo.toml index 826433cb330f2..6f967e93389b8 100644 --- a/crates/test-cluster/Cargo.toml +++ b/crates/test-cluster/Cargo.toml @@ -6,6 +6,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] anyhow.workspace = true bcs.workspace = true diff --git a/crates/transaction-fuzzer/Cargo.toml b/crates/transaction-fuzzer/Cargo.toml index 15fe64e0735b4..106bebdf5a8d1 100644 --- a/crates/transaction-fuzzer/Cargo.toml +++ b/crates/transaction-fuzzer/Cargo.toml @@ -7,6 +7,9 @@ description = "Tool to fuzz the system with randomly generated transactions" license = "Apache-2.0" publish = false +[lints] +workspace = true + [dependencies] proptest.workspace = true proptest-derive.workspace = true diff --git a/crates/transaction-fuzzer/src/programmable_transaction_gen.rs b/crates/transaction-fuzzer/src/programmable_transaction_gen.rs index 85de6eabbe2a6..3526a02009d61 100644 --- a/crates/transaction-fuzzer/src/programmable_transaction_gen.rs +++ b/crates/transaction-fuzzer/src/programmable_transaction_gen.rs @@ -404,7 +404,7 @@ pub fn gen_move_vec_input( /// A helper function to generate enough input coins for a command (transfer, merge, or create vector) /// - either collect them all from previous command or generate additional ones if the previous -/// command does not deliver enough. +/// command does not deliver enough. fn gen_enough_arguments( builder: &mut ProgrammableTransactionBuilder, prev_cmd_num: i64, diff --git a/crates/typed-store-derive/src/lib.rs b/crates/typed-store-derive/src/lib.rs index 9b0c73b8acd12..be1d81862cb8d 100644 --- a/crates/typed-store-derive/src/lib.rs +++ b/crates/typed-store-derive/src/lib.rs @@ -93,7 +93,7 @@ fn extract_struct_info( } else { field_name.clone() }; - if attrs.get(DB_OPTIONS_DEPRECATE).is_some() { + if attrs.contains_key(DB_OPTIONS_DEPRECATE) { deprecated_cfs.push(field_name.clone()); } diff --git a/crates/typed-store/src/lib.rs b/crates/typed-store/src/lib.rs index 734d22dc9cfea..00743e16fd65c 100644 --- a/crates/typed-store/src/lib.rs +++ b/crates/typed-store/src/lib.rs @@ -33,7 +33,8 @@ pub type StoreError = typed_store_error::TypedStoreError; /// 5. Other convenience features /// /// 1. Flexible configuration: -/// a. Static options specified at struct definition +/// a. Static options specified at struct definition +/// /// The definer of the struct can specify the default options for each table using annotations /// We can also supply column family options on the default ones /// A user defined function of signature () -> Options can be provided for each table @@ -90,10 +91,10 @@ pub type StoreError = typed_store_error::TypedStoreError; ///``` /// /// 2. Auto-generated `open` routine -/// The function `open_tables_read_write` is generated which allows for specifying DB wide options and custom table configs as mentioned above +/// The function `open_tables_read_write` is generated which allows for specifying DB wide options and custom table configs as mentioned above /// /// 3. Auto-generated `read_only_mode` handle -/// This mode provides handle struct which opens the DB in read only mode and has certain features like dumping and counting the keys in the tables +/// This mode provides handle struct which opens the DB in read only mode and has certain features like dumping and counting the keys in the tables /// /// Use the function `Tables::get_read_only_handle` which returns a handle that only allows read only features ///``` @@ -138,10 +139,10 @@ pub type StoreError = typed_store_error::TypedStoreError; /// } /// ``` /// 4. Auto-generated memory stats method -/// `self.get_memory_usage` is derived to provide memory and cache usage +/// `self.get_memory_usage` is derived to provide memory and cache usage /// /// 5. Other convenience features -/// `Tables::describe_tables` is used to get a list of the table names and key-value types as string in a BTreeMap +/// `Tables::describe_tables` is used to get a list of the table names and key-value types as string in a BTreeMap /// /// // Bad usage example /// // Structs fields most only be of type Store or DMBap diff --git a/crates/typed-store/src/rocks/mod.rs b/crates/typed-store/src/rocks/mod.rs index 752b42fba8ab3..ca6505b9a448e 100644 --- a/crates/typed-store/src/rocks/mod.rs +++ b/crates/typed-store/src/rocks/mod.rs @@ -88,9 +88,8 @@ mod tests; /// # Arguments /// /// * `db` - a reference to a rocks DB object -/// * `cf;` - a comma separated list of column families to open. For each -/// column family a concatenation of column family name (cf) and Key-Value -/// should be provided. +/// * `cf;` - a comma separated list of column families to open. For each column family a +/// concatenation of column family name (cf) and Key-Value should be provided. /// /// # Examples /// @@ -2735,7 +2734,7 @@ fn populate_missing_cfs( /// Given a vec, find the value which is one more than the vector /// if the vector was a big endian number. /// If the vector is already minimum, don't change it. -fn big_endian_saturating_add_one(v: &mut Vec) { +fn big_endian_saturating_add_one(v: &mut [u8]) { if is_max(v) { return; } @@ -2769,7 +2768,6 @@ fn test_helpers() { uint::construct_uint! { // 32 byte number - #[cfg_attr(feature = "scale-info", derive(TypeInfo))] struct Num32(4); } diff --git a/crates/typed-store/tests/macro_tests.rs b/crates/typed-store/tests/macro_tests.rs index ccd040ebddef9..dc8252864c144 100644 --- a/crates/typed-store/tests/macro_tests.rs +++ b/crates/typed-store/tests/macro_tests.rs @@ -166,13 +166,13 @@ async fn macro_test() { // Test pagination let m = tbls_secondary.dump("table1", 2, 0).unwrap(); assert_eq!(2, m.len()); - assert_eq!(format!("\"1\""), *m.get(&"\"1\"".to_string()).unwrap()); - assert_eq!(format!("\"2\""), *m.get(&"\"2\"".to_string()).unwrap()); + assert_eq!(format!("\"1\""), *m.get("\"1\"").unwrap()); + assert_eq!(format!("\"2\""), *m.get("\"2\"").unwrap()); let m = tbls_secondary.dump("table1", 3, 2).unwrap(); assert_eq!(3, m.len()); - assert_eq!(format!("\"7\""), *m.get(&"\"7\"".to_string()).unwrap()); - assert_eq!(format!("\"8\""), *m.get(&"\"8\"".to_string()).unwrap()); + assert_eq!(format!("\"7\""), *m.get("\"7\"").unwrap()); + assert_eq!(format!("\"8\""), *m.get("\"8\"").unwrap()); } #[tokio::test] @@ -306,13 +306,13 @@ async fn test_sallydb() { // Test pagination let m = example_db_secondary.dump("col1", 2, 0).unwrap(); assert_eq!(2, m.len()); - assert_eq!(format!("\"1\""), *m.get(&"\"1\"".to_string()).unwrap()); - assert_eq!(format!("\"2\""), *m.get(&"\"2\"".to_string()).unwrap()); + assert_eq!(format!("\"1\""), *m.get("\"1\"").unwrap()); + assert_eq!(format!("\"2\""), *m.get("\"2\"").unwrap()); let m = example_db_secondary.dump("col1", 3, 2).unwrap(); assert_eq!(3, m.len()); - assert_eq!(format!("\"7\""), *m.get(&"\"7\"".to_string()).unwrap()); - assert_eq!(format!("\"8\""), *m.get(&"\"8\"".to_string()).unwrap()); + assert_eq!(format!("\"7\""), *m.get("\"7\"").unwrap()); + assert_eq!(format!("\"8\""), *m.get("\"8\"").unwrap()); } #[tokio::test] diff --git a/deny.toml b/deny.toml index 4d26ba89ccb0e..b1f837e63143e 100644 --- a/deny.toml +++ b/deny.toml @@ -9,42 +9,15 @@ # The values provided in this template are the default values that will be used # when any section or field is not specified in your own configuration -# If 1 or more target triples (and optionally, target_features) are specified, -# only the specified targets will be checked when running `cargo deny check`. -# This means, if a particular package is only ever used as a target specific -# dependency, such as, for example, the `nix` crate only being used via the -# `target_family = "unix"` configuration, that only having windows targets in -# this list would mean the nix crate, as well as any of its exclusive -# dependencies not shared by any other crates, would be ignored, as the target -# list here is effectively saying which targets you are building for. -targets = [ - # The triple can be any string, but only the target triples built in to - # rustc (as of 1.40) can be checked against actual config expressions - #{ triple = "x86_64-unknown-linux-musl" }, - # You can also specify which target_features you promise are enabled for a - # particular target. target_features are currently not validated against - # the actual valid features supported by the target architecture. - #{ triple = "wasm32-unknown-unknown", features = ["atomics"] }, -] - # This section is considered when running `cargo deny check advisories` # More documentation for the advisories section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html [advisories] +version = 2 # The path where the advisory database is cloned/fetched into db-path = "~/.cargo/advisory-db" # The url(s) of the advisory databases to use db-urls = ["https://github.com/rustsec/advisory-db"] -# The lint level for security vulnerabilities -vulnerability = "deny" -# The lint level for unmaintained crates -unmaintained = "warn" -# The lint level for crates that have been yanked from their source registry -yanked = "warn" -# The lint level for crates with security notices. Note that as of -# 2019-12-17 there are no security notice advisories in -# https://github.com/rustsec/advisory-db -notice = "warn" # A list of advisory IDs to ignore. Note that ignored advisories will still # output a note when they are encountered. ignore = [ @@ -55,8 +28,6 @@ ignore = [ "RUSTSEC-2022-0071", # `tui` is unmaintained; use `ratatui` instead "RUSTSEC-2023-0049", - # ansi_term is Unmaintained - "RUSTSEC-2021-0139", # we don't do RSA signing on Sui (only verifying for zklogin) "RUSTSEC-2023-0071", # A few dependencies use unpatched rustls. @@ -78,8 +49,7 @@ ignore = [ # More documentation for the licenses section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html [licenses] -# The lint level for crates which do not have a detectable license -unlicensed = "deny" +version = 2 # List of explicitly allowed licenses # See https://spdx.org/licenses/ for list of possible licenses # [possible values: any SPDX 3.11 short identifier (+ optional exception)]. @@ -98,26 +68,6 @@ allow = [ "Unicode-DFS-2016", #"Apache-2.0 WITH LLVM-exception", ] -# List of explicitly disallowed licenses -# See https://spdx.org/licenses/ for list of possible licenses -# [possible values: any SPDX 3.11 short identifier (+ optional exception)]. -deny = [ - #"Nokia", -] -# Lint level for licenses considered copyleft -copyleft = "deny" -# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses -# * both - The license will be approved if it is both OSI-approved *AND* FSF -# * either - The license will be approved if it is either OSI-approved *OR* FSF -# * osi-only - The license will be approved if is OSI-approved *AND NOT* FSF -# * fsf-only - The license will be approved if is FSF *AND NOT* OSI-approved -# * neither - This predicate is ignored and the default lint level is used -allow-osi-fsf-free = "neither" -# Lint level used when no other predicates are matched -# 1. License isn't in the allow or deny lists -# 2. License isn't copyleft -# 3. License isn't OSI/FSF, or allow-osi-fsf-free = "neither" -default = "deny" # The confidence threshold for detecting a license from license text. # The higher the value, the more closely the license text must be to the # canonical license text of a valid SPDX license file. @@ -251,8 +201,6 @@ github = [ "mystenmark", "bmwill", "mystenlabs", - "MystenLabs", "nextest-rs", "wlmyng", # jsonrpsee fork - "quinn-rs", ] diff --git a/docker/deterministic-canary/Dockerfile b/docker/deterministic-canary/Dockerfile index 67f253135d3b6..5ebdef630f182 100644 --- a/docker/deterministic-canary/Dockerfile +++ b/docker/deterministic-canary/Dockerfile @@ -1,7 +1,7 @@ ARG PROFILE=release # ARG BUILD_DATE # ARG GIT_REVISION -ARG RUST_VERSION=1.76.0 +ARG RUST_VERSION=1.80.1 FROM scratch AS base diff --git a/docker/sui-bridge-indexer/Dockerfile b/docker/sui-bridge-indexer/Dockerfile index 3be48a6e006cb..4f0fcde7b9c42 100644 --- a/docker/sui-bridge-indexer/Dockerfile +++ b/docker/sui-bridge-indexer/Dockerfile @@ -2,7 +2,7 @@ # # Copy in all crates, Cargo.toml and Cargo.lock unmodified, # and build the application. -FROM rust:1.75-bullseye AS builder +FROM rust:1.80.1-bullseye AS builder ARG PROFILE=release ARG GIT_REVISION ENV GIT_REVISION=$GIT_REVISION diff --git a/docker/sui-graphql-rpc/Dockerfile b/docker/sui-graphql-rpc/Dockerfile index 0035b8268bd81..049b8603e39c8 100644 --- a/docker/sui-graphql-rpc/Dockerfile +++ b/docker/sui-graphql-rpc/Dockerfile @@ -2,7 +2,7 @@ # # Copy in all crates, Cargo.toml and Cargo.lock unmodified, # and build the application. -FROM rust:1.75-bullseye AS builder +FROM rust:1.80.1-bullseye AS builder ARG PROFILE=release ENV PROFILE=$PROFILE ARG GIT_REVISION diff --git a/docker/sui-indexer-tidb/Dockerfile b/docker/sui-indexer-tidb/Dockerfile index d1d46bf81024c..6d11dc569bd60 100644 --- a/docker/sui-indexer-tidb/Dockerfile +++ b/docker/sui-indexer-tidb/Dockerfile @@ -2,7 +2,7 @@ # # Copy in all crates, Cargo.toml and Cargo.lock unmodified, # and build the application. -FROM rust:1.75-bullseye AS builder +FROM rust:1.80.1-bullseye AS builder ARG PROFILE=release ARG GIT_REVISION ENV GIT_REVISION=$GIT_REVISION diff --git a/docker/sui-indexer/Dockerfile b/docker/sui-indexer/Dockerfile index db27235841255..98635444f78c3 100644 --- a/docker/sui-indexer/Dockerfile +++ b/docker/sui-indexer/Dockerfile @@ -2,7 +2,7 @@ # # Copy in all crates, Cargo.toml and Cargo.lock unmodified, # and build the application. -FROM rust:1.75-bullseye AS builder +FROM rust:1.80.1-bullseye AS builder ARG PROFILE=release ARG GIT_REVISION ENV GIT_REVISION=$GIT_REVISION diff --git a/docker/sui-node/Dockerfile b/docker/sui-node/Dockerfile index 190e352cc6da6..e9557b7698adc 100644 --- a/docker/sui-node/Dockerfile +++ b/docker/sui-node/Dockerfile @@ -2,7 +2,7 @@ # # Copy in all crates, Cargo.toml and Cargo.lock unmodified, # and build the application. -FROM rust:1.75-bullseye AS builder +FROM rust:1.80.1-bullseye AS builder ARG PROFILE=release ARG GIT_REVISION ENV GIT_REVISION=$GIT_REVISION diff --git a/docker/sui-services/Dockerfile b/docker/sui-services/Dockerfile index dd9cc69f5edda..2002fe6b9140b 100644 --- a/docker/sui-services/Dockerfile +++ b/docker/sui-services/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.75-bullseye AS chef +FROM rust:1.80.1-bullseye AS chef WORKDIR sui ARG GIT_REVISION ENV GIT_REVISION=$GIT_REVISION diff --git a/docker/sui-source-service/Dockerfile b/docker/sui-source-service/Dockerfile index bb73ef2e3e0d5..0936bd0562256 100644 --- a/docker/sui-source-service/Dockerfile +++ b/docker/sui-source-service/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.75-bullseye AS chef +FROM rust:1.80.1-bullseye AS chef WORKDIR sui ARG GIT_REVISION ENV GIT_REVISION=$GIT_REVISION diff --git a/docker/sui-tools/Dockerfile b/docker/sui-tools/Dockerfile index e475fd2abf160..4f800e03b01e6 100644 --- a/docker/sui-tools/Dockerfile +++ b/docker/sui-tools/Dockerfile @@ -2,7 +2,7 @@ # # Copy in all crates, Cargo.toml and Cargo.lock unmodified, # and build the application. -FROM rust:1.75-bullseye AS builder +FROM rust:1.80.1-bullseye AS builder ARG PROFILE=release ARG GIT_REVISION ENV GIT_REVISION=$GIT_REVISION diff --git a/external-crates/move/Cargo.toml b/external-crates/move/Cargo.toml index 8bac472e296d6..4aeea3a73a592 100644 --- a/external-crates/move/Cargo.toml +++ b/external-crates/move/Cargo.toml @@ -83,7 +83,7 @@ parking_lot = "0.11.1" paste = "1.0.5" petgraph = "0.5.1" phf = { version = "0.11", features = ["macros"] } -plotters = { version = "0.3.0", default_features = false, features = ["evcxr", "line_series", "histogram"]} +plotters = { version = "0.3.0", default-features = false, features = ["evcxr", "line_series", "histogram"]} pretty = "0.10.0" prettydiff = "0.4.0" primitive-types = { version = "0.10.1", features = ["impl-serde"]} diff --git a/external-crates/move/crates/move-binary-format/src/file_format.rs b/external-crates/move/crates/move-binary-format/src/file_format.rs index ff60d27ee3849..c65207ff96e15 100644 --- a/external-crates/move/crates/move-binary-format/src/file_format.rs +++ b/external-crates/move/crates/move-binary-format/src/file_format.rs @@ -12,15 +12,15 @@ //! //! Overall the binary format is structured in a number of sections: //! - **Header**: this must start at offset 0 in the binary. It contains a blob that starts every -//! Diem binary, followed by the version of the VM used to compile the code, and last is the -//! number of tables present in this binary. +//! Diem binary, followed by the version of the VM used to compile the code, and last is the +//! number of tables present in this binary. //! - **Table Specification**: it's a number of tuple of the form -//! `(table type, starting_offset, byte_count)`. The number of entries is specified in the -//! header (last entry in header). There can only be a single entry per table type. The -//! `starting offset` is from the beginning of the binary. Tables must cover the entire size of -//! the binary blob and cannot overlap. +//! `(table type, starting_offset, byte_count)`. The number of entries is specified in the +//! header (last entry in header). There can only be a single entry per table type. The +//! `starting offset` is from the beginning of the binary. Tables must cover the entire size of +//! the binary blob and cannot overlap. //! - **Table Content**: the serialized form of the specific entries in the table. Those roughly -//! map to the structs defined in this module. Entries in each table must be unique. +//! map to the structs defined in this module. Entries in each table must be unique. //! //! We have two formats: one for modules here represented by `CompiledModule`, another //! for transaction scripts which is `CompiledScript`. Building those tables and passing them diff --git a/external-crates/move/crates/move-binary-format/src/file_format_common.rs b/external-crates/move/crates/move-binary-format/src/file_format_common.rs index 7c81c755a012a..7d006ef74f9f9 100644 --- a/external-crates/move/crates/move-binary-format/src/file_format_common.rs +++ b/external-crates/move/crates/move-binary-format/src/file_format_common.rs @@ -334,7 +334,7 @@ pub enum Opcodes { } /// Upper limit on the binary size -pub const BINARY_SIZE_LIMIT: usize = usize::max_value(); +pub const BINARY_SIZE_LIMIT: usize = usize::MAX; /// A wrapper for the binary vector #[derive(Default, Debug)] diff --git a/external-crates/move/crates/move-binary-format/src/proptest_types/functions.rs b/external-crates/move/crates/move-binary-format/src/proptest_types/functions.rs index a549e18fb8b94..42bbfacfc1b75 100644 --- a/external-crates/move/crates/move-binary-format/src/proptest_types/functions.rs +++ b/external-crates/move/crates/move-binary-format/src/proptest_types/functions.rs @@ -55,7 +55,7 @@ impl SignatureState { } fn add_signature(&mut self, sig: Signature) -> SignatureIndex { - debug_assert!(self.signatures.len() < TableSize::max_value() as usize); + debug_assert!(self.signatures.len() < TableSize::MAX as usize); if let Some(idx) = self.signature_map.get(&sig) { return *idx; } @@ -81,7 +81,7 @@ impl FieldHandleState { #[allow(unused)] fn add_field_handle(&mut self, fh: FieldHandle) -> FieldHandleIndex { - debug_assert!(self.field_handles.len() < TableSize::max_value() as usize); + debug_assert!(self.field_handles.len() < TableSize::MAX as usize); if let Some(idx) = self.field_map.get(&fh) { return *idx; } @@ -105,7 +105,7 @@ impl VariantHandleState { } fn add_variant_handle(&mut self, vh: VariantHandle) -> Option { - debug_assert!(self.variant_handles.len() < TableSize::max_value() as usize); + debug_assert!(self.variant_handles.len() < TableSize::MAX as usize); if let Some(idx) = self.variant_map.get(&vh) { return Some(*idx); } @@ -135,7 +135,7 @@ impl VariantInstantiationHandleState { &mut self, vh: VariantInstantiationHandle, ) -> Option { - debug_assert!(self.variant_instantiation_handles.len() < TableSize::max_value() as usize); + debug_assert!(self.variant_instantiation_handles.len() < TableSize::MAX as usize); if let Some(idx) = self.variant_map.get(&vh) { return Some(*idx); } @@ -179,7 +179,7 @@ where #[allow(unused)] fn add_instantiation(&mut self, inst: T) -> TableIndex { - debug_assert!(self.instantiations.len() < TableSize::max_value() as usize); + debug_assert!(self.instantiations.len() < TableSize::MAX as usize); if let Some(idx) = self.instantiation_map.get(&inst) { return *idx; } @@ -381,7 +381,7 @@ impl<'a> FnDefnMaterializeState<'a> { } fn add_function_handle(&mut self, handle: FunctionHandle) -> FunctionHandleIndex { - debug_assert!(self.function_handles.len() < TableSize::max_value() as usize); + debug_assert!(self.function_handles.len() < TableSize::MAX as usize); self.function_handles.push(handle); FunctionHandleIndex((self.function_handles.len() - 1) as TableIndex) } @@ -488,7 +488,7 @@ impl FunctionDefinitionGen { pub fn materialize(self, state: &mut FnDefnMaterializeState) -> Option { // This precondition should never fail because the table size cannot be greater - // than TableSize::max_value() + // than TableSize::MAX let iden_idx = IdentifierIndex(self.name.index(state.identifiers_len) as TableIndex); if state .def_function_handles diff --git a/external-crates/move/crates/move-binary-format/src/proptest_types/types.rs b/external-crates/move/crates/move-binary-format/src/proptest_types/types.rs index 6cd5e43e76afd..49071e100b080 100644 --- a/external-crates/move/crates/move-binary-format/src/proptest_types/types.rs +++ b/external-crates/move/crates/move-binary-format/src/proptest_types/types.rs @@ -23,9 +23,6 @@ use proptest::{ }; use std::collections::BTreeSet; -#[derive(Debug)] -struct TypeSignatureIndex(u16); - #[derive(Debug)] pub struct StDefnMaterializeState { pub self_module_handle_idx: ModuleHandleIndex, diff --git a/external-crates/move/crates/move-binary-format/src/serializer.rs b/external-crates/move/crates/move-binary-format/src/serializer.rs index 2d5a362e23914..0c8c6038df4d9 100644 --- a/external-crates/move/crates/move-binary-format/src/serializer.rs +++ b/external-crates/move/crates/move-binary-format/src/serializer.rs @@ -228,11 +228,11 @@ impl CompiledModule { let mut ser = ModuleSerializer::new(version); let mut temp = BinaryData::new(); ser.serialize_tables(&mut temp, self)?; - if temp.len() > u32::max_value() as usize { + if temp.len() > u32::MAX as usize { bail!( "table content size ({}) cannot exceed ({})", temp.len(), - u32::max_value() + u32::MAX ); } ser.common.serialize_header(&mut binary_data)?; @@ -296,11 +296,11 @@ struct ModuleSerializer { // Helpers // fn check_index_in_binary(index: usize) -> Result { - if index > u32::max_value() as usize { + if index > u32::MAX as usize { bail!( "Compilation unit too big ({}) cannot exceed {}", index, - u32::max_value() + u32::MAX ) } Ok(index as u32) diff --git a/external-crates/move/crates/move-binary-format/src/unit_tests/number_tests.rs b/external-crates/move/crates/move-binary-format/src/unit_tests/number_tests.rs index b99e94bb66e33..1e5f97f551374 100644 --- a/external-crates/move/crates/move-binary-format/src/unit_tests/number_tests.rs +++ b/external-crates/move/crates/move-binary-format/src/unit_tests/number_tests.rs @@ -42,8 +42,8 @@ fn uleb128_test() { uleb128_test_u64(2u64.pow(exp), n + 1); n += 1; } - uleb128_test_u64(u64::max_value() - 1, 10); - uleb128_test_u64(u64::max_value(), 10); + uleb128_test_u64(u64::MAX - 1, 10); + uleb128_test_u64(u64::MAX, 10); } #[test] diff --git a/external-crates/move/crates/move-bytecode-verifier/src/control_flow_v5.rs b/external-crates/move/crates/move-bytecode-verifier/src/control_flow_v5.rs index b24d7aeca62b9..eb705b9498b8b 100644 --- a/external-crates/move/crates/move-bytecode-verifier/src/control_flow_v5.rs +++ b/external-crates/move/crates/move-bytecode-verifier/src/control_flow_v5.rs @@ -37,7 +37,7 @@ pub fn verify( fn verify_fallthrough( current_function: FunctionDefinitionIndex, - code: &Vec, + code: &[Bytecode], ) -> PartialVMResult<()> { // Check to make sure that the bytecode vector ends with a branching instruction. match code.last() { diff --git a/external-crates/move/crates/move-bytecode-verifier/src/script_signature.rs b/external-crates/move/crates/move-bytecode-verifier/src/script_signature.rs index a26628c138ed0..8f11893a3f44a 100644 --- a/external-crates/move/crates/move-bytecode-verifier/src/script_signature.rs +++ b/external-crates/move/crates/move-bytecode-verifier/src/script_signature.rs @@ -9,6 +9,7 @@ //! - (DEPRECATED) Has an empty return type //! - All return types are not references //! - Satisfies the additional checks provided as an argument via `check_signature` +//! //! `check_signature` should be used by adapters to quickly and easily verify custom signature //! rules for entrypoints diff --git a/external-crates/move/crates/move-command-line-common/src/files.rs b/external-crates/move/crates/move-command-line-common/src/files.rs index 9300f49f895fc..b7b1039c7c12a 100644 --- a/external-crates/move/crates/move-command-line-common/src/files.rs +++ b/external-crates/move/crates/move-command-line-common/src/files.rs @@ -212,6 +212,7 @@ pub fn try_exists_vfs(vfs_path: &VfsPath) -> VfsResult { /// - For each directory in `paths`, it will return all files that satisfy the predicate /// - Any file explicitly passed in `paths`, it will include that file in the result, regardless /// of the file extension +/// /// It implements the same functionality as find_filenames above but for the virtual file system pub fn find_filenames_vfs bool>( paths: &[VfsPath], @@ -244,7 +245,8 @@ pub fn find_filenames_vfs bool>( /// - For each directory in `paths`, it will return all files with the `MOVE_EXTENSION` found /// recursively in that directory /// - If `keep_specified_files` any file explicitly passed in `paths`, will be added to the result -/// Otherwise, they will be discarded +/// +/// Otherwise, they will be discarded /// It implements the same functionality as find_move_filenames above but for the virtual file /// system pub fn find_move_filenames_vfs( diff --git a/external-crates/move/crates/move-compiler/src/cfgir/cfg.rs b/external-crates/move/crates/move-compiler/src/cfgir/cfg.rs index d640a3f20589a..8cad547a7ce11 100644 --- a/external-crates/move/crates/move-compiler/src/cfgir/cfg.rs +++ b/external-crates/move/crates/move-compiler/src/cfgir/cfg.rs @@ -205,6 +205,7 @@ impl<'a> ImmForwardCFG<'a> { /// Returns /// - A CFG /// - A set of infinite loop heads + /// /// This _must_ be called after `BlockMutCFG::new`, as the mutable version optimizes the code /// This will be done for external usage, /// since the Mut CFG is used during the building of the cfgir::ast::Program diff --git a/external-crates/move/crates/move-compiler/src/naming/translate.rs b/external-crates/move/crates/move-compiler/src/naming/translate.rs index ed6593ec344e9..f238eb60f6ff1 100644 --- a/external-crates/move/crates/move-compiler/src/naming/translate.rs +++ b/external-crates/move/crates/move-compiler/src/naming/translate.rs @@ -51,6 +51,7 @@ pub struct ResolvedModuleFunction { pub mident: ModuleIdent, pub name: FunctionName, pub tyarg_arity: usize, + #[allow(unused)] pub arity: usize, } @@ -93,6 +94,7 @@ pub enum FieldInfo { pub struct ResolvedConstant { pub mident: ModuleIdent, pub name: ConstantName, + #[allow(unused)] pub decl_loc: Loc, } @@ -138,6 +140,7 @@ pub(super) enum ResolvedConstructor { #[derive(Debug, Clone)] pub(super) enum ResolvedCallSubject { Builtin(Box), + #[allow(unused)] Constructor(Box), Function(Box), Var(Box), @@ -146,6 +149,7 @@ pub(super) enum ResolvedCallSubject { #[derive(Debug, Clone)] pub(super) enum ResolvedUseFunFunction { + #[allow(unused)] Builtin(Box), Module(Box), Unbound, @@ -3193,7 +3197,7 @@ fn unique_pattern_binders( ) -> Vec<(Mutability, P::Var)> { use E::MatchPattern_ as EP; - fn report_duplicate(context: &mut Context, var: P::Var, locs: &Vec<(Mutability, Loc)>) { + fn report_duplicate(context: &mut Context, var: P::Var, locs: &[(Mutability, Loc)]) { assert!(locs.len() > 1, "ICE pattern duplicate detection error"); let (_, first_loc) = locs.first().unwrap(); let mut diag = diag!( diff --git a/external-crates/move/crates/move-compiler/src/to_bytecode/canonicalize_handles.rs b/external-crates/move/crates/move-compiler/src/to_bytecode/canonicalize_handles.rs index 36d4a2544ef4b..5f816dd627ab4 100644 --- a/external-crates/move/crates/move-compiler/src/to_bytecode/canonicalize_handles.rs +++ b/external-crates/move/crates/move-compiler/src/to_bytecode/canonicalize_handles.rs @@ -31,7 +31,7 @@ use move_symbol_pool::Symbol; /// /// - Friend Declarations are sorted in lexical order (by address name and module name), followed by /// unnamed addresses in their original order. - +/// /// Key for ordering module handles, distinguishing the module's self handle, handles with names, /// and handles without names. #[derive(Eq, PartialEq, Ord, PartialOrd)] @@ -336,7 +336,7 @@ fn remap_code(code: &mut CodeUnit, functions: &[TableIndex]) { /// /// is sorted according to `key`. fn permutation<'p, T, K: Ord>( - pool: &'p Vec, + pool: &'p [T], key: impl Fn(TableIndex, &'p T) -> K + 'p, ) -> Vec { let mut inverse: Vec<_> = (0..pool.len() as TableIndex).collect(); @@ -352,7 +352,7 @@ fn permutation<'p, T, K: Ord>( /// Re-order `pool` according to the `permutation` array. `permutation[i]` is the new location of /// `pool[i]`. -fn apply_permutation(pool: &mut Vec, mut permutation: Vec) { +fn apply_permutation(pool: &mut [T], mut permutation: Vec) { assert_eq!(pool.len(), permutation.len()); // At every iteration we confirm that one more value is in its final position in the pool, diff --git a/external-crates/move/crates/move-compiler/src/typing/deprecation_warnings.rs b/external-crates/move/crates/move-compiler/src/typing/deprecation_warnings.rs index dc6c387a99cd9..9ba6765d66dc3 100644 --- a/external-crates/move/crates/move-compiler/src/typing/deprecation_warnings.rs +++ b/external-crates/move/crates/move-compiler/src/typing/deprecation_warnings.rs @@ -19,6 +19,7 @@ const NOTE_STR: &str = "note"; #[derive(Debug, Clone)] pub struct Deprecation { // The source location of the deprecation attribute + #[allow(unused)] pub source_location: Loc, // The type of the member that is deprecated (function, constant, etc.) pub location: AttributePosition, diff --git a/external-crates/move/crates/move-compiler/src/typing/expand.rs b/external-crates/move/crates/move-compiler/src/typing/expand.rs index 2fd127861672a..9f36764277e55 100644 --- a/external-crates/move/crates/move-compiler/src/typing/expand.rs +++ b/external-crates/move/crates/move-compiler/src/typing/expand.rs @@ -318,11 +318,11 @@ fn inferred_numerical_value( Some(sp!(_, bt)) if bt.is_numeric() => bt, _ => panic!("ICE inferred num failed {:?}", &ty.value), }; - let u8_max = U256::from(std::u8::MAX); - let u16_max = U256::from(std::u16::MAX); - let u32_max = U256::from(std::u32::MAX); - let u64_max = U256::from(std::u64::MAX); - let u128_max = U256::from(std::u128::MAX); + let u8_max = U256::from(u8::MAX); + let u16_max = U256::from(u16::MAX); + let u32_max = U256::from(u32::MAX); + let u64_max = U256::from(u64::MAX); + let u128_max = U256::from(u128::MAX); let u256_max = U256::max_value(); let max = match bt { BT::U8 => u8_max, diff --git a/external-crates/move/crates/move-compiler/src/unit_test/plan_builder.rs b/external-crates/move/crates/move-compiler/src/unit_test/plan_builder.rs index 066cd6f982799..7aab1a163d71d 100644 --- a/external-crates/move/crates/move-compiler/src/unit_test/plan_builder.rs +++ b/external-crates/move/crates/move-compiler/src/unit_test/plan_builder.rs @@ -713,7 +713,7 @@ fn convert_attribute_value_u64( ) -> Option<(Loc, u64)> { use E::{AttributeValue_ as EAV, Value_ as EV}; match value { - sp!(vloc, EAV::Value(sp!(_, EV::InferredNum(u)))) if *u <= U256::from(std::u64::MAX) => { + sp!(vloc, EAV::Value(sp!(_, EV::InferredNum(u)))) if *u <= U256::from(u64::MAX) => { Some((*vloc, u.down_cast_lossy())) } sp!(vloc, EAV::Value(sp!(_, EV::U64(u)))) => Some((*vloc, *u)), diff --git a/external-crates/move/crates/move-core-types/src/state.rs b/external-crates/move/crates/move-core-types/src/state.rs index 6d94c574a9dd6..f57e1abdcad79 100644 --- a/external-crates/move/crates/move-core-types/src/state.rs +++ b/external-crates/move/crates/move-core-types/src/state.rs @@ -13,7 +13,7 @@ pub enum VMState { } thread_local! { - static STATE: RefCell = RefCell::new(VMState::OTHER); + static STATE: RefCell = const { RefCell::new(VMState::OTHER) }; } pub fn set_state(state: VMState) -> VMState { diff --git a/external-crates/move/crates/move-core-types/src/u256.rs b/external-crates/move/crates/move-core-types/src/u256.rs index fb240326cebad..d47245857df5c 100644 --- a/external-crates/move/crates/move-core-types/src/u256.rs +++ b/external-crates/move/crates/move-core-types/src/u256.rs @@ -567,7 +567,6 @@ impl Distribution for Standard { // Rand impl below are inspired by u128 impl found in https://rust-random.github.io/rand/src/rand/distributions/uniform.rs.html #[derive(Clone, Copy, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] pub struct UniformU256 { low: U256, range: U256, diff --git a/external-crates/move/crates/move-ir-to-bytecode/src/context.rs b/external-crates/move/crates/move-ir-to-bytecode/src/context.rs index b62cda8506c6d..1d320b4653cf9 100644 --- a/external-crates/move/crates/move-ir-to-bytecode/src/context.rs +++ b/external-crates/move/crates/move-ir-to-bytecode/src/context.rs @@ -48,7 +48,7 @@ macro_rules! get_or_add_item_macro { }}; } -pub const TABLE_MAX_SIZE: usize = u16::max_value() as usize; +pub const TABLE_MAX_SIZE: usize = u16::MAX as usize; fn get_or_add_item_ref( m: &mut HashMap, k: &K, diff --git a/external-crates/move/crates/move-model/src/ty.rs b/external-crates/move/crates/move-model/src/ty.rs index 8083e4eaa7119..31ef1d646d1b7 100644 --- a/external-crates/move/crates/move-model/src/ty.rs +++ b/external-crates/move/crates/move-model/src/ty.rs @@ -173,19 +173,18 @@ impl Type { /// Returns true if this is any number type. pub fn is_number(&self) -> bool { - if let Type::Primitive(p) = self { - if let PrimitiveType::U8 - | PrimitiveType::U16 - | PrimitiveType::U32 - | PrimitiveType::U64 - | PrimitiveType::U128 - | PrimitiveType::U256 - | PrimitiveType::Num = p - { - return true; - } - } - false + matches!( + self, + Type::Primitive( + PrimitiveType::U8 + | PrimitiveType::U16 + | PrimitiveType::U32 + | PrimitiveType::U64 + | PrimitiveType::U128 + | PrimitiveType::U256 + | PrimitiveType::Num, + ) + ) } /// Returns true if this is an address or signer type. pub fn is_signer_or_address(&self) -> bool { @@ -780,6 +779,7 @@ impl TypeUnificationAdapter { /// - any type parameter on the LHS with index < P will be treated as concrete types and /// - only type parameters on the LHS with index >= P are treated as variables and thus, /// participate in the type unification process. + /// /// The same rule applies to the RHS parameters via `treat_rhs_type_param_as_var_after_index`. fn new<'a, I>( lhs_types: I, @@ -982,6 +982,7 @@ impl TypeInstantiationDerivation { /// - be assigned with a concrete type already and hence, ceases to be a type parameter, or /// - does not have any matching instantiation and hence, either remains a type parameter or is /// represented as a type error. + /// /// But in anyway, these type parameters no longer participate in type unification anymore. /// /// If `target_lhs` is True, derive instantiations for the type parameter with @@ -1043,6 +1044,7 @@ impl TypeInstantiationDerivation { /// - finds all possible instantiations for parameter at index 2 (`inst_param_2`) /// - for each instantiation in `inst_param_2`, /// - ...... + /// /// The process continues until all type parameters are analyzed (i.e., reaching the type /// parameter at index `N`). /// diff --git a/external-crates/move/crates/move-stackless-bytecode/src/access_path.rs b/external-crates/move/crates/move-stackless-bytecode/src/access_path.rs index 52927f081a542..84d41e97e530d 100644 --- a/external-crates/move/crates/move-stackless-bytecode/src/access_path.rs +++ b/external-crates/move/crates/move-stackless-bytecode/src/access_path.rs @@ -6,6 +6,7 @@ //! memory. Some examples of concrete paths are: //! * `0x7/M::T/f` (i.e., the field `f` of the `M::T` resource stored at address `0x7` //! * `Formal(0)/[2]` (i.e., the value stored at index 2 of the array bound the 0th formal of the current procedure) +//! //! An abstract path is similar; it consists of the following components: //! * A *root*, which is either an abstract address or a local //! * Zero or more *offsets*, where an offset is a field, an unknown vector index, or an abstract struct type diff --git a/external-crates/move/crates/move-stackless-bytecode/src/inconsistency_check.rs b/external-crates/move/crates/move-stackless-bytecode/src/inconsistency_check.rs index 7ca6aad925ba2..8a5f2dec7e20a 100644 --- a/external-crates/move/crates/move-stackless-bytecode/src/inconsistency_check.rs +++ b/external-crates/move/crates/move-stackless-bytecode/src/inconsistency_check.rs @@ -11,6 +11,7 @@ //! an `assert false` before //! - every `return` and //! - every `abort` (if the `unconditional-abort-as-inconsistency` option is set). +//! //! In this way, if the instrumented `assert false` can be proved, it means we have an inconsistency //! in the specifications. //! diff --git a/external-crates/move/crates/move-stackless-bytecode/src/packed_types_analysis.rs b/external-crates/move/crates/move-stackless-bytecode/src/packed_types_analysis.rs index 1e0783cd8b308..10fc6fbe99891 100644 --- a/external-crates/move/crates/move-stackless-bytecode/src/packed_types_analysis.rs +++ b/external-crates/move/crates/move-stackless-bytecode/src/packed_types_analysis.rs @@ -26,6 +26,7 @@ use crate::{ /// - Transaction scripts have at most 1 type argument /// - The only values that can be bound to a transaction script type argument are XUS and /// XDX. Passing any other values will lead to an aborted transaction. +/// /// The first assumption is checked and will trigger an assert failure if violated. The second /// is unchecked, but would be a nice property for the prover. pub fn get_packed_types( diff --git a/external-crates/move/crates/move-stdlib-natives/src/debug.rs b/external-crates/move/crates/move-stdlib-natives/src/debug.rs index 1aee70ebed864..d4e55a46ea170 100644 --- a/external-crates/move/crates/move-stdlib-natives/src/debug.rs +++ b/external-crates/move/crates/move-stdlib-natives/src/debug.rs @@ -286,7 +286,7 @@ mod testing { Ok(()) } - fn is_non_empty_vector_u8(vec: &Vec) -> bool { + fn is_non_empty_vector_u8(vec: &[A::MoveValue]) -> bool { if vec.is_empty() { false } else { diff --git a/external-crates/move/crates/move-vm-runtime/src/tracing.rs b/external-crates/move/crates/move-vm-runtime/src/tracing.rs index b016879c9bb45..a4c984c62a537 100644 --- a/external-crates/move/crates/move-vm-runtime/src/tracing.rs +++ b/external-crates/move/crates/move-vm-runtime/src/tracing.rs @@ -48,7 +48,6 @@ static DEBUGGING_ENABLED: Lazy = static LOGGING_FILE: Lazy> = Lazy::new(|| { Mutex::new( OpenOptions::new() - .write(true) .create(true) .append(true) .open(&*FILE_PATH) diff --git a/external-crates/move/crates/move-vm-test-utils/src/gas_schedule.rs b/external-crates/move/crates/move-vm-test-utils/src/gas_schedule.rs index 2d4cfed4537ed..128d7e4447841 100644 --- a/external-crates/move/crates/move-vm-test-utils/src/gas_schedule.rs +++ b/external-crates/move/crates/move-vm-test-utils/src/gas_schedule.rs @@ -33,10 +33,7 @@ use move_vm_types::{ }; use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; -use std::{ - ops::{Add, Mul}, - u64, -}; +use std::ops::{Add, Mul}; pub enum GasUnit {} pub type Gas = GasQuantity; diff --git a/external-crates/move/crates/move-vm-types/src/values/values_impl.rs b/external-crates/move/crates/move-vm-types/src/values/values_impl.rs index e09471bf6e027..aab6897fdc244 100644 --- a/external-crates/move/crates/move-vm-types/src/values/values_impl.rs +++ b/external-crates/move/crates/move-vm-types/src/values/values_impl.rs @@ -2018,7 +2018,7 @@ impl IntegerValue { match self { U8(x) => Ok(x), U16(x) => { - if x > (std::u8::MAX as u16) { + if x > (u8::MAX as u16) { Err(PartialVMError::new(StatusCode::ARITHMETIC_ERROR) .with_message(format!("Cannot cast u16({}) to u8", x))) } else { @@ -2026,7 +2026,7 @@ impl IntegerValue { } } U32(x) => { - if x > (std::u8::MAX as u32) { + if x > (u8::MAX as u32) { Err(PartialVMError::new(StatusCode::ARITHMETIC_ERROR) .with_message(format!("Cannot cast u32({}) to u8", x))) } else { @@ -2034,7 +2034,7 @@ impl IntegerValue { } } U64(x) => { - if x > (std::u8::MAX as u64) { + if x > (u8::MAX as u64) { Err(PartialVMError::new(StatusCode::ARITHMETIC_ERROR) .with_message(format!("Cannot cast u64({}) to u8", x))) } else { @@ -2042,7 +2042,7 @@ impl IntegerValue { } } U128(x) => { - if x > (std::u8::MAX as u128) { + if x > (u8::MAX as u128) { Err(PartialVMError::new(StatusCode::ARITHMETIC_ERROR) .with_message(format!("Cannot cast u128({}) to u8", x))) } else { @@ -2050,7 +2050,7 @@ impl IntegerValue { } } U256(x) => { - if x > (u256::U256::from(std::u8::MAX)) { + if x > (u256::U256::from(u8::MAX)) { Err(PartialVMError::new(StatusCode::ARITHMETIC_ERROR) .with_message(format!("Cannot cast u256({}) to u8", x))) } else { @@ -2067,7 +2067,7 @@ impl IntegerValue { U8(x) => Ok(x as u16), U16(x) => Ok(x), U32(x) => { - if x > (std::u16::MAX as u32) { + if x > (u16::MAX as u32) { Err(PartialVMError::new(StatusCode::ARITHMETIC_ERROR) .with_message(format!("Cannot cast u32({}) to u16", x))) } else { @@ -2075,7 +2075,7 @@ impl IntegerValue { } } U64(x) => { - if x > (std::u16::MAX as u64) { + if x > (u16::MAX as u64) { Err(PartialVMError::new(StatusCode::ARITHMETIC_ERROR) .with_message(format!("Cannot cast u64({}) to u16", x))) } else { @@ -2083,7 +2083,7 @@ impl IntegerValue { } } U128(x) => { - if x > (std::u16::MAX as u128) { + if x > (u16::MAX as u128) { Err(PartialVMError::new(StatusCode::ARITHMETIC_ERROR) .with_message(format!("Cannot cast u128({}) to u16", x))) } else { @@ -2091,7 +2091,7 @@ impl IntegerValue { } } U256(x) => { - if x > (u256::U256::from(std::u16::MAX)) { + if x > (u256::U256::from(u16::MAX)) { Err(PartialVMError::new(StatusCode::ARITHMETIC_ERROR) .with_message(format!("Cannot cast u256({}) to u16", x))) } else { @@ -2109,7 +2109,7 @@ impl IntegerValue { U16(x) => Ok(x as u32), U32(x) => Ok(x), U64(x) => { - if x > (std::u32::MAX as u64) { + if x > (u32::MAX as u64) { Err(PartialVMError::new(StatusCode::ARITHMETIC_ERROR) .with_message(format!("Cannot cast u64({}) to u32", x))) } else { @@ -2117,7 +2117,7 @@ impl IntegerValue { } } U128(x) => { - if x > (std::u32::MAX as u128) { + if x > (u32::MAX as u128) { Err(PartialVMError::new(StatusCode::ARITHMETIC_ERROR) .with_message(format!("Cannot cast u128({}) to u32", x))) } else { @@ -2125,7 +2125,7 @@ impl IntegerValue { } } U256(x) => { - if x > (u256::U256::from(std::u32::MAX)) { + if x > (u256::U256::from(u32::MAX)) { Err(PartialVMError::new(StatusCode::ARITHMETIC_ERROR) .with_message(format!("Cannot cast u128({}) to u32", x))) } else { @@ -2144,7 +2144,7 @@ impl IntegerValue { U32(x) => Ok(x as u64), U64(x) => Ok(x), U128(x) => { - if x > (std::u64::MAX as u128) { + if x > (u64::MAX as u128) { Err(PartialVMError::new(StatusCode::ARITHMETIC_ERROR) .with_message(format!("Cannot cast u128({}) to u64", x))) } else { @@ -2152,7 +2152,7 @@ impl IntegerValue { } } U256(x) => { - if x > (u256::U256::from(std::u64::MAX)) { + if x > (u256::U256::from(u64::MAX)) { Err(PartialVMError::new(StatusCode::ARITHMETIC_ERROR) .with_message(format!("Cannot cast u256({}) to u64", x))) } else { @@ -2172,7 +2172,7 @@ impl IntegerValue { U64(x) => Ok(x as u128), U128(x) => Ok(x), U256(x) => { - if x > (u256::U256::from(std::u128::MAX)) { + if x > (u256::U256::from(u128::MAX)) { Err(PartialVMError::new(StatusCode::ARITHMETIC_ERROR) .with_message(format!("Cannot cast u256({}) to u128", x))) } else { diff --git a/external-crates/move/crates/test-generation/src/abstract_state.rs b/external-crates/move/crates/test-generation/src/abstract_state.rs index 00325826f9402..b83e2759c98b9 100644 --- a/external-crates/move/crates/test-generation/src/abstract_state.rs +++ b/external-crates/move/crates/test-generation/src/abstract_state.rs @@ -511,7 +511,7 @@ impl AbstractState { pub fn stack_push(&mut self, item: AbstractValue) { // Programs that are large enough to exceed this bound // will not be generated - debug_assert!(self.stack.len() < usize::max_value()); + debug_assert!(self.stack.len() < usize::MAX); self.stack.push(item); } @@ -521,7 +521,7 @@ impl AbstractState { if let Some(abstract_value) = self.register_move() { // Programs that are large enough to exceed this bound // will not be generated - debug_assert!(self.stack.len() < usize::max_value()); + debug_assert!(self.stack.len() < usize::MAX); self.stack.push(abstract_value); Ok(()) } else { diff --git a/external-crates/move/crates/test-generation/src/borrow_graph.rs b/external-crates/move/crates/test-generation/src/borrow_graph.rs index df1ea3fde6c18..8d5a489a78136 100644 --- a/external-crates/move/crates/test-generation/src/borrow_graph.rs +++ b/external-crates/move/crates/test-generation/src/borrow_graph.rs @@ -67,7 +67,7 @@ impl BorrowGraph { } self.partition_map.insert(self.partition_counter, vec![n]); // Implication of `checked_add` - debug_assert!(self.partitions.len() < usize::max_value()); + debug_assert!(self.partitions.len() < usize::MAX); self.partitions.push(self.partition_counter); Ok(()) } else { diff --git a/external-crates/move/crates/test-generation/src/bytecode_generator.rs b/external-crates/move/crates/test-generation/src/bytecode_generator.rs index 3177706654b32..efbb3aae9141e 100644 --- a/external-crates/move/crates/test-generation/src/bytecode_generator.rs +++ b/external-crates/move/crates/test-generation/src/bytecode_generator.rs @@ -157,7 +157,7 @@ impl FunctionGenerationContext { pub fn incr_instruction_count(&mut self) -> Option<()> { self.bytecode_len += 1; - if self.bytecode_len >= (u16::max_value() - 1) as u64 { + if self.bytecode_len >= (u16::MAX - 1) as u64 { return None; } Some(()) @@ -357,25 +357,23 @@ impl<'a> BytecodeGenerator<'a> { } BytecodeType::U8(instruction) => { // Generate a random u8 constant to load - Some(instruction(self.rng.gen_range(0..u8::max_value()))) + Some(instruction(self.rng.gen_range(0..u8::MAX))) } BytecodeType::U16(instruction) => { // Generate a random u16 constant to load - Some(instruction(self.rng.gen_range(0..u16::max_value()))) + Some(instruction(self.rng.gen_range(0..u16::MAX))) } BytecodeType::U32(instruction) => { // Generate a random u32 constant to load - Some(instruction(self.rng.gen_range(0..u32::max_value()))) + Some(instruction(self.rng.gen_range(0..u32::MAX))) } BytecodeType::U64(instruction) => { // Generate a random u64 constant to load - Some(instruction(self.rng.gen_range(0..u64::max_value()))) + Some(instruction(self.rng.gen_range(0..u64::MAX))) } BytecodeType::U128(instruction) => { // Generate a random u128 constant to load - Some(instruction(Box::new( - self.rng.gen_range(0..u128::max_value()), - ))) + Some(instruction(Box::new(self.rng.gen_range(0..u128::MAX)))) } BytecodeType::U256(instruction) => { // Generate a random u256 constant to load @@ -442,7 +440,7 @@ impl<'a> BytecodeGenerator<'a> { || unsatisfied_preconditions == 0 { // The size of matches cannot be greater than the number of bytecode instructions - debug_assert!(matches.len() < usize::max_value()); + debug_assert!(matches.len() < usize::MAX); matches.push((*stack_effect, instruction)); } } @@ -572,7 +570,7 @@ impl<'a> BytecodeGenerator<'a> { exact: bool, ) -> Option { // Bytecode will never be generated this large - debug_assert!(bytecode.len() < usize::max_value()); + debug_assert!(bytecode.len() < usize::MAX); debug!("**********************"); debug!("State1: {}", state); debug!("Next instr: {:?}", instruction); diff --git a/external-crates/move/crates/test-generation/src/control_flow_graph.rs b/external-crates/move/crates/test-generation/src/control_flow_graph.rs index 78100aa710d89..341d68ed5f6d7 100644 --- a/external-crates/move/crates/test-generation/src/control_flow_graph.rs +++ b/external-crates/move/crates/test-generation/src/control_flow_graph.rs @@ -95,22 +95,22 @@ impl CFG { // The number of edges will be at most `2*target_blocks`` // Since target blocks is at most a `u16`, this will not overflow even if // `usize` is a `u32` - debug_assert!(edges.len() < usize::max_value()); + debug_assert!(edges.len() < usize::MAX); edges.push((parent_block_id, current_block_id)); block_queue.push_back(current_block_id); // `current_block_id` is bound by the max og `target_block_size` - debug_assert!(current_block_id < u16::max_value()); + debug_assert!(current_block_id < u16::MAX); current_block_id += 1; // Generate a second child edge with prob = 1/2 if rng.gen_bool(0.5) && current_block_id < target_blocks { // The number of edges will be at most `2*target_blocks`` // Since target blocks is at most a `u16`, this will not overflow even if // `usize` is a `u32` - debug_assert!(edges.len() < usize::max_value()); + debug_assert!(edges.len() < usize::MAX); edges.push((parent_block_id, current_block_id)); block_queue.push_back(current_block_id); // `current_block_id` is bound by the max og `target_block_size` - debug_assert!(current_block_id < u16::max_value()); + debug_assert!(current_block_id < u16::MAX); current_block_id += 1; } } @@ -156,7 +156,7 @@ impl CFG { for (parent, child) in self.edges.iter() { if *parent == block_id { // Length is bound by iteration on `self.edges` - debug_assert!(children_ids.len() < usize::max_value()); + debug_assert!(children_ids.len() < usize::MAX); children_ids.push(*child); } } @@ -175,7 +175,7 @@ impl CFG { for (parent, child) in self.edges.iter() { if *child == block_id { // Iteration is bound by the self.edges vector length - debug_assert!(parent_ids.len() < usize::max_value()); + debug_assert!(parent_ids.len() < usize::MAX); parent_ids.push(*parent); } } diff --git a/external-crates/move/crates/test-generation/src/lib.rs b/external-crates/move/crates/test-generation/src/lib.rs index 4a4ce8449659a..676044d88b632 100644 --- a/external-crates/move/crates/test-generation/src/lib.rs +++ b/external-crates/move/crates/test-generation/src/lib.rs @@ -236,9 +236,7 @@ pub fn module_frame_generation( let mut module = generate_module(&mut rng, generation_options.clone()); // Either get the number of iterations provided by the user, or iterate "infinitely"--up to // u128::MAX number of times. - let iters = num_iters - .map(|x| x as u128) - .unwrap_or_else(|| std::u128::MAX); + let iters = num_iters.map(|x| x as u128).unwrap_or_else(|| u128::MAX); while generated < iters && sender.send(module).is_ok() { module = generate_module(&mut rng, generation_options.clone()); diff --git a/external-crates/move/crates/test-generation/tests/generic_instructions.rs b/external-crates/move/crates/test-generation/tests/generic_instructions.rs index 66eb17078de50..0f6305f419638 100644 --- a/external-crates/move/crates/test-generation/tests/generic_instructions.rs +++ b/external-crates/move/crates/test-generation/tests/generic_instructions.rs @@ -13,7 +13,7 @@ use test_generation::transitions::Subst; #[test] fn unify_no_subst() { use SignatureToken::*; - let tys = vec![Bool, U64, Vector(Box::new(U8)), Address]; + let tys = [Bool, U64, Vector(Box::new(U8)), Address]; for tok1 in tys.iter() { for tok2 in tys.iter() { let should_unify = tok1.clone() == tok2.clone(); diff --git a/external-crates/move/move-execution/v0/crates/move-bytecode-verifier/src/control_flow_v5.rs b/external-crates/move/move-execution/v0/crates/move-bytecode-verifier/src/control_flow_v5.rs index b24d7aeca62b9..eb705b9498b8b 100644 --- a/external-crates/move/move-execution/v0/crates/move-bytecode-verifier/src/control_flow_v5.rs +++ b/external-crates/move/move-execution/v0/crates/move-bytecode-verifier/src/control_flow_v5.rs @@ -37,7 +37,7 @@ pub fn verify( fn verify_fallthrough( current_function: FunctionDefinitionIndex, - code: &Vec, + code: &[Bytecode], ) -> PartialVMResult<()> { // Check to make sure that the bytecode vector ends with a branching instruction. match code.last() { diff --git a/external-crates/move/move-execution/v0/crates/move-bytecode-verifier/src/script_signature.rs b/external-crates/move/move-execution/v0/crates/move-bytecode-verifier/src/script_signature.rs index b55ea638e1e3d..35b065b204dbe 100644 --- a/external-crates/move/move-execution/v0/crates/move-bytecode-verifier/src/script_signature.rs +++ b/external-crates/move/move-execution/v0/crates/move-bytecode-verifier/src/script_signature.rs @@ -9,6 +9,7 @@ //! - (DEPRECATED) Has an empty return type //! - All return types are not references //! - Satisfies the additional checks provided as an argument via `check_signature` +//! //! `check_signature` should be used by adapters to quickly and easily verify custom signature //! rules for entrypoints diff --git a/external-crates/move/move-execution/v0/crates/move-vm-runtime/src/tracing.rs b/external-crates/move/move-execution/v0/crates/move-vm-runtime/src/tracing.rs index b016879c9bb45..a4c984c62a537 100644 --- a/external-crates/move/move-execution/v0/crates/move-vm-runtime/src/tracing.rs +++ b/external-crates/move/move-execution/v0/crates/move-vm-runtime/src/tracing.rs @@ -48,7 +48,6 @@ static DEBUGGING_ENABLED: Lazy = static LOGGING_FILE: Lazy> = Lazy::new(|| { Mutex::new( OpenOptions::new() - .write(true) .create(true) .append(true) .open(&*FILE_PATH) diff --git a/external-crates/move/move-execution/v1/crates/move-bytecode-verifier/src/control_flow_v5.rs b/external-crates/move/move-execution/v1/crates/move-bytecode-verifier/src/control_flow_v5.rs index b24d7aeca62b9..eb705b9498b8b 100644 --- a/external-crates/move/move-execution/v1/crates/move-bytecode-verifier/src/control_flow_v5.rs +++ b/external-crates/move/move-execution/v1/crates/move-bytecode-verifier/src/control_flow_v5.rs @@ -37,7 +37,7 @@ pub fn verify( fn verify_fallthrough( current_function: FunctionDefinitionIndex, - code: &Vec, + code: &[Bytecode], ) -> PartialVMResult<()> { // Check to make sure that the bytecode vector ends with a branching instruction. match code.last() { diff --git a/external-crates/move/move-execution/v1/crates/move-bytecode-verifier/src/script_signature.rs b/external-crates/move/move-execution/v1/crates/move-bytecode-verifier/src/script_signature.rs index b55ea638e1e3d..35b065b204dbe 100644 --- a/external-crates/move/move-execution/v1/crates/move-bytecode-verifier/src/script_signature.rs +++ b/external-crates/move/move-execution/v1/crates/move-bytecode-verifier/src/script_signature.rs @@ -9,6 +9,7 @@ //! - (DEPRECATED) Has an empty return type //! - All return types are not references //! - Satisfies the additional checks provided as an argument via `check_signature` +//! //! `check_signature` should be used by adapters to quickly and easily verify custom signature //! rules for entrypoints diff --git a/external-crates/move/move-execution/v1/crates/move-vm-runtime/src/tracing.rs b/external-crates/move/move-execution/v1/crates/move-vm-runtime/src/tracing.rs index b016879c9bb45..a4c984c62a537 100644 --- a/external-crates/move/move-execution/v1/crates/move-vm-runtime/src/tracing.rs +++ b/external-crates/move/move-execution/v1/crates/move-vm-runtime/src/tracing.rs @@ -48,7 +48,6 @@ static DEBUGGING_ENABLED: Lazy = static LOGGING_FILE: Lazy> = Lazy::new(|| { Mutex::new( OpenOptions::new() - .write(true) .create(true) .append(true) .open(&*FILE_PATH) diff --git a/external-crates/move/move-execution/v2/crates/move-bytecode-verifier/src/control_flow_v5.rs b/external-crates/move/move-execution/v2/crates/move-bytecode-verifier/src/control_flow_v5.rs index b24d7aeca62b9..eb705b9498b8b 100644 --- a/external-crates/move/move-execution/v2/crates/move-bytecode-verifier/src/control_flow_v5.rs +++ b/external-crates/move/move-execution/v2/crates/move-bytecode-verifier/src/control_flow_v5.rs @@ -37,7 +37,7 @@ pub fn verify( fn verify_fallthrough( current_function: FunctionDefinitionIndex, - code: &Vec, + code: &[Bytecode], ) -> PartialVMResult<()> { // Check to make sure that the bytecode vector ends with a branching instruction. match code.last() { diff --git a/external-crates/move/move-execution/v2/crates/move-bytecode-verifier/src/script_signature.rs b/external-crates/move/move-execution/v2/crates/move-bytecode-verifier/src/script_signature.rs index b55ea638e1e3d..35b065b204dbe 100644 --- a/external-crates/move/move-execution/v2/crates/move-bytecode-verifier/src/script_signature.rs +++ b/external-crates/move/move-execution/v2/crates/move-bytecode-verifier/src/script_signature.rs @@ -9,6 +9,7 @@ //! - (DEPRECATED) Has an empty return type //! - All return types are not references //! - Satisfies the additional checks provided as an argument via `check_signature` +//! //! `check_signature` should be used by adapters to quickly and easily verify custom signature //! rules for entrypoints diff --git a/external-crates/move/move-execution/v2/crates/move-vm-runtime/src/tracing.rs b/external-crates/move/move-execution/v2/crates/move-vm-runtime/src/tracing.rs index b016879c9bb45..a4c984c62a537 100644 --- a/external-crates/move/move-execution/v2/crates/move-vm-runtime/src/tracing.rs +++ b/external-crates/move/move-execution/v2/crates/move-vm-runtime/src/tracing.rs @@ -48,7 +48,6 @@ static DEBUGGING_ENABLED: Lazy = static LOGGING_FILE: Lazy> = Lazy::new(|| { Mutex::new( OpenOptions::new() - .write(true) .create(true) .append(true) .open(&*FILE_PATH) diff --git a/narwhal/config/src/lib.rs b/narwhal/config/src/lib.rs index 37f92aec91fb9..6ee97a903091f 100644 --- a/narwhal/config/src/lib.rs +++ b/narwhal/config/src/lib.rs @@ -99,7 +99,11 @@ impl Import for D {} pub trait Export: Serialize { fn export(&self, path: &str) -> Result<(), ConfigError> { let writer = || -> Result<(), std::io::Error> { - let file = OpenOptions::new().create(true).write(true).open(path)?; + let file = OpenOptions::new() + .create(true) + .truncate(true) + .write(true) + .open(path)?; let mut writer = BufWriter::new(file); let data = serde_json::to_string_pretty(self).unwrap(); writer.write_all(data.as_ref())?; diff --git a/narwhal/node/src/benchmark_client.rs b/narwhal/node/src/benchmark_client.rs index 1f6e10843dfec..a8d721f882d8c 100644 --- a/narwhal/node/src/benchmark_client.rs +++ b/narwhal/node/src/benchmark_client.rs @@ -31,6 +31,7 @@ use worker::LazyNarwhalClient; /// * the size of the transactions via the --size property /// * the worker address to send the transactions to. A url format is expected ex http://127.0.0.1:7000 /// * the rate of sending transactions via the --rate parameter +/// /// Optionally the --nodes parameter can be passed where a list of worker addresses /// should be passed. The benchmarking client will first try to connect to all of those nodes before start sending /// any transactions. That confirms the system is up and running and ready to start processing the transactions. diff --git a/narwhal/node/src/main.rs b/narwhal/node/src/main.rs index 8de09ecd12106..3aa919b9b5012 100644 --- a/narwhal/node/src/main.rs +++ b/narwhal/node/src/main.rs @@ -303,7 +303,7 @@ async fn main() -> Result<(), eyre::Report> { /// Generate all the genesis files required for benchmarks. fn benchmark_genesis( - ips: &Vec, + ips: &[String], working_directory: &PathBuf, num_workers: usize, base_port: usize, diff --git a/narwhal/primary/src/consensus/metrics.rs b/narwhal/primary/src/consensus/metrics.rs index d855a249327bf..11a16da29d8f9 100644 --- a/narwhal/primary/src/consensus/metrics.rs +++ b/narwhal/primary/src/consensus/metrics.rs @@ -37,7 +37,7 @@ pub struct ConsensusMetrics { /// all the nodes are expected to report the same results. For every leader of each round the /// output can be one of the following: /// * committed: the leader has been found and its subdag will get committed - no matter if the leader - /// is committed on its time or not (part of recursion) + /// is committed on its time or not (part of recursion) /// * not_found: the leader has not been found on the commit path and doesn't get committed /// * no_path: the leader exists but there is no path that leads to it pub leader_election: IntCounterVec, @@ -135,9 +135,9 @@ pub struct ChannelMetrics { /// occupancy of the channel from the `Consensus` to `SubscriberHandler`. /// See also: /// * tx_committed_certificates in primary, where the committed certificates - /// from `Consensus` are sent to `primary::StateHandler` + /// from `Consensus` are sent to `primary::StateHandler` /// * tx_new_certificates where the newly accepted certificates are sent - /// from `primary::Synchronizer` to `Consensus` + /// from `primary::Synchronizer` to `Consensus` pub tx_sequence: IntGauge, } diff --git a/narwhal/primary/src/synchronizer.rs b/narwhal/primary/src/synchronizer.rs index 6ce964d43501a..f7953c8bfab87 100644 --- a/narwhal/primary/src/synchronizer.rs +++ b/narwhal/primary/src/synchronizer.rs @@ -336,6 +336,7 @@ impl Inner { /// - Validating and accepting certificates received from peers. /// - Triggering fetching for certificates and batches. /// - Broadcasting created certificates. +/// /// `Synchronizer` contains most of the certificate processing logic in Narwhal. #[derive(Clone)] pub struct Synchronizer { @@ -1516,9 +1517,7 @@ impl State { ) -> Option<((u64, CertificateDigest), Option)> { // Accept suspended certificates at and below gc round because their parents will not // be accepted into the DAG store anymore, in sanitize_certificate(). - let Some(((round, digest), _children)) = self.missing.first_key_value() else { - return None; - }; + let ((round, digest), _children) = self.missing.first_key_value()?; // Note that gc_round is the highest round where certificates are gc'ed, and which will // never be in a consensus commit. It's safe to gc up to gc_round, so anything suspended on gc_round + 1 // can safely be accepted as their parents (of gc_round) have already been removed from the DAG. diff --git a/narwhal/primary/tests/randomized_tests.rs b/narwhal/primary/tests/randomized_tests.rs index 79274b9dbdd18..db357ab53ae5a 100644 --- a/narwhal/primary/tests/randomized_tests.rs +++ b/narwhal/primary/tests/randomized_tests.rs @@ -299,7 +299,7 @@ fn generate_randomised_dag( /// * nodes that don't create certificates at all for some rounds (failures) /// * leaders that don't get enough support (f+1) for their immediate round /// * slow nodes - nodes that create certificates but those might not referenced by nodes of -/// subsequent rounds. +/// subsequent rounds. pub fn make_certificates_with_parameters( seed: u64, committee: &Committee, diff --git a/narwhal/storage/src/certificate_store.rs b/narwhal/storage/src/certificate_store.rs index 17517c5edd686..8f1264f94745d 100644 --- a/narwhal/storage/src/certificate_store.rs +++ b/narwhal/storage/src/certificate_store.rs @@ -187,50 +187,6 @@ impl Cache for CertificateStoreCache { } } -/// An implementation that basically disables the caching functionality when used for CertificateStore. -#[derive(Clone)] -struct NoCache {} - -impl Cache for NoCache { - fn write(&self, _certificate: Certificate) { - // no-op - } - - fn write_all(&self, _certificate: Vec) { - // no-op - } - - fn read(&self, _digest: &CertificateDigest) -> Option { - None - } - - fn read_all( - &self, - digests: Vec, - ) -> Vec<(CertificateDigest, Option)> { - digests.into_iter().map(|digest| (digest, None)).collect() - } - - fn contains(&self, _digest: &CertificateDigest) -> bool { - false - } - - fn multi_contains<'a>( - &self, - digests: impl Iterator, - ) -> Vec { - digests.map(|_| false).collect() - } - - fn remove(&self, _digest: &CertificateDigest) { - // no-op - } - - fn remove_all(&self, _digests: Vec) { - // no-op - } -} - /// The main storage when we have to deal with certificates. It maintains /// two storages, one main which saves the certificates by their ids, and a /// secondary one which acts as an index to allow us fast retrieval based @@ -731,7 +687,7 @@ impl CertificateStore { #[cfg(test)] mod test { - use crate::certificate_store::{CertificateStore, NoCache}; + use crate::certificate_store::CertificateStore; use crate::{Cache, CertificateStoreCache}; use config::AuthorityIdentifier; use fastcrypto::hash::Hash; @@ -749,6 +705,50 @@ mod test { use test_utils::{latest_protocol_version, temp_dir, CommitteeFixture}; use types::{Certificate, CertificateAPI, CertificateDigest, HeaderAPI, Round}; + /// An implementation that basically disables the caching functionality when used for CertificateStore. + #[derive(Clone)] + struct NoCache {} + + impl Cache for NoCache { + fn write(&self, _certificate: Certificate) { + // no-op + } + + fn write_all(&self, _certificate: Vec) { + // no-op + } + + fn read(&self, _digest: &CertificateDigest) -> Option { + None + } + + fn read_all( + &self, + digests: Vec, + ) -> Vec<(CertificateDigest, Option)> { + digests.into_iter().map(|digest| (digest, None)).collect() + } + + fn contains(&self, _digest: &CertificateDigest) -> bool { + false + } + + fn multi_contains<'a>( + &self, + digests: impl Iterator, + ) -> Vec { + digests.map(|_| false).collect() + } + + fn remove(&self, _digest: &CertificateDigest) { + // no-op + } + + fn remove_all(&self, _digests: Vec) { + // no-op + } + } + fn new_store(path: std::path::PathBuf) -> CertificateStore { let (certificate_map, certificate_id_by_round_map, certificate_id_by_origin_map) = create_db_maps(path); diff --git a/narwhal/test-utils/src/cluster.rs b/narwhal/test-utils/src/cluster.rs index 84fbf658a12b2..cd0e426f2a90d 100644 --- a/narwhal/test-utils/src/cluster.rs +++ b/narwhal/test-utils/src/cluster.rs @@ -178,6 +178,7 @@ impl Cluster { /// Returns all the running authorities. Any authority that: /// * has been started ever /// * or has been stopped + /// /// will not be returned by this method. pub async fn authorities(&self) -> Vec { let mut result = Vec::new(); diff --git a/narwhal/types/src/primary.rs b/narwhal/types/src/primary.rs index a2ab6d0afcd68..a478479ab0e54 100644 --- a/narwhal/types/src/primary.rs +++ b/narwhal/types/src/primary.rs @@ -1729,6 +1729,7 @@ pub struct FetchCertificatesRequest { /// This contains per authority serialized RoaringBitmap for the round diffs between /// - rounds of certificates to be skipped from the response and /// - the GC round. + /// /// These rounds are skipped because the requestor already has them. pub skip_rounds: Vec<(AuthorityIdentifier, Vec)>, /// Maximum number of certificates that should be returned. diff --git a/narwhal/worker/Cargo.toml b/narwhal/worker/Cargo.toml index bfb56b3886dfe..6b70a2be94f81 100644 --- a/narwhal/worker/Cargo.toml +++ b/narwhal/worker/Cargo.toml @@ -6,6 +6,9 @@ authors = ["Mysten Labs "] edition = "2021" publish = false +[lints] +workspace = true + [dependencies] arc-swap.workspace = true async-trait.workspace = true diff --git a/narwhal/worker/src/handlers.rs b/narwhal/worker/src/handlers.rs index e908739dbd7ba..8aab5309d1820 100644 --- a/narwhal/worker/src/handlers.rs +++ b/narwhal/worker/src/handlers.rs @@ -114,6 +114,7 @@ impl WorkerToWorker for WorkerReceiverHandler { /// Defines how the network receiver handles incoming primary messages. pub struct PrimaryReceiverHandler { // The id of this authority. + #[allow(unused)] pub authority_id: AuthorityIdentifier, // The id of this worker. pub id: WorkerId, @@ -127,6 +128,7 @@ pub struct PrimaryReceiverHandler { // Timeout on RequestBatches RPC. pub request_batches_timeout: Duration, // Number of random nodes to query when retrying batch requests. + #[allow(unused)] pub request_batches_retry_nodes: usize, // Synchronize header payloads from other workers. pub network: Option, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 6d833ff50699a..a56a283d2abc1 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.75" +channel = "1.80.1" diff --git a/sui-execution/latest/sui-adapter/Cargo.toml b/sui-execution/latest/sui-adapter/Cargo.toml index 04f1d9734cf8d..7a58fe23095ff 100644 --- a/sui-execution/latest/sui-adapter/Cargo.toml +++ b/sui-execution/latest/sui-adapter/Cargo.toml @@ -7,6 +7,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] anyhow = { workspace = true, features = ["backtrace"] } bcs.workspace = true diff --git a/sui-execution/latest/sui-move-natives/src/crypto/group_ops.rs b/sui-execution/latest/sui-move-natives/src/crypto/group_ops.rs index 7a740b6f2b191..93535741f7567 100644 --- a/sui-execution/latest/sui-move-natives/src/crypto/group_ops.rs +++ b/sui-execution/latest/sui-move-natives/src/crypto/group_ops.rs @@ -571,8 +571,8 @@ fn multi_scalar_mul( base_cost: Option, base_cost_per_addition: Option, max_len: u32, - scalars: &Vec, - points: &Vec, + scalars: &[u8], + points: &[u8], ) -> PartialVMResult where G: GroupElement diff --git a/sui-execution/latest/sui-verifier/src/entry_points_verifier.rs b/sui-execution/latest/sui-verifier/src/entry_points_verifier.rs index e3147b9d5a24d..9eadf862fcad0 100644 --- a/sui-execution/latest/sui-verifier/src/entry_points_verifier.rs +++ b/sui-execution/latest/sui-verifier/src/entry_points_verifier.rs @@ -28,8 +28,8 @@ use crate::{verification_failure, INIT_FN_NAME}; /// - The function must have `Visibility::Private` /// - The function can have at most two parameters: /// - mandatory &mut TxContext or &TxContext (see `is_tx_context`) in the last position -/// - optional one-time witness type (see one_time_witness verifier pass) passed by value in the first -/// position +/// - optional one-time witness type (see one_time_witness verifier pass) passed by value in the +/// first position /// /// For transaction entry points /// - The function must have `is_entry` true diff --git a/sui-execution/v0/sui-adapter/Cargo.toml b/sui-execution/v0/sui-adapter/Cargo.toml index 0eb11447ba112..745245766b109 100644 --- a/sui-execution/v0/sui-adapter/Cargo.toml +++ b/sui-execution/v0/sui-adapter/Cargo.toml @@ -7,6 +7,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] anyhow = { workspace = true, features = ["backtrace"] } bcs.workspace = true diff --git a/sui-execution/v0/sui-verifier/Cargo.toml b/sui-execution/v0/sui-verifier/Cargo.toml index bb3dde2501689..e5304b9386808 100644 --- a/sui-execution/v0/sui-verifier/Cargo.toml +++ b/sui-execution/v0/sui-verifier/Cargo.toml @@ -7,6 +7,9 @@ description = "Move framework for Sui platform" license = "Apache-2.0" publish = false +[lints] +workspace = true + [dependencies] move-binary-format.workspace = true move-bytecode-utils.workspace = true diff --git a/sui-execution/v0/sui-verifier/src/entry_points_verifier.rs b/sui-execution/v0/sui-verifier/src/entry_points_verifier.rs index b32ba8fcde498..002d0b3a795c3 100644 --- a/sui-execution/v0/sui-verifier/src/entry_points_verifier.rs +++ b/sui-execution/v0/sui-verifier/src/entry_points_verifier.rs @@ -27,7 +27,7 @@ use crate::{verification_failure, INIT_FN_NAME}; /// - The function can have at most two parameters: /// - mandatory &mut TxContext or &TxContext (see `is_tx_context`) in the last position /// - optional one-time witness type (see one_time_witness verifier pass) passed by value in the first -/// position +/// position /// /// For transaction entry points /// - The function must have `is_entry` true diff --git a/sui-execution/v1/sui-adapter/Cargo.toml b/sui-execution/v1/sui-adapter/Cargo.toml index 8dce979551406..d986af97a9856 100644 --- a/sui-execution/v1/sui-adapter/Cargo.toml +++ b/sui-execution/v1/sui-adapter/Cargo.toml @@ -7,6 +7,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] anyhow = { workspace = true, features = ["backtrace"] } bcs.workspace = true diff --git a/sui-execution/v1/sui-verifier/src/entry_points_verifier.rs b/sui-execution/v1/sui-verifier/src/entry_points_verifier.rs index d107c81b98f4b..2f6a706e0f24d 100644 --- a/sui-execution/v1/sui-verifier/src/entry_points_verifier.rs +++ b/sui-execution/v1/sui-verifier/src/entry_points_verifier.rs @@ -27,7 +27,7 @@ use crate::{verification_failure, INIT_FN_NAME}; /// - The function can have at most two parameters: /// - mandatory &mut TxContext or &TxContext (see `is_tx_context`) in the last position /// - optional one-time witness type (see one_time_witness verifier pass) passed by value in the first -/// position +/// position /// /// For transaction entry points /// - The function must have `is_entry` true diff --git a/sui-execution/v2/sui-adapter/Cargo.toml b/sui-execution/v2/sui-adapter/Cargo.toml index ae29ab4845fc0..cb8bf360a0b12 100644 --- a/sui-execution/v2/sui-adapter/Cargo.toml +++ b/sui-execution/v2/sui-adapter/Cargo.toml @@ -7,6 +7,9 @@ license = "Apache-2.0" publish = false edition = "2021" +[lints] +workspace = true + [dependencies] anyhow = { workspace = true, features = ["backtrace"] } bcs.workspace = true diff --git a/sui-execution/v2/sui-move-natives/src/crypto/group_ops.rs b/sui-execution/v2/sui-move-natives/src/crypto/group_ops.rs index 54cc84f55be48..8f1e459486371 100644 --- a/sui-execution/v2/sui-move-natives/src/crypto/group_ops.rs +++ b/sui-execution/v2/sui-move-natives/src/crypto/group_ops.rs @@ -563,8 +563,8 @@ fn multi_scalar_mul( base_cost: Option, base_cost_per_addition: Option, max_len: u32, - scalars: &Vec, - points: &Vec, + scalars: &[u8], + points: &[u8], ) -> PartialVMResult where G: GroupElement diff --git a/sui-execution/v2/sui-verifier/src/entry_points_verifier.rs b/sui-execution/v2/sui-verifier/src/entry_points_verifier.rs index 9785762cf5581..6e17dba9ffa3b 100644 --- a/sui-execution/v2/sui-verifier/src/entry_points_verifier.rs +++ b/sui-execution/v2/sui-verifier/src/entry_points_verifier.rs @@ -29,7 +29,7 @@ use crate::{verification_failure, INIT_FN_NAME}; /// - The function can have at most two parameters: /// - mandatory &mut TxContext or &TxContext (see `is_tx_context`) in the last position /// - optional one-time witness type (see one_time_witness verifier pass) passed by value in the first -/// position +/// position /// /// For transaction entry points /// - The function must have `is_entry` true