Skip to content

feat: compiler v2 #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 26, 2025
Merged

feat: compiler v2 #206

merged 9 commits into from
May 26, 2025

Conversation

beer-1
Copy link
Member

@beer-1 beer-1 commented May 23, 2025

Description

  • add missing compiler v2 checks
  • add lint option on build cmd
  • fix lint for move

A new linter feature will be added after this PR.

Example usage:

initiad move build --path ./precompile/modules/initia_stdlib --lint

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Improved compiler and language version handling, including support for the latest stable versions and additional version identifiers.
    • Enhanced compiler options with dynamic version validation, bytecode version inference, and new experimental flags for controlling compilation flow.
    • Added support for external checks during package builds.
    • Improved validation and warnings for entry functions and view attributes in Move code.
    • Introduced new Move-related dependencies to support compiler and linter enhancements.
  • Bug Fixes

    • Corrected byte slicing in string handling for Move native functions.
  • Chores

    • Suppressed Clippy warnings about large error types in numerous native functions for cleaner code.
    • Updated comments and formatting for improved code readability.
    • Refined borrowing patterns in Move modules to use immutable references where applicable.
    • Simplified code style in Move modules for more concise and idiomatic expressions.
    • Streamlined lifetime annotations in Rust implementations for clarity and conciseness.

@beer-1 beer-1 requested a review from sh-cha May 23, 2025 07:09
@beer-1 beer-1 self-assigned this May 23, 2025
@beer-1 beer-1 requested a review from a team as a code owner May 23, 2025 07:09
Copy link

coderabbitai bot commented May 23, 2025

Walkthrough

This update introduces dynamic version handling for the Move compiler and language, adds support for external lint checks during package builds, and refines experimental flag handling in the compiler configuration. Numerous native functions across the codebase now suppress Clippy warnings for large error types. Minor comment and formatting improvements, as well as reference equality and borrowing adjustments in Move modules, are also included.

Changes

File(s) Change Summary
Cargo.toml, crates/compiler/Cargo.toml, crates/types/Cargo.toml Added move-compiler-v2 and move-linter as workspace dependencies and as dependencies for the compiler and types crates. Updated local development paths to new directory structure.
crates/compiler/src/built_package.rs Refactored build logic to support external lint checks, dynamic compiler/language version selection, bytecode version inference, and experimental compiler flags controlling compilation flow and error handling. Added public functions for version checking and bytecode inference.
crates/compiler/src/extended_checks.rs Improved error messages for init_module, added signer argument order checks for entry functions, and disallowed signer parameters in view functions. Invoked new signer argument checks during entry function validation.
crates/compiler/src/test_package.rs, crates/e2e-move-tests/src/tests/move_unit.rs Updated to use latest stable compiler and language versions, added explicit version validation and bytecode version inference before test package building.
crates/e2e-move-tests/src/test_utils/mock_chain.rs, libmovevm/src/vm.rs Minor comment formatting updates.
crates/types/src/compiler.rs Added enable_lint_checks field to CompilerBuildConfig. Expanded version string handling to accept "latest", "latest_stable", and new version numbers for compiler and language versions. Updated conversion to BuildConfig to include lint checks experiment.
types/bcs.go, types/compiler/build/options.go Added EnableLintChecks field to Go CompilerBuildConfig struct with serialization/deserialization support. Added WithLintChecks build option function to enable lint checks.
crates/vm/src/verifier/transaction_arg_validation.rs Refactored cursor boundary checks to use is_none_or instead of negated is_some_and, inverting logic but preserving validation intent.
crates/natives/src/account.rs, address.rs, base64.rs, bech32.rs, biguint.rs, block.rs, code.rs, cosmos.rs, crypto/ed25519.rs, crypto/secp256k1.rs, debug.rs, dispatchable_fungible_asset.rs, event.rs, from_bcs.rs, function_info.rs, interface/context.rs, json.rs, keccak.rs, move_stdlib/bcs.rs, move_stdlib/hash.rs, move_stdlib/signer.rs, move_stdlib/string.rs, move_stdlib/unit_test.rs, object.rs, oracle.rs, query.rs, staking.rs, string_utils.rs, table.rs, transaction_context.rs, type_info.rs Added #[allow(clippy::result_large_err)] attribute to many native functions to suppress Clippy warnings about large error types. Minor logic tweaks in some helpers and string formatting.
precompile/modules/initia_stdlib/sources/code.move Changed borrow_global_mut to borrow_global for ModuleStore in verify_modules_upgrade_policy.
precompile/modules/initia_stdlib/sources/fa/fungible_asset.move Changed metadata equality assertion in burn function to compare references instead of values.
precompile/modules/initia_stdlib/sources/minitswap.move Replaced unnecessary mutable borrows with immutable borrows for ModuleStore and VirtualPool in several functions; simplified object address borrowing; changed some function parameters from mutable to immutable references.
precompile/modules/initia_stdlib/sources/multisig_v2.move Changed closure predicate to compare references of tier names instead of values in construct_members_with_tiers.
precompile/modules/initia_stdlib/sources/simple_map.move Simplified keys and values functions by replacing multi-line closures with concise single-line closures.
precompile/modules/initia_stdlib/sources/stableswap.move Replaced mutable borrows with immutable borrows where appropriate; changed some equality checks to reference equality.
precompile/modules/initia_stdlib/sources/staking.move Changed mutable borrows of ModuleStore to immutable borrows; changed some equality checks to compare references in delegation and unbonding logic.
precompile/modules/initia_stdlib/sources/token/collection.move Changed mutable borrows to immutable borrows when checking for supply resources in count function.
precompile/modules/minitia_stdlib/sources/code.move Changed borrow_global_mut to borrow_global for ModuleStore in verify_modules_upgrade_policy.
precompile/modules/minitia_stdlib/sources/fa/fungible_asset.move Changed metadata equality assertion in burn to reference equality; changed mutable borrow to immutable borrow in mutate_metadata when moving metadata into ExtraMetadata.
precompile/modules/minitia_stdlib/sources/managed_coin.move Reformatted test_mutate_metadata function parameter list from multi-line to single-line without logic changes.
precompile/modules/minitia_stdlib/sources/multisig_v2.move Changed closure predicate to compare references of tier names instead of values in construct_members_with_tiers.
precompile/modules/minitia_stdlib/sources/simple_map.move Simplified keys and values functions by replacing multi-line closures with concise single-line closures.
precompile/modules/minitia_stdlib/sources/token/collection.move Changed mutable borrows to immutable borrows when checking for supply resources in count function.
crates/gas/src/misc.rs Simplified lifetime annotations in ValueVisitor implementations by replacing explicit lifetimes with anonymous lifetimes.
crates/storage/src/module_storage.rs Replaced explicit lifetime parameters with anonymous lifetimes in trait implementations and Deref impl for BorrowedOrOwned.
crates/storage/src/state_view_impl.rs Removed explicit lifetime parameters from impl blocks, replacing with anonymous lifetimes in multiple trait implementations.
crates/storage/src/struct_resolver.rs Removed explicit lifetime parameter from StructResolver trait implementation, replaced with anonymous lifetime.
crates/resource-viewer/src/module_view.rs Changed lifetime parameter to anonymous lifetime in CompiledModuleView trait implementation for ModuleView.
libmovevm/src/storage.rs Changed trait impl lifetime parameters from explicit to anonymous in StateView and Storage for GoStorage.
libmovevm/src/table_storage.rs Changed trait impl lifetime parameter from explicit to anonymous in TableResolver for GoTableStorage.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant BuiltPackage
    participant CompilerConfig
    participant ExternalChecks
    participant Compiler

    User->>BuiltPackage: build(package_path, config, docgen_options)
    BuiltPackage->>BuiltPackage: build_with_external_checks(..., external_checks=[])
    BuiltPackage->>CompilerConfig: Set compiler/language version (latest_stable)
    BuiltPackage->>BuiltPackage: check_versions()
    BuiltPackage->>BuiltPackage: inferred_bytecode_version()
    BuiltPackage->>Compiler: compile_package_no_exit(..., external_checks)
    Compiler-->>BuiltPackage: Compilation result
    BuiltPackage->>BuiltPackage: Handle experimental flags & warnings
    BuiltPackage-->>User: BuiltPackage result
Loading

Poem

A rabbit hopped through fields of code,
With versions fresh—no longer old!
External checks and warnings bright,
Bytecode guessed just right.
Clippy’s grumbles now suppressed—
Our native functions pass the test.
🐇✨ Compile away, the future’s blessed!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91524c3 and 2149c63.

📒 Files selected for processing (5)
  • crates/compiler/src/extended_checks.rs (8 hunks)
  • crates/e2e-move-tests/src/test_utils/mock_chain.rs (2 hunks)
  • crates/resource-viewer/src/module_view.rs (1 hunks)
  • libmovevm/src/storage.rs (2 hunks)
  • libmovevm/src/table_storage.rs (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • libmovevm/src/table_storage.rs
  • libmovevm/src/storage.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/e2e-move-tests/src/test_utils/mock_chain.rs
  • crates/compiler/src/extended_checks.rs
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Rust libmovevm
  • GitHub Check: rust lint
🔇 Additional comments (1)
crates/resource-viewer/src/module_view.rs (1)

26-26: Improved lifetime syntax to use anonymous lifetime.

The change from an explicit named lifetime 'a to an anonymous lifetime '_ improves code conciseness while maintaining the same semantics. This follows modern Rust conventions for lifetime elision and aligns with similar changes across the codebase.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@beer-1 beer-1 added the enhancement New feature or request label May 23, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🔭 Outside diff range comments (2)
crates/e2e-move-tests/src/tests/move_unit.rs (1)

30-41: 🛠️ Refactor suggestion

static mut access is still data-race-prone – wrap in UnsafeCell/Mutex or OnceLock
The unchanged BLANK_TABLE_RESOLVER is mutated through addr_of_mut!(BLANK_TABLE_RESOLVER) inside unit_test_extensions_hook. If these tests are ever executed in parallel, the raw mutable reference may cause UB. Consider guarding the value behind a Mutex or OnceLock, or using Lazy<Mutex<_>>.

crates/compiler/src/built_package.rs (1)

163-167: ⚠️ Potential issue

Store the mutated new_config, not the original

Self currently retains the unmodified config, so helper methods that serialize byte-code will use the wrong version. Replace it with the updated new_config.

-        Ok(Self {
-            config,
+        Ok(Self {
+            config: new_config,
             package_path,
             package,
         })

This ensures consistency between compilation settings and any subsequent operations performed through the BuiltPackage API.

♻️ Duplicate comments (4)
crates/natives/src/query.rs (4)

143-143: Duplicate: lint suppression suggestion
Refer to the suggestion at lines 64–64 for consolidating clippy::result_large_err suppression.


277-277: Duplicate: lint suppression suggestion
Refer to the suggestion at lines 64–64 for consolidating clippy::result_large_err suppression.


298-298: Duplicate: lint suppression suggestion
Refer to the suggestion at lines 64–64 for consolidating clippy::result_large_err suppression.


355-355: Duplicate: lint suppression suggestion
Refer to the suggestion at lines 64–64 for consolidating clippy::result_large_err suppression.

🧹 Nitpick comments (25)
crates/natives/src/from_bcs.rs (1)

28-28: Suppress large error type lint on native_from_bytes
The added #[allow(clippy::result_large_err)] correctly suppresses the Clippy warning about a large Result error type and aligns with the crate-wide pattern for native functions.

Optionally, if multiple functions in this module require the same suppression, you could move this to a module-level attribute (#![allow(clippy::result_large_err)] at the top) for cleaner code.

crates/natives/src/move_stdlib/signer.rs (1)

1-27: Optional: Consolidate lint suppression at module level
To reduce repetitive annotations and apply the suppression globally within this file, consider moving the attribute to the top of the module:

--- a/crates/natives/src/move_stdlib/signer.rs
+++ b/crates/natives/src/move_stdlib/signer.rs
@@
 // SPDX-License-Identifier: Apache-2.0
+#![allow(clippy::result_large_err)]

You could then remove individual #[allow(clippy::result_large_err)] annotations on each native function.

crates/natives/src/cosmos.rs (2)

42-43: Consistent suppression of Clippy result_large_err lint
The added #[allow(clippy::result_large_err)] aligns with similar suppressions in other native modules to avoid warnings about large error types. Approving this change. Consider moving this to a module‐level attribute (#![allow(clippy::result_large_err)]) if multiple functions require it, to reduce repetition.


85-86: Suppress Clippy lint for testing function
Adding #[allow(clippy::result_large_err)] on native_requested_messages ensures consistency with native_stargate. If future test-only natives also need this, grouping the suppression at the top of the module can keep the code DRY.

crates/natives/src/object.rs (1)

19-19: Suppress large error type lint consistently.
Adding #[allow(clippy::result_large_err)] on native_exists_at matches the pattern used across other native functions to silence warnings about returning Result with a large error type without altering logic. Consider DRY’ing this by applying a module‐level allowance (#![allow(clippy::result_large_err)]) if every function in this file requires it.

crates/natives/src/crypto/secp256k1.rs (1)

89-90: Suppressing Clippy’s result_large_err lint for native_recover_public_key
This mirrors the pattern used for native_verify to silence warnings on large error types. As more native functions accumulate this attribute, consider moving the suppression to the module level (e.g., #![allow(clippy::result_large_err)] at the top) to reduce repetition.

crates/natives/src/address.rs (2)

19-19: Clippy lint suppression for large error variants
Suppressing clippy::result_large_err on native_to_string is consistent with the crate’s pattern of returning SafeNativeResult across native functions. To reduce repetition, consider moving this to a module-level allow (e.g., #![allow(clippy::result_large_err)] at the top) or a crate-level configuration.


38-38: Apply consistent lint suppression to native_from_string
The addition of #[allow(clippy::result_large_err)] here mirrors the suppression on other native functions and avoids noise from large-result warnings. As above, you may lift this attribute to the module or crate root to DRY up the code.

crates/natives/src/account.rs (1)

103-104: Approve Clippy suppression and consider module-level consolidation.
Adding #[allow(clippy::result_large_err)] here aligns with the project's pattern to suppress large‐error‐type warnings. For maintainability, you may consolidate these repeated attributes by placing a single #![allow(clippy::result_large_err)] at the top of the module instead of on each function.

crates/natives/src/debug.rs (1)

53-56: Suggest more idiomatic handling of the unused args parameter.

Rather than using #[allow(unused_variables)], you can rename args to _args and then group Clippy allows in one attribute for clarity. This avoids an explicit allow and follows Rust’s convention for unused parameters. For example:

- #[inline]
- #[allow(unused_variables)]
- #[allow(clippy::result_large_err)]
+ #[inline]
+ #[allow(clippy::result_large_err)]
 fn native_stack_trace(
     context: &mut SafeNativeContext,
     ty_args: Vec<Type>,
-    args: VecDeque<Value>,
+    _args: VecDeque<Value>,
 ) -> SafeNativeResult<SmallVec<[Value; 1]>> {
crates/natives/src/keccak.rs (1)

26-26: Optional: Module-level lint suppression
If multiple functions in this module require the same Clippy allowance, consider moving it to the top of the file as a module-level attribute (#![allow(clippy::result_large_err)]) to reduce repetition and improve maintainability.

crates/natives/src/move_stdlib/hash.rs (3)

26-28: Consider consolidating Clippy allows at module level
The addition of #[allow(clippy::result_large_err)] on native_sha2_256 silences warnings about large error types, which is consistent with other natives. To reduce repetition and improve maintainability, you could apply #![allow(clippy::result_large_err)] at the top of this file instead of annotating each function.


55-57: Consider consolidating Clippy allows at module level
You've added #[allow(clippy::result_large_err)] to native_sha3_256. If most native functions in this file require the same suppression, a file-level attribute would improve readability and reduce boilerplate.


84-86: Consider consolidating Clippy allows at module level
The #[allow(clippy::result_large_err)] on native_ripemd160 matches the pattern above. For consistency and to avoid duplication, consider moving this suppression to a module-level #![allow(clippy::result_large_err)].

crates/natives/src/interface/context.rs (1)

48-48: Consolidate repeated Clippy suppressions
The added #[allow(clippy::result_large_err)] matches other native functions, but since this lint is suppressed in many places, consider moving it out of individual methods and into the module or crate root (e.g., #![allow(clippy::result_large_err)] at the top of context.rs or in lib.rs) to DRY up the code and improve maintainability.

crates/natives/src/oracle.rs (1)

65-66: Consider module-level lint suppression
The #[allow(clippy::result_large_err)] attribute correctly silences warnings here, but since multiple native functions in this module require it, consider applying a file-level attribute:

#![allow(clippy::result_large_err)]

at the top of the file and removing the per-function #[allow(...)] annotations to reduce duplication.

crates/natives/src/biguint.rs (1)

31-31: Consider grouping Clippy lint suppression at module level
Since all native functions in this file return a large Result error type, you can reduce repetition by using a module-level attribute:

#![allow(clippy::result_large_err)]

at the top of the file instead of annotating each function.

crates/natives/src/transaction_context.rs (1)

45-46: Suppress clippy::result_large_err for native_get_transaction_hash
This addition correctly silences the large error type warning for this native function. Since multiple functions in this file require the same suppression, consider moving to a module-level attribute (#![allow(clippy::result_large_err)]) to reduce repetition and improve maintainability.

crates/natives/src/query.rs (1)

64-64: Consolidate Clippy suppression
Suppressing clippy::result_large_err on each native function is acceptable, but you can reduce repetition by applying it at the module level with a top-of-file #![allow(clippy::result_large_err)].

crates/e2e-move-tests/src/tests/move_unit.rs (1)

73-75: Consider pinning the compiler & language versions for deterministic test runs
Using CompilerVersion::latest_stable() / LanguageVersion::latest_stable() keeps tests on the bleeding-edge, but it also means that a new tool-chain release can suddenly break CI (or give different results on local machines vs. CI caches). Re-running the exact same commit in the future may start failing for reasons unrelated to the code under test.
You may want to:

  • Hard-code a specific stable version (e.g. pull the current value into a constant) or
  • Read the target version from an env-var / cargo feature so that updates are explicit.
-    build_config.compiler_config.compiler_version = Some(CompilerVersion::latest_stable());
-    build_config.compiler_config.language_version = Some(LanguageVersion::latest_stable());
+    // Keep tests reproducible.  Bump deliberately when you really want the upgrade.
+    const COMPILER_V: CompilerVersion = CompilerVersion::V2_1;      // ← pick current stable
+    const LANGUAGE_V: LanguageVersion = LanguageVersion::V2_1;      // ← idem
+    build_config.compiler_config.compiler_version = Some(COMPILER_V);
+    build_config.compiler_config.language_version = Some(LANGUAGE_V);
crates/compiler/src/test_package.rs (3)

42-50: Same reproducibility concern for test packages
For the same reasons mentioned in move_unit.rs, dynamically pulling the current stable version can lead to irreproducible CI. Pin or gate the upgrade behind an explicit flag to avoid surprise failures.


52-57: check_versions returns an anyhow::Result<()> – capture and surface warnings
Today any mismatch aborts the build, but check_versions might also emit non-fatal warnings (e.g. about deprecated versions). You’re discarding that context. Consider logging the warnings (if the API supports it) so users know why a version combination was rejected.


58-64: Avoid double option moves – use references when calling inferred_bytecode_version
inferred_bytecode_version only needs read-only access; passing the owned Options consumes them and forces the extra let binding. Passing as references keeps the original values intact and is a tad clearer:

-let bytecode_version = inferred_bytecode_version(
-    new_build_config.compiler_config.language_version,
-    new_build_config.compiler_config.bytecode_version,
-);
-new_build_config.compiler_config.bytecode_version = bytecode_version;
+new_build_config.compiler_config.bytecode_version =
+    inferred_bytecode_version(
+        &new_build_config.compiler_config.language_version,
+        &new_build_config.compiler_config.bytecode_version,
+    );

(Adjust the callee signature accordingly if feasible.)

crates/compiler/src/extended_checks.rs (1)

224-253: #[view] still allows &mut signer parameters
The new check blocks signer and immutable &signer but intentionally skips &mut signer. However, check_transaction_args (called earlier) already rejects both &signer and &mut signer.
Because of that, the current if guard in lines 236-243 can be simplified:

-                        Type::Reference(mutability, inner) => {
-                            if let Type::Primitive(inner) = inner.as_ref() {
-                                if inner == &PrimitiveType::Signer
-                                    && mutability == &ReferenceKind::Immutable
-                                {
-                                    ...
-                                }
-                            }
-                        }
+                        Type::Reference(_, inner) if matches!(inner.as_ref(), Type::Primitive(PrimitiveType::Signer)) => {
+                            // `&signer` or `&mut signer`
+                            self.env.error(
+                                param_loc,
+                                "`#[view]` function cannot use a reference to `signer` parameter",
+                            )
+                        }

This keeps the rule simple and avoids diverging behaviour if check_transaction_args is ever relaxed.

crates/compiler/src/built_package.rs (1)

51-58: Consider accepting external checks by slice or iterator

external_checks is taken by value as a Vec<Arc<dyn ExternalChecks>>.
Because build_with_external_checks forwards the vector unchanged to compile_package_no_exit, the current signature forces callers to allocate a fresh Vec even when they already keep the checks in some other collection (e.g. a slice or &[Arc<_>]). Accepting impl IntoIterator<Item = Arc<dyn ExternalChecks>> (or &[Arc<dyn ExternalChecks>]) would make the API more flexible and avoid an extra allocation.

This is optional and can be revisited later.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd1526b and bab4f49.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (41)
  • Cargo.toml (1 hunks)
  • crates/compiler/Cargo.toml (1 hunks)
  • crates/compiler/src/built_package.rs (7 hunks)
  • crates/compiler/src/extended_checks.rs (5 hunks)
  • crates/compiler/src/test_package.rs (2 hunks)
  • crates/e2e-move-tests/src/test_utils/mock_chain.rs (1 hunks)
  • crates/e2e-move-tests/src/tests/move_unit.rs (1 hunks)
  • crates/natives/src/account.rs (5 hunks)
  • crates/natives/src/address.rs (2 hunks)
  • crates/natives/src/base64.rs (2 hunks)
  • crates/natives/src/bech32.rs (2 hunks)
  • crates/natives/src/biguint.rs (10 hunks)
  • crates/natives/src/block.rs (2 hunks)
  • crates/natives/src/code.rs (1 hunks)
  • crates/natives/src/cosmos.rs (2 hunks)
  • crates/natives/src/crypto/ed25519.rs (5 hunks)
  • crates/natives/src/crypto/secp256k1.rs (4 hunks)
  • crates/natives/src/debug.rs (2 hunks)
  • crates/natives/src/dispatchable_fungible_asset.rs (1 hunks)
  • crates/natives/src/event.rs (2 hunks)
  • crates/natives/src/from_bcs.rs (1 hunks)
  • crates/natives/src/function_info.rs (5 hunks)
  • crates/natives/src/interface/context.rs (1 hunks)
  • crates/natives/src/json.rs (4 hunks)
  • crates/natives/src/keccak.rs (1 hunks)
  • crates/natives/src/move_stdlib/bcs.rs (2 hunks)
  • crates/natives/src/move_stdlib/hash.rs (3 hunks)
  • crates/natives/src/move_stdlib/signer.rs (1 hunks)
  • crates/natives/src/move_stdlib/string.rs (5 hunks)
  • crates/natives/src/move_stdlib/unit_test.rs (1 hunks)
  • crates/natives/src/object.rs (1 hunks)
  • crates/natives/src/oracle.rs (2 hunks)
  • crates/natives/src/query.rs (6 hunks)
  • crates/natives/src/staking.rs (8 hunks)
  • crates/natives/src/string_utils.rs (5 hunks)
  • crates/natives/src/table.rs (11 hunks)
  • crates/natives/src/transaction_context.rs (4 hunks)
  • crates/natives/src/type_info.rs (2 hunks)
  • crates/types/src/compiler.rs (1 hunks)
  • crates/vm/src/verifier/transaction_arg_validation.rs (2 hunks)
  • libmovevm/src/vm.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: rust lint
  • GitHub Check: Rust libmovevm
🔇 Additional comments (72)
libmovevm/src/vm.rs (1)

116-118: Approve cosmetic comment block simplification
The new shorter slash-style header before the storage operation functions is clear and consistent with surrounding code. No functional impact.

crates/natives/src/type_info.rs (2)

51-52: Properly suppresses Clippy’s result_large_err lint for native_type_of.
The #[allow(clippy::result_large_err)] attribute is correctly placed immediately above the function signature, matching the pattern used in other native modules.


85-86: Properly suppresses Clippy’s result_large_err lint for native_type_name.
The attribute placement is consistent and aligns with the newly adopted convention across native functions.

crates/natives/src/bech32.rs (2)

39-44: Suppress Clippy’s result_large_err lint for native_encode
Adding #[allow(clippy::result_large_err)] here aligns with the pattern across other native functions and prevents noisy warnings without altering behavior.


81-85: Suppress Clippy’s result_large_err lint for native_decode
Similarly, this attribute is consistent with the rest of the native implementations and has no side effects on the function logic.

crates/natives/src/move_stdlib/unit_test.rs (1)

30-30: Code enhancement to suppress Clippy warning.

Adding the #[allow(clippy::result_large_err)] attribute is consistent with similar changes across other native functions in the codebase. This suppresses Clippy warnings about large error types in the Result return value without changing the function's behavior or signature.

crates/natives/src/base64.rs (2)

27-27: Suppress large error type lint as intended

Adding the #[allow(clippy::result_large_err)] attribute here aligns with the broader pattern of suppressing this lint for native functions returning a SafeNativeResult with potentially large error variants.


54-54: Consistent lint suppression for native_decode

The #[allow(clippy::result_large_err)] attribute is appropriately applied to native_decode, matching the suppression in native_encode and other native functions.

crates/natives/src/code.rs (1)

120-120: Suppress Clippy warning for large error types.
Adding #[allow(clippy::result_large_err)] to the native_request_publish function appropriately silences Clippy’s complaints about returning a Result with a sizeable error type. This matches the existing pattern across other native functions and keeps lint output clean without altering behavior.

crates/natives/src/event.rs (2)

62-62: Suppress Clippy lint for large error types in native_emit_event
The addition of #[allow(clippy::result_large_err)] here is consistent with the pattern applied across other native functions returning potentially large Result error types. This change only affects linting and does not modify behavior.


161-161: Suppress Clippy lint for large error types in native_emitted_events
Adding #[allow(clippy::result_large_err)] matches the approach used in native_emit_event and other natives in this directory, ensuring consistent lint suppression without impacting functionality.

crates/natives/src/move_stdlib/signer.rs (1)

27-27: Consistent Clippy lint suppression for large error types
Adding #[allow(clippy::result_large_err)] to native_borrow_address aligns with the pattern used across native modules to suppress lints about large error types without altering function logic.

crates/natives/src/crypto/secp256k1.rs (3)

42-43: Suppressing Clippy’s result_large_err lint for native_verify
Adding #[allow(clippy::result_large_err)] here is consistent with other native functions and prevents noisy warnings due to the large Result error type. Ensure the error types remain correct and document the rationale if not already captured.


162-163: Suppressing Clippy’s result_large_err lint for native_test_only_generate_keys
Test-only functions can also yield large errors; this suppression keeps the lint output focused on real issues.


187-188: Suppressing Clippy’s result_large_err lint for native_test_only_sign
Consistent with other testing natives, this attribute keeps Clippy warnings at bay for large error returns.

crates/natives/src/block.rs (2)

33-33: LGTM: Appropriate lint suppression for native function.

This change appropriately suppresses the Clippy warning about large error types in the Result return value. This is consistent with the pattern applied throughout the codebase for native functions and helps reduce noise in the build output without compromising code quality.


50-50: LGTM: Consistent lint suppression for test function.

Adding the same Clippy suppression to the test-only function maintains consistency across the codebase. This is good practice as it standardizes how these warnings are handled throughout the native functions.

crates/natives/src/account.rs (4)

165-166: Approve Clippy suppression for native_create_account.
The lint suppression is consistent with other native implementations and prevents noise around large error types.


209-210: Approve Clippy suppression for native_create_address.
This matches the convention used across the natives crate to keep Clippy happy when returning large Result types.


240-241: Approve Clippy suppression for native_create_signer.
Suppressing result_large_err here is appropriate to avoid spurious lint failures on native functions.


282-283: Approve Clippy suppression for the testing helper.
Adding the lint allow on native_test_only_set_account_info ensures consistent treatment of Result sizes in test‐only functions.

crates/natives/src/json.rs (1)

30-30: Clippy warning suppression looks appropriate.

The addition of #[allow(clippy::result_large_err)] attributes to all JSON native functions consistently addresses Clippy warnings about large error types in these functions' return values. This approach aligns with the PR objective of fixing linting issues.

While suppressing warnings is appropriate here for consistency with other native functions, a future refactoring could consider redesigning the error types to be more compact (perhaps using Box<dyn Error> or similar techniques) if the size of error types becomes a performance concern.

Also applies to: 72-72, 82-82, 101-101

crates/natives/src/debug.rs (1)

26-28: Approve suppression of large error lints on native_print.

Adding #[allow(clippy::result_large_err)] to native_print is consistent with other native functions in this crate and prevents noisy lints without altering behavior.

crates/natives/src/keccak.rs (1)

26-26: Suppress Clippy lint for large Result error types
Adding #[allow(clippy::result_large_err)] silences warnings about large error types in the function’s Result return, matching patterns applied across other native functions. This does not alter logic or error handling.

crates/natives/src/crypto/ed25519.rs (5)

39-39: Suppress Clippy large-error lint for native_verify.

Adding #[allow(clippy::result_large_err)] is appropriate here to avoid spurious warnings on the inherently large Result type returned by native_verify, which wraps PartialVMError.


91-91: Suppress Clippy large-error lint for pop_vec_of_vec_u8.

Silencing clippy::result_large_err is reasonable in this helper since it returns a SafeNativeResult that can wrap sizeable error types (PartialVMError, TryFromSliceError).


158-158: Suppress Clippy large-error lint for native_batch_verify.

The batch verification function also returns a large Result type. Allowing clippy::result_large_err here aligns it with other native functions.


227-227: Suppress Clippy large-error lint for native_test_only_generate_keys.

This test-only native function returns a SafeNativeResult with potentially large error variants. The lint suppression is valid.


242-242: Suppress Clippy large-error lint for native_test_only_sign.

Adding #[allow(clippy::result_large_err)] here correctly silences warnings on the large error type returned by this test-only signing function.

crates/natives/src/table.rs (1)

314-878: LGTM: Consistent application of Clippy lint suppression across native functions.

The addition of #[allow(clippy::result_large_err)] to all native functions that return Result types with potentially large error variants is appropriate. This approach is consistent with the PR objective of fixing linting issues, and applies the same pattern across all relevant functions without altering their behavior.

crates/natives/src/staking.rs (3)

151-151: Appropriate suppression of Clippy warnings for native staking functions.

The added #[allow(clippy::result_large_err)] attributes are appropriate here since these functions interact with external staking APIs and need to return detailed error information. The large error types are necessary for proper error handling and debugging in this context.

Also applies to: 207-207, 279-279, 323-323


389-389: Consistent lint suppression applied to test-only function.

Good to see the same lint suppression applied consistently to the test-only function, maintaining coding standards across both production and test code.


416-416: Appropriate lint suppression for helper functions.

The helper functions that handle BigDecimal conversions and error handling also need detailed error types. These suppressions are consistent with the approach taken for the main native functions and improve the overall lint compliance of the codebase.

Also applies to: 426-426, 443-443

crates/natives/src/oracle.rs (1)

104-105: Approve Clippy lint suppression for test function
Adding #[allow(clippy::result_large_err)] to native_test_only_set_price aligns with the pattern adopted across native modules to suppress large error-type warnings in test-only code. This change is consistent and necessary.

crates/natives/src/biguint.rs (9)

63-63: Suppress Clippy result_large_err lint for native_sub
The attribute is correctly applied to silence warnings about large error variants returned by native_sub.


101-101: Suppress Clippy result_large_err lint for native_mul
The added attribute appropriately suppresses the result_large_err lint for this multiplication native.


133-133: Suppress Clippy result_large_err lint for native_div
Correctly added to avoid clippy warnings on large error types when dividing.


165-165: Suppress Clippy result_large_err lint for native_new
The annotation properly silences clippy’s large error lint for the constructor native.


215-215: Suppress Clippy result_large_err lint for native_cast
Appropriate addition to silence lint warnings on casting errors.


317-317: Suppress Clippy result_large_err lint for native_lt
Attribute correctly added to suppress large error type warnings on the less-than check.


342-342: Suppress Clippy result_large_err lint for native_le
The lint suppression is correctly applied for the less-or-equal native function.


367-367: Suppress Clippy result_large_err lint for native_gt
Correct use of the attribute to silence warnings on the greater-than native.


392-392: Suppress Clippy result_large_err lint for native_ge
Appropriately suppresses the large error lint for the greater-or-equal native.

crates/natives/src/transaction_context.rs (3)

67-68: Silence clippy::result_large_err for native_generate_unique_address
Appropriately suppresses the large error type lint for this function’s Result return.


99-100: Suppress large error type lint in native_test_only_get_session_id
Correctly prevents Clippy from warning about the potentially large error type in this test-only function under the testing feature.


113-114: Silence clippy::result_large_err for native_test_only_set_transaction_hash
This allow-attribute is valid to avoid Clippy warnings on the function’s error type.

crates/natives/src/string_utils.rs (4)

97-97: Suppress Clippy warning for large error types on format_vector
Addition of #[allow(clippy::result_large_err)] here aligns with the broader pattern across native functions to suppress this lint.


131-131: Suppress Clippy warning for large error types on native_format_impl
Consistent with other native functions; the attribute is appropriate.


396-396: Suppress Clippy warning for large error types on native_format
Adding #[allow(clippy::result_large_err)] is consistent and justified given the large error type of SafeNativeResult.


440-440: Suppress Clippy warning for large error types on native_format_list
Attribute inclusion here follows the crate-wide convention. Approved.

crates/natives/src/move_stdlib/string.rs (4)

39-39: LGTM: Adding Clippy suppression for large error type

This is a reasonable lint suppression to avoid warnings about large error types in the Result return value. It's consistent with the PR's goal of fixing linting issues.


68-68: LGTM: Adding Clippy suppression for large error type

This is a reasonable lint suppression to avoid warnings about large error types in the Result return value. It's consistent with the PR's goal of fixing linting issues.


97-97: LGTM: Adding Clippy suppression for large error type

This is a reasonable lint suppression to avoid warnings about large error types in the Result return value. It's consistent with the PR's goal of fixing linting issues.


136-136: LGTM: Adding Clippy suppression for large error type

This is a reasonable lint suppression to avoid warnings about large error types in the Result return value. It's consistent with the PR's goal of fixing linting issues.

crates/compiler/Cargo.toml (1)

46-46: LGTM - Dependency addition looks good.

The addition of the move-compiler-v2 dependency is properly configured with workspace-level management, which aligns with the PR objective of adding support for compiler version 2.

crates/natives/src/dispatchable_fungible_asset.rs (1)

18-18: LGTM - Lint suppression appropriate for this function.

The added attribute suppresses Clippy warnings about large error types in the Result return value, which is consistent with the PR's objective of fixing linting issues. This is a reasonable approach as the error type is part of the core design of the native function implementation.

crates/natives/src/move_stdlib/bcs.rs (2)

44-44: LGTM - Appropriate lint suppression for native_to_bytes.

This lint suppression for large error types is necessary and consistent with the pattern applied to other native functions across the codebase.


103-103: LGTM - Appropriate lint suppression for native_serialized_size.

This lint suppression for large error types is necessary and consistent with the pattern applied to other native functions across the codebase.

crates/types/src/compiler.rs (2)

93-95: LGTM - Enhanced compiler version handling.

The addition of support for symbolic compiler versions (latest and latest_stable) improves flexibility by allowing users to target the most recent or stable compiler without specifying exact version numbers.


101-105: LGTM - Extended language version support.

The implementation correctly adds support for newer language versions (2.2, 2.3) and symbolic references (latest, latest_stable), which enhances the compiler's ability to work with different Move language specifications.

crates/vm/src/verifier/transaction_arg_validation.rs (2)

467-470: Logic change using is_none_or instead of negated is_some_and

The condition now uses is_none_or with an inverted predicate instead of what was likely a negated is_some_and. While functionally equivalent, this improves readability by avoiding double negation.


566-566: Consistent use of is_none_or pattern

Similar to the previous change, this uses the same is_none_or pattern for boundary checking, maintaining consistency in the codebase.

crates/natives/src/function_info.rs (5)

23-23: Clippy suppression for large error type

Added #[allow(clippy::result_large_err)] to suppress warnings about large error types in function return values, which is appropriate for this native function that needs to return detailed error information.


35-35: Consistent suppression of Clippy warning

This annotation maintains consistency with other native functions that return complex error types.


75-75: Clippy warning suppression for native function

Added suppression annotation for the large error type returned by this dispatch compatibility check function.


136-136: Suppression for identifier validation function

Consistently applied the same Clippy suppression pattern to this native function.


170-170: Final Clippy suppression in the file

Completed the pattern of suppressing large error type warnings across all relevant native functions in this file.

Cargo.toml (1)

129-129:

✅ Verification successful

Added dependency on Move compiler v2

Added the move-compiler-v2 dependency using the same Git repository and revision as other Move dependencies, which is essential for supporting the compiler version 2 features mentioned in the PR title.


🏁 Script executed:

#!/bin/bash
# Verify that this dependency is correctly referenced in the compiler crate
grep -r "move-compiler-v2" --include="Cargo.toml" crates/

Length of output: 122


Dependency correctly configured

Confirmed that:

  • The root Cargo.toml pins move-compiler-v2 to the intended Git revision.
  • crates/compiler/Cargo.toml references it with workspace = true.

No further changes needed.

crates/e2e-move-tests/src/test_utils/mock_chain.rs (1)

484-485: Minor comment style improvement

Changed the comment style for the section divider to be more consistent, using a line of forward slashes and a regular comment instead of a doc comment.

crates/compiler/src/built_package.rs (3)

47-50: Delegation pattern looks good

Forwarding the public build API to the more general build_with_external_checks avoids code duplication and keeps the default path clean.
No further action required.


71-78: 👍 Sensible default-to-latest-stable behaviour

Falling back to CompilerVersion::latest_stable() and LanguageVersion::latest_stable() when the caller didn’t specify explicit versions is a safer default than pinning to a hard-coded constant.


275-305: Minor ergonomics & verification request for check_versions

  1. unwrap_or_default() is invoked on &Option<CompilerVersion> / &Option<LanguageVersion>.
    This compiles only if CompilerVersion and LanguageVersion implement Copy.
    If they are (or later become) non-Copy, this will fail. Consider cloning explicitly or passing the Option by value.

  2. After emitting the warnings, error_writer.flush()?; could be added to guarantee the messages appear before subsequent output (especially useful when piping logs).

Please confirm that both CompilerVersion and LanguageVersion are indeed Copy; otherwise the current implementation will not compile.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
types/bcs.go (1)

3-6: 💡 Verification agent

🧩 Analysis chain

Warning about modifying auto-generated file

This file has a prominent warning indicating it should not be modified directly, but changes have been made to it. Consider whether these changes should be part of the code generation process instead of direct modifications.


🏁 Script executed:

#!/bin/bash
# Look for the code generation script mentioned in the file header
echo "Searching for code generation script..."
fd -t f "generate-bcs-go" --exec grep -l "generate.*bcs.*go" {} \;

Length of output: 158


Update code generation process for types/bcs.go modifications

It looks like you’ve manually edited an auto-generated file without updating the generator itself. I couldn’t find a generate-bcs-go script in the repo, so these changes will be lost the next time codegen runs. Please:

  • Add or locate the generate-bcs-go tool in your repo (e.g. under a tools/ or scripts/ directory).
  • Revert manual edits in types/bcs.go.
  • Incorporate your intended changes into the generator so that running it regenerates the correct output.
♻️ Duplicate comments (1)
crates/compiler/src/built_package.rs (1)

69-81: ⚠️ Potential issue

Added version validation and bytecode version inference

This improvement:

  1. Validates compiler and language versions
  2. Warns about unstable versions
  3. Infers the appropriate bytecode version based on language version
  4. Sets the inferred version in the compiler configuration

However, there's an issue that needs fixing.

The inferred bytecode version is updated in new_config but not in the original config that's stored in Self (line 154). This could cause inconsistencies if code elsewhere accesses self.config.compiler_config.bytecode_version.

Fix this by updating the original config:

new_config.compiler_config.bytecode_version = bytecode_version;
+config.compiler_config.bytecode_version = bytecode_version;
🧹 Nitpick comments (1)
crates/compiler/src/built_package.rs (1)

103-109: Added experimental flags for warnings handling and early exit

Two more experimental flags are now supported:

  1. FAIL_ON_WARNING: Fails with an error if warnings are found
  2. STOP_AFTER_EXTENDED_CHECKS: Exits after extended checks

The same concern about using std::process::exit applies here.

Consider refactoring to return a result instead of calling std::process::exit directly, which would give library users more control:

if model_options.experiment_on(Experiment::STOP_AFTER_EXTENDED_CHECKS) {
-    std::process::exit(if model.has_warnings() { 1 } else { 0 })
+    return Ok(Self {
+        config,
+        package_path,
+        package,
+        early_exit: Some(if model.has_warnings() { 1 } else { 0 }),
+    });
}

You would need to add an early_exit field to BuiltPackage and have consumers check this field.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bab4f49 and 490462b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (21)
  • Cargo.toml (2 hunks)
  • crates/compiler/Cargo.toml (1 hunks)
  • crates/compiler/src/built_package.rs (7 hunks)
  • crates/types/Cargo.toml (1 hunks)
  • crates/types/src/compiler.rs (3 hunks)
  • precompile/modules/initia_stdlib/sources/code.move (1 hunks)
  • precompile/modules/initia_stdlib/sources/fa/fungible_asset.move (1 hunks)
  • precompile/modules/initia_stdlib/sources/minitswap.move (15 hunks)
  • precompile/modules/initia_stdlib/sources/multisig_v2.move (1 hunks)
  • precompile/modules/initia_stdlib/sources/simple_map.move (1 hunks)
  • precompile/modules/initia_stdlib/sources/stableswap.move (4 hunks)
  • precompile/modules/initia_stdlib/sources/staking.move (5 hunks)
  • precompile/modules/initia_stdlib/sources/token/collection.move (1 hunks)
  • precompile/modules/minitia_stdlib/sources/code.move (1 hunks)
  • precompile/modules/minitia_stdlib/sources/fa/fungible_asset.move (2 hunks)
  • precompile/modules/minitia_stdlib/sources/managed_coin.move (1 hunks)
  • precompile/modules/minitia_stdlib/sources/multisig_v2.move (1 hunks)
  • precompile/modules/minitia_stdlib/sources/simple_map.move (1 hunks)
  • precompile/modules/minitia_stdlib/sources/token/collection.move (1 hunks)
  • types/bcs.go (3 hunks)
  • types/compiler/build/options.go (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • precompile/modules/initia_stdlib/sources/simple_map.move
  • precompile/modules/minitia_stdlib/sources/simple_map.move
  • crates/types/Cargo.toml
  • precompile/modules/minitia_stdlib/sources/managed_coin.move
🚧 Files skipped from review as they are similar to previous changes (3)
  • crates/compiler/Cargo.toml
  • Cargo.toml
  • crates/types/src/compiler.rs
🧰 Additional context used
🧬 Code Graph Analysis (2)
types/compiler/build/options.go (1)
types/bcs.go (1)
  • CompilerBuildConfig (188-202)
types/bcs.go (1)
types/serialize.go (2)
  • SerializeBool (45-52)
  • DeserializeBool (55-58)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Rust libmovevm
🔇 Additional comments (43)
precompile/modules/minitia_stdlib/sources/multisig_v2.move (1)

720-722: Optimization: Changed string comparison to reference comparison.

The comparison in the predicate has been updated from value comparison (tt.name == tier_name) to reference comparison (&tt.name == &tier_name), which is more efficient for String types. This change aligns with the broader pattern of optimizations in the PR.

precompile/modules/initia_stdlib/sources/multisig_v2.move (1)

721-722: Good optimization: Using reference comparison for strings

The change to compare string references instead of string values is a performance improvement. In Move, strings are resource types (vectors of bytes), so comparing by reference avoids unnecessary copying and is more efficient.

precompile/modules/minitia_stdlib/sources/code.move (1)

254-255: Good improvement to borrowing pattern

Changed from mutable to immutable borrow since the function only reads from ModuleStore without modifying it. This follows Move best practices of only requesting the minimum necessary access level.

precompile/modules/minitia_stdlib/sources/token/collection.move (2)

362-362: Appropriate immutable borrow

Changed from mutable to immutable borrow for FixedSupply since the function only reads the current_supply field without modifying the resource.


365-365: Appropriate immutable borrow

Changed from mutable to immutable borrow for UnlimitedSupply since the function only reads the current_supply field without modifying the resource.

precompile/modules/minitia_stdlib/sources/fa/fungible_asset.move (2)

871-871: Improved reference comparison

Changed from value comparison to reference comparison, which is more efficient for complex types as it avoids copying the entire metadata value.


962-962: Appropriate immutable borrow

Changed from mutable to immutable borrow for Metadata since the function only reads from it to initialize the ExtraMetadata resource without modifying the original resource.

precompile/modules/initia_stdlib/sources/staking.move (5)

1018-1018: Improved resource access pattern with immutable borrow

Changed from mutable to immutable borrow of ModuleStore in claim_reward since no modification is needed.


1243-1243: Improved resource access pattern with immutable borrow

Changed from mutable to immutable borrow of ModuleStore in destroy_delegation_and_extract_reward since no modification is needed.


1278-1278: Improved resource access pattern with immutable borrow

Changed from mutable to immutable borrow of ModuleStore in unbonding_share_from_amount since no modification is needed.


1181-1181: Updated BigDecimal comparison to use references

Changed equality check to compare references rather than values for BigDecimal types, which is the recommended pattern for custom types with potentially expensive equality operations.


1456-1456: Updated BigDecimal comparison to use references

Changed equality check to compare references rather than values for BigDecimal types, maintaining consistency with the pattern used elsewhere in the codebase.

precompile/modules/initia_stdlib/sources/stableswap.move (5)

499-499: Improved vector access with immutable borrow

Changed from mutable to immutable borrow when accessing coin_amounts vector since no modification is needed here.


990-990: Simplified object address access

Removed unnecessary dereferencing when accessing the object address.


1380-1382: Updated metadata comparison to use references

Changed equality check to compare references rather than values for Object types, which aligns with the comparison pattern used elsewhere in the codebase.


1392-1393: Updated metadata comparison to use references

Changed equality check to compare references rather than values for Object types, maintaining consistency in comparison operations.


1395-1396: Updated metadata comparison to use references

Changed equality check to compare references rather than values for Object types, maintaining consistency in comparison operations.

types/compiler/build/options.go (1)

103-107: Added function to enable lint checks in compiler configuration

New function WithLintChecks() follows the established pattern of other option functions and enables the new lint checking functionality in the compiler build process.

This change aligns with the PR objective of "adding missing checks for compiler version 2" and is consistent with the pattern used for other compiler build options.

precompile/modules/initia_stdlib/sources/fa/fungible_asset.move (1)

817-819: Improved reference equality check for metadata comparison.

The change to compare references (&ref.metadata == &metadata) instead of direct values is more appropriate for this type of comparison, ensuring consistent behavior when dealing with Object<Metadata> types.

precompile/modules/initia_stdlib/sources/code.move (1)

254-256: Good practice: Changed mutable borrow to immutable borrow.

Replaced borrow_global_mut with borrow_global since this function only reads from the module_store and doesn't modify it. This follows the principle of least privilege and improves code safety.

precompile/modules/initia_stdlib/sources/token/collection.move (2)

361-363: Good practice: Changed mutable borrow to immutable borrow.

Using borrow_global instead of borrow_global_mut is more appropriate since this view function only reads the current_supply without modifying the FixedSupply resource.


364-366: Good practice: Changed mutable borrow to immutable borrow.

Using borrow_global instead of borrow_global_mut is more appropriate since this view function only reads the current_supply without modifying the UnlimitedSupply resource.

types/bcs.go (3)

193-193: New field added to CompilerBuildConfig struct

The addition of the EnableLintChecks field to the CompilerBuildConfig struct provides support for integrating external lint checks during package builds, which aligns with the compiler v2 feature.


210-210: Field properly included in serialization method

The new EnableLintChecks field is correctly incorporated into the struct's serialization method, maintaining consistency with the other configuration options.


239-239: Field properly included in deserialization method

The new EnableLintChecks field is correctly incorporated into the struct's deserialization method, ensuring it can be properly restored from serialized data.

precompile/modules/initia_stdlib/sources/minitswap.move (13)

354-359: Code optimized by replacing mutable borrow with immutable borrow

The code has been optimized by changing borrow_global_mut to borrow_global and table::borrow_mut to table::borrow since the ModuleStore and pools are only being read in this function, not modified.


553-554: Immutable borrow for read-only access

Correctly changed to immutable borrow since the VirtualPool is only being read here, not modified.


697-699: Simplified object address dereferencing

The code now directly passes the result of option::borrow to object::object_address without first dereferencing the option. This is cleaner and more idiomatic.


764-766: Consistent immutable borrow pattern

This change follows the same pattern as the previous modifications, using immutable borrow to access the VirtualPool object address.


1105-1109: Kept mutable borrow where needed

Mutable borrow is correctly maintained here because the deactivate function needs to modify pool.active.


1118-1123: Mixed borrowing approach aligns with function requirements

Immutable borrows are used for reading the ModuleStore and pools, while a mutable borrow is correctly used for the VirtualPool that will be modified by setting pool.active = true.


1137-1141: Consistent pattern for accessing VirtualPool

This change follows the same pattern as previous modifications, using immutable borrows for read-only access while maintaining mutable borrow of the VirtualPool that will be modified.


1337-1342: Module and pools accessed with immutable borrows

The update_pool_params function correctly uses immutable borrows for ModuleStore and pools while maintaining a mutable borrow for the VirtualPool that will be updated.


1857-1864: Immutable borrows for callback handlers

Callback handlers like ibc_ack appropriately use immutable borrows since they're only reading the object state before calling other functions that handle the mutations.


1879-1886: Consistent immutable borrowing in timeout handler

Similarly, the ibc_timeout handler uses immutable borrows in a consistent manner with the other callbacks.


1935-1939: Optimized borrow chain

The borrowing chain has been simplified by directly passing the result of option::borrow to object::object_address without intermediate dereferencing.


1950-1954: Consistent immutable borrowing pattern

This follows the same pattern established throughout the file, using immutable borrows where possible and simplifying the object address resolution chain.


2261-2264: Changed parameter type to immutable reference

The send_ibc_message function now correctly takes an immutable reference to pool since it doesn't modify the pool state directly.

crates/compiler/src/built_package.rs (5)

50-50: Added lint checks to compilation process

The code now includes MoveLintChecks::make() in the external checks vector, integrating lint checking into the compilation process.


61-67: Dynamic version handling for better maintainability

Instead of using fixed versions, the code now dynamically uses the latest stable versions for compiler and language. This is more maintainable and automatically adapts to new stable releases.


84-84: Updated compilation to include external checks

The compilation call now includes the external checks (including lint checks) and a stderr handler.


264-295: Added version validation function with helpful warnings

The new check_versions function validates compiler and language versions, providing colored warnings for unstable versions and checking compatibility.


297-306: Added bytecode version inference function

The new inferred_bytecode_version function determines the appropriate bytecode version based on language version and any explicitly set bytecode version.

Copy link
Contributor

@sh-cha sh-cha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@beer-1 beer-1 merged commit 5ca3a51 into main May 26, 2025
4 checks passed
@beer-1 beer-1 deleted the feat/compiler-v2 branch May 26, 2025 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants